@soybeanjs/cli 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const m=require("cac"),r=require("enquirer"),cryptoJs=require("crypto-js"),s=require("path"),fs=require("fs"),kolorist=require("kolorist"),rimraf=require("rimraf"),changelog=require("@soybeanjs/changelog"),e=require("bumpp"),c12=require("c12"),promises=require("fs/promises");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const m__default=_interopDefaultCompat(m),r__default=_interopDefaultCompat(r),s__default=_interopDefaultCompat(s),e__default=_interopDefaultCompat(e),version="0.7.1";async function execCommand(t,n,o){const{execa:a}=await import("execa");return(await a(t,n,o))?.stdout?.trim()||""}class Crypto{constructor(n){this.secret=n}enCrypto(n){const o=JSON.stringify(n);return cryptoJs.AES.encrypt(o,this.secret).toString()}deCrypto(n){const o=cryptoJs.AES.decrypt(n,this.secret).toString(cryptoJs.enc.Utf8);if(o)try{return JSON.parse(o)}catch{return null}return null}}async function gitCommit(t,n){const o=t.map(([F,d])=>{const g=`${`${F}:`.padEnd(12)}${d}`;return{name:F,message:g}}),a=n.map(([F,d])=>({name:F,message:`${F.padEnd(30)} (${d})`})),c=await r__default.prompt([{name:"types",type:"select",message:"\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",choices:o},{name:"scopes",type:"select",message:"\u9009\u62E9\u4E00\u4E2Ascope",choices:a},{name:"description",type:"text",message:"\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"}]),E=`${c.types}(${c.scopes}): ${c.description}`;execCommand("git",["commit","-m",E],{stdio:"inherit"})}async function gitCommitVerify(){const t=await execCommand("git",["rev-parse","--show-toplevel"]),n=s__default.join(t,".git","COMMIT_EDITMSG"),o=fs.readFileSync(n,"utf-8").trim();if(!/(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(o))throw new Error(`${kolorist.bgRed(" ERROR ")} ${kolorist.red(`Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!
2
+ "use strict";const d$1=require("cac"),a$1=require("node:path"),node_fs=require("node:fs"),l$1=require("enquirer"),kolorist=require("kolorist"),cryptoJs=require("crypto-js"),rimraf=require("rimraf"),s=require("path"),fs=require("fs"),changelog=require("@soybeanjs/changelog"),e=require("bumpp"),c12=require("c12"),promises=require("fs/promises");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const d__default=_interopDefaultCompat(d$1),a__default=_interopDefaultCompat(a$1),l__default=_interopDefaultCompat(l$1),s__default=_interopDefaultCompat(s),e__default=_interopDefaultCompat(e),version="0.7.3";var c=Object.defineProperty,a=(t,o,r)=>o in t?c(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,n=(t,o,r)=>(a(t,typeof o!="symbol"?o+"":o,r),r);async function execCommand(t,o,r){const{execa:m}=await import("execa");return(await m(t,o,r))?.stdout?.trim()||""}class Crypto{constructor(o){n(this,"secret"),this.secret=o}enCrypto(o){const r=JSON.stringify(o);return cryptoJs.AES.encrypt(r,this.secret).toString()}deCrypto(o){const r=cryptoJs.AES.decrypt(o,this.secret).toString(cryptoJs.enc.Utf8);if(r)try{return JSON.parse(r)}catch{return null}return null}}async function gitCommit(t,o){const r=t.map(([g,h])=>{const y=`${`${g}:`.padEnd(12)}${h}`;return{name:g,message:y}}),m=o.map(([g,h])=>({name:g,message:`${g.padEnd(30)} (${h})`})),u=await l__default.prompt([{name:"types",type:"select",message:"Please select a type",choices:r},{name:"scopes",type:"select",message:"Please select a scope",choices:m},{name:"description",type:"text",message:"Please enter a description"}]),f=`${u.types}(${u.scopes}): ${u.description}`;await execCommand("git",["commit","-m",f],{stdio:"inherit"})}async function gitCommitVerify(){const t=await execCommand("git",["rev-parse","--show-toplevel"]),o=a__default.join(t,".git","COMMIT_EDITMSG"),r=node_fs.readFileSync(o,"utf8").trim();if(!/(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(r))throw new Error(`${kolorist.bgRed(" ERROR ")} ${kolorist.red("git commit message must match the Conventional Commits standard!")}
3
3
 
4
- `)}${kolorist.green("\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F")}`)}async function cleanup(t){await rimraf.rimraf(t,{glob:!0})}async function initSimpleGitHooks(t=process.cwd()){const n=s__default.join(t,".husky"),o=fs.existsSync(n),a=s__default.join(t,".git","hooks");o&&(await rimraf.rimraf(n),await execCommand("git",["config","core.hooksPath",a],{stdio:"inherit"})),await rimraf.rimraf(a),await execCommand("npx",["simple-git-hooks"],{stdio:"inherit"})}async function ncu(t=["--deep","-u"]){execCommand("npx",["ncu",...t],{stdio:"inherit"})}async function prettierWrite(t){await execCommand("npx",["prettier","--write",".",...t],{stdio:"inherit"})}async function eslintPrettier(){await execCommand("npx",["eslint",".","--fix"],{stdio:"inherit"}),await execCommand("npx",["soy","prettier-format"],{stdio:"inherit"})}async function execLintStaged(t){const n=(await import("lint-staged")).default;return n({config:t,allowEmpty:!0})}async function genChangelog(t,n=!1){n?await changelog.generateTotalChangelog(t):await changelog.generateChangelog(t)}async function release(){await e__default({files:["**/package.json","!**/node_modules"],execute:"npx soy changelog",all:!0,tag:!0,commit:"chore(projects): release v%s",push:!0})}const i="*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",l={cwd:process.cwd(),cleanupDirs:["**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/node_modules","!node_modules/**"],gitCommitTypes:[["init","\u9879\u76EE\u521D\u59CB\u5316"],["feat","\u6DFB\u52A0\u65B0\u7279\u6027"],["fix","\u4FEE\u590Dbug"],["docs","\u4EC5\u4EC5\u4FEE\u6539\u6587\u6863"],["style","\u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91"],["refactor","\u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug"],["perf","\u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C"],["test","\u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B"],["build","\u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9"],["ci","CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539"],["chore","\u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49"],["revert","\u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C"]],gitCommitScopes:[["projects","\u9879\u76EE\u642D\u5EFA"],["components","\u7EC4\u4EF6\u76F8\u5173"],["hooks","hook \u76F8\u5173"],["utils","utils \u76F8\u5173"],["types","ts\u7C7B\u578B\u76F8\u5173"],["styles","\u6837\u5F0F\u76F8\u5173"],["deps","\u9879\u76EE\u4F9D\u8D56"],["auth","\u5BF9 auth \u4FEE\u6539"],["release","\u7248\u672C\u53D1\u5E03"],["other","\u5176\u4ED6\u4FEE\u6539"]],ncuCommandArgs:["--deep","-u"],changelogOptions:{},prettierWriteGlob:[`!**/${i}`,"!*.min.*","!CHANGELOG.md","!dist","!LICENSE*","!output","!coverage","!public","!temp","!package-lock.json","!pnpm-lock.yaml","!yarn.lock","!.github","!__snapshots__","!node_modules"],lintStagedConfig:{[i]:"eslint --fix","*":"soy prettier-write"}},p="U2FsdGVkX1+vLW5S5+vcx+LKGSR2PtJOAZUZsVCTKM0+ecI3hDuARJn6kdLzzR1LVl0179NmgMoX6fV28TMu3A==";async function loadCliOptions(t,n=process.cwd()){const{config:o}=await c12.loadConfig({name:"soybean",defaults:l,overrides:t,cwd:n,packageJson:!0}),a=await u$1(n);if(o&&a){const c=new Crypto("SOYBEAN_JS");o.changelogOptions={...o.changelogOptions,github:{repo:"",token:c.deCrypto(p)||""}}}return o}async function u$1(t){let n=!1;const o="soybean";try{const a=await promises.readFile(`${t}/package.json`,"utf-8"),c=JSON.parse(a);n=c.name?.includes(o)||c.repository?.url?.includes(o)||c.author?.includes(o)||c.author?.name?.includes(o)||c.author?.url?.includes(o)}catch{}return n}async function u(){const t=await loadCliOptions(),n=m__default("soybean");n.version(version).option("--total","Generate changelog by total tags").help();const o={"git-commit":{desc:"\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",action:async()=>{await gitCommit(t.gitCommitTypes,t.gitCommitScopes)}},"git-commit-verify":{desc:"\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",action:async()=>{await gitCommitVerify()}},cleanup:{desc:"\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",action:async()=>{await cleanup(t.cleanupDirs)}},"init-simple-git-hooks":{desc:"\u521D\u59CB\u5316 simple-git-hooks \u94A9\u5B50",action:async()=>{await initSimpleGitHooks(t.cwd)}},ncu:{desc:"\u547D\u4EE4 npm-check-updates, \u5347\u7EA7\u4F9D\u8D56",action:async()=>{await ncu(t.ncuCommandArgs)}},"prettier-write":{desc:"\u6267\u884C prettier --write \u683C\u5F0F\u5316",action:async()=>{await prettierWrite(t.prettierWriteGlob)}},"lint-staged":{desc:"\u6267\u884Clint-staged",action:async()=>{const a=await execLintStaged(t.lintStagedConfig).catch(()=>{process.exitCode=1});process.exitCode=a?0:1}},changelog:{desc:"\u751F\u6210changelog",action:async a=>{await genChangelog(t.changelogOptions,a?.total)}},release:{desc:"\u53D1\u5E03\uFF1A\u66F4\u65B0\u7248\u672C\u53F7\u3001\u751F\u6210changelog\u3001\u63D0\u4EA4\u4EE3\u7801",action:async()=>{await release()}},"init-git-hooks":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 init-simple-git-hooks",action:async()=>{await initSimpleGitHooks(t.cwd)}},"update-pkg":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 ncu",action:async()=>{await ncu(t.ncuCommandArgs)}},"prettier-format":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 prettier-write",action:async()=>{await prettierWrite(t.prettierWriteGlob)}},"eslint-prettier":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",action:async()=>{await eslintPrettier()}}};for await(const[a,{desc:c,action:E}]of Object.entries(o))n.command(a,c).action(E);n.parse()}u();function defineConfig(t){return t}exports.defineConfig=defineConfig;
4
+ ${kolorist.green("Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org")}`)}async function cleanup(t){await rimraf.rimraf(t,{glob:!0})}async function initSimpleGitHooks(t=process.cwd()){const o=s__default.join(t,".husky"),r=fs.existsSync(o),m=s__default.join(t,".git","hooks");r&&(await rimraf.rimraf(o),await execCommand("git",["config","core.hooksPath",m],{stdio:"inherit"})),await rimraf.rimraf(m),await execCommand("npx",["simple-git-hooks"],{stdio:"inherit"})}async function ncu(t=["--deep","-u"]){execCommand("npx",["ncu",...t],{stdio:"inherit"})}async function prettierWrite(t){await execCommand("npx",["prettier","--write",".",...t],{stdio:"inherit"})}async function eslintPrettier(){await execCommand("npx",["eslint",".","--fix"],{stdio:"inherit"}),await execCommand("npx",["soy","prettier-format"],{stdio:"inherit"})}async function execLintStaged(t){const o=(await import("lint-staged")).default;return o({config:t,allowEmpty:!0})}async function genChangelog(t,o=!1){o?await changelog.generateTotalChangelog(t):await changelog.generateChangelog(t)}async function release(){await e__default({files:["**/package.json","!**/node_modules"],execute:"npx soy changelog",all:!0,tag:!0,commit:"chore(projects): release v%s",push:!0})}const i$1="*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",p={cwd:process.cwd(),cleanupDirs:["**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/node_modules","!node_modules/**"],gitCommitTypes:[["feat","A new feature"],["fix","A bug fix"],["docs","Documentation only changes"],["style","Changes that do not affect the meaning of the code"],["refactor","A code change that neither fixes a bug nor adds a feature"],["perf","A code change that improves performance"],["test","Adding missing tests or correcting existing tests"],["build","Changes that affect the build system or external dependencies"],["ci","Changes to our CI configuration files and scripts"],["chore","Other changes that don't modify src or test files"],["revert","Reverts a previous commit"]],gitCommitScopes:[["projects","project"],["components","components"],["hooks","hook functions"],["utils","utils functions"],["types","TS declaration"],["styles","style"],["deps","project dependencies"],["release","release project"],["other","other changes"]],ncuCommandArgs:["--deep","-u"],changelogOptions:{},prettierWriteGlob:[`!**/${i$1}`,"!*.min.*","!CHANGELOG.md","!dist","!LICENSE*","!output","!coverage","!public","!temp","!package-lock.json","!pnpm-lock.yaml","!yarn.lock","!.github","!__snapshots__","!node_modules"],lintStagedConfig:{[i$1]:"eslint --fix","*":"soy prettier-write"}},l="U2FsdGVkX1+vLW5S5+vcx+LKGSR2PtJOAZUZsVCTKM0+ecI3hDuARJn6kdLzzR1LVl0179NmgMoX6fV28TMu3A==";async function loadCliOptions(t,o=process.cwd()){const{config:r}=await c12.loadConfig({name:"soybean",defaults:p,overrides:t,cwd:o,packageJson:!0}),m=await d(o);if(r&&m){const u=new Crypto("SOYBEAN_JS");r.changelogOptions={...r.changelogOptions,github:{repo:"",token:u.deCrypto(l)||""}}}return r}async function d(t){let o=!1;const r="soybean";try{const m=await promises.readFile(`${t}/package.json`,"utf-8"),u=JSON.parse(m);o=u.name?.includes(r)||u.repository?.url?.includes(r)||u.author?.includes(r)||u.author?.name?.includes(r)||u.author?.url?.includes(r)}catch{}return o}const i="the command is deprecated, it will be removed in the next major version 1.0.0";async function v(){const t=await loadCliOptions(),o=d__default("soybean");o.version(version).option("--total","Generate changelog by total tags").help();const r={cleanup:{desc:"delete dirs: node_modules, dist, etc.",action:async()=>{await cleanup(t.cleanupDirs)}},ncu:{desc:"npm-check-updates, it can update package.json dependencies to the latest version",action:async()=>{await ncu(t.ncuCommandArgs)}},"git-commit":{desc:"git commit, generate commit message which match Conventional Commits standard",action:async()=>{await gitCommit(t.gitCommitTypes,t.gitCommitScopes)}},"git-commit-verify":{desc:"verify git commit message, make sure it match Conventional Commits standard",action:async()=>{await gitCommitVerify()}},"prettier-write":{desc:"run prettier --write",action:async()=>{await prettierWrite(t.prettierWriteGlob)}},"lint-staged":{desc:"run lint-staged",action:async()=>{const m=await execLintStaged(t.lintStagedConfig).catch(()=>{process.exitCode=1});process.exitCode=m?0:1}},changelog:{desc:"generate changelog",action:async m=>{await genChangelog(t.changelogOptions,m?.total)}},release:{desc:"release: update version, generate changelog, commit code",action:async()=>{await release()}},"init-simple-git-hooks":{desc:`init simple-git-hooks and remove husky (${i})`,action:async()=>{await initSimpleGitHooks(t.cwd)}},"init-git-hooks":{desc:`same as init-simple-git-hooks (${i})`,action:async()=>{await initSimpleGitHooks(t.cwd)}},"update-pkg":{desc:`same as ncu (${i})`,action:async()=>{await ncu(t.ncuCommandArgs)}},"prettier-format":{desc:`same as prettier-write (${i})`,action:async()=>{await prettierWrite(t.prettierWriteGlob)}},"eslint-prettier":{desc:i,action:async()=>{await eslintPrettier()}}};for await(const[m,{desc:u,action:f}]of Object.entries(r))o.command(m,u).action(f);o.parse()}v();function defineConfig(t){return t}exports.defineConfig=defineConfig;
@@ -0,0 +1,48 @@
1
+ import { ChangelogOption } from '@soybeanjs/changelog';
2
+
3
+ interface CliOption {
4
+ /**
5
+ * the project root directory
6
+ */
7
+ cwd: string;
8
+ /**
9
+ * cleanup dirs
10
+ * @default
11
+ * ```json
12
+ * ["** /dist", "** /pnpm-lock.yaml", "** /node_modules", "!node_modules/**"]
13
+ * ```
14
+ * @description glob pattern syntax {@link https://github.com/isaacs/minimatch}
15
+ */
16
+ cleanupDirs: string[];
17
+ /**
18
+ * git commit types
19
+ */
20
+ gitCommitTypes: [string, string][];
21
+ /**
22
+ * git commit scopes
23
+ */
24
+ gitCommitScopes: [string, string][];
25
+ /**
26
+ * npm-check-updates command args
27
+ * @default ["--deep","-u"]
28
+ */
29
+ ncuCommandArgs: string[];
30
+ /**
31
+ * options of generate changelog
32
+ * @link https://github.com/soybeanjs/changelog
33
+ */
34
+ changelogOptions: Partial<ChangelogOption>;
35
+ /**
36
+ * prettier write glob
37
+ * @description glob pattern syntax {@link https://github.com/micromatch/micromatch}
38
+ */
39
+ prettierWriteGlob: string[];
40
+ /**
41
+ * lint-staged config
42
+ */
43
+ lintStagedConfig: Record<string, string | string[]>;
44
+ }
45
+
46
+ declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
47
+
48
+ export { type CliOption, defineConfig };
@@ -0,0 +1,48 @@
1
+ import { ChangelogOption } from '@soybeanjs/changelog';
2
+
3
+ interface CliOption {
4
+ /**
5
+ * the project root directory
6
+ */
7
+ cwd: string;
8
+ /**
9
+ * cleanup dirs
10
+ * @default
11
+ * ```json
12
+ * ["** /dist", "** /pnpm-lock.yaml", "** /node_modules", "!node_modules/**"]
13
+ * ```
14
+ * @description glob pattern syntax {@link https://github.com/isaacs/minimatch}
15
+ */
16
+ cleanupDirs: string[];
17
+ /**
18
+ * git commit types
19
+ */
20
+ gitCommitTypes: [string, string][];
21
+ /**
22
+ * git commit scopes
23
+ */
24
+ gitCommitScopes: [string, string][];
25
+ /**
26
+ * npm-check-updates command args
27
+ * @default ["--deep","-u"]
28
+ */
29
+ ncuCommandArgs: string[];
30
+ /**
31
+ * options of generate changelog
32
+ * @link https://github.com/soybeanjs/changelog
33
+ */
34
+ changelogOptions: Partial<ChangelogOption>;
35
+ /**
36
+ * prettier write glob
37
+ * @description glob pattern syntax {@link https://github.com/micromatch/micromatch}
38
+ */
39
+ prettierWriteGlob: string[];
40
+ /**
41
+ * lint-staged config
42
+ */
43
+ lintStagedConfig: Record<string, string | string[]>;
44
+ }
45
+
46
+ declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
47
+
48
+ export { type CliOption, defineConfig };
package/dist/index.d.ts CHANGED
@@ -45,4 +45,4 @@ interface CliOption {
45
45
 
46
46
  declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
47
47
 
48
- export { CliOption, defineConfig };
48
+ export { type CliOption, defineConfig };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import C from"cac";import y from"enquirer";import{AES as F,enc as D}from"crypto-js";import r from"path";import{readFileSync as f,existsSync as h}from"fs";import{bgRed as w,red as A,green as B}from"kolorist";import{rimraf as p}from"rimraf";import{generateTotalChangelog as k,generateChangelog as x}from"@soybeanjs/changelog";import S from"bumpp";import{loadConfig as b}from"c12";import{readFile as v}from"fs/promises";const j="0.7.1";async function n(u,t,e){const{execa:i}=await import("execa");return(await i(u,t,e))?.stdout?.trim()||""}class O{constructor(t){this.secret=t}enCrypto(t){const e=JSON.stringify(t);return F.encrypt(e,this.secret).toString()}deCrypto(t){const e=F.decrypt(t,this.secret).toString(D.Utf8);if(e)try{return JSON.parse(e)}catch{return null}return null}}async function $(u,t){const e=u.map(([s,c])=>{const g=`${`${s}:`.padEnd(12)}${c}`;return{name:s,message:g}}),i=t.map(([s,c])=>({name:s,message:`${s.padEnd(30)} (${c})`})),o=await y.prompt([{name:"types",type:"select",message:"\u8BF7\u9009\u62E9\u63D0\u4EA4\u7684\u7C7B\u578B",choices:e},{name:"scopes",type:"select",message:"\u9009\u62E9\u4E00\u4E2Ascope",choices:i},{name:"description",type:"text",message:"\u8BF7\u8F93\u5165\u63D0\u4EA4\u63CF\u8FF0"}]),a=`${o.types}(${o.scopes}): ${o.description}`;n("git",["commit","-m",a],{stdio:"inherit"})}async function G(){const u=await n("git",["rev-parse","--show-toplevel"]),t=r.join(u,".git","COMMIT_EDITMSG"),e=f(t,"utf-8").trim();if(!/(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(e))throw new Error(`${w(" ERROR ")} ${A(`Git\u63D0\u4EA4\u4FE1\u606F\u4E0D\u7B26\u5408 Angular \u89C4\u8303!
2
+ import w from"cac";import C from"node:path";import{readFileSync as v}from"node:fs";import k from"enquirer";import{bgRed as b,red as x,green as j}from"kolorist";import{AES as d,enc as S}from"crypto-js";import{rimraf as p}from"rimraf";import l from"path";import{existsSync as $}from"fs";import{generateTotalChangelog as O,generateChangelog as A}from"@soybeanjs/changelog";import E from"bumpp";import{loadConfig as G}from"c12";import{readFile as _}from"fs/promises";const R="0.7.3";var T=Object.defineProperty,J=(e,t,o)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,L=(e,t,o)=>(J(e,typeof t!="symbol"?t+"":t,o),o);async function a(e,t,o){const{execa:n}=await import("execa");return(await n(e,t,o))?.stdout?.trim()||""}class N{constructor(t){L(this,"secret"),this.secret=t}enCrypto(t){const o=JSON.stringify(t);return d.encrypt(o,this.secret).toString()}deCrypto(t){const o=d.decrypt(t,this.secret).toString(S.Utf8);if(o)try{return JSON.parse(o)}catch{return null}return null}}async function P(e,t){const o=e.map(([s,m])=>{const y=`${`${s}:`.padEnd(12)}${m}`;return{name:s,message:y}}),n=t.map(([s,m])=>({name:s,message:`${s.padEnd(30)} (${m})`})),i=await k.prompt([{name:"types",type:"select",message:"Please select a type",choices:o},{name:"scopes",type:"select",message:"Please select a scope",choices:n},{name:"description",type:"text",message:"Please enter a description"}]),r=`${i.types}(${i.scopes}): ${i.description}`;await a("git",["commit","-m",r],{stdio:"inherit"})}async function M(){const e=await a("git",["rev-parse","--show-toplevel"]),t=C.join(e,".git","COMMIT_EDITMSG"),o=v(t,"utf8").trim();if(!/(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(o))throw new Error(`${b(" ERROR ")} ${x("git commit message must match the Conventional Commits standard!")}
3
3
 
4
- `)}${B("\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 pnpm commit \u751F\u6210\u7B26\u5408\u89C4\u8303\u7684Git\u63D0\u4EA4\u4FE1\u606F")}`)}async function _(u){await p(u,{glob:!0})}async function m(u=process.cwd()){const t=r.join(u,".husky"),e=h(t),i=r.join(u,".git","hooks");e&&(await p(t),await n("git",["config","core.hooksPath",i],{stdio:"inherit"})),await p(i),await n("npx",["simple-git-hooks"],{stdio:"inherit"})}async function E(u=["--deep","-u"]){n("npx",["ncu",...u],{stdio:"inherit"})}async function l(u){await n("npx",["prettier","--write",".",...u],{stdio:"inherit"})}async function J(){await n("npx",["eslint",".","--fix"],{stdio:"inherit"}),await n("npx",["soy","prettier-format"],{stdio:"inherit"})}async function L(u){const t=(await import("lint-staged")).default;return t({config:u,allowEmpty:!0})}async function N(u,t=!1){t?await k(u):await x(u)}async function R(){await S({files:["**/package.json","!**/node_modules"],execute:"npx soy changelog",all:!0,tag:!0,commit:"chore(projects): release v%s",push:!0})}const d="*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",T={cwd:process.cwd(),cleanupDirs:["**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/node_modules","!node_modules/**"],gitCommitTypes:[["init","\u9879\u76EE\u521D\u59CB\u5316"],["feat","\u6DFB\u52A0\u65B0\u7279\u6027"],["fix","\u4FEE\u590Dbug"],["docs","\u4EC5\u4EC5\u4FEE\u6539\u6587\u6863"],["style","\u4EC5\u4EC5\u4FEE\u6539\u4E86\u7A7A\u683C\u3001\u683C\u5F0F\u7F29\u8FDB\u3001\u9017\u53F7\u7B49\u7B49\uFF0C\u4E0D\u6539\u53D8\u4EE3\u7801\u903B\u8F91"],["refactor","\u4EE3\u7801\u91CD\u6784\uFF0C\u6CA1\u6709\u52A0\u65B0\u529F\u80FD\u6216\u8005\u4FEE\u590Dbug"],["perf","\u4F18\u5316\u76F8\u5173\uFF0C\u6BD4\u5982\u63D0\u5347\u6027\u80FD\u3001\u4F53\u9A8C"],["test","\u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B"],["build","\u4F9D\u8D56\u76F8\u5173\u7684\u5185\u5BB9"],["ci","CI\u914D\u7F6E\u76F8\u5173\uFF0C\u4F8B\u5982\u5BF9k8s\uFF0Cdocker\u7684\u914D\u7F6E\u6587\u4EF6\u7684\u4FEE\u6539"],["chore","\u6539\u53D8\u6784\u5EFA\u6D41\u7A0B\u3001\u6216\u8005\u589E\u52A0\u4F9D\u8D56\u5E93\u3001\u5DE5\u5177\u7B49"],["revert","\u56DE\u6EDA\u5230\u4E0A\u4E00\u4E2A\u7248\u672C"]],gitCommitScopes:[["projects","\u9879\u76EE\u642D\u5EFA"],["components","\u7EC4\u4EF6\u76F8\u5173"],["hooks","hook \u76F8\u5173"],["utils","utils \u76F8\u5173"],["types","ts\u7C7B\u578B\u76F8\u5173"],["styles","\u6837\u5F0F\u76F8\u5173"],["deps","\u9879\u76EE\u4F9D\u8D56"],["auth","\u5BF9 auth \u4FEE\u6539"],["release","\u7248\u672C\u53D1\u5E03"],["other","\u5176\u4ED6\u4FEE\u6539"]],ncuCommandArgs:["--deep","-u"],changelogOptions:{},prettierWriteGlob:[`!**/${d}`,"!*.min.*","!CHANGELOG.md","!dist","!LICENSE*","!output","!coverage","!public","!temp","!package-lock.json","!pnpm-lock.yaml","!yarn.lock","!.github","!__snapshots__","!node_modules"],lintStagedConfig:{[d]:"eslint --fix","*":"soy prettier-write"}},M="U2FsdGVkX1+vLW5S5+vcx+LKGSR2PtJOAZUZsVCTKM0+ecI3hDuARJn6kdLzzR1LVl0179NmgMoX6fV28TMu3A==";async function I(u,t=process.cwd()){const{config:e}=await b({name:"soybean",defaults:T,overrides:u,cwd:t,packageJson:!0}),i=await V(t);if(e&&i){const o=new O("SOYBEAN_JS");e.changelogOptions={...e.changelogOptions,github:{repo:"",token:o.deCrypto(M)||""}}}return e}async function V(u){let t=!1;const e="soybean";try{const i=await v(`${u}/package.json`,"utf-8"),o=JSON.parse(i);t=o.name?.includes(e)||o.repository?.url?.includes(e)||o.author?.includes(e)||o.author?.name?.includes(e)||o.author?.url?.includes(e)}catch{}return t}async function W(){const u=await I(),t=C("soybean");t.version(j).option("--total","Generate changelog by total tags").help();const e={"git-commit":{desc:"\u751F\u6210\u7B26\u5408 Conventional Commits \u89C4\u8303\u7684\u63D0\u4EA4\u4FE1\u606F",action:async()=>{await $(u.gitCommitTypes,u.gitCommitScopes)}},"git-commit-verify":{desc:"\u6821\u9A8C git \u63D0\u4EA4\u4FE1\u606F\u662F\u5426\u7B26\u5408 Conventional Commits \u89C4\u8303",action:async()=>{await G()}},cleanup:{desc:"\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",action:async()=>{await _(u.cleanupDirs)}},"init-simple-git-hooks":{desc:"\u521D\u59CB\u5316 simple-git-hooks \u94A9\u5B50",action:async()=>{await m(u.cwd)}},ncu:{desc:"\u547D\u4EE4 npm-check-updates, \u5347\u7EA7\u4F9D\u8D56",action:async()=>{await E(u.ncuCommandArgs)}},"prettier-write":{desc:"\u6267\u884C prettier --write \u683C\u5F0F\u5316",action:async()=>{await l(u.prettierWriteGlob)}},"lint-staged":{desc:"\u6267\u884Clint-staged",action:async()=>{const i=await L(u.lintStagedConfig).catch(()=>{process.exitCode=1});process.exitCode=i?0:1}},changelog:{desc:"\u751F\u6210changelog",action:async i=>{await N(u.changelogOptions,i?.total)}},release:{desc:"\u53D1\u5E03\uFF1A\u66F4\u65B0\u7248\u672C\u53F7\u3001\u751F\u6210changelog\u3001\u63D0\u4EA4\u4EE3\u7801",action:async()=>{await R()}},"init-git-hooks":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 init-simple-git-hooks",action:async()=>{await m(u.cwd)}},"update-pkg":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 ncu",action:async()=>{await E(u.ncuCommandArgs)}},"prettier-format":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 prettier-write",action:async()=>{await l(u.prettierWriteGlob)}},"eslint-prettier":{desc:"\u8BE5\u547D\u4EE4\u5DF2\u5E9F\u5F03",action:async()=>{await J()}}};for await(const[i,{desc:o,action:a}]of Object.entries(e))t.command(i,o).action(a);t.parse()}W();function z(u){return u}export{z as defineConfig};
4
+ ${j("Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org")}`)}async function D(e){await p(e,{glob:!0})}async function g(e=process.cwd()){const t=l.join(e,".husky"),o=$(t),n=l.join(e,".git","hooks");o&&(await p(t),await a("git",["config","core.hooksPath",n],{stdio:"inherit"})),await p(n),await a("npx",["simple-git-hooks"],{stdio:"inherit"})}async function u(e=["--deep","-u"]){a("npx",["ncu",...e],{stdio:"inherit"})}async function h(e){await a("npx",["prettier","--write",".",...e],{stdio:"inherit"})}async function I(){await a("npx",["eslint",".","--fix"],{stdio:"inherit"}),await a("npx",["soy","prettier-format"],{stdio:"inherit"})}async function V(e){const t=(await import("lint-staged")).default;return t({config:e,allowEmpty:!0})}async function W(e,t=!1){t?await O(e):await A(e)}async function z(){await E({files:["**/package.json","!**/node_modules"],execute:"npx soy changelog",all:!0,tag:!0,commit:"chore(projects): release v%s",push:!0})}const f="*.{js,jsx,mjs,cjs,json,ts,tsx,mts,cts,vue,svelte,astro}",F={cwd:process.cwd(),cleanupDirs:["**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/node_modules","!node_modules/**"],gitCommitTypes:[["feat","A new feature"],["fix","A bug fix"],["docs","Documentation only changes"],["style","Changes that do not affect the meaning of the code"],["refactor","A code change that neither fixes a bug nor adds a feature"],["perf","A code change that improves performance"],["test","Adding missing tests or correcting existing tests"],["build","Changes that affect the build system or external dependencies"],["ci","Changes to our CI configuration files and scripts"],["chore","Other changes that don't modify src or test files"],["revert","Reverts a previous commit"]],gitCommitScopes:[["projects","project"],["components","components"],["hooks","hook functions"],["utils","utils functions"],["types","TS declaration"],["styles","style"],["deps","project dependencies"],["release","release project"],["other","other changes"]],ncuCommandArgs:["--deep","-u"],changelogOptions:{},prettierWriteGlob:[`!**/${f}`,"!*.min.*","!CHANGELOG.md","!dist","!LICENSE*","!output","!coverage","!public","!temp","!package-lock.json","!pnpm-lock.yaml","!yarn.lock","!.github","!__snapshots__","!node_modules"],lintStagedConfig:{[f]:"eslint --fix","*":"soy prettier-write"}},U="U2FsdGVkX1+vLW5S5+vcx+LKGSR2PtJOAZUZsVCTKM0+ecI3hDuARJn6kdLzzR1LVl0179NmgMoX6fV28TMu3A==";async function H(e,t=process.cwd()){const{config:o}=await G({name:"soybean",defaults:F,overrides:e,cwd:t,packageJson:!0}),n=await K(t);if(o&&n){const i=new N("SOYBEAN_JS");o.changelogOptions={...o.changelogOptions,github:{repo:"",token:i.deCrypto(U)||""}}}return o}async function K(e){let t=!1;const o="soybean";try{const n=await _(`${e}/package.json`,"utf-8"),i=JSON.parse(n);t=i.name?.includes(o)||i.repository?.url?.includes(o)||i.author?.includes(o)||i.author?.name?.includes(o)||i.author?.url?.includes(o)}catch{}return t}const c="the command is deprecated, it will be removed in the next major version 1.0.0";async function X(){const e=await H(),t=w("soybean");t.version(R).option("--total","Generate changelog by total tags").help();const o={cleanup:{desc:"delete dirs: node_modules, dist, etc.",action:async()=>{await D(e.cleanupDirs)}},ncu:{desc:"npm-check-updates, it can update package.json dependencies to the latest version",action:async()=>{await u(e.ncuCommandArgs)}},"git-commit":{desc:"git commit, generate commit message which match Conventional Commits standard",action:async()=>{await P(e.gitCommitTypes,e.gitCommitScopes)}},"git-commit-verify":{desc:"verify git commit message, make sure it match Conventional Commits standard",action:async()=>{await M()}},"prettier-write":{desc:"run prettier --write",action:async()=>{await h(e.prettierWriteGlob)}},"lint-staged":{desc:"run lint-staged",action:async()=>{const n=await V(e.lintStagedConfig).catch(()=>{process.exitCode=1});process.exitCode=n?0:1}},changelog:{desc:"generate changelog",action:async n=>{await W(e.changelogOptions,n?.total)}},release:{desc:"release: update version, generate changelog, commit code",action:async()=>{await z()}},"init-simple-git-hooks":{desc:`init simple-git-hooks and remove husky (${c})`,action:async()=>{await g(e.cwd)}},"init-git-hooks":{desc:`same as init-simple-git-hooks (${c})`,action:async()=>{await g(e.cwd)}},"update-pkg":{desc:`same as ncu (${c})`,action:async()=>{await u(e.ncuCommandArgs)}},"prettier-format":{desc:`same as prettier-write (${c})`,action:async()=>{await h(e.prettierWriteGlob)}},"eslint-prettier":{desc:c,action:async()=>{await I()}}};for await(const[n,{desc:i,action:r}]of Object.entries(o))t.command(n,i).action(r);t.parse()}X();function Z(e){return e}export{Z as defineConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "SoybeanJS's command line tools",
5
5
  "author": {
6
6
  "name": "Soybean",
@@ -36,39 +36,40 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@soybeanjs/changelog": "0.3.2",
40
- "bumpp": "9.1.1",
39
+ "@soybeanjs/changelog": "0.3.4",
40
+ "bumpp": "9.2.0",
41
41
  "c12": "1.4.2",
42
42
  "cac": "6.7.14",
43
43
  "consola": "3.2.3",
44
- "crypto-js": "^4.1.1",
44
+ "crypto-js": "4.1.1",
45
45
  "enquirer": "2.4.1",
46
46
  "execa": "8.0.1",
47
47
  "kolorist": "1.8.0",
48
48
  "lint-staged": "14.0.1",
49
49
  "minimist": "1.2.8",
50
- "npm-check-updates": "16.13.0",
51
- "rimraf": "5.0.1"
50
+ "npm-check-updates": "16.14.5",
51
+ "rimraf": "5.0.5"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@soybeanjs/cli": "link:",
55
- "@types/crypto-js": "^4.1.1",
56
- "@types/node": "20.5.2",
57
- "eslint": "8.47.0",
58
- "eslint-config-soybeanjs": "0.5.5",
55
+ "@types/crypto-js": "4.1.2",
56
+ "@types/node": "20.8.4",
57
+ "eslint": "8.51.0",
58
+ "eslint-config-soybeanjs": "0.5.7",
59
59
  "simple-git-hooks": "2.9.0",
60
- "tsx": "3.12.7",
61
- "typescript": "5.1.6",
62
- "unbuild": "1.2.1"
60
+ "tsx": "3.13.0",
61
+ "typescript": "5.2.2",
62
+ "unbuild": "2.0.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "pnpm typecheck && unbuild && pnpm build-pkg",
66
66
  "build-pkg": "pnpm -r --filter='./packages/*' run build",
67
+ "stub": "pnpm -r run stub",
67
68
  "lint": "eslint . --fix",
68
69
  "format": "soy prettier-write",
69
70
  "commit": "soy git-commit",
70
71
  "cleanup": "soy cleanup",
71
- "ncu": "soy ncu",
72
+ "update-pkg": "soy ncu",
72
73
  "publish-pkg": "pnpm -r publish --access public",
73
74
  "typecheck": "tsc --noEmit",
74
75
  "release": "soy release && pnpm build && pnpm publish-pkg"