nuxt-gin-tools 0.2.23 → 0.3.1
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 +194 -72
- package/index.js +28 -28
- package/package.json +2 -2
- package/src/assets/go-gin-server.json +5 -0
- package/src/assets/pack-config.schema.json +62 -0
- package/src/assets/server-config.schema.json +35 -0
- package/src/cli/commands/build.d.ts +1 -0
- package/src/cli/commands/build.js +22 -0
- package/src/cli/commands/cleanup.d.ts +11 -0
- package/src/cli/commands/cleanup.js +115 -0
- package/src/cli/commands/develop.d.ts +26 -0
- package/src/cli/commands/develop.js +168 -0
- package/src/cli/commands/install.d.ts +6 -0
- package/src/cli/commands/install.js +59 -0
- package/src/cli/commands/update.d.ts +9 -0
- package/src/cli/commands/update.js +89 -0
- package/src/cli/options.d.ts +10 -0
- package/src/cli/options.js +66 -0
- package/src/cli/terminal-ui.d.ts +7 -0
- package/src/cli/terminal-ui.js +191 -0
- package/src/config/package-manager.d.ts +7 -0
- package/src/config/package-manager.js +39 -0
- package/src/nuxt-gin.d.ts +103 -0
- package/src/nuxt-gin.js +178 -0
- package/src/pack.d.ts +1 -1
- package/src/services/build-service.d.ts +7 -0
- package/src/services/build-service.js +35 -0
- package/src/services/go-dev-service.d.ts +8 -0
- package/src/services/go-dev-service.js +356 -0
- package/src/services/pack-service.d.ts +23 -0
- package/src/services/pack-service.js +372 -0
- package/src/system/ports.d.ts +7 -0
- package/src/system/ports.js +112 -0
|
@@ -0,0 +1,356 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.startGoDev = startGoDev;
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
18
|
+
const fs_extra_1 = require("fs-extra");
|
|
19
|
+
const path_1 = require("path");
|
|
20
|
+
const nuxt_gin_1 = require("../nuxt-gin");
|
|
21
|
+
const ports_1 = require("../system/ports");
|
|
22
|
+
const terminal_ui_1 = require("../cli/terminal-ui");
|
|
23
|
+
const cwd = process.cwd();
|
|
24
|
+
const RESTART_DEBOUNCE_MS = 150;
|
|
25
|
+
const SHUTDOWN_TIMEOUT_MS = 2000;
|
|
26
|
+
const LOG_TAG = "go-watch";
|
|
27
|
+
const GO_WATCH_PREFIX = `[${LOG_TAG}]`;
|
|
28
|
+
const DEFAULT_GO_WATCH_CONFIG = {
|
|
29
|
+
includeExt: ["go", "tpl", "html"],
|
|
30
|
+
includeDir: [],
|
|
31
|
+
includeFile: [],
|
|
32
|
+
excludeDir: [
|
|
33
|
+
"assets",
|
|
34
|
+
".build/.server",
|
|
35
|
+
"vendor",
|
|
36
|
+
"testdata",
|
|
37
|
+
"node_modules",
|
|
38
|
+
"vue",
|
|
39
|
+
"api",
|
|
40
|
+
".vscode",
|
|
41
|
+
".git",
|
|
42
|
+
],
|
|
43
|
+
excludeFile: [],
|
|
44
|
+
excludeRegex: ["_test.go"],
|
|
45
|
+
tmpDir: ".build/.server",
|
|
46
|
+
testDataDir: "testdata",
|
|
47
|
+
};
|
|
48
|
+
function toDefaultGoWatchOptions() {
|
|
49
|
+
return {
|
|
50
|
+
include: {
|
|
51
|
+
ext: [...DEFAULT_GO_WATCH_CONFIG.includeExt],
|
|
52
|
+
dir: [...DEFAULT_GO_WATCH_CONFIG.includeDir],
|
|
53
|
+
file: [...DEFAULT_GO_WATCH_CONFIG.includeFile],
|
|
54
|
+
},
|
|
55
|
+
exclude: {
|
|
56
|
+
dir: [...DEFAULT_GO_WATCH_CONFIG.excludeDir],
|
|
57
|
+
file: [...DEFAULT_GO_WATCH_CONFIG.excludeFile],
|
|
58
|
+
regex: [...DEFAULT_GO_WATCH_CONFIG.excludeRegex],
|
|
59
|
+
},
|
|
60
|
+
tmpDir: DEFAULT_GO_WATCH_CONFIG.tmpDir,
|
|
61
|
+
testDataDir: DEFAULT_GO_WATCH_CONFIG.testDataDir,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function normalizeConfiguredGoWatchOptions(config) {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
66
|
+
const include = config === null || config === void 0 ? void 0 : config.include;
|
|
67
|
+
const exclude = config === null || config === void 0 ? void 0 : config.exclude;
|
|
68
|
+
return {
|
|
69
|
+
includeExt: (_b = (_a = include === null || include === void 0 ? void 0 : include.ext) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.includeExt) !== null && _b !== void 0 ? _b : [],
|
|
70
|
+
includeDir: (_d = (_c = include === null || include === void 0 ? void 0 : include.dir) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config.includeDir) !== null && _d !== void 0 ? _d : [],
|
|
71
|
+
includeFile: (_f = (_e = include === null || include === void 0 ? void 0 : include.file) !== null && _e !== void 0 ? _e : config === null || config === void 0 ? void 0 : config.includeFile) !== null && _f !== void 0 ? _f : [],
|
|
72
|
+
excludeDir: (_h = (_g = exclude === null || exclude === void 0 ? void 0 : exclude.dir) !== null && _g !== void 0 ? _g : config === null || config === void 0 ? void 0 : config.excludeDir) !== null && _h !== void 0 ? _h : [],
|
|
73
|
+
excludeFile: (_k = (_j = exclude === null || exclude === void 0 ? void 0 : exclude.file) !== null && _j !== void 0 ? _j : config === null || config === void 0 ? void 0 : config.excludeFile) !== null && _k !== void 0 ? _k : [],
|
|
74
|
+
excludeRegex: (_m = (_l = exclude === null || exclude === void 0 ? void 0 : exclude.regex) !== null && _l !== void 0 ? _l : config === null || config === void 0 ? void 0 : config.excludeRegex) !== null && _m !== void 0 ? _m : [],
|
|
75
|
+
tmpDir: (_o = config === null || config === void 0 ? void 0 : config.tmpDir) !== null && _o !== void 0 ? _o : DEFAULT_GO_WATCH_CONFIG.tmpDir,
|
|
76
|
+
testDataDir: (_p = config === null || config === void 0 ? void 0 : config.testDataDir) !== null && _p !== void 0 ? _p : DEFAULT_GO_WATCH_CONFIG.testDataDir,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function getGinPort() {
|
|
80
|
+
var _a;
|
|
81
|
+
const ginPort = (_a = (0, nuxt_gin_1.readLegacyServerConfig)()) === null || _a === void 0 ? void 0 : _a.ginPort;
|
|
82
|
+
if (Number.isInteger(ginPort) && ginPort > 0) {
|
|
83
|
+
return ginPort;
|
|
84
|
+
}
|
|
85
|
+
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(cwd, "server.config.json"))) {
|
|
86
|
+
(0, terminal_ui_1.printCommandWarn)("[config] server.config.json not found; Go watcher will start without port cleanup");
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function killGinPortIfNeeded(ginPort) {
|
|
91
|
+
if (!ginPort) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
(0, ports_1.killPort)(ginPort, { logPrefix: LOG_TAG, portLabel: "ginPort" });
|
|
95
|
+
}
|
|
96
|
+
function normalizePath(filePath) {
|
|
97
|
+
return filePath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
98
|
+
}
|
|
99
|
+
function toProjectRelative(filePath) {
|
|
100
|
+
const abs = (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.resolve)(cwd, filePath);
|
|
101
|
+
return normalizePath((0, path_1.relative)(cwd, abs));
|
|
102
|
+
}
|
|
103
|
+
function toStringArray(value) {
|
|
104
|
+
if (!Array.isArray(value)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return value
|
|
108
|
+
.filter((item) => typeof item === "string")
|
|
109
|
+
.map((item) => item.trim())
|
|
110
|
+
.filter(Boolean);
|
|
111
|
+
}
|
|
112
|
+
function toStringValue(value) {
|
|
113
|
+
if (typeof value !== "string") {
|
|
114
|
+
return "";
|
|
115
|
+
}
|
|
116
|
+
return value.trim();
|
|
117
|
+
}
|
|
118
|
+
function loadWatchConfig() {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
120
|
+
const projectConfig = (0, nuxt_gin_1.resolveNuxtGinProjectConfig)();
|
|
121
|
+
for (const warning of projectConfig.warnings) {
|
|
122
|
+
(0, terminal_ui_1.printCommandWarn)(`[config] ${warning}`);
|
|
123
|
+
}
|
|
124
|
+
const configuredDefaults = (0, nuxt_gin_1.mergeDefined)(toDefaultGoWatchOptions(), projectConfig.config.goWatch);
|
|
125
|
+
const normalizedDefaults = normalizeConfiguredGoWatchOptions(configuredDefaults);
|
|
126
|
+
const defaultConfig = {
|
|
127
|
+
includeExt: new Set(normalizedDefaults.includeExt),
|
|
128
|
+
includeDir: [...normalizedDefaults.includeDir],
|
|
129
|
+
includeFile: new Set(normalizedDefaults.includeFile),
|
|
130
|
+
excludeDir: [...normalizedDefaults.excludeDir],
|
|
131
|
+
excludeFile: new Set(normalizedDefaults.excludeFile),
|
|
132
|
+
excludeRegex: normalizedDefaults.excludeRegex.map((item) => new RegExp(item)),
|
|
133
|
+
tmpDir: normalizedDefaults.tmpDir,
|
|
134
|
+
testDataDir: normalizedDefaults.testDataDir,
|
|
135
|
+
};
|
|
136
|
+
const candidates = [
|
|
137
|
+
process.env.NUXT_GIN_WATCH_CONFIG,
|
|
138
|
+
(0, path_1.join)(cwd, ".go-watch.json"),
|
|
139
|
+
].filter((item) => Boolean(item));
|
|
140
|
+
const configPath = candidates.find((item) => (0, fs_extra_1.existsSync)(item));
|
|
141
|
+
if (!configPath) {
|
|
142
|
+
return defaultConfig;
|
|
143
|
+
}
|
|
144
|
+
let parsedConfig = {};
|
|
145
|
+
try {
|
|
146
|
+
parsedConfig = JSON.parse((0, fs_extra_1.readFileSync)(configPath, "utf-8"));
|
|
147
|
+
}
|
|
148
|
+
catch (_j) {
|
|
149
|
+
(0, terminal_ui_1.printCommandWarn)(`${GO_WATCH_PREFIX} invalid watch config JSON, fallback to defaults: ${configPath}`);
|
|
150
|
+
return defaultConfig;
|
|
151
|
+
}
|
|
152
|
+
const includeExt = toStringArray((_a = parsedConfig.includeExt) !== null && _a !== void 0 ? _a : parsedConfig.include_ext)
|
|
153
|
+
.map((item) => item.replace(/^\./, ""))
|
|
154
|
+
.filter((item) => /^[a-zA-Z0-9]+$/.test(item));
|
|
155
|
+
const includeDir = toStringArray((_b = parsedConfig.includeDir) !== null && _b !== void 0 ? _b : parsedConfig.include_dir)
|
|
156
|
+
.map((item) => normalizePath(item))
|
|
157
|
+
.filter(Boolean);
|
|
158
|
+
const includeFile = toStringArray((_c = parsedConfig.includeFile) !== null && _c !== void 0 ? _c : parsedConfig.include_file)
|
|
159
|
+
.map((item) => normalizePath(item))
|
|
160
|
+
.filter(Boolean);
|
|
161
|
+
const excludeDir = toStringArray((_d = parsedConfig.excludeDir) !== null && _d !== void 0 ? _d : parsedConfig.exclude_dir)
|
|
162
|
+
.map((item) => normalizePath(item))
|
|
163
|
+
.filter(Boolean);
|
|
164
|
+
const excludeFile = toStringArray((_e = parsedConfig.excludeFile) !== null && _e !== void 0 ? _e : parsedConfig.exclude_file)
|
|
165
|
+
.map((item) => normalizePath(item))
|
|
166
|
+
.filter(Boolean);
|
|
167
|
+
const excludeRegex = toStringArray((_f = parsedConfig.excludeRegex) !== null && _f !== void 0 ? _f : parsedConfig.exclude_regex)
|
|
168
|
+
.map((item) => {
|
|
169
|
+
try {
|
|
170
|
+
return new RegExp(item);
|
|
171
|
+
}
|
|
172
|
+
catch (_a) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
.filter((item) => item instanceof RegExp);
|
|
177
|
+
const tmpDir = normalizePath(toStringValue((_g = parsedConfig.tmpDir) !== null && _g !== void 0 ? _g : parsedConfig.tmp_dir) || defaultConfig.tmpDir);
|
|
178
|
+
const testdataDir = normalizePath(toStringValue((_h = parsedConfig.testDataDir) !== null && _h !== void 0 ? _h : parsedConfig.testdata_dir) ||
|
|
179
|
+
defaultConfig.testDataDir);
|
|
180
|
+
return {
|
|
181
|
+
includeExt: new Set(includeExt.length ? includeExt : [...defaultConfig.includeExt]),
|
|
182
|
+
includeDir,
|
|
183
|
+
includeFile: new Set(includeFile),
|
|
184
|
+
excludeDir: [...new Set([...defaultConfig.excludeDir, ...excludeDir, tmpDir, testdataDir])],
|
|
185
|
+
excludeFile: new Set(excludeFile),
|
|
186
|
+
excludeRegex: excludeRegex.length ? excludeRegex : defaultConfig.excludeRegex,
|
|
187
|
+
tmpDir,
|
|
188
|
+
testDataDir: testdataDir,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function pathInDir(relPath, dir) {
|
|
192
|
+
const normalizedDir = normalizePath(dir).replace(/\/+$/, "");
|
|
193
|
+
return relPath === normalizedDir || relPath.startsWith(`${normalizedDir}/`);
|
|
194
|
+
}
|
|
195
|
+
function shouldIgnore(relPath, config) {
|
|
196
|
+
if (!relPath || relPath === ".") {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (config.excludeFile.has(relPath)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (config.excludeDir.some((dir) => pathInDir(relPath, dir))) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return config.excludeRegex.some((reg) => reg.test(relPath));
|
|
206
|
+
}
|
|
207
|
+
function shouldTrigger(relPath, config) {
|
|
208
|
+
if (shouldIgnore(relPath, config)) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
const ext = (0, path_1.extname)(relPath).replace(/^\./, "");
|
|
212
|
+
const inIncludedFile = config.includeFile.has(relPath);
|
|
213
|
+
if (config.includeDir.length > 0) {
|
|
214
|
+
const inIncludedDir = config.includeDir.some((dir) => pathInDir(relPath, dir));
|
|
215
|
+
if (!inIncludedDir && !inIncludedFile) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (inIncludedFile) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (!ext) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
return config.includeExt.has(ext);
|
|
226
|
+
}
|
|
227
|
+
function quote(arg) {
|
|
228
|
+
if (/\s/.test(arg)) {
|
|
229
|
+
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
230
|
+
}
|
|
231
|
+
return arg;
|
|
232
|
+
}
|
|
233
|
+
function runGoProcess(ginPort) {
|
|
234
|
+
const command = `go run ${quote("main.go")}`;
|
|
235
|
+
killGinPortIfNeeded(ginPort);
|
|
236
|
+
(0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `start: ${command}`);
|
|
237
|
+
return (0, child_process_1.spawn)(command, {
|
|
238
|
+
cwd,
|
|
239
|
+
shell: true,
|
|
240
|
+
stdio: "inherit",
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function stopGoProcess(proc) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
if (!proc || proc.killed || proc.exitCode !== null) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
yield new Promise((resolveStop) => {
|
|
249
|
+
let finished = false;
|
|
250
|
+
const done = () => {
|
|
251
|
+
if (finished) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
finished = true;
|
|
255
|
+
resolveStop();
|
|
256
|
+
};
|
|
257
|
+
const timer = setTimeout(() => {
|
|
258
|
+
try {
|
|
259
|
+
proc.kill("SIGKILL");
|
|
260
|
+
}
|
|
261
|
+
catch (_a) {
|
|
262
|
+
// best effort
|
|
263
|
+
}
|
|
264
|
+
done();
|
|
265
|
+
}, SHUTDOWN_TIMEOUT_MS);
|
|
266
|
+
proc.once("exit", () => {
|
|
267
|
+
clearTimeout(timer);
|
|
268
|
+
done();
|
|
269
|
+
});
|
|
270
|
+
try {
|
|
271
|
+
proc.kill("SIGTERM");
|
|
272
|
+
}
|
|
273
|
+
catch (_a) {
|
|
274
|
+
clearTimeout(timer);
|
|
275
|
+
done();
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 启动 Go 开发监听流程:执行 `go run main.go`,并在文件变更后自动重启。
|
|
282
|
+
*
|
|
283
|
+
* 该函数通常由 `develop()` 调用;执行后会持续监听,直到收到退出信号。
|
|
284
|
+
*
|
|
285
|
+
* @returns {Promise<void>} 仅在监听流程被中断并完成清理后返回。
|
|
286
|
+
*/
|
|
287
|
+
function startGoDev(ginPortOverride) {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
289
|
+
const watchConfig = loadWatchConfig();
|
|
290
|
+
const ginPort = ginPortOverride !== null && ginPortOverride !== void 0 ? ginPortOverride : getGinPort();
|
|
291
|
+
const watchRoots = watchConfig.includeDir.length
|
|
292
|
+
? watchConfig.includeDir.map((dir) => (0, path_1.join)(cwd, dir))
|
|
293
|
+
: [cwd];
|
|
294
|
+
(0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `watching: ${watchRoots.map((item) => toProjectRelative(item)).join(", ")}`);
|
|
295
|
+
let restarting = false;
|
|
296
|
+
let goProc = runGoProcess(ginPort);
|
|
297
|
+
let restartTimer = null;
|
|
298
|
+
const watcher = chokidar_1.default.watch(watchRoots, {
|
|
299
|
+
ignoreInitial: true,
|
|
300
|
+
ignored: (pathName) => shouldIgnore(toProjectRelative(pathName), watchConfig),
|
|
301
|
+
awaitWriteFinish: {
|
|
302
|
+
stabilityThreshold: 120,
|
|
303
|
+
pollInterval: 20,
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
const triggerRestart = (eventName, changedPath) => {
|
|
307
|
+
const relPath = toProjectRelative(changedPath);
|
|
308
|
+
if (!shouldTrigger(relPath, watchConfig)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (restartTimer) {
|
|
312
|
+
clearTimeout(restartTimer);
|
|
313
|
+
}
|
|
314
|
+
restartTimer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
if (restarting) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
restarting = true;
|
|
319
|
+
(0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `${eventName}: ${relPath}, restarting...`);
|
|
320
|
+
yield stopGoProcess(goProc);
|
|
321
|
+
goProc = runGoProcess(ginPort);
|
|
322
|
+
restarting = false;
|
|
323
|
+
}), RESTART_DEBOUNCE_MS);
|
|
324
|
+
};
|
|
325
|
+
watcher
|
|
326
|
+
.on("add", (filePath) => triggerRestart("add", filePath))
|
|
327
|
+
.on("change", (filePath) => triggerRestart("change", filePath))
|
|
328
|
+
.on("unlink", (filePath) => triggerRestart("unlink", filePath))
|
|
329
|
+
.on("error", (error) => {
|
|
330
|
+
(0, terminal_ui_1.printCommandError)(`${GO_WATCH_PREFIX} watcher error`, error);
|
|
331
|
+
});
|
|
332
|
+
const shutdown = () => __awaiter(this, void 0, void 0, function* () {
|
|
333
|
+
if (restartTimer) {
|
|
334
|
+
clearTimeout(restartTimer);
|
|
335
|
+
restartTimer = null;
|
|
336
|
+
}
|
|
337
|
+
yield watcher.close();
|
|
338
|
+
yield stopGoProcess(goProc);
|
|
339
|
+
});
|
|
340
|
+
process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
|
|
341
|
+
yield shutdown();
|
|
342
|
+
process.exit(0);
|
|
343
|
+
}));
|
|
344
|
+
process.on("SIGTERM", () => __awaiter(this, void 0, void 0, function* () {
|
|
345
|
+
yield shutdown();
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}));
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (require.main === module) {
|
|
351
|
+
// 兼容直接执行该文件(例如 node src/dev-go.js)。
|
|
352
|
+
startGoDev().catch((error) => {
|
|
353
|
+
(0, terminal_ui_1.printCommandError)(`${GO_WATCH_PREFIX} failed to start`, error);
|
|
354
|
+
process.exit(1);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PackConfig } from "../pack";
|
|
2
|
+
export declare function builtPath(relativePath: string): string;
|
|
3
|
+
export declare const ZIP_PATH: string;
|
|
4
|
+
export declare const SERVER_PATH: string;
|
|
5
|
+
export declare const ORIGINAL_DIST_PATH: string;
|
|
6
|
+
export declare const LEGACY_PACK_CONFIG_PATH: string;
|
|
7
|
+
export declare const LEGACY_PACK_CONFIG_TS_PATH: string;
|
|
8
|
+
export declare const LEGACY_PACK_CONFIG_JS_PATH: string;
|
|
9
|
+
export declare const LEGACY_PACK_CONFIG_CJS_PATH: string;
|
|
10
|
+
export declare const LEGACY_PACK_CONFIG_MJS_PATH: string;
|
|
11
|
+
export declare const BUILD_EXECUTABLE: string;
|
|
12
|
+
export declare const SERVER_EXECUTABLE: string;
|
|
13
|
+
export declare const PACKAGE_JSON_CONTENT: {
|
|
14
|
+
private: boolean;
|
|
15
|
+
scripts: {
|
|
16
|
+
start: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const FILES_TO_COPY: {
|
|
20
|
+
[k: string]: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function buildAndPack(config?: PackConfig): Promise<void>;
|
|
23
|
+
export default buildAndPack;
|