@soybeanjs/cli 0.7.7-beta.1 → 0.7.7-beta.2

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 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.7-beta.1";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!")}
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.7-beta.2";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
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;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
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.7-beta.1";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!")}
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.7-beta.2";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
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.7-beta.1",
3
+ "version": "0.7.7-beta.2",
4
4
  "description": "SoybeanJS's command line tools",
5
5
  "author": {
6
6
  "name": "Soybean",