@lntvow/dev 6.0.2 → 6.0.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/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- (e=>e.major>20||e.major===20&&e.minor>=19)((e=>{let[t=`0`,n=`0`]=e.split(`.`);return{major:Number(t),minor:Number(n)}})(process.versions.node))||(process.stderr.write(`@lntvow/dev: Node.js v20.19+ is required (current: v${process.versions.node}).\nIf you use nvm, run:\n nvm install 20\n nvm use 20\n nvm alias default 20\n`),process.exit(1)),import(`./main-BHdrzS82.mjs`);export{};
2
+ (e=>e.major>20||e.major===20&&e.minor>=19)((e=>{let[t=`0`,n=`0`]=e.split(`.`);return{major:Number(t),minor:Number(n)}})(process.versions.node))||(process.stderr.write(`@lntvow/dev: Node.js v20.19+ is required (current: v${process.versions.node}).\nIf you use nvm, run:\n nvm install 20\n nvm use 20\n nvm alias default 20\n`),process.exit(1)),import(`./main-BOsGC6gV.mjs`);export{};
@@ -0,0 +1 @@
1
+ import{Option as e,program as t}from"commander";import{copyFileSync as n,existsSync as r,mkdirSync as i,readFileSync as a,readdirSync as o,statSync as s,writeFileSync as c}from"node:fs";import{basename as l,resolve as u}from"node:path";import{fileURLToPath as d}from"node:url";import{isCancel as f,select as p}from"@clack/prompts";import{execSync as m}from"node:child_process";import h from"picocolors";import g from"dayjs";import _ from"simple-git";var v=`@lntvow/dev`,y=`6.0.3`;const b={prepare:`cli hooks`,clean:`cli clean ./node_modules/`,upgrade:`cli upgrade -u -x "@types/node,typescript" && pnpm install`,tidy:`cli tidy`,commit:`git add -A && cli commit`,release:`pnpm lint && git add -A && cli release package.json -a`,changelog:`cli changelog -p angular -i CHANGELOG.md -s`,version:`pnpm changelog && git add -A`,"lint:eslint":`eslint --fix --cache`,"lint:tsc":`tsc --noEmit`,lint:`cli parallel lint:eslint lint:tsc`},x=[`@lntvow/cli`,`@lntvow/eslint-config`,`eslint`,`prettier`,`typescript`].sort((e,t)=>e.localeCompare(t)),S={info:e=>console.log(h.blue(`● ${e}`)),success:e=>console.log(h.green(`✓ ${e}`)),warn:e=>console.log(h.yellow(`▲ ${e}`)),error:e=>console.log(h.red(`✗ ${e}`))};function C(e,t={}){try{return m(e,{stdio:`inherit`,...t})}catch(t){throw S.error(`命令执行失败: ${e}`),t}}async function w(){for(let{file:e,manager:t}of[{file:`pnpm-lock.yaml`,manager:`pnpm`},{file:`yarn.lock`,manager:`yarn`},{file:`package-lock.json`,manager:`npm`}])if(r(u(process.cwd(),e)))return t;let e=process.env.npm_config_user_agent||``;return e.startsWith(`pnpm`)?`pnpm`:e.startsWith(`yarn`)?`yarn`:T()}async function T(){let e=await p({message:`No lock file found. Please select a package manager`,options:[{label:`pnpm`,value:`pnpm`},{label:`yarn`,value:`yarn`},{label:`npm`,value:`npm`}],initialValue:`pnpm`});if(f(e))throw Error(`Package manager selection canceled.`);return e}function E(e,t){if(s(e).isDirectory()){if(l(e)===`node_modules`)return;i(t,{recursive:!0}),o(e).forEach(n=>{E(u(e,n),u(t,n))})}else{if(r(t))return;n(e,t)}}function D(t){t.command(`init`).description(`init project`).option(`-t, --temp`,`copy template files`,!0).option(`--no-temp`,`not copy template files`).option(`-s, --scripts`,`init scripts`,!0).option(`--no-scripts`,`not init scripts`).addOption(new e(`--pm <manager>`,`package manager (auto-detect from lockfile/userAgent; prompt if ambiguous)`).choices([`pnpm`,`yarn`,`npm`])).action(O)}async function O(e){S.success(`Init project by @lntvow/dev`),S.info(`Cwd is ${process.cwd()}`);let{temp:t,scripts:n,pm:r}=e;try{t&&k(),await j(r),n&&A(),S.success(`Project initialization completed successfully!`)}catch(e){S.error(`Initialization failed: ${e.message}`),process.exit(1)}}function k(){try{let e=d(new URL(`./configs`,import.meta.url)),t=process.cwd();S.info(`Copying template files from "${e}" to "${t}"`),E(e,t),S.success(`Template files copied successfully`)}catch(e){throw S.error(`Failed to copy template files: ${e.message}`),e}}function A(){let e,t=u(process.cwd(),`package.json`);try{S.info(`Updating package.json scripts...`),e=a(t,`utf-8`);let n=JSON.parse(e),r={...n,scripts:{...b,...n.scripts}};c(t,JSON.stringify(r,null,2)),S.success(`Package.json scripts updated successfully`)}catch(n){throw e&&c(t,e),S.error(`Failed to update package.json: ${n.message}`),n}}async function j(e){try{let t=x.map(e=>`${e}@latest`).join(` `),n=e??await w(),r={pnpm:`pnpm add -D ${t}`,yarn:`yarn add -D ${t}`,npm:`npm install -D ${t}`}[n];S.info(`Installing dependencies: ${r}`),C(r),S.success(`Dependencies installed successfully`)}catch(e){throw S.error(`Dependency installation failed: ${e.message}`),e}}function M(e){e.command(`release`).description(`git release`).action(N)}async function N(){console.log(h.green(`Release project...`));try{await P(),S.success(`Release completed successfully!`)}catch(e){S.error(`Release failed: ${e.message}`),process.exit(1)}}async function P(){let e=_(process.cwd());try{let t=g().format(`YYYYMMDD`);await e.pull(),await e.add(`.`),await e.commit(t,[`--no-verify`]),await e.push(`origin`),S.success(`提交成功: ${t}`)}catch(e){S.error(`Git操作失败: ${e.message}`),process.exit(1)}}t.name(v).version(y,`-v, --version`,`output the version number`),D(t),M(t),t.parse();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "description": "Development environment dependencies package",
5
5
  "keywords": [
6
6
  "dev"
@@ -25,7 +25,7 @@
25
25
  "dist/configs/*"
26
26
  ],
