lzx-test-cli 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/bin/index.js +19 -6
  2. package/package.json +2 -2
package/bin/index.js CHANGED
@@ -10,10 +10,10 @@ import ora from 'ora';
10
10
  import compressing from 'compressing'; //支持- tar - gzip - tgz - zip
11
11
  import { spawn } from 'child_process';
12
12
  import fetch from 'node-fetch';
13
- // import download from 'download-git-repo';
14
- console.log(
15
- chalk.green('开始创建项目!')
16
- );
13
+
14
+ import { createRequire } from 'node:module';
15
+ const require = createRequire(import.meta.url);
16
+ const pkg = require('../package.json');
17
17
 
18
18
  /**
19
19
  *
@@ -84,7 +84,7 @@ function showPercent(downloaded, total) {
84
84
  * @param {string} url 下载链接
85
85
  * @param {string} targetDir 目标文件夹
86
86
  * @param {string} fileName 保存的文件名
87
- * @description: 下载文件并显示进度条
87
+ * @description: 下载文件并显示进度
88
88
  */
89
89
  export async function downloadFileToFolder(url, targetDir, fileName, headers = {}) {
90
90
  // 目标文件夹确保存在
@@ -156,6 +156,7 @@ const main_proj_remote_url = 'http://10.14.121.116:8081/repository/npm-hosted/ar
156
156
  const sub_proj_remote_url = 'http://10.14.121.116:8081/repository/npm-hosted/artery5-manager-platform/-/artery5-manager-platform-1.0.2.tgz';
157
157
 
158
158
  const program = new Command();
159
+
159
160
  program
160
161
  .command('create')
161
162
  .alias('init')
@@ -164,6 +165,9 @@ program
164
165
  // .option('-f, --force', '强制覆盖,如果文件存在则强制覆盖')
165
166
  // .option('-l, --local-path <path>', '从本地下载模版创建')
166
167
  .action(async () => {
168
+ console.log(
169
+ chalk.green('开始创建项目!')
170
+ );
167
171
  try {
168
172
  let { projectName } = await inquirer.prompt([
169
173
  {
@@ -272,10 +276,19 @@ program
272
276
  }
273
277
  })
274
278
 
279
+
280
+
281
+ program
282
+ .name(pkg.name)
283
+ .description(pkg.description || 'CLI 工具')
284
+ .version(pkg.version);
285
+
275
286
  program.on('--help', function () {
276
287
  console.log('\nExamples:')
277
288
  console.log(`artery-cli create`)
278
289
  })
279
- program.parse();
290
+
291
+
292
+ program.parse(process.argv);
280
293
 
281
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lzx-test-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "bin": {
5
5
  "lzx-test-cli": "bin/index.js"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "keywords": [],
14
14
  "author": "",
15
15
  "license": "ISC",
16
- "description": "",
16
+ "description": "示例cli工具",
17
17
  "devDependencies": {
18
18
  "@types/node": "^25.0.6",
19
19
  "ts-node": "^10.9.2",