nuxt-gin-tools 0.3.2 → 0.3.3
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/README.md +6 -2
- package/index.js +1 -1
- package/package.json +2 -12
- package/src/cli/commands/build.d.ts +4 -1
- package/src/cli/commands/build.js +114 -19
- package/src/cli/commands/cleanup.d.ts +2 -0
- package/src/cli/commands/cleanup.js +65 -2
- package/src/cli/commands/develop.js +67 -22
- package/src/cli/commands/install.js +99 -44
- package/src/cli/commands/update.js +52 -17
- package/src/cli/prompt.d.ts +20 -0
- package/src/cli/prompt.js +72 -0
- package/src/config/package-manager.d.ts +2 -2
- package/src/config/package-manager.js +9 -2
- package/.go-watch.json +0 -20
- package/commands/api-generate.d.ts +0 -11
- package/commands/api-generate.js +0 -133
- package/commands/builder.d.ts +0 -7
- package/commands/builder.js +0 -35
- package/commands/cleanup.d.ts +0 -11
- package/commands/cleanup.js +0 -109
- package/commands/dev-go.d.ts +0 -8
- package/commands/dev-go.js +0 -306
- package/commands/develop.d.ts +0 -26
- package/commands/develop.js +0 -143
- package/commands/pack.d.ts +0 -36
- package/commands/pack.js +0 -392
- package/commands/postinstall.d.ts +0 -6
- package/commands/postinstall.js +0 -53
- package/commands/update.d.ts +0 -9
- package/commands/update.js +0 -47
- package/src/cli-options.d.ts +0 -9
- package/src/cli-options.js +0 -58
- package/src/go-gin-server.json +0 -5
- package/src/pack-config.schema.json +0 -62
- package/src/package-manager.d.ts +0 -7
- package/src/package-manager.js +0 -39
- package/src/server-config.json +0 -35
- package/src/terminal-ui.d.ts +0 -7
- package/src/terminal-ui.js +0 -118
- package/src/utils.d.ts +0 -7
- package/src/utils.js +0 -112
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ Updates project dependencies with a conservative default strategy:
|
|
|
167
167
|
|
|
168
168
|
Options:
|
|
169
169
|
|
|
170
|
-
- `--package-manager <auto|bun|pnpm|npm>`: package manager selection, default `auto`
|
|
170
|
+
- `--package-manager <auto|bun|pnpm|yarn|npm|cnpm>`: package manager selection, default `auto`
|
|
171
171
|
- `--latest <true|false>`: whether to use the aggressive update strategy, default `false`
|
|
172
172
|
- `--skip-go`: skip Go dependency updates
|
|
173
173
|
- `--skip-node`: skip Node dependency updates
|
|
@@ -178,6 +178,8 @@ Examples:
|
|
|
178
178
|
nuxt-gin update
|
|
179
179
|
nuxt-gin update --package-manager bun --latest true
|
|
180
180
|
nuxt-gin update --package-manager pnpm --latest false
|
|
181
|
+
nuxt-gin update --package-manager yarn --latest true
|
|
182
|
+
nuxt-gin update --package-manager cnpm --latest false
|
|
181
183
|
```
|
|
182
184
|
|
|
183
185
|
Also prints a styled command banner before execution.
|
|
@@ -495,7 +497,7 @@ src/
|
|
|
495
497
|
|
|
496
498
|
参数:
|
|
497
499
|
|
|
498
|
-
- `--package-manager <auto|bun|pnpm|npm>`:指定包管理器,默认 `auto`
|
|
500
|
+
- `--package-manager <auto|bun|pnpm|yarn|npm|cnpm>`:指定包管理器,默认 `auto`
|
|
499
501
|
- `--latest <true|false>`:是否使用更激进的升级策略,默认 `false`
|
|
500
502
|
- `--skip-go`:跳过 Go 依赖更新
|
|
501
503
|
- `--skip-node`:跳过 Node 依赖更新
|
|
@@ -506,6 +508,8 @@ src/
|
|
|
506
508
|
nuxt-gin update
|
|
507
509
|
nuxt-gin update --package-manager bun --latest true
|
|
508
510
|
nuxt-gin update --package-manager pnpm --latest false
|
|
511
|
+
nuxt-gin update --package-manager yarn --latest true
|
|
512
|
+
nuxt-gin update --package-manager cnpm --latest false
|
|
509
513
|
```
|
|
510
514
|
|
|
511
515
|
执行前也会输出一段样式化 banner。
|
package/index.js
CHANGED
|
@@ -74,7 +74,7 @@ function main() {
|
|
|
74
74
|
const rawPackageManager = (0, options_1.getOption)(options, "package-manager");
|
|
75
75
|
const packageManagerCandidate = rawPackageManager !== null && rawPackageManager !== void 0 ? rawPackageManager : "auto";
|
|
76
76
|
if (!(0, package_manager_1.isPackageManagerSelection)(packageManagerCandidate)) {
|
|
77
|
-
throw new Error(`Invalid value for --package-manager: ${packageManagerCandidate}. Expected one of: auto, bun, pnpm, npm`);
|
|
77
|
+
throw new Error(`Invalid value for --package-manager: ${packageManagerCandidate}. Expected one of: auto, bun, pnpm, yarn, npm, cnpm`);
|
|
78
78
|
}
|
|
79
79
|
const packageManagerOption = packageManagerCandidate;
|
|
80
80
|
switch (command) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-gin-tools",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "This project is used as a dependency for [nuxt-gin-starter](https://github.com/RapboyGao/nuxt-gin-starter.git)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nuxt-gin": "index.js"
|
|
@@ -8,24 +8,14 @@
|
|
|
8
8
|
"keywords": [],
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "ts-node scripts/build-package.ts",
|
|
13
|
-
"publish": "npm publish --access public"
|
|
14
|
-
},
|
|
15
11
|
"dependencies": {
|
|
16
12
|
"7zip-min": "^3.0.1",
|
|
13
|
+
"@inquirer/prompts": "^8.3.2",
|
|
17
14
|
"chalk": "^5.6.2",
|
|
18
15
|
"chokidar": "^5.0.0",
|
|
19
16
|
"concurrently": "^9.2.1",
|
|
20
17
|
"fast-glob": "^3.3.3",
|
|
21
18
|
"fs-extra": "^11.3.4",
|
|
22
19
|
"jiti": "^2.6.1"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/fs-extra": "^11.0.4",
|
|
26
|
-
"@types/node": "^25.5.0",
|
|
27
|
-
"nuxt": "^4.4.2",
|
|
28
|
-
"ts-node": "^10.9.2",
|
|
29
|
-
"typescript": "^5.9.3"
|
|
30
20
|
}
|
|
31
21
|
}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PackConfig } from "../../pack";
|
|
2
|
+
export { BUILD_EXECUTABLE, FILES_TO_COPY, LEGACY_PACK_CONFIG_CJS_PATH, LEGACY_PACK_CONFIG_JS_PATH, LEGACY_PACK_CONFIG_MJS_PATH, LEGACY_PACK_CONFIG_PATH, LEGACY_PACK_CONFIG_TS_PATH, ORIGINAL_DIST_PATH, PACKAGE_JSON_CONTENT, SERVER_EXECUTABLE, SERVER_PATH, ZIP_PATH, builtPath, } from "../../services/pack-service";
|
|
3
|
+
export declare function buildAndPack(config?: PackConfig): Promise<void>;
|
|
4
|
+
export default buildAndPack;
|
|
@@ -1,22 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
4
10
|
};
|
|
5
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
Object.defineProperty(exports, "
|
|
12
|
+
exports.builtPath = exports.ZIP_PATH = exports.SERVER_PATH = exports.SERVER_EXECUTABLE = exports.PACKAGE_JSON_CONTENT = exports.ORIGINAL_DIST_PATH = exports.LEGACY_PACK_CONFIG_TS_PATH = exports.LEGACY_PACK_CONFIG_PATH = exports.LEGACY_PACK_CONFIG_MJS_PATH = exports.LEGACY_PACK_CONFIG_JS_PATH = exports.LEGACY_PACK_CONFIG_CJS_PATH = exports.FILES_TO_COPY = exports.BUILD_EXECUTABLE = void 0;
|
|
13
|
+
exports.buildAndPack = buildAndPack;
|
|
14
|
+
const nuxt_gin_1 = require("../../nuxt-gin");
|
|
15
|
+
const prompt_1 = require("../prompt");
|
|
16
|
+
const pack_service_1 = require("../../services/pack-service");
|
|
17
|
+
var pack_service_2 = require("../../services/pack-service");
|
|
18
|
+
Object.defineProperty(exports, "BUILD_EXECUTABLE", { enumerable: true, get: function () { return pack_service_2.BUILD_EXECUTABLE; } });
|
|
19
|
+
Object.defineProperty(exports, "FILES_TO_COPY", { enumerable: true, get: function () { return pack_service_2.FILES_TO_COPY; } });
|
|
20
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_CJS_PATH", { enumerable: true, get: function () { return pack_service_2.LEGACY_PACK_CONFIG_CJS_PATH; } });
|
|
21
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_JS_PATH", { enumerable: true, get: function () { return pack_service_2.LEGACY_PACK_CONFIG_JS_PATH; } });
|
|
22
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_MJS_PATH", { enumerable: true, get: function () { return pack_service_2.LEGACY_PACK_CONFIG_MJS_PATH; } });
|
|
23
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_PATH", { enumerable: true, get: function () { return pack_service_2.LEGACY_PACK_CONFIG_PATH; } });
|
|
24
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_TS_PATH", { enumerable: true, get: function () { return pack_service_2.LEGACY_PACK_CONFIG_TS_PATH; } });
|
|
25
|
+
Object.defineProperty(exports, "ORIGINAL_DIST_PATH", { enumerable: true, get: function () { return pack_service_2.ORIGINAL_DIST_PATH; } });
|
|
26
|
+
Object.defineProperty(exports, "PACKAGE_JSON_CONTENT", { enumerable: true, get: function () { return pack_service_2.PACKAGE_JSON_CONTENT; } });
|
|
27
|
+
Object.defineProperty(exports, "SERVER_EXECUTABLE", { enumerable: true, get: function () { return pack_service_2.SERVER_EXECUTABLE; } });
|
|
28
|
+
Object.defineProperty(exports, "SERVER_PATH", { enumerable: true, get: function () { return pack_service_2.SERVER_PATH; } });
|
|
29
|
+
Object.defineProperty(exports, "ZIP_PATH", { enumerable: true, get: function () { return pack_service_2.ZIP_PATH; } });
|
|
30
|
+
Object.defineProperty(exports, "builtPath", { enumerable: true, get: function () { return pack_service_2.builtPath; } });
|
|
31
|
+
function hasExplicitBuildOptions(config) {
|
|
32
|
+
return Boolean((config === null || config === void 0 ? void 0 : config.binaryName) !== undefined ||
|
|
33
|
+
(config === null || config === void 0 ? void 0 : config.skipGo) !== undefined ||
|
|
34
|
+
(config === null || config === void 0 ? void 0 : config.skipNuxt) !== undefined ||
|
|
35
|
+
(config === null || config === void 0 ? void 0 : config.skipBuild) !== undefined ||
|
|
36
|
+
(config === null || config === void 0 ? void 0 : config.skipZip) !== undefined);
|
|
37
|
+
}
|
|
38
|
+
function promptForBuildConfig() {
|
|
39
|
+
return __awaiter(this, arguments, void 0, function* (baseConfig = {}) {
|
|
40
|
+
var _a, _b, _c, _d, _e;
|
|
41
|
+
const configuredOptions = (_a = (0, nuxt_gin_1.resolveNuxtGinProjectConfig)().config.pack) !== null && _a !== void 0 ? _a : {};
|
|
42
|
+
const resolvedFromPrompt = Object.assign({}, baseConfig);
|
|
43
|
+
const effectiveSkipBuild = (_b = baseConfig.skipBuild) !== null && _b !== void 0 ? _b : configuredOptions.skipBuild;
|
|
44
|
+
const effectiveSkipZip = (_c = baseConfig.skipZip) !== null && _c !== void 0 ? _c : configuredOptions.skipZip;
|
|
45
|
+
if (effectiveSkipBuild === undefined || effectiveSkipZip === undefined) {
|
|
46
|
+
const mode = yield (0, prompt_1.selectWithDefault)({
|
|
47
|
+
label: "build",
|
|
48
|
+
message: "Choose build workflow",
|
|
49
|
+
defaultValue: "full",
|
|
50
|
+
nonInteractiveMessage: "Non-interactive terminal detected, using default build workflow: full",
|
|
51
|
+
options: [
|
|
52
|
+
{
|
|
53
|
+
label: "Full build + pack",
|
|
54
|
+
value: "full",
|
|
55
|
+
hint: "Build Go and Nuxt, assemble bundle, then create 7z archive",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "Build only",
|
|
59
|
+
value: "build-only",
|
|
60
|
+
hint: "Build artifacts and assemble bundle, but skip 7z archive",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: "Pack existing build",
|
|
64
|
+
value: "pack-only",
|
|
65
|
+
hint: "Reuse existing artifacts and only assemble bundle + 7z archive",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: "Bundle only",
|
|
69
|
+
value: "bundle-only",
|
|
70
|
+
hint: "Reuse existing artifacts and only assemble bundle directory",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
if (effectiveSkipBuild === undefined) {
|
|
75
|
+
resolvedFromPrompt.skipBuild = mode === "pack-only" || mode === "bundle-only";
|
|
76
|
+
}
|
|
77
|
+
if (effectiveSkipZip === undefined) {
|
|
78
|
+
resolvedFromPrompt.skipZip = mode === "build-only" || mode === "bundle-only";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const finalSkipBuild = (_e = (_d = resolvedFromPrompt.skipBuild) !== null && _d !== void 0 ? _d : effectiveSkipBuild) !== null && _e !== void 0 ? _e : false;
|
|
82
|
+
if (!finalSkipBuild && baseConfig.skipGo === undefined && configuredOptions.skipGo === undefined) {
|
|
83
|
+
resolvedFromPrompt.skipGo = !(yield (0, prompt_1.confirmWithDefault)({
|
|
84
|
+
label: "build",
|
|
85
|
+
message: "Include Go build step?",
|
|
86
|
+
defaultValue: true,
|
|
87
|
+
nonInteractiveMessage: "Non-interactive terminal detected, including Go build step by default",
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
if (!finalSkipBuild && baseConfig.skipNuxt === undefined && configuredOptions.skipNuxt === undefined) {
|
|
91
|
+
resolvedFromPrompt.skipNuxt = !(yield (0, prompt_1.confirmWithDefault)({
|
|
92
|
+
label: "build",
|
|
93
|
+
message: "Include Nuxt build step?",
|
|
94
|
+
defaultValue: true,
|
|
95
|
+
nonInteractiveMessage: "Non-interactive terminal detected, including Nuxt build step by default",
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
if (baseConfig.writeScripts === undefined && configuredOptions.writeScripts === undefined) {
|
|
99
|
+
resolvedFromPrompt.writeScripts = yield (0, prompt_1.confirmWithDefault)({
|
|
100
|
+
label: "build",
|
|
101
|
+
message: "Generate startup scripts in bundle output?",
|
|
102
|
+
defaultValue: true,
|
|
103
|
+
nonInteractiveMessage: "Non-interactive terminal detected, generating startup scripts by default",
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return resolvedFromPrompt;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function buildAndPack(config) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const resolvedConfig = hasExplicitBuildOptions(config)
|
|
112
|
+
? config
|
|
113
|
+
: yield promptForBuildConfig(config);
|
|
114
|
+
return (0, pack_service_1.buildAndPack)(resolvedConfig);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.default = buildAndPack;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type CleanupOptions = {
|
|
2
2
|
dryRun?: boolean;
|
|
3
|
+
skipNuxtCleanup?: boolean;
|
|
4
|
+
cleanupPaths?: string[];
|
|
3
5
|
};
|
|
4
6
|
export declare function ifExistsRemove(relativePath: string, options?: CleanupOptions, actions?: string[]): void;
|
|
5
7
|
export declare function cleanUpNuxt(options?: CleanupOptions, actions?: string[]): Promise<void> | Promise<import("concurrently").CloseEvent[]>;
|
|
@@ -53,6 +53,7 @@ const FS = __importStar(require("fs-extra"));
|
|
|
53
53
|
const Path = __importStar(require("path"));
|
|
54
54
|
const concurrently_1 = __importDefault(require("concurrently"));
|
|
55
55
|
const nuxt_gin_1 = require("../../nuxt-gin");
|
|
56
|
+
const prompt_1 = require("../prompt");
|
|
56
57
|
const terminal_ui_1 = require("../terminal-ui");
|
|
57
58
|
const cwd = process.cwd();
|
|
58
59
|
const CLEANUP_PATHS = [
|
|
@@ -63,6 +64,59 @@ const CLEANUP_PATHS = [
|
|
|
63
64
|
"vue/.output",
|
|
64
65
|
".openapi-generator",
|
|
65
66
|
];
|
|
67
|
+
function hasExplicitCleanupOptions(options) {
|
|
68
|
+
return Boolean((options === null || options === void 0 ? void 0 : options.cleanupPaths) !== undefined || (options === null || options === void 0 ? void 0 : options.skipNuxtCleanup) !== undefined);
|
|
69
|
+
}
|
|
70
|
+
function resolveCleanupOptions() {
|
|
71
|
+
return __awaiter(this, arguments, void 0, function* (options = {}, configuredOptions = {}) {
|
|
72
|
+
if (hasExplicitCleanupOptions(options)) {
|
|
73
|
+
return options;
|
|
74
|
+
}
|
|
75
|
+
if (configuredOptions.cleanupPaths !== undefined ||
|
|
76
|
+
configuredOptions.skipNuxtCleanup !== undefined) {
|
|
77
|
+
return options;
|
|
78
|
+
}
|
|
79
|
+
const mode = yield (0, prompt_1.selectWithDefault)({
|
|
80
|
+
label: "cleanup",
|
|
81
|
+
message: "Choose cleanup workflow",
|
|
82
|
+
defaultValue: "full",
|
|
83
|
+
nonInteractiveMessage: "Non-interactive terminal detected, using default cleanup workflow: full",
|
|
84
|
+
options: [
|
|
85
|
+
{
|
|
86
|
+
label: "Full cleanup",
|
|
87
|
+
value: "full",
|
|
88
|
+
hint: "Run nuxt cleanup and remove generated build output",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: "Nuxt only",
|
|
92
|
+
value: "nuxt-only",
|
|
93
|
+
hint: "Only run nuxt cleanup",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: "Build output only",
|
|
97
|
+
value: "build-only",
|
|
98
|
+
hint: "Only remove generated directories without running nuxt cleanup",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
if (mode === "nuxt-only") {
|
|
103
|
+
return {
|
|
104
|
+
skipNuxtCleanup: false,
|
|
105
|
+
cleanupPaths: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (mode === "build-only") {
|
|
109
|
+
return {
|
|
110
|
+
skipNuxtCleanup: true,
|
|
111
|
+
cleanupPaths: [...CLEANUP_PATHS],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
skipNuxtCleanup: false,
|
|
116
|
+
cleanupPaths: [...CLEANUP_PATHS],
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
66
120
|
function ifExistsRemove(relativePath, options = {}, actions = []) {
|
|
67
121
|
const absolutePath = Path.resolve(cwd, relativePath);
|
|
68
122
|
if (FS.existsSync(absolutePath)) {
|
|
@@ -76,6 +130,10 @@ function ifExistsRemove(relativePath, options = {}, actions = []) {
|
|
|
76
130
|
}
|
|
77
131
|
}
|
|
78
132
|
function cleanUpNuxt(options = {}, actions = []) {
|
|
133
|
+
if (options.skipNuxtCleanup) {
|
|
134
|
+
actions.push("skipped nuxt cleanup");
|
|
135
|
+
return Promise.resolve();
|
|
136
|
+
}
|
|
79
137
|
if (options.dryRun) {
|
|
80
138
|
(0, terminal_ui_1.printCommandInfo)("cleanup", "would run `npx nuxt cleanup`");
|
|
81
139
|
actions.push("would run nuxt cleanup");
|
|
@@ -89,7 +147,9 @@ function cleanUpNuxt(options = {}, actions = []) {
|
|
|
89
147
|
]).result;
|
|
90
148
|
}
|
|
91
149
|
function cleanUpBuild(options = {}, actions = []) {
|
|
92
|
-
|
|
150
|
+
var _a;
|
|
151
|
+
const cleanupTargets = (_a = options.cleanupPaths) !== null && _a !== void 0 ? _a : [...CLEANUP_PATHS];
|
|
152
|
+
for (const path of cleanupTargets) {
|
|
93
153
|
ifExistsRemove(path, options, actions);
|
|
94
154
|
}
|
|
95
155
|
}
|
|
@@ -98,12 +158,15 @@ function cleanUpBuild(options = {}, actions = []) {
|
|
|
98
158
|
*/
|
|
99
159
|
function cleanUp() {
|
|
100
160
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
161
|
+
var _a;
|
|
101
162
|
(0, terminal_ui_1.printCommandBanner)("cleanup", "Remove generated build output and temporary files");
|
|
102
163
|
const projectConfig = (0, nuxt_gin_1.resolveNuxtGinProjectConfig)();
|
|
103
164
|
for (const warning of projectConfig.warnings) {
|
|
104
165
|
(0, terminal_ui_1.printCommandWarn)(`[config] ${warning}`);
|
|
105
166
|
}
|
|
106
|
-
const
|
|
167
|
+
const configuredOptions = (_a = projectConfig.config.cleanup) !== null && _a !== void 0 ? _a : {};
|
|
168
|
+
const promptedOptions = yield resolveCleanupOptions(options, configuredOptions);
|
|
169
|
+
const resolvedOptions = (0, nuxt_gin_1.mergeDefined)(configuredOptions, promptedOptions);
|
|
107
170
|
const actions = [];
|
|
108
171
|
const result = cleanUpNuxt(resolvedOptions, actions);
|
|
109
172
|
cleanUpBuild(resolvedOptions, actions);
|
|
@@ -23,27 +23,72 @@ const install_1 = __importDefault(require("./install"));
|
|
|
23
23
|
const go_dev_service_1 = require("../../services/go-dev-service");
|
|
24
24
|
const nuxt_gin_1 = require("../../nuxt-gin");
|
|
25
25
|
const ports_1 = require("../../system/ports");
|
|
26
|
+
const prompt_1 = require("../prompt");
|
|
26
27
|
const terminal_ui_1 = require("../terminal-ui");
|
|
27
28
|
const cwd = process.cwd();
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
function hasExplicitDevelopModeOptions(options) {
|
|
30
|
+
return Boolean((options === null || options === void 0 ? void 0 : options.skipGo) !== undefined || (options === null || options === void 0 ? void 0 : options.skipNuxt) !== undefined);
|
|
31
|
+
}
|
|
32
|
+
function resolveDevelopOptions() {
|
|
33
|
+
return __awaiter(this, arguments, void 0, function* (options = {}, configuredOptions = {}) {
|
|
34
|
+
if (hasExplicitDevelopModeOptions(options)) {
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
if (configuredOptions.skipGo !== undefined || configuredOptions.skipNuxt !== undefined) {
|
|
38
|
+
return options;
|
|
39
|
+
}
|
|
40
|
+
const mode = yield (0, prompt_1.selectWithDefault)({
|
|
41
|
+
label: "dev",
|
|
42
|
+
message: "Choose development workflow",
|
|
43
|
+
defaultValue: "full",
|
|
44
|
+
nonInteractiveMessage: "Non-interactive terminal detected, using default development workflow: full",
|
|
45
|
+
options: [
|
|
46
|
+
{
|
|
47
|
+
label: "Nuxt + Go",
|
|
48
|
+
value: "full",
|
|
49
|
+
hint: "Start both the Nuxt dev server and Go watcher",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "Nuxt only",
|
|
53
|
+
value: "nuxt-only",
|
|
54
|
+
hint: "Only start the Nuxt dev server",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "Go only",
|
|
58
|
+
value: "go-only",
|
|
59
|
+
hint: "Only start the Go watcher",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
skipGo: mode === "nuxt-only",
|
|
65
|
+
skipNuxt: mode === "go-only",
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function resolveDevelopContext() {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
71
|
+
var _a, _b, _c, _d, _e;
|
|
72
|
+
const projectConfig = (0, nuxt_gin_1.resolveNuxtGinProjectConfig)();
|
|
73
|
+
for (const warning of projectConfig.warnings) {
|
|
74
|
+
(0, terminal_ui_1.printCommandWarn)(`[config] ${warning}`);
|
|
75
|
+
}
|
|
76
|
+
const serverConfig = (0, nuxt_gin_1.readLegacyServerConfig)();
|
|
77
|
+
if (!serverConfig) {
|
|
78
|
+
throw new Error("server.config.json is required in project root for ginPort, nuxtPort, and baseUrl.");
|
|
79
|
+
}
|
|
80
|
+
const configuredOptions = (_a = projectConfig.config.dev) !== null && _a !== void 0 ? _a : {};
|
|
81
|
+
const promptedOptions = yield resolveDevelopOptions(options, configuredOptions);
|
|
82
|
+
const resolvedOptions = (0, nuxt_gin_1.mergeDefined)(configuredOptions, promptedOptions);
|
|
83
|
+
const cleanupBeforeDevelop = (_c = (_b = projectConfig.config.dev) === null || _b === void 0 ? void 0 : _b.cleanupBeforeDevelop) !== null && _c !== void 0 ? _c : false;
|
|
84
|
+
const killPortBeforeDevelop = (_e = (_d = projectConfig.config.dev) === null || _d === void 0 ? void 0 : _d.killPortBeforeDevelop) !== null && _e !== void 0 ? _e : true;
|
|
85
|
+
return {
|
|
86
|
+
options: resolvedOptions,
|
|
87
|
+
serverConfig,
|
|
88
|
+
cleanupBeforeDevelop,
|
|
89
|
+
killPortBeforeDevelop,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
47
92
|
}
|
|
48
93
|
function prepareDevelop(context) {
|
|
49
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -95,7 +140,7 @@ function runGoDev(serverConfig) {
|
|
|
95
140
|
function develop() {
|
|
96
141
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
97
142
|
(0, terminal_ui_1.printCommandBanner)("dev", "Start Nuxt and Go development workflows");
|
|
98
|
-
const context = resolveDevelopContext(options);
|
|
143
|
+
const context = yield resolveDevelopContext(options);
|
|
99
144
|
const actions = [];
|
|
100
145
|
yield prepareDevelop(context);
|
|
101
146
|
// 在开发前确保占用端口被释放
|
|
@@ -133,7 +178,7 @@ function develop() {
|
|
|
133
178
|
function developNuxt() {
|
|
134
179
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
135
180
|
(0, terminal_ui_1.printCommandBanner)("dev:nuxt", "Start Nuxt development server only");
|
|
136
|
-
const context = resolveDevelopContext(options);
|
|
181
|
+
const context = yield resolveDevelopContext(Object.assign(Object.assign({}, options), { skipGo: true }));
|
|
137
182
|
const actions = [];
|
|
138
183
|
yield prepareDevelop(Object.assign(Object.assign({}, context), { options: Object.assign(Object.assign({}, context.options), { skipGo: true }) }));
|
|
139
184
|
if (context.killPortBeforeDevelop) {
|
|
@@ -153,7 +198,7 @@ function developNuxt() {
|
|
|
153
198
|
function developGo() {
|
|
154
199
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
155
200
|
(0, terminal_ui_1.printCommandBanner)("dev:go", "Start Go watcher only");
|
|
156
|
-
const context = resolveDevelopContext(options);
|
|
201
|
+
const context = yield resolveDevelopContext(Object.assign(Object.assign({}, options), { skipNuxt: true }));
|
|
157
202
|
const actions = [];
|
|
158
203
|
yield prepareDevelop(Object.assign(Object.assign({}, context), { options: Object.assign(Object.assign({}, context.options), { skipNuxt: true }) }));
|
|
159
204
|
if (context.killPortBeforeDevelop) {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -7,53 +16,99 @@ exports.postInstall = postInstall;
|
|
|
7
16
|
const concurrently_1 = __importDefault(require("concurrently"));
|
|
8
17
|
const node_child_process_1 = require("node:child_process");
|
|
9
18
|
const nuxt_gin_1 = require("../../nuxt-gin");
|
|
19
|
+
const prompt_1 = require("../prompt");
|
|
10
20
|
const terminal_ui_1 = require("../terminal-ui");
|
|
11
|
-
function
|
|
12
|
-
(0
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
function hasExplicitInstallOptions(options) {
|
|
22
|
+
return Boolean((options === null || options === void 0 ? void 0 : options.skipGo) !== undefined || (options === null || options === void 0 ? void 0 : options.skipNuxt) !== undefined);
|
|
23
|
+
}
|
|
24
|
+
function resolveInstallOptions() {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* (options = {}, configuredOptions = {}) {
|
|
26
|
+
if (hasExplicitInstallOptions(options)) {
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
if (configuredOptions.skipGo !== undefined || configuredOptions.skipNuxt !== undefined) {
|
|
30
|
+
return options;
|
|
31
|
+
}
|
|
32
|
+
const mode = yield (0, prompt_1.selectWithDefault)({
|
|
33
|
+
label: "install",
|
|
34
|
+
message: "Choose install workflow",
|
|
35
|
+
defaultValue: "full",
|
|
36
|
+
nonInteractiveMessage: "Non-interactive terminal detected, using default install workflow: full",
|
|
37
|
+
options: [
|
|
38
|
+
{
|
|
39
|
+
label: "Nuxt + Go",
|
|
40
|
+
value: "full",
|
|
41
|
+
hint: "Prepare Nuxt runtime and download Go modules",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "Nuxt only",
|
|
45
|
+
value: "nuxt-only",
|
|
46
|
+
hint: "Only run Nuxt prepare",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: "Go only",
|
|
50
|
+
value: "go-only",
|
|
51
|
+
hint: "Only download and tidy Go modules",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
28
54
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
return {
|
|
56
|
+
skipGo: mode === "nuxt-only",
|
|
57
|
+
skipNuxt: mode === "go-only",
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function postInstall() {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
63
|
+
var _a;
|
|
64
|
+
(0, terminal_ui_1.printCommandBanner)("install", "Prepare Nuxt and optional Go dependencies");
|
|
65
|
+
const projectConfig = (0, nuxt_gin_1.resolveNuxtGinProjectConfig)();
|
|
66
|
+
for (const warning of projectConfig.warnings) {
|
|
67
|
+
(0, terminal_ui_1.printCommandWarn)(`[config] ${warning}`);
|
|
68
|
+
}
|
|
69
|
+
const configuredOptions = (_a = projectConfig.config.install) !== null && _a !== void 0 ? _a : {};
|
|
70
|
+
const promptedOptions = yield resolveInstallOptions(options, configuredOptions);
|
|
71
|
+
const resolvedOptions = (0, nuxt_gin_1.mergeDefined)(configuredOptions, promptedOptions);
|
|
72
|
+
const actions = [];
|
|
73
|
+
const commands = [];
|
|
74
|
+
const hasGo = (0, node_child_process_1.spawnSync)("go", ["version"], { stdio: "ignore", shell: true }).status ===
|
|
75
|
+
0;
|
|
76
|
+
if (!resolvedOptions.skipNuxt) {
|
|
77
|
+
actions.push("prepared Nuxt runtime");
|
|
78
|
+
commands.push({
|
|
79
|
+
command: "npx nuxt prepare",
|
|
80
|
+
name: "nuxt",
|
|
81
|
+
prefixColor: "blue",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (!resolvedOptions.skipGo && hasGo) {
|
|
85
|
+
actions.push("downloaded and tidied Go modules");
|
|
86
|
+
commands.push({
|
|
87
|
+
command: "go mod download && go mod tidy",
|
|
88
|
+
name: "go",
|
|
89
|
+
prefixColor: "green",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (!resolvedOptions.skipGo) {
|
|
93
|
+
(0, terminal_ui_1.printCommandWarn)("Go was not detected, skipping Go dependency bootstrap");
|
|
94
|
+
actions.push("skipped Go bootstrap because Go was not detected");
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
actions.push("skipped Go bootstrap by option");
|
|
98
|
+
}
|
|
99
|
+
if (resolvedOptions.skipNuxt) {
|
|
100
|
+
actions.push("skipped Nuxt prepare by option");
|
|
101
|
+
}
|
|
102
|
+
if (commands.length === 0) {
|
|
103
|
+
(0, terminal_ui_1.printCommandWarn)("Nothing selected for install, skipping bootstrap");
|
|
104
|
+
(0, terminal_ui_1.printCommandSummary)("install", actions.length > 0 ? actions : ["nothing was executed"]);
|
|
105
|
+
return Promise.resolve();
|
|
106
|
+
}
|
|
107
|
+
// 执行并发命令
|
|
108
|
+
return (0, concurrently_1.default)(commands).result.then(() => {
|
|
109
|
+
(0, terminal_ui_1.printCommandSuccess)("install", "Project bootstrap completed");
|
|
110
|
+
(0, terminal_ui_1.printCommandSummary)("install", actions);
|
|
36
111
|
});
|
|
37
|
-
}
|
|
38
|
-
else if (!resolvedOptions.skipGo) {
|
|
39
|
-
(0, terminal_ui_1.printCommandWarn)("Go was not detected, skipping Go dependency bootstrap");
|
|
40
|
-
actions.push("skipped Go bootstrap because Go was not detected");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
actions.push("skipped Go bootstrap by option");
|
|
44
|
-
}
|
|
45
|
-
if (resolvedOptions.skipNuxt) {
|
|
46
|
-
actions.push("skipped Nuxt prepare by option");
|
|
47
|
-
}
|
|
48
|
-
if (commands.length === 0) {
|
|
49
|
-
(0, terminal_ui_1.printCommandWarn)("Nothing selected for install, skipping bootstrap");
|
|
50
|
-
(0, terminal_ui_1.printCommandSummary)("install", actions.length > 0 ? actions : ["nothing was executed"]);
|
|
51
|
-
return Promise.resolve();
|
|
52
|
-
}
|
|
53
|
-
// 执行并发命令
|
|
54
|
-
return (0, concurrently_1.default)(commands).result.then(() => {
|
|
55
|
-
(0, terminal_ui_1.printCommandSuccess)("install", "Project bootstrap completed");
|
|
56
|
-
(0, terminal_ui_1.printCommandSummary)("install", actions);
|
|
57
112
|
});
|
|
58
113
|
}
|
|
59
114
|
exports.default = postInstall;
|