@soybeanjs/cli 1.0.0-beta.4 → 1.0.0-beta.5
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 +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const m$1=require("cac"),a$1=require("node:path"),node_fs=require("node:fs"),l$1=require("enquirer"),kolorist=require("kolorist"),node_module=require("node:module"),rimraf=require("rimraf"),changelog=require("@soybeanjs/changelog"),r=require("bumpp"),i$1=require("node:process"),promises=require("node:fs/promises"),c12=require("c12");var _documentCurrentScript=typeof document<"u"?document.currentScript:null;function _interopDefaultCompat(e){return e&&typeof e=="object"&&"default"in e?e.default:e}const m__default=_interopDefaultCompat(m$1),a__default=_interopDefaultCompat(a$1),l__default=_interopDefaultCompat(l$1),r__default=_interopDefaultCompat(r),i__default=_interopDefaultCompat(i$1),version="1.0.0-beta.
|
|
2
|
+
"use strict";const m$1=require("cac"),a$1=require("node:path"),node_fs=require("node:fs"),l$1=require("enquirer"),kolorist=require("kolorist"),node_module=require("node:module"),rimraf=require("rimraf"),changelog=require("@soybeanjs/changelog"),r=require("bumpp"),i$1=require("node:process"),promises=require("node:fs/promises"),c12=require("c12");var _documentCurrentScript=typeof document<"u"?document.currentScript:null;function _interopDefaultCompat(e){return e&&typeof e=="object"&&"default"in e?e.default:e}const m__default=_interopDefaultCompat(m$1),a__default=_interopDefaultCompat(a$1),l__default=_interopDefaultCompat(l$1),r__default=_interopDefaultCompat(r),i__default=_interopDefaultCompat(i$1),version="1.0.0-beta.5";var i=Object.defineProperty,a=(e,t,s)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,o=(e,t,s)=>(a(e,typeof t!="symbol"?t+"":t,s),s);async function execCommand(e,t,s){const{execa:c}=await import("execa");return(await c(e,t,s))?.stdout?.trim()||""}const u=node_module.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.src||new URL("index.cjs",document.baseURI).href),n=u("crypto-js");class Crypto{constructor(t){o(this,"secret"),this.secret=t}enCrypto(t){const s=JSON.stringify(t);return n.AES.encrypt(s,this.secret).toString()}deCrypto(t){const s=n.AES.decrypt(t,this.secret).toString(n.enc.Utf8);if(s)try{return JSON.parse(s)}catch{return null}return null}}async function gitCommit(e,t){const s=e.map(([h,y])=>{const C=`${`${h}:`.padEnd(12)}${y}`;return{name:h,message:C}}),c=t.map(([h,y])=>({name:h,message:`${h.padEnd(30)} (${y})`})),p=await l__default.prompt([{name:"types",type:"select",message:"Please select a type",choices:s},{name:"scopes",type:"select",message:"Please select a scope",choices:c},{name:"description",type:"text",message:"Please enter a description"}]),g=`${p.types}(${p.scopes}): ${p.description}`;await execCommand("git",["commit","-m",g],{stdio:"inherit"})}async function gitCommitVerify(){const e=await execCommand("git",["rev-parse","--show-toplevel"]),t=a__default.join(e,".git","COMMIT_EDITMSG"),s=node_fs.readFileSync(t,"utf8").trim();if(!/(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(s))throw new Error(`${kolorist.bgRed(" ERROR ")} ${kolorist.red("git commit message must match the Conventional Commits standard!")}
|
|
3
3
|
|
|
4
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(e){await rimraf.rimraf(e,{glob:!0})}async function ncu(e=["--deep","-u"]){execCommand("npx",["ncu",...e],{stdio:"inherit"})}async function genChangelog(e,t=!1){t?await changelog.generateTotalChangelog(e):await changelog.generateChangelog(e)}async function release(e="npx soy changelog",t=!0){await r__default({files:["**/package.json","!**/node_modules"],execute:e,all:!0,tag:!0,commit:"chore(projects): release v%s",push:t})}const l={cwd:i__default.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:{}},d="U2FsdGVkX18dc7x8PmAq30sl+nyGmi5VJJwninmYBRs8vVILEIjY+kT/F8ajm/6gRTMbDAEmx5WKInQBzeNSig==";async function loadCliOptions(e,t=i__default.cwd()){const{config:s}=await c12.loadConfig({name:"soybean",defaults:l,overrides:e,cwd:t,packageJson:!0}),c=await m(t);if(s&&c){const p=new Crypto("SOYBEAN_JS");s.changelogOptions={...s.changelogOptions,github:{repo:"",token:p.deCrypto(d)||""}}}return s}async function m(e){let t=!1;const s="soybean";try{const c=await promises.readFile(a__default.join(e,"package.json"),"utf-8"),p=JSON.parse(c);t=p.name?.includes(s)||p.repository?.url?.includes(s)||p.author?.includes(s)||p.author?.name?.includes(s)||p.author?.url?.includes(s)}catch{}return t}async function f(){const e=await loadCliOptions(),t=m__default("soybean");t.version(version).option("-e, --execute [command]","Execute additional command after bumping and before git commit. Defaults to 'npx soy changelog'").option("-p, --push","Indicates whether to push the git commit and tag").option("-t, --total","Generate changelog by total tags").option("-c, --cleanupDir <dir>",'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them').help();const s={cleanup:{desc:"delete dirs: node_modules, dist, etc.",action:async c=>{const p=(c?.cleanupDir?.split(",")||[]).map(g=>g.trim()).filter(Boolean);p.length&&(e.cleanupDirs=p),await cleanup(e.cleanupDirs)}},ncu:{desc:"npm-check-updates, it can update package.json dependencies to the latest version",action:async()=>{await ncu(e.ncuCommandArgs)}},"git-commit":{desc:"git commit, generate commit message which match Conventional Commits standard",action:async()=>{await gitCommit(e.gitCommitTypes,e.gitCommitScopes)}},"git-commit-verify":{desc:"verify git commit message, make sure it match Conventional Commits standard",action:async()=>{await gitCommitVerify()}},changelog:{desc:"generate changelog",action:async c=>{await genChangelog(e.changelogOptions,c?.total)}},release:{desc:"release: update version, generate changelog, commit code",action:async c=>{await release(c?.execute,c?.push)}}};for await(const[c,{desc:p,action:g}]of Object.entries(s))t.command(c,p).action(g);t.parse()}f();function defineConfig(e){return e}exports.defineConfig=defineConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import g from"cac";import p from"node:path";import{readFileSync as u}from"node:fs";import f from"enquirer";import{bgRed as h,red as y,green as w}from"kolorist";import{createRequire as C}from"node:module";import{rimraf as v}from"rimraf";import{generateTotalChangelog as b,generateChangelog as x}from"@soybeanjs/changelog";import k from"bumpp";import l from"node:process";import{readFile as j}from"node:fs/promises";import{loadConfig as S}from"c12";const $="1.0.0-beta.
|
|
2
|
+
import g from"cac";import p from"node:path";import{readFileSync as u}from"node:fs";import f from"enquirer";import{bgRed as h,red as y,green as w}from"kolorist";import{createRequire as C}from"node:module";import{rimraf as v}from"rimraf";import{generateTotalChangelog as b,generateChangelog as x}from"@soybeanjs/changelog";import k from"bumpp";import l from"node:process";import{readFile as j}from"node:fs/promises";import{loadConfig as S}from"c12";const $="1.0.0-beta.5";var O=Object.defineProperty,A=(e,t,o)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t,o)=>(A(e,typeof t!="symbol"?t+"":t,o),o);async function r(e,t,o){const{execa:n}=await import("execa");return(await n(e,t,o))?.stdout?.trim()||""}const D=C(import.meta.url),m=D("crypto-js");class R{constructor(t){E(this,"secret"),this.secret=t}enCrypto(t){const o=JSON.stringify(t);return m.AES.encrypt(o,this.secret).toString()}deCrypto(t){const o=m.AES.decrypt(t,this.secret).toString(m.enc.Utf8);if(o)try{return JSON.parse(o)}catch{return null}return null}}async function T(e,t){const o=e.map(([s,c])=>{const d=`${`${s}:`.padEnd(12)}${c}`;return{name:s,message:d}}),n=t.map(([s,c])=>({name:s,message:`${s.padEnd(30)} (${c})`})),a=await f.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"}]),i=`${a.types}(${a.scopes}): ${a.description}`;await r("git",["commit","-m",i],{stdio:"inherit"})}async function I(){const e=await r("git",["rev-parse","--show-toplevel"]),t=p.join(e,".git","COMMIT_EDITMSG"),o=u(t,"utf8").trim();if(!/(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i.test(o))throw new Error(`${h(" ERROR ")} ${y("git commit message must match the Conventional Commits standard!")}
|
|
3
3
|
|
|
4
4
|
${w("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 J(e){await v(e,{glob:!0})}async function _(e=["--deep","-u"]){r("npx",["ncu",...e],{stdio:"inherit"})}async function G(e,t=!1){t?await b(e):await x(e)}async function M(e="npx soy changelog",t=!0){await k({files:["**/package.json","!**/node_modules"],execute:e,all:!0,tag:!0,commit:"chore(projects): release v%s",push:t})}const N={cwd:l.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:{}},P="U2FsdGVkX18dc7x8PmAq30sl+nyGmi5VJJwninmYBRs8vVILEIjY+kT/F8ajm/6gRTMbDAEmx5WKInQBzeNSig==";async function B(e,t=l.cwd()){const{config:o}=await S({name:"soybean",defaults:N,overrides:e,cwd:t,packageJson:!0}),n=await F(t);if(o&&n){const a=new R("SOYBEAN_JS");o.changelogOptions={...o.changelogOptions,github:{repo:"",token:a.deCrypto(P)||""}}}return o}async function F(e){let t=!1;const o="soybean";try{const n=await j(p.join(e,"package.json"),"utf-8"),a=JSON.parse(n);t=a.name?.includes(o)||a.repository?.url?.includes(o)||a.author?.includes(o)||a.author?.name?.includes(o)||a.author?.url?.includes(o)}catch{}return t}async function V(){const e=await B(),t=g("soybean");t.version($).option("-e, --execute [command]","Execute additional command after bumping and before git commit. Defaults to 'npx soy changelog'").option("-p, --push","Indicates whether to push the git commit and tag").option("-t, --total","Generate changelog by total tags").option("-c, --cleanupDir <dir>",'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them').help();const o={cleanup:{desc:"delete dirs: node_modules, dist, etc.",action:async n=>{const a=(n?.cleanupDir?.split(",")||[]).map(i=>i.trim()).filter(Boolean);a.length&&(e.cleanupDirs=a),await J(e.cleanupDirs)}},ncu:{desc:"npm-check-updates, it can update package.json dependencies to the latest version",action:async()=>{await _(e.ncuCommandArgs)}},"git-commit":{desc:"git commit, generate commit message which match Conventional Commits standard",action:async()=>{await T(e.gitCommitTypes,e.gitCommitScopes)}},"git-commit-verify":{desc:"verify git commit message, make sure it match Conventional Commits standard",action:async()=>{await I()}},changelog:{desc:"generate changelog",action:async n=>{await G(e.changelogOptions,n?.total)}},release:{desc:"release: update version, generate changelog, commit code",action:async n=>{await M(n?.execute,n?.push)}}};for await(const[n,{desc:a,action:i}]of Object.entries(o))t.command(n,a).action(i);t.parse()}V();function Y(e){return e}export{Y as defineConfig};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.5",
|
|
5
5
|
"packageManager": "pnpm@8.12.0",
|
|
6
6
|
"description": "SoybeanJS's command line tools",
|
|
7
7
|
"author": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@soybeanjs/cli": "link:",
|
|
56
|
-
"@soybeanjs/eslint-config": "1.0.
|
|
56
|
+
"@soybeanjs/eslint-config": "1.0.12",
|
|
57
57
|
"@types/crypto-js": "4.2.1",
|
|
58
58
|
"@types/node": "20.10.4",
|
|
59
59
|
"eslint": "8.55.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"simple-git-hooks": {
|
|
69
69
|
"commit-msg": "pnpm soy git-commit-verify",
|
|
70
|
-
"pre-commit": "pnpm typecheck"
|
|
70
|
+
"pre-commit": "pnpm typecheck && pnpm lint-staged"
|
|
71
71
|
},
|
|
72
72
|
"lint-staged": {
|
|
73
73
|
"*": "eslint --fix"
|