Skip to content

Commit

Permalink
发布
Browse files Browse the repository at this point in the history
  • Loading branch information
MuyianKing committed Nov 6, 2024
1 parent c16c99d commit 18f66c8
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 42 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [0.1.2](https://github.com/MuyianKing/cli/compare/v0.1.0...v0.1.2) (2024-11-06)


### Bug Fixes

* :bug: 修改README.md ([c16c99d](https://github.com/MuyianKing/cli/commit/c16c99d9bace9c1007e63acc564e28a022fae9bb))



# [0.1.0](https://github.com/MuyianKing/cli/compare/9ebd88e7f51cd61d74d56b462813883daacefeb0...v0.1.0) (2024-11-06)


Expand All @@ -14,4 +23,7 @@

* :sparkles: 增加命令缺失提示 ([7d96a69](https://github.com/MuyianKing/cli/commit/7d96a69f04faa31c3dccebce176cf39f5bc022e4))
* :sparkles: 增加github action 配置 ([9895c0b](https://github.com/MuyianKing/cli/commit/9895c0b1e5e3f5ec570c5cb7ca2b6dce08705bcf))
* :sparkles: 增加html-vue模板 ([ad9bc3c](https://github.com/MuyianKing/cli/commit/ad9bc3c7e714692d6a4c9d42cb7d48dce2db3a36))
* :sparkles: 增加html-vue模板 ([ad9bc3c](https://github.com/MuyianKing/cli/commit/ad9bc3c7e714692d6a4c9d42cb7d48dce2db3a36))



1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 发布脚本
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@muyianking/cli",
"version": "0.1.0",
"version": "0.1.2",
"description": "慕易安的脚手架",
"author": "muyian",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
{ value: 'refactor', name: '重构: ♻️ 代码重构(不包括 bug 修复、功能新增)', emoji: ':recycle:' },
{ value: 'perf', name: '性能: ⚡️ 性能优化', emoji: ':zap:' },
{ value: 'test', name: '测试: ✅ 添加疏漏测试或已有测试改动', emoji: ':white_check_mark:' },
{ value: 'build', name: '构建: 📦️ 构建流程、外部依赖变更(如升级 npm 包、修改 vite 配置等)', emoji: ':package:' },
{ value: 'release', name: '构建: 📦️ 构建流程、外部依赖变更(如升级 npm 包、修改 vite 配置等)', emoji: ':package:' },
{ value: 'ci', name: '集成: 🎡 修改 CI 配置、脚本', emoji: ':ferris_wheel:' },
{ value: 'revert', name: '回退: ⏪️ 回滚 commit', emoji: ':rewind:' },
{ value: 'chore', name: '其他: 🔨 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)', emoji: ':hammer:' },
Expand Down
79 changes: 40 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
{
"name": "cli",
"type": "module",
"version": "0.0.1",
"private": false,
"scripts": {
"update-dep": "npm-check-updates && ncu -u && pnpm i",
"commit": "git add . && git cz",
"lint": "git add . && lint-staged",
"husky-lint": "git add . && lint-staged",
"prepare": "husky",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"dependencies": {},
"devDependencies": {
"@antfu/eslint-config": "^3.8.0",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/eslintrc": "^3.1.0",
"cz-git": "^1.10.1",
"eslint": "^9.13.0",
"eslint-plugin-format": "^0.1.2",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"publish": "git "
},
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
},
"lint-staged": {
"*.{js,ts,vue}": [
"eslint --fix"
]
}
}
"name": "cli",
"type": "module",
"version": "0.1.2",
"private": false,
"scripts": {
"update-dep": "npm-check-updates && ncu -u && pnpm i",
"commit": "git add . && git cz",
"lint": "git add . && lint-staged",
"husky-lint": "git add . && lint-staged",
"prepare": "husky",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"publish": "node ./script/publish.js"
},
"dependencies": {},
"devDependencies": {
"@antfu/eslint-config": "^3.8.0",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/eslintrc": "^3.1.0",
"cz-git": "^1.10.1",
"eslint": "^9.13.0",
"eslint-plugin-format": "^0.1.2",
"fs-extra": "^11.2.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10"
},
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
},
"lint-staged": {
"*.{js,ts,vue}": [
"eslint --fix"
]
}
}
28 changes: 28 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions script/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import child_process from 'node:child_process'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import fsExtra from 'fs-extra'
import getObjectFromJson from './utils/getObjectFromJson.js'

const __dirname = fileURLToPath(import.meta.url)

/**
* 4、提交package.json和changelog.md
* 5、创建tag
* 6、提交tag
*/

// 读取版本
function getVersion() {
const package_path = path.resolve(__dirname, `../../cli/package.json`)
const _config = getObjectFromJson(package_path)
return _config.version
}

function publish() {
// 修改package.json版本号
const _path = `../../package.json`
const package_path = path.resolve(__dirname, _path)
const _config = getObjectFromJson(package_path)
_config.version = getVersion()

const fileStr = JSON.stringify(_config, '', '\t')
fsExtra.outputFile(
package_path,
fileStr,
'utf-8',
)

// 生成changelog.md
child_process.exec('pnpm log', (error) => {
if (!error) {
// 成功
child_process.exec('git add .', (error) => {
console.log('error1', error)

child_process.exec('git cz', (error) => {
console.log('error2', error)
})
})
} else {
console.log('生成changelog.md失败', error)
}
})
}

publish()
6 changes: 6 additions & 0 deletions script/utils/getObjectFromJson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { readFileSync } from 'node:fs'

export default function (path) {
const data = readFileSync(path)
return JSON.parse(data)
}

0 comments on commit 18f66c8

Please sign in to comment.