This commit is contained in:
hanshiyang committed 2025-09-23 10:43:28 +08:00
commit 977ba1c283
456 files changed
+52892

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { execSync } from 'child_process'
import fs from 'fs'
import path from 'path'
const pkgPath = path.resolve('package.json')
// 校验包合法性
fs.accessSync(path.resolve('dist'), fs.constants.F_OK)
fs.accessSync(path.resolve('dist/canvas-editor.es.js'), fs.constants.F_OK)
fs.accessSync(path.resolve('dist/canvas-editor.umd.js'), fs.constants.F_OK)
// 缓存项目package.json
const sourcePkg = fs.readFileSync(pkgPath, 'utf-8')
// 删除无用属性
const targetPkg = JSON.parse(sourcePkg)
Reflect.deleteProperty(targetPkg, 'dependencies')
Reflect.deleteProperty(targetPkg.scripts, 'postinstall')
fs.writeFileSync(pkgPath, JSON.stringify(targetPkg, null, 2))
// 发布包
try {
execSync('npm publish')
} catch (error) {
throw new Error(error)
} finally {
// 还原
fs.writeFileSync(pkgPath, sourcePkg)
}
+19
View File
@@ -0,0 +1,19 @@
// @ts-check
import { readFileSync } from 'fs'
import path from 'path'
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
const msg = readFileSync(msgPath, 'utf-8').trim()
const commitRE =
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release|improve)(\(.+\))?: .{1,50}/
if (!commitRE.test(msg)) {
console.error(
`invalid commit message format.\n\n` +
` Proper commit message format is required for automated changelog generation. Examples:\n\n` +
` feat: add page header\n` +
` fix: IME position error #155\n`
)
process.exit(1)
}