27
27
  "dependencies": {
28
- "@clack/prompts": "^0.11.0",
28
+ "@clack/prompts": "^1.3.0",
29
29
  "commander": "^14.0.3",
30
30
  "dayjs": "^1.11.20",
31
31
  "local-pkg": "^1.1.2",
@@ -33,7 +33,7 @@
33
33
  "simple-git": "^3.36.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@lntvow/cli": "^0.0.3",
36
+ "@lntvow/cli": "^0.0.6",
37
37
  "@lntvow/eslint-config": "^10.1.8",
38
38
  "@types/node": "^20.19.39",
39
39
  "eslint": "^10.3.0",
@@ -49,10 +49,10 @@
49
49
  "clean": "cli clean ./node_modules/",
50
50
  "upgrade": "cli upgrade -u -x \"@types/node,typescript\" && pnpm install",
51
51
  "tidy": "cli tidy",
52
- "commit": "git add . && cli cz",
53
- "release": "pnpm lint && git add . && cli release package.json -a",
52
+ "commit": "git add -A && cli cz",
53
+ "release": "pnpm lint && git add -A && cli release package.json -a",
54
54
  "changelog": "cli changelog -p angular -i CHANGELOG.md -s",
55
- "version": "pnpm changelog",
55
+ "version": "pnpm changelog && git add -A",
56
56
  "lint:eslint": "eslint --fix --cache",
57
57
  "lint:tsc": "tsc --noEmit",
58
58
  "lint": "cli parallel lint:eslint lint:tsc",
@@ -1 +0,0 @@
1
- import{Option as e,program as t}from"commander";import{copyFileSync as n,existsSync as r,mkdirSync as i,readFileSync as a,readdirSync as o,statSync as s,writeFileSync as c}from"node:fs";import{basename as l,resolve as u}from"node:path";import{fileURLToPath as d}from"node:url";import{isCancel as f,select as p}from"@clack/prompts";import{execSync as m}from"node:child_process";import h from"picocolors";import g from"dayjs";import _ from"simple-git";var v=`@lntvow/dev`,y=`6.0.2`;const b={prepare:`cli hooks`,clean:`cli clean ./node_modules/`,upgrade:`cli upgrade -u -x "@types/node,typescript" && pnpm install`,tidy:`cli tidy`,commit:`git add . && cli commit`,release:`pnpm lint && git add . && cli release package.json -a`,changelog:`cli changelog -p angular -i CHANGELOG.md -s`,version:`pnpm changelog`,"lint:eslint":`eslint --fix --cache`,"lint:tsc":`tsc --noEmit`,lint:`cli parallel lint:eslint lint:tsc`},x=[`@lntvow/cli`,`@lntvow/eslint-config`,`eslint`,`prettier`,`typescript`].sort((e,t)=>e.localeCompare(t)),S={info:e=>console.log(h.blue(`● ${e}`)),success:e=>console.log(h.green(`✓ ${e}`)),warn:e=>console.log(h.yellow(`▲ ${e}`)),error:e=>console.log(h.red(`✗ ${e}`))};function C(e,t={}){try{return m(e,{stdio:`inherit`,...t})}catch(t){throw S.error(`命令执行失败: ${e}`),t}}async function w(){for(let{file:e,manager:t}of[{file:`pnpm-lock.yaml`,manager:`pnpm`},{file:`yarn.lock`,manager:`yarn`},{file:`package-lock.json`,manager:`npm`}])if(r(u(process.cwd(),e)))return t;let e=process.env.npm_config_user_agent||``;return e.startsWith(`pnpm`)?`pnpm`:e.startsWith(`yarn`)?`yarn`:T()}async function T(){let e=await p({message:`No lock file found. Please select a package manager`,options:[{label:`pnpm`,value:`pnpm`},{label:`yarn`,value:`yarn`},{label:`npm`,value:`npm`}],initialValue:`pnpm`});if(f(e))throw Error(`Package manager selection canceled.`);return e}function E(e,t){if(s(e).isDirectory()){if(l(e)===`node_modules`)return;i(t,{recursive:!0}),o(e).forEach(n=>{E(u(e,n),u(t,n))})}else{if(r(t))return;n(e,t)}}function D(t){t.command(`init`).description(`init project`).option(`-t, --temp`,`copy template files`,!0).option(`--no-temp`,`not copy template files`).option(`-s, --scripts`,`init scripts`,!0).option(`--no-scripts`,`not init scripts`).addOption(new e(`--pm <manager>`,`package manager (auto-detect from lockfile/userAgent; prompt if ambiguous)`).choices([`pnpm`,`yarn`,`npm`])).action(O)}async function O(e){S.success(`Init project by @lntvow/dev`),S.info(`Cwd is ${process.cwd()}`);let{temp:t,scripts:n,pm:r}=e;try{t&&k(),await j(r),n&&A(),S.success(`Project initialization completed successfully!`)}catch(e){S.error(`Initialization failed: ${e.message}`),process.exit(1)}}function k(){try{let e=d(new URL(`./configs`,import.meta.url)),t=process.cwd();S.info(`Copying template files from "${e}" to "${t}"`),E(e,t),S.success(`Template files copied successfully`)}catch(e){throw S.error(`Failed to copy template files: ${e.message}`),e}}function A(){let e,t=u(process.cwd(),`package.json`);try{S.info(`Updating package.json scripts...`),e=a(t,`utf-8`);let n=JSON.parse(e),r={...n,scripts:{...b,...n.scripts}};c(t,JSON.stringify(r,null,2)),S.success(`Package.json scripts updated successfully`)}catch(n){throw e&&c(t,e),S.error(`Failed to update package.json: ${n.message}`),n}}async function j(e){try{let t=x.map(e=>`${e}@latest`).join(` `),n=e??await w(),r={pnpm:`pnpm add -D ${t}`,yarn:`yarn add -D ${t}`,npm:`npm install -D ${t}`}[n];S.info(`Installing dependencies: ${r}`),C(r),S.success(`Dependencies installed successfully`)}catch(e){throw S.error(`Dependency installation failed: ${e.message}`),e}}function M(e){e.command(`release`).description(`git release`).action(N)}async function N(){console.log(h.green(`Release project...`));try{await P(),S.success(`Release completed successfully!`)}catch(e){S.error(`Release failed: ${e.message}`),process.exit(1)}}async function P(){let e=_(process.cwd());try{let t=g().format(`YYYYMMDD`);await e.pull(),await e.add(`.`),await e.commit(t,[`--no-verify`]),await e.push(`origin`),S.success(`提交成功: ${t}`)}catch(e){S.error(`Git操作失败: ${e.message}`),process.exit(1)}}t.name(v).version(y,`-v, --version`,`output the version number`),D(t),M(t),t.parse();export{};