@gct-paas/cli 0.1.6 → 0.1.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.
- package/CHANGELOG.md +8 -0
- package/dist/actions/index.cjs +15 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/restore-files/restore-files.cjs +19 -0
- package/dist/actions/restore-files/restore-files.d.ts +3 -0
- package/dist/actions/update-catalog-env/update-catalog-env.cjs +61 -0
- package/dist/actions/update-catalog-env/update-catalog-env.d.ts +4 -0
- package/dist/commands/index.cjs +4 -0
- package/dist/commands/restore-files/restore-files.cjs +16 -0
- package/dist/commands/restore-files/restore-files.d.ts +6 -0
- package/dist/commands/update-catalog-env/update-catalog-env.cjs +16 -0
- package/dist/commands/update-catalog-env/update-catalog-env.d.ts +6 -0
- package/dist/utils/git-util/git-util.cjs +25 -0
- package/dist/utils/git-util/git-util.d.ts +7 -0
- package/dist/utils/index.cjs +16 -0
- package/dist/utils/index.d.ts +1 -0
- package/es/actions/index.d.ts +2 -0
- package/es/actions/index.mjs +2 -0
- package/es/actions/restore-files/restore-files.d.ts +3 -0
- package/es/actions/restore-files/restore-files.mjs +13 -0
- package/es/actions/update-catalog-env/update-catalog-env.d.ts +4 -0
- package/es/actions/update-catalog-env/update-catalog-env.mjs +69 -0
- package/es/bin.mjs +0 -0
- package/es/commands/index.mjs +4 -0
- package/es/commands/restore-files/restore-files.d.ts +6 -0
- package/es/commands/restore-files/restore-files.mjs +9 -0
- package/es/commands/update-catalog-env/update-catalog-env.d.ts +6 -0
- package/es/commands/update-catalog-env/update-catalog-env.mjs +9 -0
- package/es/utils/git-util/git-util.d.ts +7 -0
- package/es/utils/git-util/git-util.mjs +21 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +1 -0
- package/package.json +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.7] - 2026-04-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- 命令 init-git 初始化项目获取到本地后的配置
|
|
15
|
+
- 命令 update-catalog-env 根据分支修改 pnpm catalog 配置,使具体分支使用对应环境的底包
|
|
16
|
+
- 命令 restore-files 还原指定的已经修改的文件列表,目前还原修改的 pnpm-workspace.yaml 文件
|
|
17
|
+
|
|
10
18
|
## [0.1.3] - 2025-06-16
|
|
11
19
|
|
|
12
20
|
### Added
|
package/dist/actions/index.cjs
CHANGED
|
@@ -21,6 +21,20 @@ Object.defineProperty(exports, "InitGitAction", {
|
|
|
21
21
|
return _initGit.InitGitAction;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "RestoreFilesAction", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _restoreFiles.RestoreFilesAction;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "UpdateCatalogEnvAction", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _updateCatalogEnv.UpdateCatalogEnvAction;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
var _genApi = require("./gen-api/gen-api.cjs");
|
|
25
37
|
var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
|
26
|
-
var _initGit = require("./init-git/init-git.cjs");
|
|
38
|
+
var _initGit = require("./init-git/init-git.cjs");
|
|
39
|
+
var _restoreFiles = require("./restore-files/restore-files.cjs");
|
|
40
|
+
var _updateCatalogEnv = require("./update-catalog-env/update-catalog-env.cjs");
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { GenApiAction } from './gen-api/gen-api';
|
|
2
2
|
export { GenCdnLibAction } from './gen-cdn-lib/gen-cdn-lib';
|
|
3
3
|
export { InitGitAction } from './init-git/init-git';
|
|
4
|
+
export { RestoreFilesAction } from './restore-files/restore-files';
|
|
5
|
+
export { UpdateCatalogEnvAction } from './update-catalog-env/update-catalog-env';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RestoreFilesAction = void 0;
|
|
7
|
+
var _consola = require("consola");
|
|
8
|
+
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const FILES_TO_RESTORE = ["pnpm-workspace.yaml"];
|
|
11
|
+
class RestoreFilesAction {
|
|
12
|
+
async run() {
|
|
13
|
+
const git = (0, _simpleGit.default)(process.cwd());
|
|
14
|
+
_consola.consola.start(`\u8FD8\u539F\u6587\u4EF6: ${FILES_TO_RESTORE.join(", ")}`);
|
|
15
|
+
await git.checkout(FILES_TO_RESTORE);
|
|
16
|
+
_consola.consola.success("\u6587\u4EF6\u8FD8\u539F\u5B8C\u6210");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.RestoreFilesAction = RestoreFilesAction;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UpdateCatalogEnvAction = void 0;
|
|
7
|
+
var _pacote = _interopRequireDefault(require("pacote"));
|
|
8
|
+
var _consola = require("consola");
|
|
9
|
+
var _listr = require("listr2");
|
|
10
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
11
|
+
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
12
|
+
var _utils = require("../../utils/index.cjs");
|
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const envMap = {
|
|
16
|
+
"paas-dev": "dev",
|
|
17
|
+
"paas-test": "test"
|
|
18
|
+
};
|
|
19
|
+
class UpdateCatalogEnvAction {
|
|
20
|
+
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"];
|
|
21
|
+
async run() {
|
|
22
|
+
_consola.consola.start("\u4FEE\u6539 pnpm catalog \u914D\u7F6E...");
|
|
23
|
+
const branch = await (0, _utils.getBranchName)();
|
|
24
|
+
const tag = envMap[branch];
|
|
25
|
+
if (!tag) {
|
|
26
|
+
_consola.consola.info(`\u5F53\u524D\u5206\u652F ${branch} \u4E0D\u5339\u914D\u4EFB\u4F55\u73AF\u5883\u6807\u7B7E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const catalogPath = _path.default.join(process.cwd(), "pnpm-workspace.yaml");
|
|
30
|
+
const pnpmConfig = _jsYaml.default.load(await _fsExtra.default.readFile(catalogPath, "utf-8"));
|
|
31
|
+
const catalogCfg = pnpmConfig.catalog;
|
|
32
|
+
if (!catalogCfg) {
|
|
33
|
+
_consola.consola.warn("pnpm-workspace.yaml \u4E2D\u7F3A\u5C11 catalog \u914D\u7F6E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const tasks = new _listr.Listr(this.packages.map(pkg => ({
|
|
37
|
+
title: `\u8BBE\u7F6E ${pkg} \u7684 catalog \u6807\u7B7E\u4E3A ${tag}`,
|
|
38
|
+
task: async (_, task) => {
|
|
39
|
+
if (!catalogCfg[pkg]) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
task.title = `${pkg}@${tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
|
|
43
|
+
try {
|
|
44
|
+
const pkgInfo = await _pacote.default.manifest(`${pkg}@${tag}`);
|
|
45
|
+
catalogCfg[pkg] = pkgInfo.version;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const err = error;
|
|
48
|
+
throw new Error(`\u65E0\u6CD5\u83B7\u53D6 ${pkg}@${tag} \u7684\u7248\u672C\u4FE1\u606F\uFF0C\u53EF\u80FD\u662F\u5305\u4E0D\u5B58\u5728\u6216\u7F51\u7EDC\u95EE\u9898: ${err.message}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})), {
|
|
52
|
+
concurrent: true
|
|
53
|
+
});
|
|
54
|
+
await tasks.run();
|
|
55
|
+
await _fsExtra.default.writeFile(catalogPath, _jsYaml.default.dump(pnpmConfig, {
|
|
56
|
+
indent: 2
|
|
57
|
+
}), "utf-8");
|
|
58
|
+
_consola.consola.success("pnpm catalog \u914D\u7F6E\u4FEE\u6539\u5B8C\u6210");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.UpdateCatalogEnvAction = UpdateCatalogEnvAction;
|
package/dist/commands/index.cjs
CHANGED
|
@@ -8,11 +8,15 @@ var _consola = require("consola");
|
|
|
8
8
|
var _genApi = require("./gen-api/gen-api.cjs");
|
|
9
9
|
var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
|
10
10
|
var _initGit = require("./init-git/init-git.cjs");
|
|
11
|
+
var _restoreFiles = require("./restore-files/restore-files.cjs");
|
|
12
|
+
var _updateCatalogEnv = require("./update-catalog-env/update-catalog-env.cjs");
|
|
11
13
|
class CommandLoader {
|
|
12
14
|
static load(program) {
|
|
13
15
|
new _genApi.GenApiCommand().load(program);
|
|
14
16
|
new _genCdnLib.GenCdnLibCommand().load(program);
|
|
15
17
|
new _initGit.InitGitCommand().load(program);
|
|
18
|
+
new _restoreFiles.RestoreFilesCommand().load(program);
|
|
19
|
+
new _updateCatalogEnv.UpdateCatalogEnvCommand().load(program);
|
|
16
20
|
this.handleInvalidCommand(program);
|
|
17
21
|
}
|
|
18
22
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RestoreFilesCommand = void 0;
|
|
7
|
+
var _actions = require("../../actions/index.cjs");
|
|
8
|
+
class RestoreFilesCommand {
|
|
9
|
+
load(program) {
|
|
10
|
+
program.command("restore-files").description("\u8FD8\u539F\u9884\u8BBE\u7684\u5DF2\u4FEE\u6539\u6587\u4EF6\u5217\u8868\u5230 HEAD \u7248\u672C").action(this.action.bind(this));
|
|
11
|
+
}
|
|
12
|
+
async action() {
|
|
13
|
+
await new _actions.RestoreFilesAction().run();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RestoreFilesCommand = RestoreFilesCommand;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UpdateCatalogEnvCommand = void 0;
|
|
7
|
+
var _actions = require("../../actions/index.cjs");
|
|
8
|
+
class UpdateCatalogEnvCommand {
|
|
9
|
+
load(program) {
|
|
10
|
+
program.command("update-catalog-env").description("\u6839\u636E git \u5206\u652F\uFF0C\u66F4\u65B0\u9879\u76EE pnpm catalog \u914D\u7F6E\u4E3A\u5177\u4F53\u73AF\u5883").action(this.action.bind(this));
|
|
11
|
+
}
|
|
12
|
+
async action() {
|
|
13
|
+
await new _actions.UpdateCatalogEnvAction().run();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.UpdateCatalogEnvCommand = UpdateCatalogEnvCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBranchName = getBranchName;
|
|
7
|
+
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
async function getBranchName() {
|
|
10
|
+
let targetBranch = process.env.CI_COMMIT_BRANCH || process.env.CI_BUILD_REF_NAME;
|
|
11
|
+
if (!targetBranch) {
|
|
12
|
+
const cwdGit = (0, _simpleGit.default)(process.cwd());
|
|
13
|
+
try {
|
|
14
|
+
const raw = await cwdGit.revparse(["--abbrev-ref", "HEAD"]);
|
|
15
|
+
const resolved = raw.trim();
|
|
16
|
+
if (resolved && resolved !== "HEAD") {
|
|
17
|
+
targetBranch = resolved;
|
|
18
|
+
}
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
if (!targetBranch) {
|
|
22
|
+
throw new Error("\u65E0\u6CD5\u81EA\u52A8\u83B7\u53D6\u5F53\u524D git \u5206\u652F\uFF1A\u5F53\u524D\u53EF\u80FD\u5904\u4E8E\u6E38\u79BB HEAD\uFF08detached HEAD\uFF09\u72B6\u6001\uFF08CI \u73AF\u5883\u5E38\u89C1\uFF09\u3002\u8BF7\u901A\u8FC7 options.branch \u660E\u786E\u6307\u5B9A\u5206\u652F\u540D\uFF0C\u6216\u786E\u4FDD\u73AF\u5883\u53D8\u91CF CI_COMMIT_BRANCH / CI_BUILD_REF_NAME \u5DF2\u8BBE\u7F6E\u3002");
|
|
23
|
+
}
|
|
24
|
+
return targetBranch;
|
|
25
|
+
}
|
package/dist/utils/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
localBinExists: true,
|
|
8
|
+
loadLocalBinCommandLoader: true
|
|
9
|
+
};
|
|
6
10
|
Object.defineProperty(exports, "loadLocalBinCommandLoader", {
|
|
7
11
|
enumerable: true,
|
|
8
12
|
get: function () {
|
|
@@ -15,4 +19,16 @@ Object.defineProperty(exports, "localBinExists", {
|
|
|
15
19
|
return _localBinaries.localBinExists;
|
|
16
20
|
}
|
|
17
21
|
});
|
|
22
|
+
var _gitUtil = require("./git-util/git-util.cjs");
|
|
23
|
+
Object.keys(_gitUtil).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _gitUtil[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _gitUtil[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
18
34
|
var _localBinaries = require("./local-binaries/local-binaries.cjs");
|
package/dist/utils/index.d.ts
CHANGED
package/es/actions/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { GenApiAction } from './gen-api/gen-api';
|
|
2
2
|
export { GenCdnLibAction } from './gen-cdn-lib/gen-cdn-lib';
|
|
3
3
|
export { InitGitAction } from './init-git/init-git';
|
|
4
|
+
export { RestoreFilesAction } from './restore-files/restore-files';
|
|
5
|
+
export { UpdateCatalogEnvAction } from './update-catalog-env/update-catalog-env';
|
package/es/actions/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { GenApiAction } from "./gen-api/gen-api.mjs";
|
|
2
2
|
export { GenCdnLibAction } from "./gen-cdn-lib/gen-cdn-lib.mjs";
|
|
3
3
|
export { InitGitAction } from "./init-git/init-git.mjs";
|
|
4
|
+
export { RestoreFilesAction } from "./restore-files/restore-files.mjs";
|
|
5
|
+
export { UpdateCatalogEnvAction } from "./update-catalog-env/update-catalog-env.mjs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { consola } from "consola";
|
|
2
|
+
import simpleGit from "simple-git";
|
|
3
|
+
const FILES_TO_RESTORE = [
|
|
4
|
+
"pnpm-workspace.yaml"
|
|
5
|
+
];
|
|
6
|
+
export class RestoreFilesAction {
|
|
7
|
+
async run() {
|
|
8
|
+
const git = simpleGit(process.cwd());
|
|
9
|
+
consola.start(`\u8FD8\u539F\u6587\u4EF6: ${FILES_TO_RESTORE.join(", ")}`);
|
|
10
|
+
await git.checkout(FILES_TO_RESTORE);
|
|
11
|
+
consola.success("\u6587\u4EF6\u8FD8\u539F\u5B8C\u6210");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import pacote from "pacote";
|
|
2
|
+
import { consola } from "consola";
|
|
3
|
+
import { Listr } from "listr2";
|
|
4
|
+
import fse from "fs-extra";
|
|
5
|
+
import jsYaml from "js-yaml";
|
|
6
|
+
import { getBranchName } from "../../utils/index.mjs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
const envMap = {
|
|
9
|
+
"paas-dev": "dev",
|
|
10
|
+
"paas-test": "test"
|
|
11
|
+
};
|
|
12
|
+
export class UpdateCatalogEnvAction {
|
|
13
|
+
packages = [
|
|
14
|
+
"@gct-paas/api",
|
|
15
|
+
"@gct-paas/core",
|
|
16
|
+
"@gct-paas/core-mobile",
|
|
17
|
+
"@gct-paas/core-pad",
|
|
18
|
+
"@gct-paas/core-web",
|
|
19
|
+
"@gct-paas/design",
|
|
20
|
+
"@gct-paas/design-mobile",
|
|
21
|
+
"@gct-paas/design-pad",
|
|
22
|
+
"@gct-paas/design-web",
|
|
23
|
+
"@gct-paas/native",
|
|
24
|
+
"@gct-paas/render",
|
|
25
|
+
"@gct-paas/render-mobile",
|
|
26
|
+
"@gct-paas/render-pad",
|
|
27
|
+
"@gct-paas/render-web",
|
|
28
|
+
"@gct-paas/schema",
|
|
29
|
+
"@gct-paas/v-ben"
|
|
30
|
+
];
|
|
31
|
+
async run() {
|
|
32
|
+
consola.start("\u4FEE\u6539 pnpm catalog \u914D\u7F6E...");
|
|
33
|
+
const branch = await getBranchName();
|
|
34
|
+
const tag = envMap[branch];
|
|
35
|
+
if (!tag) {
|
|
36
|
+
consola.info(`\u5F53\u524D\u5206\u652F ${branch} \u4E0D\u5339\u914D\u4EFB\u4F55\u73AF\u5883\u6807\u7B7E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const catalogPath = path.join(process.cwd(), "pnpm-workspace.yaml");
|
|
40
|
+
const pnpmConfig = jsYaml.load(await fse.readFile(catalogPath, "utf-8"));
|
|
41
|
+
const catalogCfg = pnpmConfig.catalog;
|
|
42
|
+
if (!catalogCfg) {
|
|
43
|
+
consola.warn("pnpm-workspace.yaml \u4E2D\u7F3A\u5C11 catalog \u914D\u7F6E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const tasks = new Listr(
|
|
47
|
+
this.packages.map((pkg) => ({
|
|
48
|
+
title: `\u8BBE\u7F6E ${pkg} \u7684 catalog \u6807\u7B7E\u4E3A ${tag}`,
|
|
49
|
+
task: async (_, task) => {
|
|
50
|
+
if (!catalogCfg[pkg]) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
task.title = `${pkg}@${tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
|
|
54
|
+
try {
|
|
55
|
+
const pkgInfo = await pacote.manifest(`${pkg}@${tag}`);
|
|
56
|
+
catalogCfg[pkg] = pkgInfo.version;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const err = error;
|
|
59
|
+
throw new Error(`\u65E0\u6CD5\u83B7\u53D6 ${pkg}@${tag} \u7684\u7248\u672C\u4FE1\u606F\uFF0C\u53EF\u80FD\u662F\u5305\u4E0D\u5B58\u5728\u6216\u7F51\u7EDC\u95EE\u9898: ${err.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})),
|
|
63
|
+
{ concurrent: true }
|
|
64
|
+
);
|
|
65
|
+
await tasks.run();
|
|
66
|
+
await fse.writeFile(catalogPath, jsYaml.dump(pnpmConfig, { indent: 2 }), "utf-8");
|
|
67
|
+
consola.success("pnpm catalog \u914D\u7F6E\u4FEE\u6539\u5B8C\u6210");
|
|
68
|
+
}
|
|
69
|
+
}
|
package/es/bin.mjs
CHANGED
|
File without changes
|
package/es/commands/index.mjs
CHANGED
|
@@ -2,11 +2,15 @@ import { consola } from "consola";
|
|
|
2
2
|
import { GenApiCommand } from "./gen-api/gen-api.mjs";
|
|
3
3
|
import { GenCdnLibCommand } from "./gen-cdn-lib/gen-cdn-lib.mjs";
|
|
4
4
|
import { InitGitCommand } from "./init-git/init-git.mjs";
|
|
5
|
+
import { RestoreFilesCommand } from "./restore-files/restore-files.mjs";
|
|
6
|
+
import { UpdateCatalogEnvCommand } from "./update-catalog-env/update-catalog-env.mjs";
|
|
5
7
|
export class CommandLoader {
|
|
6
8
|
static load(program) {
|
|
7
9
|
new GenApiCommand().load(program);
|
|
8
10
|
new GenCdnLibCommand().load(program);
|
|
9
11
|
new InitGitCommand().load(program);
|
|
12
|
+
new RestoreFilesCommand().load(program);
|
|
13
|
+
new UpdateCatalogEnvCommand().load(program);
|
|
10
14
|
this.handleInvalidCommand(program);
|
|
11
15
|
}
|
|
12
16
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RestoreFilesAction } from "../../actions/index.mjs";
|
|
2
|
+
export class RestoreFilesCommand {
|
|
3
|
+
load(program) {
|
|
4
|
+
program.command("restore-files").description("\u8FD8\u539F\u9884\u8BBE\u7684\u5DF2\u4FEE\u6539\u6587\u4EF6\u5217\u8868\u5230 HEAD \u7248\u672C").action(this.action.bind(this));
|
|
5
|
+
}
|
|
6
|
+
async action() {
|
|
7
|
+
await new RestoreFilesAction().run();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UpdateCatalogEnvAction } from "../../actions/index.mjs";
|
|
2
|
+
export class UpdateCatalogEnvCommand {
|
|
3
|
+
load(program) {
|
|
4
|
+
program.command("update-catalog-env").description("\u6839\u636E git \u5206\u652F\uFF0C\u66F4\u65B0\u9879\u76EE pnpm catalog \u914D\u7F6E\u4E3A\u5177\u4F53\u73AF\u5883").action(this.action.bind(this));
|
|
5
|
+
}
|
|
6
|
+
async action() {
|
|
7
|
+
await new UpdateCatalogEnvAction().run();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import simpleGit from "simple-git";
|
|
2
|
+
export async function getBranchName() {
|
|
3
|
+
let targetBranch = process.env.CI_COMMIT_BRANCH || process.env.CI_BUILD_REF_NAME;
|
|
4
|
+
if (!targetBranch) {
|
|
5
|
+
const cwdGit = simpleGit(process.cwd());
|
|
6
|
+
try {
|
|
7
|
+
const raw = await cwdGit.revparse(["--abbrev-ref", "HEAD"]);
|
|
8
|
+
const resolved = raw.trim();
|
|
9
|
+
if (resolved && resolved !== "HEAD") {
|
|
10
|
+
targetBranch = resolved;
|
|
11
|
+
}
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (!targetBranch) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"\u65E0\u6CD5\u81EA\u52A8\u83B7\u53D6\u5F53\u524D git \u5206\u652F\uFF1A\u5F53\u524D\u53EF\u80FD\u5904\u4E8E\u6E38\u79BB HEAD\uFF08detached HEAD\uFF09\u72B6\u6001\uFF08CI \u73AF\u5883\u5E38\u89C1\uFF09\u3002\u8BF7\u901A\u8FC7 options.branch \u660E\u786E\u6307\u5B9A\u5206\u652F\u540D\uFF0C\u6216\u786E\u4FDD\u73AF\u5883\u53D8\u91CF CI_COMMIT_BRANCH / CI_BUILD_REF_NAME \u5DF2\u8BBE\u7F6E\u3002"
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return targetBranch;
|
|
21
|
+
}
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
@@ -33,8 +33,18 @@
|
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"author": "gct",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"run": "tsx src/bin.ts gen-cdn-lib --tag=dev --dir=/Users/zhr/workspace/gct/gct-paas-cdn/extras",
|
|
38
|
+
"build": "unbuild",
|
|
39
|
+
"publish:next": "npm run build && npm publish --access public --tag=next --registry=https://registry.npmjs.org/",
|
|
40
|
+
"publish:dev": "npm run build && npm publish --access public --tag=dev --registry=https://registry.npmjs.org/",
|
|
41
|
+
"publish:alpha": "npm run build && npm publish --access public --tag=alpha --registry=https://registry.npmjs.org/",
|
|
42
|
+
"publish:beta": "npm run build && npm publish --access public --tag=beta --registry=https://registry.npmjs.org/",
|
|
43
|
+
"publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
36
45
|
"dependencies": {
|
|
37
46
|
"@inquirer/prompts": "^8.2.0",
|
|
47
|
+
"@types/js-yaml": "^4.0.9",
|
|
38
48
|
"commander": "^14.0.2",
|
|
39
49
|
"consola": "^3.4.2",
|
|
40
50
|
"core-js": "^3.48.0",
|
|
@@ -43,6 +53,7 @@
|
|
|
43
53
|
"got": "^14.6.6",
|
|
44
54
|
"handlebars": "^4.7.8",
|
|
45
55
|
"handlebars-helpers": "^0.10.0",
|
|
56
|
+
"js-yaml": "^4.1.1",
|
|
46
57
|
"listr2": "^10.2.1",
|
|
47
58
|
"lodash-es": "^4.17.23",
|
|
48
59
|
"ora": "^9.1.0",
|
|
@@ -59,14 +70,5 @@
|
|
|
59
70
|
"tsx": "^4.21.0",
|
|
60
71
|
"typescript": "^5.9.3",
|
|
61
72
|
"unbuild": "^3.6.1"
|
|
62
|
-
},
|
|
63
|
-
"scripts": {
|
|
64
|
-
"run": "tsx src/bin.ts gen-cdn-lib --tag=dev --dir=/Users/zhr/workspace/gct/gct-paas-cdn/extras",
|
|
65
|
-
"build": "unbuild",
|
|
66
|
-
"publish:next": "npm run build && npm publish --access public --tag=next --registry=https://registry.npmjs.org/",
|
|
67
|
-
"publish:dev": "npm run build && npm publish --access public --tag=dev --registry=https://registry.npmjs.org/",
|
|
68
|
-
"publish:alpha": "npm run build && npm publish --access public --tag=alpha --registry=https://registry.npmjs.org/",
|
|
69
|
-
"publish:beta": "npm run build && npm publish --access public --tag=beta --registry=https://registry.npmjs.org/",
|
|
70
|
-
"publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/"
|
|
71
73
|
}
|
|
72
|
-
}
|
|
74
|
+
}
|