-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45884c2
commit 1a4a641
Showing
14 changed files
with
198 additions
and
191 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- run: npx changelogithub # or [email protected] if ensure the stable result | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,7 +271,7 @@ var import_kolorist2 = require("kolorist"); | |
// package.json | ||
var package_default = { | ||
name: "@soybeanjs/cli", | ||
version: "0.2.0", | ||
version: "0.2.5", | ||
description: "SoybeanJS's command lint tools", | ||
author: { | ||
name: "Soybean", | ||
|
@@ -303,12 +303,11 @@ var package_default = { | |
commit: "soy git-commit", | ||
cleanup: "soy cleanup", | ||
"update-pkg": "soy update-pkg", | ||
"update-version": 'bumpp package.json --execute="pnpm gen-log" --commit --all --push --tag', | ||
"publish-pkg": "pnpm -r publish --access public", | ||
release: "pnpm update-version && pnpm publish-pkg", | ||
"gen-log": "conventional-changelog -p angular -i CHANGELOG.md -s" | ||
release: "soy release", | ||
"publish-pkg": "pnpm -r publish --access public" | ||
}, | ||
dependencies: { | ||
changelogen: "0.5.3", | ||
commander: "10.0.1", | ||
enquirer: "2.3.6", | ||
execa: "7.1.1", | ||
|
@@ -320,8 +319,6 @@ var package_default = { | |
devDependencies: { | ||
"@soybeanjs/cli": "link:", | ||
"@types/node": "^20.2.3", | ||
bumpp: "9.1.0", | ||
"conventional-changelog-cli": "^2.2.2", | ||
eslint: "8.41.0", | ||
"eslint-config-soybeanjs": "0.3.8", | ||
"lint-staged": "13.2.2", | ||
|
@@ -331,22 +328,22 @@ var package_default = { | |
typescript: "5.0.4" | ||
}, | ||
"simple-git-hooks": { | ||
"commit-msg": "pnpm soybean git-commit-verify", | ||
"pre-commit": "pnpm exec lint-staged --concurrent false" | ||
"commit-msg": "pnpm soy git-commit-verify", | ||
"pre-commit": "pnpm lint-staged" | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}": [ | ||
"*.{js,json,ts}": [ | ||
"eslint . --fix" | ||
] | ||
} | ||
}; | ||
|
||
// src/command/git/commit.ts | ||
// src/command/git-commit.ts | ||
var import_enquirer = __toESM(require("enquirer")); | ||
var import_execa = require("execa"); | ||
|
||
// src/command/git/config.ts | ||
var types = [ | ||
// src/configs/git.ts | ||
var gitCommitTypes = [ | ||
{ value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" }, | ||
{ value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" }, | ||
{ value: "fix", title: "fix: \u4FEE\u590Dbug" }, | ||
|
@@ -355,11 +352,12 @@ var types = [ | |
{ value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" }, | ||
{ value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" }, | ||
{ value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" }, | ||
{ value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" }, | ||
{ value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" }, | ||
{ value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" }, | ||
{ value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" } | ||
]; | ||
var scopes = [ | ||
var gitCommitScopes = [ | ||
["projects", "\u9879\u76EE\u642D\u5EFA"], | ||
["components", "\u7EC4\u4EF6\u76F8\u5173"], | ||
["hooks", "hook \u76F8\u5173"], | ||
|
@@ -377,20 +375,20 @@ var scopes = [ | |
}; | ||
}); | ||
|
||
// src/command/git/commit.ts | ||
// src/command/git-commit.ts | ||
async function gitCommit() { | ||
const result = await import_enquirer.default.prompt([ | ||
{ | ||
name: "types", | ||
type: "select", | ||
message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B", | ||
choices: types.map((item) => ({ name: item.value, message: item.title })) | ||
choices: gitCommitTypes.map((item) => ({ name: item.value, message: item.title })) | ||
}, | ||
{ | ||
name: "scopes", | ||
type: "select", | ||
message: "\u9009\u62E9\u4E00\u4E2Ascope", | ||
choices: scopes.map((item) => ({ name: item.value, message: item.title })) | ||
choices: gitCommitScopes.map((item) => ({ name: item.value, message: item.title })) | ||
}, | ||
{ | ||
name: "description", | ||
|
@@ -402,17 +400,16 @@ async function gitCommit() { | |
(0, import_execa.execa)("git", ["commit", "-m", commitMsg], { stdio: "inherit" }); | ||
} | ||
|
||
// src/command/git/verify-commit.ts | ||
// src/command/git-verify.ts | ||
var import_fs = require("fs"); | ||
var import_kolorist = require("kolorist"); | ||
function verifyGitCommit() { | ||
function gitCommitVerify() { | ||
const gitMsgPath = "./.git/COMMIT_EDITMSG"; | ||
const commitMsg = (0, import_fs.readFileSync)(gitMsgPath, "utf-8").trim(); | ||
const RELEASE_MSG = "chore: release"; | ||
const REG_EXP = new RegExp( | ||
`(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}` | ||
); | ||
if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) { | ||
const types2 = gitCommitTypes.map((item) => item.value).join("|"); | ||
const scopes = gitCommitScopes.map((item) => item.value).join("|"); | ||
const REG_EXP = new RegExp(`(${types2})!*(\\((${scopes}))\\))*!*:\\s.{1,100}`); | ||
if (!REG_EXP.test(commitMsg)) { | ||
throw new Error( | ||
`${(0, import_kolorist.bgRed)(" ERROR ")} ${(0, import_kolorist.red)("Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!\n\n")}${(0, import_kolorist.green)( | ||
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F" | ||
|
@@ -554,8 +551,8 @@ var unescape = (s, { windowsPathsNoEscape = false } = {}) => { | |
}; | ||
|
||
// node_modules/.pnpm/[email protected]/node_modules/minimatch/dist/mjs/ast.js | ||
var types2 = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]); | ||
var isExtglobType = (c) => types2.has(c); | ||
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]); | ||
var isExtglobType = (c) => types.has(c); | ||
var startNoTraversal = "(?!\\.\\.?(?:$|/))"; | ||
var startNoDot = "(?!\\.)"; | ||
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]); | ||
|
@@ -6367,12 +6364,18 @@ function prettierFormat() { | |
}); | ||
} | ||
|
||
// src/scripts/release.ts | ||
var import_execa5 = require("execa"); | ||
async function release() { | ||
await (0, import_execa5.execa)("npx", ["changelogen", "--release --push --no-github"]); | ||
} | ||
|
||
// src/index.ts | ||
import_commander.program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => { | ||
gitCommit(); | ||
}); | ||
import_commander.program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => { | ||
verifyGitCommit(); | ||
gitCommitVerify(); | ||
}); | ||
import_commander.program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => { | ||
cleanup(); | ||
|
@@ -6386,5 +6389,8 @@ import_commander.program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u | |
import_commander.program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => { | ||
prettierFormat(); | ||
}); | ||
import_commander.program.command("release").description("\u7248\u672C\u53D1\u5E03").action(() => { | ||
release(); | ||
}); | ||
import_commander.program.version(package_default.version).description((0, import_kolorist2.blue)("soybean alias soy\n\nhttps://github.com/soybeanjs/cli")); | ||
import_commander.program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,7 @@ import { blue } from "kolorist"; | |
// package.json | ||
var package_default = { | ||
name: "@soybeanjs/cli", | ||
version: "0.2.0", | ||
version: "0.2.5", | ||
description: "SoybeanJS's command lint tools", | ||
author: { | ||
name: "Soybean", | ||
|
@@ -302,12 +302,11 @@ var package_default = { | |
commit: "soy git-commit", | ||
cleanup: "soy cleanup", | ||
"update-pkg": "soy update-pkg", | ||
"update-version": 'bumpp package.json --execute="pnpm gen-log" --commit --all --push --tag', | ||
"publish-pkg": "pnpm -r publish --access public", | ||
release: "pnpm update-version && pnpm publish-pkg", | ||
"gen-log": "conventional-changelog -p angular -i CHANGELOG.md -s" | ||
release: "soy release", | ||
"publish-pkg": "pnpm -r publish --access public" | ||
}, | ||
dependencies: { | ||
changelogen: "0.5.3", | ||
commander: "10.0.1", | ||
enquirer: "2.3.6", | ||
execa: "7.1.1", | ||
|
@@ -319,8 +318,6 @@ var package_default = { | |
devDependencies: { | ||
"@soybeanjs/cli": "link:", | ||
"@types/node": "^20.2.3", | ||
bumpp: "9.1.0", | ||
"conventional-changelog-cli": "^2.2.2", | ||
eslint: "8.41.0", | ||
"eslint-config-soybeanjs": "0.3.8", | ||
"lint-staged": "13.2.2", | ||
|
@@ -330,22 +327,22 @@ var package_default = { | |
typescript: "5.0.4" | ||
}, | ||
"simple-git-hooks": { | ||
"commit-msg": "pnpm soybean git-commit-verify", | ||
"pre-commit": "pnpm exec lint-staged --concurrent false" | ||
"commit-msg": "pnpm soy git-commit-verify", | ||
"pre-commit": "pnpm lint-staged" | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}": [ | ||
"*.{js,json,ts}": [ | ||
"eslint . --fix" | ||
] | ||
} | ||
}; | ||
|
||
// src/command/git/commit.ts | ||
// src/command/git-commit.ts | ||
import enquirer from "enquirer"; | ||
import { execa } from "execa"; | ||
|
||
// src/command/git/config.ts | ||
var types = [ | ||
// src/configs/git.ts | ||
var gitCommitTypes = [ | ||
{ value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" }, | ||
{ value: "feat", title: "feat: \u6DFB\u52A0\u65B0\u7279\u6027" }, | ||
{ value: "fix", title: "fix: \u4FEE\u590Dbug" }, | ||
|
@@ -354,11 +351,12 @@ var types = [ | |
{ value: "refactor", title: "refactor: \u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug" }, | ||
{ value: "perf", title: "perf: \u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C" }, | ||
{ value: "test", title: "test: \u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B" }, | ||
{ value: "build", title: "build: \u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9" }, | ||
{ value: "ci", title: "ci: CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539" }, | ||
{ value: "chore", title: "chore: \u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49" }, | ||
{ value: "revert", title: "revert: \u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C" } | ||
]; | ||
var scopes = [ | ||
var gitCommitScopes = [ | ||
["projects", "\u9879\u76EE\u642D\u5EFA"], | ||
["components", "\u7EC4\u4EF6\u76F8\u5173"], | ||
["hooks", "hook \u76F8\u5173"], | ||
|
@@ -376,20 +374,20 @@ var scopes = [ | |
}; | ||
}); | ||
|
||
// src/command/git/commit.ts | ||
// src/command/git-commit.ts | ||
async function gitCommit() { | ||
const result = await enquirer.prompt([ | ||
{ | ||
name: "types", | ||
type: "select", | ||
message: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B", | ||
choices: types.map((item) => ({ name: item.value, message: item.title })) | ||
choices: gitCommitTypes.map((item) => ({ name: item.value, message: item.title })) | ||
}, | ||
{ | ||
name: "scopes", | ||
type: "select", | ||
message: "\u9009\u62E9\u4E00\u4E2Ascope", | ||
choices: scopes.map((item) => ({ name: item.value, message: item.title })) | ||
choices: gitCommitScopes.map((item) => ({ name: item.value, message: item.title })) | ||
}, | ||
{ | ||
name: "description", | ||
|
@@ -401,17 +399,16 @@ async function gitCommit() { | |
execa("git", ["commit", "-m", commitMsg], { stdio: "inherit" }); | ||
} | ||
|
||
// src/command/git/verify-commit.ts | ||
// src/command/git-verify.ts | ||
import { readFileSync } from "fs"; | ||
import { bgRed, red, green } from "kolorist"; | ||
function verifyGitCommit() { | ||
function gitCommitVerify() { | ||
const gitMsgPath = "./.git/COMMIT_EDITMSG"; | ||
const commitMsg = readFileSync(gitMsgPath, "utf-8").trim(); | ||
const RELEASE_MSG = "chore: release"; | ||
const REG_EXP = new RegExp( | ||
`(${types.map((item) => item.value).join("|")})\\((${scopes.map((item) => item.value).join("|")})\\):\\s.{1,50}` | ||
); | ||
if (!REG_EXP.test(commitMsg) && !commitMsg.includes(RELEASE_MSG)) { | ||
const types2 = gitCommitTypes.map((item) => item.value).join("|"); | ||
const scopes = gitCommitScopes.map((item) => item.value).join("|"); | ||
const REG_EXP = new RegExp(`(${types2})!*(\\((${scopes}))\\))*!*:\\s.{1,100}`); | ||
if (!REG_EXP.test(commitMsg)) { | ||
throw new Error( | ||
`${bgRed(" ERROR ")} ${red("Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!\n\n")}${green( | ||
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F" | ||
|
@@ -553,8 +550,8 @@ var unescape = (s, { windowsPathsNoEscape = false } = {}) => { | |
}; | ||
|
||
// node_modules/.pnpm/[email protected]/node_modules/minimatch/dist/mjs/ast.js | ||
var types2 = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]); | ||
var isExtglobType = (c) => types2.has(c); | ||
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]); | ||
var isExtglobType = (c) => types.has(c); | ||
var startNoTraversal = "(?!\\.\\.?(?:$|/))"; | ||
var startNoDot = "(?!\\.)"; | ||
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]); | ||
|
@@ -6366,12 +6363,18 @@ function prettierFormat() { | |
}); | ||
} | ||
|
||
// src/scripts/release.ts | ||
import { execa as execa5 } from "execa"; | ||
async function release() { | ||
await execa5("npx", ["changelogen", "--release --push --no-github"]); | ||
} | ||
|
||
// src/index.ts | ||
program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => { | ||
gitCommit(); | ||
}); | ||
program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => { | ||
verifyGitCommit(); | ||
gitCommitVerify(); | ||
}); | ||
program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => { | ||
cleanup(); | ||
|
@@ -6385,5 +6388,8 @@ program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() | |
program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => { | ||
prettierFormat(); | ||
}); | ||
program.command("release").description("\u7248\u672C\u53D1\u5E03").action(() => { | ||
release(); | ||
}); | ||
program.version(package_default.version).description(blue("soybean alias soy\n\nhttps://github.com/soybeanjs/cli")); | ||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.