@gct-paas/cli 0.1.6-dev.1 → 0.1.6-dev.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/actions/gen-cdn-lib/gen-cdn-lib.cjs +82 -0
- package/dist/actions/gen-cdn-lib/gen-cdn-lib.d.ts +11 -0
- package/dist/actions/index.cjs +8 -1
- package/dist/actions/index.d.ts +1 -0
- package/dist/commands/gen-cdn-lib/gen-cdn-lib.cjs +16 -0
- package/dist/commands/gen-cdn-lib/gen-cdn-lib.d.ts +6 -0
- package/dist/commands/index.cjs +2 -0
- package/dist/interface/i-gen-cdn-lib-options/i-gen-cdn-lib-options.cjs +1 -0
- package/dist/interface/i-gen-cdn-lib-options/i-gen-cdn-lib-options.d.ts +44 -0
- package/dist/interface/index.d.ts +1 -0
- package/es/actions/gen-cdn-lib/gen-cdn-lib.d.ts +11 -0
- package/es/actions/gen-cdn-lib/gen-cdn-lib.mjs +91 -0
- package/es/actions/index.d.ts +1 -0
- package/es/actions/index.mjs +1 -0
- package/es/commands/gen-cdn-lib/gen-cdn-lib.d.ts +6 -0
- package/es/commands/gen-cdn-lib/gen-cdn-lib.mjs +11 -0
- package/es/commands/index.mjs +2 -0
- package/es/interface/i-gen-cdn-lib-options/i-gen-cdn-lib-options.d.ts +44 -0
- package/es/interface/i-gen-cdn-lib-options/i-gen-cdn-lib-options.mjs +0 -0
- package/es/interface/index.d.ts +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GenCdnLibAction = void 0;
|
|
7
|
+
var _pacote = _interopRequireDefault(require("pacote"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
+
var _consola = _interopRequireDefault(require("consola"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
class GenCdnLibAction {
|
|
13
|
+
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"];
|
|
14
|
+
async run(opts) {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const extraDir = opts.dir ? _path.default.resolve(cwd, opts.dir) : cwd;
|
|
17
|
+
const extraDirName = _path.default.basename(extraDir);
|
|
18
|
+
if (!_fsExtra.default.existsSync(extraDir)) {
|
|
19
|
+
_fsExtra.default.mkdirSync(extraDir, {
|
|
20
|
+
recursive: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const cacheDir = opts.cache ? _path.default.resolve(cwd, opts.cache) : _path.default.join(extraDir, ".cache");
|
|
24
|
+
const extractCacheDir = _path.default.join(cacheDir, "tmp");
|
|
25
|
+
const importMapJsonPath = opts.jsonPath ? _path.default.resolve(cwd, opts.jsonPath) : _path.default.join(extraDir, "import-map.json");
|
|
26
|
+
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`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
_consola.default.info(`\u8BFB\u53D6 import-map.json`);
|
|
31
|
+
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);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
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";
|
|
65
|
+
} 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;
|
|
68
|
+
}
|
|
69
|
+
importMap.imports[pkg] = `./${extraDirName}/${pkgInfo.name}/${pkgInfo.version}/${entryName}`;
|
|
70
|
+
_consola.default.info(`\u6210\u529F\u4FEE\u6539 ${pkg} \u8DEF\u5F84`);
|
|
71
|
+
}
|
|
72
|
+
_fsExtra.default.writeJSONSync(importMapJsonPath, importMap, {
|
|
73
|
+
spaces: 2
|
|
74
|
+
});
|
|
75
|
+
if (_fsExtra.default.existsSync(cacheDir)) {
|
|
76
|
+
_consola.default.info(`\u6B63\u5728\u5220\u9664\u7F13\u5B58\u76EE\u5F55: ${cacheDir}`);
|
|
77
|
+
_fsExtra.default.removeSync(cacheDir);
|
|
78
|
+
}
|
|
79
|
+
_consola.default.success("CDN \u5E93\u6587\u4EF6\u751F\u6210\u6210\u529F\uFF01");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.GenCdnLibAction = GenCdnLibAction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IGenCdnLibOptions } from '../../interface';
|
|
2
|
+
/**
|
|
3
|
+
* 使用 pacote 从 npm 上下载制定包,至本地 cdn 项目目录,然后修改 import-map.json 文件,适配新包的版本号
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class GenCdnLibAction
|
|
7
|
+
*/
|
|
8
|
+
export declare class GenCdnLibAction {
|
|
9
|
+
private packages;
|
|
10
|
+
run(opts: IGenCdnLibOptions): Promise<void>;
|
|
11
|
+
}
|
package/dist/actions/index.cjs
CHANGED
|
@@ -9,4 +9,11 @@ Object.defineProperty(exports, "GenApiAction", {
|
|
|
9
9
|
return _genApi.GenApiAction;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
Object.defineProperty(exports, "GenCdnLibAction", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _genCdnLib.GenCdnLibAction;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _genApi = require("./gen-api/gen-api.cjs");
|
|
19
|
+
var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GenCdnLibCommand = void 0;
|
|
7
|
+
var _actions = require("../../actions/index.cjs");
|
|
8
|
+
class GenCdnLibCommand {
|
|
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));
|
|
11
|
+
}
|
|
12
|
+
async action(args) {
|
|
13
|
+
await new _actions.GenCdnLibAction().run(args);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.GenCdnLibCommand = GenCdnLibCommand;
|
package/dist/commands/index.cjs
CHANGED
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.CommandLoader = void 0;
|
|
7
7
|
var _consola = require("consola");
|
|
8
8
|
var _genApi = require("./gen-api/gen-api.cjs");
|
|
9
|
+
var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
|
9
10
|
class CommandLoader {
|
|
10
11
|
static load(program) {
|
|
11
12
|
new _genApi.GenApiCommand().load(program);
|
|
13
|
+
new _genCdnLib.GenCdnLibCommand().load(program);
|
|
12
14
|
this.handleInvalidCommand(program);
|
|
13
15
|
}
|
|
14
16
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成 cdn 库文件命令参数接口
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @interface IGenCdnLibOptions
|
|
6
|
+
*/
|
|
7
|
+
export interface IGenCdnLibOptions {
|
|
8
|
+
/**
|
|
9
|
+
* 制定下载的版本标签,默认为 latest
|
|
10
|
+
*
|
|
11
|
+
* @type {('latest' | 'dev' | 'beta' | 'alpha')}
|
|
12
|
+
*/
|
|
13
|
+
tag: 'latest' | 'dev' | 'beta' | 'alpha';
|
|
14
|
+
/**
|
|
15
|
+
* 要输出的 extras 资源目录,未指定时默认为当前执行目录
|
|
16
|
+
*
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
dir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 指定 import-map.json 文件路径,未制定默认使用指定的 dir 目录下的 import-map.json 文件
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
jsonPath?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 是否清理输出目录后再生成
|
|
28
|
+
*
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
clean?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 指定 npm registry 地址,未指定时使用默认 registry
|
|
34
|
+
*
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
registry?: string;
|
|
38
|
+
/**
|
|
39
|
+
* 指定 pacote 缓存目录,未指定时使用默认缓存目录
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
cache?: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IGenCdnLibOptions } from '../../interface';
|
|
2
|
+
/**
|
|
3
|
+
* 使用 pacote 从 npm 上下载制定包,至本地 cdn 项目目录,然后修改 import-map.json 文件,适配新包的版本号
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class GenCdnLibAction
|
|
7
|
+
*/
|
|
8
|
+
export declare class GenCdnLibAction {
|
|
9
|
+
private packages;
|
|
10
|
+
run(opts: IGenCdnLibOptions): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import pacote from "pacote";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import log from "consola";
|
|
5
|
+
export class GenCdnLibAction {
|
|
6
|
+
packages = [
|
|
7
|
+
"@gct-paas/api",
|
|
8
|
+
"@gct-paas/core",
|
|
9
|
+
"@gct-paas/core-mobile",
|
|
10
|
+
"@gct-paas/core-pad",
|
|
11
|
+
"@gct-paas/core-web",
|
|
12
|
+
"@gct-paas/design",
|
|
13
|
+
"@gct-paas/design-mobile",
|
|
14
|
+
"@gct-paas/design-pad",
|
|
15
|
+
"@gct-paas/design-web",
|
|
16
|
+
"@gct-paas/native",
|
|
17
|
+
"@gct-paas/render",
|
|
18
|
+
"@gct-paas/render-mobile",
|
|
19
|
+
"@gct-paas/render-pad",
|
|
20
|
+
"@gct-paas/render-web",
|
|
21
|
+
"@gct-paas/schema",
|
|
22
|
+
"@gct-paas/v-ben"
|
|
23
|
+
];
|
|
24
|
+
async run(opts) {
|
|
25
|
+
const cwd = process.cwd();
|
|
26
|
+
const extraDir = opts.dir ? path.resolve(cwd, opts.dir) : cwd;
|
|
27
|
+
const extraDirName = path.basename(extraDir);
|
|
28
|
+
if (!fse.existsSync(extraDir)) {
|
|
29
|
+
fse.mkdirSync(extraDir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
const cacheDir = opts.cache ? path.resolve(cwd, opts.cache) : path.join(extraDir, ".cache");
|
|
32
|
+
const extractCacheDir = path.join(cacheDir, "tmp");
|
|
33
|
+
const importMapJsonPath = opts.jsonPath ? path.resolve(cwd, opts.jsonPath) : path.join(extraDir, "import-map.json");
|
|
34
|
+
if (!fse.existsSync(importMapJsonPath)) {
|
|
35
|
+
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`
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
log.info(`\u8BFB\u53D6 import-map.json`);
|
|
41
|
+
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
|
|
57
|
+
}
|
|
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";
|
|
77
|
+
} 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;
|
|
80
|
+
}
|
|
81
|
+
importMap.imports[pkg] = `./${extraDirName}/${pkgInfo.name}/${pkgInfo.version}/${entryName}`;
|
|
82
|
+
log.info(`\u6210\u529F\u4FEE\u6539 ${pkg} \u8DEF\u5F84`);
|
|
83
|
+
}
|
|
84
|
+
fse.writeJSONSync(importMapJsonPath, importMap, { spaces: 2 });
|
|
85
|
+
if (fse.existsSync(cacheDir)) {
|
|
86
|
+
log.info(`\u6B63\u5728\u5220\u9664\u7F13\u5B58\u76EE\u5F55: ${cacheDir}`);
|
|
87
|
+
fse.removeSync(cacheDir);
|
|
88
|
+
}
|
|
89
|
+
log.success("CDN \u5E93\u6587\u4EF6\u751F\u6210\u6210\u529F\uFF01");
|
|
90
|
+
}
|
|
91
|
+
}
|
package/es/actions/index.d.ts
CHANGED
package/es/actions/index.mjs
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GenCdnLibAction } from "../../actions/index.mjs";
|
|
2
|
+
export class GenCdnLibCommand {
|
|
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));
|
|
5
|
+
}
|
|
6
|
+
async action(args) {
|
|
7
|
+
await new GenCdnLibAction().run(
|
|
8
|
+
args
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
package/es/commands/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { consola } from "consola";
|
|
2
2
|
import { GenApiCommand } from "./gen-api/gen-api.mjs";
|
|
3
|
+
import { GenCdnLibCommand } from "./gen-cdn-lib/gen-cdn-lib.mjs";
|
|
3
4
|
export class CommandLoader {
|
|
4
5
|
static load(program) {
|
|
5
6
|
new GenApiCommand().load(program);
|
|
7
|
+
new GenCdnLibCommand().load(program);
|
|
6
8
|
this.handleInvalidCommand(program);
|
|
7
9
|
}
|
|
8
10
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成 cdn 库文件命令参数接口
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @interface IGenCdnLibOptions
|
|
6
|
+
*/
|
|
7
|
+
export interface IGenCdnLibOptions {
|
|
8
|
+
/**
|
|
9
|
+
* 制定下载的版本标签,默认为 latest
|
|
10
|
+
*
|
|
11
|
+
* @type {('latest' | 'dev' | 'beta' | 'alpha')}
|
|
12
|
+
*/
|
|
13
|
+
tag: 'latest' | 'dev' | 'beta' | 'alpha';
|
|
14
|
+
/**
|
|
15
|
+
* 要输出的 extras 资源目录,未指定时默认为当前执行目录
|
|
16
|
+
*
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
dir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 指定 import-map.json 文件路径,未制定默认使用指定的 dir 目录下的 import-map.json 文件
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
jsonPath?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 是否清理输出目录后再生成
|
|
28
|
+
*
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
clean?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 指定 npm registry 地址,未指定时使用默认 registry
|
|
34
|
+
*
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
registry?: string;
|
|
38
|
+
/**
|
|
39
|
+
* 指定 pacote 缓存目录,未指定时使用默认缓存目录
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
cache?: string;
|
|
44
|
+
}
|
|
File without changes
|
package/es/interface/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/cli",
|
|
3
|
-
"version": "0.1.6-dev.
|
|
3
|
+
"version": "0.1.6-dev.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"author": "gct",
|
|
36
36
|
"scripts": {
|
|
37
|
-
"run": "tsx src/bin.ts",
|
|
37
|
+
"run": "tsx src/bin.ts gen-cdn-lib --tag=dev --dir=/Users/zhr/workspace/gct/gct-paas-cdn/extras",
|
|
38
38
|
"build": "unbuild",
|
|
39
39
|
"publish:next": "npm run build && npm publish --access public --tag=next --registry=https://registry.npmjs.org/",
|
|
40
40
|
"publish:dev": "npm run build && npm publish --access public --tag=dev --registry=https://registry.npmjs.org/",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"handlebars-helpers": "^0.10.0",
|
|
55
55
|
"lodash-es": "^4.17.23",
|
|
56
56
|
"ora": "^9.1.0",
|
|
57
|
+
"pacote": "^21.5.0",
|
|
57
58
|
"picocolors": "^1.1.1",
|
|
58
59
|
"rimraf": "^6.1.2"
|
|
59
60
|
},
|
|
@@ -61,9 +62,10 @@
|
|
|
61
62
|
"@types/fs-extra": "^11.0.4",
|
|
62
63
|
"@types/lodash-es": "^4.17.12",
|
|
63
64
|
"@types/node": "^25.0.10",
|
|
65
|
+
"@types/pacote": "^11.1.8",
|
|
64
66
|
"tsx": "^4.21.0",
|
|
65
67
|
"typescript": "^5.9.3",
|
|
66
68
|
"unbuild": "^3.6.1"
|
|
67
69
|
},
|
|
68
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "6385e29b22a78c9971112aa313aa5c4154b8d0e5"
|
|
69
71
|
}
|