@gct-paas/cli 0.1.8 → 0.1.10
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 +13 -0
- package/dist/actions/index.cjs +8 -1
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/nginx-start/nginx-start.cjs +72 -0
- package/dist/actions/nginx-start/nginx-start.d.ts +16 -0
- package/dist/actions/update-catalog-env/update-catalog-env.cjs +10 -9
- package/dist/actions/update-catalog-env/update-catalog-env.d.ts +3 -1
- package/dist/commands/index.cjs +2 -0
- package/dist/commands/nginx-start/nginx-start.cjs +16 -0
- package/dist/commands/nginx-start/nginx-start.d.ts +15 -0
- package/dist/commands/update-catalog-env/update-catalog-env.cjs +3 -3
- package/dist/commands/update-catalog-env/update-catalog-env.d.ts +3 -1
- package/dist/constants/index.cjs +1 -1
- package/es/actions/index.d.ts +1 -0
- package/es/actions/index.mjs +1 -0
- package/es/actions/nginx-start/nginx-start.d.ts +16 -0
- package/es/actions/nginx-start/nginx-start.mjs +56 -0
- package/es/actions/update-catalog-env/update-catalog-env.d.ts +3 -1
- package/es/actions/update-catalog-env/update-catalog-env.mjs +10 -9
- package/es/commands/index.mjs +2 -0
- package/es/commands/nginx-start/nginx-start.d.ts +15 -0
- package/es/commands/nginx-start/nginx-start.mjs +9 -0
- package/es/commands/update-catalog-env/update-catalog-env.d.ts +3 -1
- package/es/commands/update-catalog-env/update-catalog-env.mjs +3 -3
- package/es/constants/index.mjs +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.10] - 2026-04-02
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- update-catalog-env 支持传递 tag 标识
|
|
15
|
+
- 新增 catalog 动态更新包 @gct-paas/core-components
|
|
16
|
+
|
|
17
|
+
## [0.1.9] - 2026-04-02
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- 命令 nginx-start 便捷本地启动 plugin 开发 nginx
|
|
22
|
+
|
|
10
23
|
## [0.1.8] - 2026-04-02
|
|
11
24
|
|
|
12
25
|
### Changed
|
package/dist/actions/index.cjs
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "InitGitAction", {
|
|
|
21
21
|
return _initGit.InitGitAction;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "NginxStartAction", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _nginxStart.NginxStartAction;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "RestoreFilesAction", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -37,4 +43,5 @@ var _genApi = require("./gen-api/gen-api.cjs");
|
|
|
37
43
|
var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
|
38
44
|
var _initGit = require("./init-git/init-git.cjs");
|
|
39
45
|
var _restoreFiles = require("./restore-files/restore-files.cjs");
|
|
40
|
-
var _updateCatalogEnv = require("./update-catalog-env/update-catalog-env.cjs");
|
|
46
|
+
var _updateCatalogEnv = require("./update-catalog-env/update-catalog-env.cjs");
|
|
47
|
+
var _nginxStart = require("./nginx-start/nginx-start.cjs");
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { GenCdnLibAction } from './gen-cdn-lib/gen-cdn-lib';
|
|
|
3
3
|
export { InitGitAction } from './init-git/init-git';
|
|
4
4
|
export { RestoreFilesAction } from './restore-files/restore-files';
|
|
5
5
|
export { UpdateCatalogEnvAction } from './update-catalog-env/update-catalog-env';
|
|
6
|
+
export { NginxStartAction } from './nginx-start/nginx-start';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NginxStartAction = void 0;
|
|
7
|
+
var _nodeChild_process = require("node:child_process");
|
|
8
|
+
var _nodeFs = require("node:fs");
|
|
9
|
+
var _nodePath = require("node:path");
|
|
10
|
+
var _consola = require("consola");
|
|
11
|
+
function sleep(ms) {
|
|
12
|
+
return new Promise(resolve2 => setTimeout(resolve2, ms));
|
|
13
|
+
}
|
|
14
|
+
class NginxStartAction {
|
|
15
|
+
nginxDir;
|
|
16
|
+
constructor(nginxDir) {
|
|
17
|
+
this.nginxDir = nginxDir ?? (0, _nodePath.resolve)(process.cwd(), "configs/nginx");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 停止已运行的 nginx 进程
|
|
21
|
+
* Windows 使用 taskkill 强制终止,其他平台使用 nginx -s stop
|
|
22
|
+
* 若 nginx 未运行则忽略错误
|
|
23
|
+
*/
|
|
24
|
+
async stopNginxIfRunning() {
|
|
25
|
+
try {
|
|
26
|
+
if (process.platform === "win32") {
|
|
27
|
+
(0, _nodeChild_process.execSync)("taskkill /F /IM nginx.exe", {
|
|
28
|
+
stdio: "pipe"
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
(0, _nodeChild_process.execSync)(`nginx -p "${this.nginxDir}" -s stop`, {
|
|
32
|
+
stdio: "pipe"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
_consola.consola.info("\u5DF2\u505C\u6B62\u73B0\u6709 nginx \u8FDB\u7A0B\uFF0C\u7B49\u5F85 1 \u79D2...");
|
|
36
|
+
await sleep(1e3);
|
|
37
|
+
} catch {
|
|
38
|
+
_consola.consola.info("nginx \u672A\u8FD0\u884C\uFF0C\u8DF3\u8FC7\u505C\u6B62\u6B65\u9AA4");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 启动 nginx
|
|
43
|
+
* Windows 下 nginx 不会自动 daemonize,使用 spawn detached 模式后台启动
|
|
44
|
+
*/
|
|
45
|
+
startNginx() {
|
|
46
|
+
for (const dir of ["logs", "temp"]) {
|
|
47
|
+
const dirPath = (0, _nodePath.resolve)(this.nginxDir, dir);
|
|
48
|
+
(0, _nodeFs.rmSync)(dirPath, {
|
|
49
|
+
recursive: true,
|
|
50
|
+
force: true
|
|
51
|
+
});
|
|
52
|
+
(0, _nodeFs.mkdirSync)(dirPath, {
|
|
53
|
+
recursive: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const nginxDirNormalized = this.nginxDir.split(_nodePath.sep).join("/");
|
|
57
|
+
const child = (0, _nodeChild_process.spawn)("nginx", ["-p", nginxDirNormalized, "-c", "nginx.conf"], {
|
|
58
|
+
cwd: process.cwd(),
|
|
59
|
+
stdio: "ignore",
|
|
60
|
+
detached: true
|
|
61
|
+
});
|
|
62
|
+
child.unref();
|
|
63
|
+
}
|
|
64
|
+
async run() {
|
|
65
|
+
_consola.consola.start("\u5F00\u59CB\u542F\u52A8 nginx...");
|
|
66
|
+
await this.stopNginxIfRunning();
|
|
67
|
+
_consola.consola.start("\u6B63\u5728\u542F\u52A8 nginx...");
|
|
68
|
+
this.startNginx();
|
|
69
|
+
_consola.consola.success("nginx \u542F\u52A8\u6267\u884C\u5B8C\u6BD5");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.NginxStartAction = NginxStartAction;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class NginxStartAction {
|
|
2
|
+
private readonly nginxDir;
|
|
3
|
+
constructor(nginxDir?: string);
|
|
4
|
+
/**
|
|
5
|
+
* 停止已运行的 nginx 进程
|
|
6
|
+
* Windows 使用 taskkill 强制终止,其他平台使用 nginx -s stop
|
|
7
|
+
* 若 nginx 未运行则忽略错误
|
|
8
|
+
*/
|
|
9
|
+
private stopNginxIfRunning;
|
|
10
|
+
/**
|
|
11
|
+
* 启动 nginx
|
|
12
|
+
* Windows 下 nginx 不会自动 daemonize,使用 spawn detached 模式后台启动
|
|
13
|
+
*/
|
|
14
|
+
private startNginx;
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -14,13 +14,16 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
14
14
|
var _constants = require("../../constants/index.cjs");
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
class UpdateCatalogEnvAction {
|
|
17
|
-
async run() {
|
|
17
|
+
async run(options) {
|
|
18
18
|
_consola.consola.start("\u4FEE\u6539 pnpm catalog \u914D\u7F6E...");
|
|
19
|
-
|
|
20
|
-
const tag = _constants.branch_2_tag[branch];
|
|
19
|
+
let tag = options?.tag;
|
|
21
20
|
if (!tag) {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const branch = await (0, _utils.getBranchName)();
|
|
22
|
+
tag = _constants.branch_2_tag[branch];
|
|
23
|
+
if (!tag) {
|
|
24
|
+
_consola.consola.info(`\u5F53\u524D\u5206\u652F ${branch} \u4E0D\u5339\u914D\u4EFB\u4F55\u73AF\u5883\u6807\u7B7E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
const catalogPath = _path.default.join(process.cwd(), "pnpm-workspace.yaml");
|
|
26
29
|
const pnpmConfig = _jsYaml.default.load(await _fsExtra.default.readFile(catalogPath, "utf-8"));
|
|
@@ -29,12 +32,10 @@ class UpdateCatalogEnvAction {
|
|
|
29
32
|
_consola.consola.warn("pnpm-workspace.yaml \u4E2D\u7F3A\u5C11 catalog \u914D\u7F6E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E");
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
|
-
const
|
|
35
|
+
const pkgsToUpdate = _constants.lib_packages.filter(pkg => pkg in catalogCfg);
|
|
36
|
+
const tasks = new _listr.Listr(pkgsToUpdate.map(pkg => ({
|
|
33
37
|
title: `\u8BBE\u7F6E ${pkg} \u7684 catalog \u6807\u7B7E\u4E3A ${tag}`,
|
|
34
38
|
task: async (_, task) => {
|
|
35
|
-
if (!catalogCfg[pkg]) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
39
|
task.title = `${pkg}@${tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
|
|
39
40
|
try {
|
|
40
41
|
const pkgInfo = await _pacote.default.manifest(`${pkg}@${tag}`);
|
package/dist/commands/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var _genCdnLib = require("./gen-cdn-lib/gen-cdn-lib.cjs");
|
|
|
10
10
|
var _initGit = require("./init-git/init-git.cjs");
|
|
11
11
|
var _restoreFiles = require("./restore-files/restore-files.cjs");
|
|
12
12
|
var _updateCatalogEnv = require("./update-catalog-env/update-catalog-env.cjs");
|
|
13
|
+
var _nginxStart = require("./nginx-start/nginx-start.cjs");
|
|
13
14
|
class CommandLoader {
|
|
14
15
|
static load(program) {
|
|
15
16
|
new _genApi.GenApiCommand().load(program);
|
|
@@ -17,6 +18,7 @@ class CommandLoader {
|
|
|
17
18
|
new _initGit.InitGitCommand().load(program);
|
|
18
19
|
new _restoreFiles.RestoreFilesCommand().load(program);
|
|
19
20
|
new _updateCatalogEnv.UpdateCatalogEnvCommand().load(program);
|
|
21
|
+
new _nginxStart.NginxStartCommand().load(program);
|
|
20
22
|
this.handleInvalidCommand(program);
|
|
21
23
|
}
|
|
22
24
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NginxStartCommand = void 0;
|
|
7
|
+
var _actions = require("../../actions/index.cjs");
|
|
8
|
+
class NginxStartCommand {
|
|
9
|
+
load(program) {
|
|
10
|
+
program.command("nginx-start").description("\u542F\u52A8 nginx\uFF08\u9700\u5C06 nginx \u53EF\u6267\u884C\u6587\u4EF6\u6DFB\u52A0\u5230\u7CFB\u7EDF PATH\uFF09").option("-d, --dir <path>", "nginx \u914D\u7F6E\u76EE\u5F55\uFF08\u9ED8\u8BA4\uFF1A<cwd>/configs/nginx\uFF09").action(this.action.bind(this));
|
|
11
|
+
}
|
|
12
|
+
async action(options) {
|
|
13
|
+
await new _actions.NginxStartAction(options.dir).run();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.NginxStartCommand = NginxStartCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { ICommand } from '../../interface';
|
|
3
|
+
/**
|
|
4
|
+
* 插件开发本地调试 nginx 启动命令
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class NginxStartCommand
|
|
8
|
+
* @implements {ICommand}
|
|
9
|
+
*/
|
|
10
|
+
export declare class NginxStartCommand implements ICommand {
|
|
11
|
+
load(program: Command): void;
|
|
12
|
+
action(options: {
|
|
13
|
+
dir?: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
}
|
|
@@ -7,10 +7,10 @@ exports.UpdateCatalogEnvCommand = void 0;
|
|
|
7
7
|
var _actions = require("../../actions/index.cjs");
|
|
8
8
|
class UpdateCatalogEnvCommand {
|
|
9
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));
|
|
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").option("-t, --tag <tag>", "\u6307\u5B9A\u73AF\u5883\u6807\u7B7E\uFF0C\u4E0D\u6307\u5B9A\u65F6\u6839\u636E git \u5206\u652F\u81EA\u52A8\u63A8\u65AD").action(this.action.bind(this));
|
|
11
11
|
}
|
|
12
|
-
async action() {
|
|
13
|
-
await new _actions.UpdateCatalogEnvAction().run();
|
|
12
|
+
async action(options) {
|
|
13
|
+
await new _actions.UpdateCatalogEnvAction().run(options);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.UpdateCatalogEnvCommand = UpdateCatalogEnvCommand;
|
|
@@ -2,5 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { ICommand } from '../../interface';
|
|
3
3
|
export declare class UpdateCatalogEnvCommand implements ICommand {
|
|
4
4
|
load(program: Command): void;
|
|
5
|
-
action(
|
|
5
|
+
action(options: {
|
|
6
|
+
tag?: string;
|
|
7
|
+
}): Promise<void>;
|
|
6
8
|
}
|
package/dist/constants/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.lib_packages = exports.branch_2_tag = void 0;
|
|
7
|
-
const lib_packages = exports.lib_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"];
|
|
7
|
+
const lib_packages = exports.lib_packages = ["@gct-paas/api", "@gct-paas/core", "@gct-paas/core-components", "@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/scss", "@gct-paas/v-ben"];
|
|
8
8
|
const branch_2_tag = exports.branch_2_tag = {
|
|
9
9
|
"paas-dev": "dev",
|
|
10
10
|
"paas-test": "test"
|
package/es/actions/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { GenCdnLibAction } from './gen-cdn-lib/gen-cdn-lib';
|
|
|
3
3
|
export { InitGitAction } from './init-git/init-git';
|
|
4
4
|
export { RestoreFilesAction } from './restore-files/restore-files';
|
|
5
5
|
export { UpdateCatalogEnvAction } from './update-catalog-env/update-catalog-env';
|
|
6
|
+
export { NginxStartAction } from './nginx-start/nginx-start';
|
package/es/actions/index.mjs
CHANGED
|
@@ -3,3 +3,4 @@ export { GenCdnLibAction } from "./gen-cdn-lib/gen-cdn-lib.mjs";
|
|
|
3
3
|
export { InitGitAction } from "./init-git/init-git.mjs";
|
|
4
4
|
export { RestoreFilesAction } from "./restore-files/restore-files.mjs";
|
|
5
5
|
export { UpdateCatalogEnvAction } from "./update-catalog-env/update-catalog-env.mjs";
|
|
6
|
+
export { NginxStartAction } from "./nginx-start/nginx-start.mjs";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class NginxStartAction {
|
|
2
|
+
private readonly nginxDir;
|
|
3
|
+
constructor(nginxDir?: string);
|
|
4
|
+
/**
|
|
5
|
+
* 停止已运行的 nginx 进程
|
|
6
|
+
* Windows 使用 taskkill 强制终止,其他平台使用 nginx -s stop
|
|
7
|
+
* 若 nginx 未运行则忽略错误
|
|
8
|
+
*/
|
|
9
|
+
private stopNginxIfRunning;
|
|
10
|
+
/**
|
|
11
|
+
* 启动 nginx
|
|
12
|
+
* Windows 下 nginx 不会自动 daemonize,使用 spawn detached 模式后台启动
|
|
13
|
+
*/
|
|
14
|
+
private startNginx;
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { execSync, spawn } from "node:child_process";
|
|
2
|
+
import { mkdirSync, rmSync } from "node:fs";
|
|
3
|
+
import { resolve, sep } from "node:path";
|
|
4
|
+
import { consola } from "consola";
|
|
5
|
+
function sleep(ms) {
|
|
6
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
7
|
+
}
|
|
8
|
+
export class NginxStartAction {
|
|
9
|
+
nginxDir;
|
|
10
|
+
constructor(nginxDir) {
|
|
11
|
+
this.nginxDir = nginxDir ?? resolve(process.cwd(), "configs/nginx");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 停止已运行的 nginx 进程
|
|
15
|
+
* Windows 使用 taskkill 强制终止,其他平台使用 nginx -s stop
|
|
16
|
+
* 若 nginx 未运行则忽略错误
|
|
17
|
+
*/
|
|
18
|
+
async stopNginxIfRunning() {
|
|
19
|
+
try {
|
|
20
|
+
if (process.platform === "win32") {
|
|
21
|
+
execSync("taskkill /F /IM nginx.exe", { stdio: "pipe" });
|
|
22
|
+
} else {
|
|
23
|
+
execSync(`nginx -p "${this.nginxDir}" -s stop`, { stdio: "pipe" });
|
|
24
|
+
}
|
|
25
|
+
consola.info("\u5DF2\u505C\u6B62\u73B0\u6709 nginx \u8FDB\u7A0B\uFF0C\u7B49\u5F85 1 \u79D2...");
|
|
26
|
+
await sleep(1e3);
|
|
27
|
+
} catch {
|
|
28
|
+
consola.info("nginx \u672A\u8FD0\u884C\uFF0C\u8DF3\u8FC7\u505C\u6B62\u6B65\u9AA4");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 启动 nginx
|
|
33
|
+
* Windows 下 nginx 不会自动 daemonize,使用 spawn detached 模式后台启动
|
|
34
|
+
*/
|
|
35
|
+
startNginx() {
|
|
36
|
+
for (const dir of ["logs", "temp"]) {
|
|
37
|
+
const dirPath = resolve(this.nginxDir, dir);
|
|
38
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
39
|
+
mkdirSync(dirPath, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
const nginxDirNormalized = this.nginxDir.split(sep).join("/");
|
|
42
|
+
const child = spawn("nginx", ["-p", nginxDirNormalized, "-c", "nginx.conf"], {
|
|
43
|
+
cwd: process.cwd(),
|
|
44
|
+
stdio: "ignore",
|
|
45
|
+
detached: true
|
|
46
|
+
});
|
|
47
|
+
child.unref();
|
|
48
|
+
}
|
|
49
|
+
async run() {
|
|
50
|
+
consola.start("\u5F00\u59CB\u542F\u52A8 nginx...");
|
|
51
|
+
await this.stopNginxIfRunning();
|
|
52
|
+
consola.start("\u6B63\u5728\u542F\u52A8 nginx...");
|
|
53
|
+
this.startNginx();
|
|
54
|
+
consola.success("nginx \u542F\u52A8\u6267\u884C\u5B8C\u6BD5");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -7,13 +7,16 @@ import { getBranchName } from "../../utils/index.mjs";
|
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { branch_2_tag, lib_packages } from "../../constants/index.mjs";
|
|
9
9
|
export class UpdateCatalogEnvAction {
|
|
10
|
-
async run() {
|
|
10
|
+
async run(options) {
|
|
11
11
|
consola.start("\u4FEE\u6539 pnpm catalog \u914D\u7F6E...");
|
|
12
|
-
|
|
13
|
-
const tag = branch_2_tag[branch];
|
|
12
|
+
let tag = options?.tag;
|
|
14
13
|
if (!tag) {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const branch = await getBranchName();
|
|
15
|
+
tag = branch_2_tag[branch];
|
|
16
|
+
if (!tag) {
|
|
17
|
+
consola.info(`\u5F53\u524D\u5206\u652F ${branch} \u4E0D\u5339\u914D\u4EFB\u4F55\u73AF\u5883\u6807\u7B7E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
const catalogPath = path.join(process.cwd(), "pnpm-workspace.yaml");
|
|
19
22
|
const pnpmConfig = jsYaml.load(await fse.readFile(catalogPath, "utf-8"));
|
|
@@ -22,13 +25,11 @@ export class UpdateCatalogEnvAction {
|
|
|
22
25
|
consola.warn("pnpm-workspace.yaml \u4E2D\u7F3A\u5C11 catalog \u914D\u7F6E\uFF0C\u8DF3\u8FC7 catalog \u8BBE\u7F6E");
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
28
|
+
const pkgsToUpdate = lib_packages.filter((pkg) => pkg in catalogCfg);
|
|
25
29
|
const tasks = new Listr(
|
|
26
|
-
|
|
30
|
+
pkgsToUpdate.map((pkg) => ({
|
|
27
31
|
title: `\u8BBE\u7F6E ${pkg} \u7684 catalog \u6807\u7B7E\u4E3A ${tag}`,
|
|
28
32
|
task: async (_, task) => {
|
|
29
|
-
if (!catalogCfg[pkg]) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
33
|
task.title = `${pkg}@${tag} \u83B7\u53D6\u5305\u4FE1\u606F...`;
|
|
33
34
|
try {
|
|
34
35
|
const pkgInfo = await pacote.manifest(`${pkg}@${tag}`);
|
package/es/commands/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { GenCdnLibCommand } from "./gen-cdn-lib/gen-cdn-lib.mjs";
|
|
|
4
4
|
import { InitGitCommand } from "./init-git/init-git.mjs";
|
|
5
5
|
import { RestoreFilesCommand } from "./restore-files/restore-files.mjs";
|
|
6
6
|
import { UpdateCatalogEnvCommand } from "./update-catalog-env/update-catalog-env.mjs";
|
|
7
|
+
import { NginxStartCommand } from "./nginx-start/nginx-start.mjs";
|
|
7
8
|
export class CommandLoader {
|
|
8
9
|
static load(program) {
|
|
9
10
|
new GenApiCommand().load(program);
|
|
@@ -11,6 +12,7 @@ export class CommandLoader {
|
|
|
11
12
|
new InitGitCommand().load(program);
|
|
12
13
|
new RestoreFilesCommand().load(program);
|
|
13
14
|
new UpdateCatalogEnvCommand().load(program);
|
|
15
|
+
new NginxStartCommand().load(program);
|
|
14
16
|
this.handleInvalidCommand(program);
|
|
15
17
|
}
|
|
16
18
|
static handleInvalidCommand(program) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { ICommand } from '../../interface';
|
|
3
|
+
/**
|
|
4
|
+
* 插件开发本地调试 nginx 启动命令
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class NginxStartCommand
|
|
8
|
+
* @implements {ICommand}
|
|
9
|
+
*/
|
|
10
|
+
export declare class NginxStartCommand implements ICommand {
|
|
11
|
+
load(program: Command): void;
|
|
12
|
+
action(options: {
|
|
13
|
+
dir?: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NginxStartAction } from "../../actions/index.mjs";
|
|
2
|
+
export class NginxStartCommand {
|
|
3
|
+
load(program) {
|
|
4
|
+
program.command("nginx-start").description("\u542F\u52A8 nginx\uFF08\u9700\u5C06 nginx \u53EF\u6267\u884C\u6587\u4EF6\u6DFB\u52A0\u5230\u7CFB\u7EDF PATH\uFF09").option("-d, --dir <path>", "nginx \u914D\u7F6E\u76EE\u5F55\uFF08\u9ED8\u8BA4\uFF1A<cwd>/configs/nginx\uFF09").action(this.action.bind(this));
|
|
5
|
+
}
|
|
6
|
+
async action(options) {
|
|
7
|
+
await new NginxStartAction(options.dir).run();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -2,5 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { ICommand } from '../../interface';
|
|
3
3
|
export declare class UpdateCatalogEnvCommand implements ICommand {
|
|
4
4
|
load(program: Command): void;
|
|
5
|
-
action(
|
|
5
|
+
action(options: {
|
|
6
|
+
tag?: string;
|
|
7
|
+
}): Promise<void>;
|
|
6
8
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UpdateCatalogEnvAction } from "../../actions/index.mjs";
|
|
2
2
|
export class UpdateCatalogEnvCommand {
|
|
3
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));
|
|
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").option("-t, --tag <tag>", "\u6307\u5B9A\u73AF\u5883\u6807\u7B7E\uFF0C\u4E0D\u6307\u5B9A\u65F6\u6839\u636E git \u5206\u652F\u81EA\u52A8\u63A8\u65AD").action(this.action.bind(this));
|
|
5
5
|
}
|
|
6
|
-
async action() {
|
|
7
|
-
await new UpdateCatalogEnvAction().run();
|
|
6
|
+
async action(options) {
|
|
7
|
+
await new UpdateCatalogEnvAction().run(options);
|
|
8
8
|
}
|
|
9
9
|
}
|
package/es/constants/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const lib_packages = [
|
|
2
2
|
"@gct-paas/api",
|
|
3
3
|
"@gct-paas/core",
|
|
4
|
+
"@gct-paas/core-components",
|
|
4
5
|
"@gct-paas/core-mobile",
|
|
5
6
|
"@gct-paas/core-pad",
|
|
6
7
|
"@gct-paas/core-web",
|
|
@@ -14,6 +15,7 @@ export const lib_packages = [
|
|
|
14
15
|
"@gct-paas/render-pad",
|
|
15
16
|
"@gct-paas/render-web",
|
|
16
17
|
"@gct-paas/schema",
|
|
18
|
+
"@gct-paas/scss",
|
|
17
19
|
"@gct-paas/v-ben"
|
|
18
20
|
];
|
|
19
21
|
export const branch_2_tag = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@types/node": "^25.0.10",
|
|
69
69
|
"@types/pacote": "^11.1.8",
|
|
70
70
|
"tsx": "^4.21.0",
|
|
71
|
-
"typescript": "^
|
|
71
|
+
"typescript": "^6.0.2",
|
|
72
72
|
"unbuild": "^3.6.1"
|
|
73
73
|
}
|
|
74
74
|
}
|