@gct-paas/cli 0.1.6-dev.6 → 0.1.6-dev.7

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.
@@ -8,9 +8,37 @@ var _pacote = _interopRequireDefault(require("pacote"));
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
10
10
  var _consola = _interopRequireDefault(require("consola"));
11
+ var _listr = require("listr2");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  class GenCdnLibAction {
13
14
  packages = ["@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-pad", "@gct-paas/core-web", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-pad", "@gct-paas/design-web", "@gct-paas/native", "@gct-paas/render", "@gct-paas/render-mobile", "@gct-paas/render-pad", "@gct-paas/render-web", "@gct-paas/schema", "@gct-paas/v-ben"];
15
+ /**
16
+ * 下载指定包并复制到外部依赖目录,返回入口文件名;若找不到入口文件则返回空字符串
17
+ */
18
+ async downloadPkg(pkg, pkgInfo, opts, extraDir, extractCacheDir, cacheDir) {
19
+ const _dlCacheDir = _path.default.join(extractCacheDir, pkgInfo.name, pkgInfo.version);
20
+ await _pacote.default.extract(pkgInfo.dist.tarball, _dlCacheDir, {
21
+ registry: opts.registry,
22
+ cache: cacheDir
23
+ });
24
+ const localPkgJson = _fsExtra.default.readJSONSync(_path.default.join(_dlCacheDir, "package.json"));
25
+ const loaderField = localPkgJson.loader;
26
+ if (!loaderField) return "";
27
+ if (!opts.noFiles) {
28
+ const sourceDistPath = _path.default.join(_dlCacheDir, "dist");
29
+ if (opts.clean) {
30
+ const extractPkgPath = _path.default.join(extraDir, pkgInfo.name);
31
+ if (_fsExtra.default.existsSync(extractPkgPath)) {
32
+ _fsExtra.default.removeSync(extractPkgPath);
33
+ }
34
+ }
35
+ const extractPath = _path.default.join(extraDir, pkgInfo.name);
36
+ _fsExtra.default.copySync(sourceDistPath, extractPath, {
37
+ overwrite: true
38
+ });
39
+ }
40
+ return _path.default.basename(loaderField);
41
+ }
14
42
  async run(opts) {
15
43
  const cwd = process.cwd();
16
44
  const extraDir = opts.dir ? _path.default.resolve(cwd, opts.dir) : cwd;
@@ -24,55 +52,44 @@ class GenCdnLibAction {
24
52
  const extractCacheDir = _path.default.join(cacheDir, "tmp");
25
53
  const importMapJsonPath = opts.jsonPath ? _path.default.resolve(cwd, opts.jsonPath) : _path.default.join(extraDir, "import-map.json");
26
54
  if (!_fsExtra.default.existsSync(importMapJsonPath)) {
27
- _consola.default.warn(`\u8B66\u544A: import-map.json \u6587\u4EF6\u4E0D\u5B58\u5728\u4E8E ${importMapJsonPath}\uFF0C\u8BF7\u786E\u4FDD\u8DEF\u5F84\u6B63\u786E\u6216\u8005\u4F7F\u7528 --jsonPath \u53C2\u6570\u6307\u5B9A\u6B63\u786E\u7684\u8DEF\u5F84`);
55
+ _consola.default.warn(`import-map.json \u6587\u4EF6\u4E0D\u5B58\u5728\u4E8E ${importMapJsonPath}\uFF0C\u8BF7\u786E\u4FDD\u8DEF\u5F84\u6B63\u786E\u6216\u4F7F\u7528 --jsonPath \u53C2\u6570\u6307\u5B9A\u6B63\u786E\u8DEF\u5F84`);
28
56
  return;
29
57
  }
30
- _consola.default.info(`\u8BFB\u53D6 import-map.json`);
58
+ _consola.default.info("\u6B63\u5728\u8BFB\u53D6 import-map.json...");
31
59
  const importMap = _fsExtra.default.readJSONSync(importMapJsonPath);
32
- _consola.default.info(`\u5F00\u59CB\u751F\u6210 CDN \u5E93\u6587\u4EF6...`);
33
- for (const pkg of this.packages) {
34
- _consola.default.info(`\u4ECE npm \u83B7\u53D6\uFF0C${pkg}@${opts.tag} \u5305\u4FE1\u606F...`);
35
- const pkgInfo = await _pacote.default.manifest(`${pkg}@${opts.tag}`, {
36
- registry: opts.registry,
37
- cache: cacheDir
38
- });
39
- _consola.default.info(`\u5F00\u59CB\u4E0B\u8F7D ${pkg}@${opts.tag} \u5305...`);
40
- const _dlCacheDir = _path.default.join(extractCacheDir, pkgInfo.name, pkgInfo.version);
41
- await _pacote.default.extract(pkgInfo.dist.tarball, _dlCacheDir, {
42
- registry: opts.registry,
43
- cache: cacheDir
44
- });
45
- const sourceDistPath = _path.default.join(_dlCacheDir, "dist");
46
- if (opts.clean) {
47
- const extractPkgPath = _path.default.join(extraDir, pkgInfo.name);
48
- if (_fsExtra.default.existsSync(extractPkgPath)) {
49
- _consola.default.info(`\u6B63\u5728\u5220\u9664 ${pkg} \u5305\u7684\u65E7\u7248\u672C...`);
50
- _fsExtra.default.removeSync(extractPkgPath);
60
+ const tasks = new _listr.Listr(this.packages.map(pkg => ({
61
+ title: `${pkg}@${opts.tag}`,
62
+ task: async (_, task) => {
63
+ task.title = `${pkg}@${opts.tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
64
+ const pkgInfo = await _pacote.default.manifest(`${pkg}@${opts.tag}`, {
65
+ registry: opts.registry,
66
+ cache: cacheDir
67
+ });
68
+ task.title = `${pkg}@${pkgInfo.version} \u4E0B\u8F7D\u4E2D...`;
69
+ const entryName = await this.downloadPkg(pkg, pkgInfo, opts, extraDir, extractCacheDir, cacheDir);
70
+ if (!entryName) {
71
+ task.skip("package.json \u4E2D\u6CA1\u6709 loader \u5B57\u6BB5\uFF0C\u5DF2\u8DF3\u8FC7");
72
+ return;
51
73
  }
74
+ importMap.imports[pkg] = `/${extraDirName}/${pkgInfo.name}/${entryName}`;
75
+ task.title = `${pkg}@${pkgInfo.version}`;
52
76
  }
53
- const extractPath = _path.default.join(extraDir, pkgInfo.name, pkgInfo.version);
54
- _consola.default.info(`\u5C06 ${pkg}@${opts.tag} \u5305\u4ECE\u7F13\u5B58\u76EE\u5F55\u590D\u5236\u81F3\u5916\u90E8\u4F9D\u8D56\u76EE\u5F55...`);
55
- _fsExtra.default.copySync(sourceDistPath, extractPath, {
56
- overwrite: true
57
- });
58
- const loaderPath = _path.default.join(extractPath, "loader.esm.min.js");
59
- const indexPath = _path.default.join(extractPath, "index.esm.min.js");
60
- let entryName = "";
61
- if (_fsExtra.default.existsSync(loaderPath)) {
62
- entryName = "loader.esm.min.js";
63
- } else if (_fsExtra.default.existsSync(indexPath)) {
64
- entryName = "index.esm.min.js";
77
+ })), {
78
+ concurrent: true
79
+ });
80
+ await tasks.run();
81
+ const timestamp = Date.now();
82
+ for (const key in importMap.imports) {
83
+ if (importMap.imports[key].includes("?t=")) {
84
+ importMap.imports[key] = importMap.imports[key].replace(/\?t=\d+/, `?t=${timestamp}`);
65
85
  } else {
66
- _consola.default.warn(`\u8B66\u544A: ${pkg}@${opts.tag} \u5305\u4E2D\u65E2\u6CA1\u6709 loader.esm.min.js \u4E5F\u6CA1\u6709 index.esm.min.js\uFF0C\u65E0\u6CD5\u627E\u5230\u5165\u53E3\u6587\u4EF6\uFF0C\u8DF3\u8FC7\u8BE5\u5305`);
67
- continue;
86
+ importMap.imports[key] = `${importMap.imports[key]}?t=${timestamp}`;
68
87
  }
69
- importMap.imports[pkg] = `./${extraDirName}/${pkgInfo.name}/${pkgInfo.version}/${entryName}`;
70
- _consola.default.info(`\u6210\u529F\u4FEE\u6539 ${pkg} \u8DEF\u5F84`);
71
88
  }
72
89
  _fsExtra.default.writeJSONSync(importMapJsonPath, importMap, {
73
90
  spaces: 2
74
91
  });
75
- if (_fsExtra.default.existsSync(cacheDir)) {
92
+ if (opts.cleanCache && _fsExtra.default.existsSync(cacheDir)) {
76
93
  _consola.default.info(`\u6B63\u5728\u5220\u9664\u7F13\u5B58\u76EE\u5F55: ${cacheDir}`);
77
94
  _fsExtra.default.removeSync(cacheDir);
78
95
  }
@@ -7,5 +7,9 @@ import { IGenCdnLibOptions } from '../../interface';
7
7
  */
8
8
  export declare class GenCdnLibAction {
9
9
  private packages;
10
+ /**
11
+ * 下载指定包并复制到外部依赖目录,返回入口文件名;若找不到入口文件则返回空字符串
12
+ */
13
+ private downloadPkg;
10
14
  run(opts: IGenCdnLibOptions): Promise<void>;
11
15
  }
@@ -7,7 +7,7 @@ exports.GenCdnLibCommand = void 0;
7
7
  var _actions = require("../../actions/index.cjs");
8
8
  class GenCdnLibCommand {
9
9
  load(program) {
10
- program.command("gen-cdn-lib").description("\u751F\u6210 cdn \u5E93\u6587\u4EF6").option("--tag <tag>", "\u6307\u5B9A\u4E0B\u8F7D\u7684\u7248\u672C\u6807\u7B7E(latest | dev | beta | alpha)\uFF0C\u9ED8\u8BA4\u4E3A latest", "latest").option("--dir <dir>", "\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u9ED8\u8BA4\u4E3A\u5F53\u524D\u6267\u884C\u76EE\u5F55").option("--jsonPath <jsonPath>", "\u6307\u5B9A import-map.json \u6587\u4EF6\u8DEF\u5F84\uFF0C\u672A\u5236\u5B9A\u9ED8\u8BA4\u4F7F\u7528\u6307\u5B9A\u7684 dir \u76EE\u5F55\u4E0B\u7684 import-map.json \u6587\u4EF6").option("--clean", "\u662F\u5426\u6E05\u7406\u8F93\u51FA\u76EE\u5F55\u540E\u518D\u751F\u6210").option("--registry <registry>", "\u6307\u5B9A npm registry \u5730\u5740\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4 registry").option("--cache <cache>", "\u6307\u5B9A pacote \u7F13\u5B58\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4\u7F13\u5B58\u76EE\u5F55").action(this.action.bind(this));
10
+ program.command("gen-cdn-lib").description("\u751F\u6210 cdn \u5E93\u6587\u4EF6").option("--tag <tag>", "\u6307\u5B9A\u4E0B\u8F7D\u7684\u7248\u672C\u6807\u7B7E(latest | dev | beta | alpha)\uFF0C\u9ED8\u8BA4\u4E3A latest", "latest").option("--dir <dir>", "\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u9ED8\u8BA4\u4E3A\u5F53\u524D\u6267\u884C\u76EE\u5F55").option("--jsonPath <jsonPath>", "\u6307\u5B9A import-map.json \u6587\u4EF6\u8DEF\u5F84\uFF0C\u672A\u5236\u5B9A\u9ED8\u8BA4\u4F7F\u7528\u6307\u5B9A\u7684 dir \u76EE\u5F55\u4E0B\u7684 import-map.json \u6587\u4EF6").option("--clean", "\u662F\u5426\u6E05\u7406\u8F93\u51FA\u76EE\u5F55\u540E\u518D\u751F\u6210").option("--registry <registry>", "\u6307\u5B9A npm registry \u5730\u5740\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4 registry").option("--cache <cache>", "\u6307\u5B9A pacote \u7F13\u5B58\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4\u7F13\u5B58\u76EE\u5F55").option("--cleanCache", "\u6E05\u7406\u7F13\u5B58\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A false", false).option("--noFiles", "\u662F\u5426\u53EA\u751F\u6210 import-map.json \u6587\u4EF6\u800C\u4E0D\u4E0B\u8F7D\u5305\u6587\u4EF6\uFF0C\u9ED8\u8BA4\u4E3A false", false).action(this.action.bind(this));
11
11
  }
12
12
  async action(args) {
13
13
  await new _actions.GenCdnLibAction().run(args);
@@ -8,9 +8,10 @@ export interface IGenCdnLibOptions {
8
8
  /**
9
9
  * 制定下载的版本标签,默认为 latest
10
10
  *
11
- * @type {('latest' | 'dev' | 'beta' | 'alpha')}
11
+ * @default 'latest'
12
+ * @type {string}
12
13
  */
13
- tag: 'latest' | 'dev' | 'beta' | 'alpha';
14
+ tag: string;
14
15
  /**
15
16
  * 要输出的 extras 资源目录,未指定时默认为当前执行目录
16
17
  *
@@ -23,6 +24,12 @@ export interface IGenCdnLibOptions {
23
24
  * @type {string}
24
25
  */
25
26
  jsonPath?: string;
27
+ /**
28
+ * 是否只生成 import-map.json 文件而不下载包文件,默认为 false
29
+ *
30
+ * @type {boolean}
31
+ */
32
+ noFiles?: boolean;
26
33
  /**
27
34
  * 是否清理输出目录后再生成
28
35
  *
@@ -41,4 +48,11 @@ export interface IGenCdnLibOptions {
41
48
  * @type {string}
42
49
  */
43
50
  cache?: string;
51
+ /**
52
+ * 清理缓存目录,默认为 false
53
+ *
54
+ * @default false
55
+ * @type {boolean}
56
+ */
57
+ cleanCache?: boolean;
44
58
  }
@@ -7,5 +7,9 @@ import { IGenCdnLibOptions } from '../../interface';
7
7
  */
8
8
  export declare class GenCdnLibAction {
9
9
  private packages;
10
+ /**
11
+ * 下载指定包并复制到外部依赖目录,返回入口文件名;若找不到入口文件则返回空字符串
12
+ */
13
+ private downloadPkg;
10
14
  run(opts: IGenCdnLibOptions): Promise<void>;
11
15
  }
@@ -2,6 +2,7 @@ import pacote from "pacote";
2
2
  import path from "path";
3
3
  import fse from "fs-extra";
4
4
  import log from "consola";
5
+ import { Listr } from "listr2";
5
6
  export class GenCdnLibAction {
6
7
  packages = [
7
8
  "@gct-paas/api",
@@ -21,6 +22,31 @@ export class GenCdnLibAction {
21
22
  "@gct-paas/schema",
22
23
  "@gct-paas/v-ben"
23
24
  ];
25
+ /**
26
+ * 下载指定包并复制到外部依赖目录,返回入口文件名;若找不到入口文件则返回空字符串
27
+ */
28
+ async downloadPkg(pkg, pkgInfo, opts, extraDir, extractCacheDir, cacheDir) {
29
+ const _dlCacheDir = path.join(extractCacheDir, pkgInfo.name, pkgInfo.version);
30
+ await pacote.extract(pkgInfo.dist.tarball, _dlCacheDir, {
31
+ registry: opts.registry,
32
+ cache: cacheDir
33
+ });
34
+ const localPkgJson = fse.readJSONSync(path.join(_dlCacheDir, "package.json"));
35
+ const loaderField = localPkgJson.loader;
36
+ if (!loaderField) return "";
37
+ if (!opts.noFiles) {
38
+ const sourceDistPath = path.join(_dlCacheDir, "dist");
39
+ if (opts.clean) {
40
+ const extractPkgPath = path.join(extraDir, pkgInfo.name);
41
+ if (fse.existsSync(extractPkgPath)) {
42
+ fse.removeSync(extractPkgPath);
43
+ }
44
+ }
45
+ const extractPath = path.join(extraDir, pkgInfo.name);
46
+ fse.copySync(sourceDistPath, extractPath, { overwrite: true });
47
+ }
48
+ return path.basename(loaderField);
49
+ }
24
50
  async run(opts) {
25
51
  const cwd = process.cwd();
26
52
  const extraDir = opts.dir ? path.resolve(cwd, opts.dir) : cwd;
@@ -33,56 +59,44 @@ export class GenCdnLibAction {
33
59
  const importMapJsonPath = opts.jsonPath ? path.resolve(cwd, opts.jsonPath) : path.join(extraDir, "import-map.json");
34
60
  if (!fse.existsSync(importMapJsonPath)) {
35
61
  log.warn(
36
- `\u8B66\u544A: import-map.json \u6587\u4EF6\u4E0D\u5B58\u5728\u4E8E ${importMapJsonPath}\uFF0C\u8BF7\u786E\u4FDD\u8DEF\u5F84\u6B63\u786E\u6216\u8005\u4F7F\u7528 --jsonPath \u53C2\u6570\u6307\u5B9A\u6B63\u786E\u7684\u8DEF\u5F84`
62
+ `import-map.json \u6587\u4EF6\u4E0D\u5B58\u5728\u4E8E ${importMapJsonPath}\uFF0C\u8BF7\u786E\u4FDD\u8DEF\u5F84\u6B63\u786E\u6216\u4F7F\u7528 --jsonPath \u53C2\u6570\u6307\u5B9A\u6B63\u786E\u8DEF\u5F84`
37
63
  );
38
64
  return;
39
65
  }
40
- log.info(`\u8BFB\u53D6 import-map.json`);
66
+ log.info("\u6B63\u5728\u8BFB\u53D6 import-map.json...");
41
67
  const importMap = fse.readJSONSync(importMapJsonPath);
42
- log.info(`\u5F00\u59CB\u751F\u6210 CDN \u5E93\u6587\u4EF6...`);
43
- for (const pkg of this.packages) {
44
- log.info(`\u4ECE npm \u83B7\u53D6\uFF0C${pkg}@${opts.tag} \u5305\u4FE1\u606F...`);
45
- const pkgInfo = await pacote.manifest(`${pkg}@${opts.tag}`, {
46
- registry: opts.registry,
47
- cache: cacheDir
48
- });
49
- log.info(`\u5F00\u59CB\u4E0B\u8F7D ${pkg}@${opts.tag} \u5305...`);
50
- const _dlCacheDir = path.join(extractCacheDir, pkgInfo.name, pkgInfo.version);
51
- await pacote.extract(
52
- pkgInfo.dist.tarball,
53
- _dlCacheDir,
54
- {
55
- registry: opts.registry,
56
- cache: cacheDir
68
+ const tasks = new Listr(
69
+ this.packages.map((pkg) => ({
70
+ title: `${pkg}@${opts.tag}`,
71
+ task: async (_, task) => {
72
+ task.title = `${pkg}@${opts.tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
73
+ const pkgInfo = await pacote.manifest(`${pkg}@${opts.tag}`, {
74
+ registry: opts.registry,
75
+ cache: cacheDir
76
+ });
77
+ task.title = `${pkg}@${pkgInfo.version} \u4E0B\u8F7D\u4E2D...`;
78
+ const entryName = await this.downloadPkg(pkg, pkgInfo, opts, extraDir, extractCacheDir, cacheDir);
79
+ if (!entryName) {
80
+ task.skip("package.json \u4E2D\u6CA1\u6709 loader \u5B57\u6BB5\uFF0C\u5DF2\u8DF3\u8FC7");
81
+ return;
82
+ }
83
+ importMap.imports[pkg] = `/${extraDirName}/${pkgInfo.name}/${entryName}`;
84
+ task.title = `${pkg}@${pkgInfo.version}`;
57
85
  }
58
- );
59
- const sourceDistPath = path.join(_dlCacheDir, "dist");
60
- if (opts.clean) {
61
- const extractPkgPath = path.join(extraDir, pkgInfo.name);
62
- if (fse.existsSync(extractPkgPath)) {
63
- log.info(`\u6B63\u5728\u5220\u9664 ${pkg} \u5305\u7684\u65E7\u7248\u672C...`);
64
- fse.removeSync(extractPkgPath);
65
- }
66
- }
67
- const extractPath = path.join(extraDir, pkgInfo.name, pkgInfo.version);
68
- log.info(`\u5C06 ${pkg}@${opts.tag} \u5305\u4ECE\u7F13\u5B58\u76EE\u5F55\u590D\u5236\u81F3\u5916\u90E8\u4F9D\u8D56\u76EE\u5F55...`);
69
- fse.copySync(sourceDistPath, extractPath, { overwrite: true });
70
- const loaderPath = path.join(extractPath, "loader.esm.min.js");
71
- const indexPath = path.join(extractPath, "index.esm.min.js");
72
- let entryName = "";
73
- if (fse.existsSync(loaderPath)) {
74
- entryName = "loader.esm.min.js";
75
- } else if (fse.existsSync(indexPath)) {
76
- entryName = "index.esm.min.js";
86
+ })),
87
+ { concurrent: true }
88
+ );
89
+ await tasks.run();
90
+ const timestamp = Date.now();
91
+ for (const key in importMap.imports) {
92
+ if (importMap.imports[key].includes("?t=")) {
93
+ importMap.imports[key] = importMap.imports[key].replace(/\?t=\d+/, `?t=${timestamp}`);
77
94
  } else {
78
- log.warn(`\u8B66\u544A: ${pkg}@${opts.tag} \u5305\u4E2D\u65E2\u6CA1\u6709 loader.esm.min.js \u4E5F\u6CA1\u6709 index.esm.min.js\uFF0C\u65E0\u6CD5\u627E\u5230\u5165\u53E3\u6587\u4EF6\uFF0C\u8DF3\u8FC7\u8BE5\u5305`);
79
- continue;
95
+ importMap.imports[key] = `${importMap.imports[key]}?t=${timestamp}`;
80
96
  }
81
- importMap.imports[pkg] = `./${extraDirName}/${pkgInfo.name}/${pkgInfo.version}/${entryName}`;
82
- log.info(`\u6210\u529F\u4FEE\u6539 ${pkg} \u8DEF\u5F84`);
83
97
  }
84
98
  fse.writeJSONSync(importMapJsonPath, importMap, { spaces: 2 });
85
- if (fse.existsSync(cacheDir)) {
99
+ if (opts.cleanCache && fse.existsSync(cacheDir)) {
86
100
  log.info(`\u6B63\u5728\u5220\u9664\u7F13\u5B58\u76EE\u5F55: ${cacheDir}`);
87
101
  fse.removeSync(cacheDir);
88
102
  }
@@ -1,7 +1,7 @@
1
1
  import { GenCdnLibAction } from "../../actions/index.mjs";
2
2
  export class GenCdnLibCommand {
3
3
  load(program) {
4
- program.command("gen-cdn-lib").description("\u751F\u6210 cdn \u5E93\u6587\u4EF6").option("--tag <tag>", "\u6307\u5B9A\u4E0B\u8F7D\u7684\u7248\u672C\u6807\u7B7E(latest | dev | beta | alpha)\uFF0C\u9ED8\u8BA4\u4E3A latest", "latest").option("--dir <dir>", "\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u9ED8\u8BA4\u4E3A\u5F53\u524D\u6267\u884C\u76EE\u5F55").option("--jsonPath <jsonPath>", "\u6307\u5B9A import-map.json \u6587\u4EF6\u8DEF\u5F84\uFF0C\u672A\u5236\u5B9A\u9ED8\u8BA4\u4F7F\u7528\u6307\u5B9A\u7684 dir \u76EE\u5F55\u4E0B\u7684 import-map.json \u6587\u4EF6").option("--clean", "\u662F\u5426\u6E05\u7406\u8F93\u51FA\u76EE\u5F55\u540E\u518D\u751F\u6210").option("--registry <registry>", "\u6307\u5B9A npm registry \u5730\u5740\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4 registry").option("--cache <cache>", "\u6307\u5B9A pacote \u7F13\u5B58\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4\u7F13\u5B58\u76EE\u5F55").action(this.action.bind(this));
4
+ program.command("gen-cdn-lib").description("\u751F\u6210 cdn \u5E93\u6587\u4EF6").option("--tag <tag>", "\u6307\u5B9A\u4E0B\u8F7D\u7684\u7248\u672C\u6807\u7B7E(latest | dev | beta | alpha)\uFF0C\u9ED8\u8BA4\u4E3A latest", "latest").option("--dir <dir>", "\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u9ED8\u8BA4\u4E3A\u5F53\u524D\u6267\u884C\u76EE\u5F55").option("--jsonPath <jsonPath>", "\u6307\u5B9A import-map.json \u6587\u4EF6\u8DEF\u5F84\uFF0C\u672A\u5236\u5B9A\u9ED8\u8BA4\u4F7F\u7528\u6307\u5B9A\u7684 dir \u76EE\u5F55\u4E0B\u7684 import-map.json \u6587\u4EF6").option("--clean", "\u662F\u5426\u6E05\u7406\u8F93\u51FA\u76EE\u5F55\u540E\u518D\u751F\u6210").option("--registry <registry>", "\u6307\u5B9A npm registry \u5730\u5740\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4 registry").option("--cache <cache>", "\u6307\u5B9A pacote \u7F13\u5B58\u76EE\u5F55\uFF0C\u672A\u6307\u5B9A\u65F6\u4F7F\u7528\u9ED8\u8BA4\u7F13\u5B58\u76EE\u5F55").option("--cleanCache", "\u6E05\u7406\u7F13\u5B58\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A false", false).option("--noFiles", "\u662F\u5426\u53EA\u751F\u6210 import-map.json \u6587\u4EF6\u800C\u4E0D\u4E0B\u8F7D\u5305\u6587\u4EF6\uFF0C\u9ED8\u8BA4\u4E3A false", false).action(this.action.bind(this));
5
5
  }
6
6
  async action(args) {
7
7
  await new GenCdnLibAction().run(
@@ -8,9 +8,10 @@ export interface IGenCdnLibOptions {
8
8
  /**
9
9
  * 制定下载的版本标签,默认为 latest
10
10
  *
11
- * @type {('latest' | 'dev' | 'beta' | 'alpha')}
11
+ * @default 'latest'
12
+ * @type {string}
12
13
  */
13
- tag: 'latest' | 'dev' | 'beta' | 'alpha';
14
+ tag: string;
14
15
  /**
15
16
  * 要输出的 extras 资源目录,未指定时默认为当前执行目录
16
17
  *
@@ -23,6 +24,12 @@ export interface IGenCdnLibOptions {
23
24
  * @type {string}
24
25
  */
25
26
  jsonPath?: string;
27
+ /**
28
+ * 是否只生成 import-map.json 文件而不下载包文件,默认为 false
29
+ *
30
+ * @type {boolean}
31
+ */
32
+ noFiles?: boolean;
26
33
  /**
27
34
  * 是否清理输出目录后再生成
28
35
  *
@@ -41,4 +48,11 @@ export interface IGenCdnLibOptions {
41
48
  * @type {string}
42
49
  */
43
50
  cache?: string;
51
+ /**
52
+ * 清理缓存目录,默认为 false
53
+ *
54
+ * @default false
55
+ * @type {boolean}
56
+ */
57
+ cleanCache?: boolean;
44
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/cli",
3
- "version": "0.1.6-dev.6",
3
+ "version": "0.1.6-dev.7",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "bin": {
@@ -52,6 +52,7 @@
52
52
  "got": "^14.6.6",
53
53
  "handlebars": "^4.7.8",
54
54
  "handlebars-helpers": "^0.10.0",
55
+ "listr2": "^10.2.1",
55
56
  "lodash-es": "^4.17.23",
56
57
  "ora": "^9.1.0",
57
58
  "pacote": "^21.5.0",
@@ -67,5 +68,5 @@
67
68
  "typescript": "^5.9.3",
68
69
  "unbuild": "^3.6.1"
69
70
  },
70
- "gitHead": "2e48c22f823afd42f491f0df915aeca837964f19"
71
+ "gitHead": "ea800dfadead2fc20cf424513bc776a340e50ee8"
71
72
  }