@xfe-repo/bff-app 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7EO6CNQD.mjs +37 -0
- package/dist/chunk-GK3IPRWV.mjs +135 -0
- package/dist/chunk-I32XDVIW.mjs +69 -0
- package/dist/chunk-MP3KTLGW.mjs +68 -0
- package/dist/{chunk-ALFB2RRD.mjs → chunk-NJP3V6ZT.mjs} +10 -5
- package/dist/chunk-NUV437MC.mjs +53 -0
- package/dist/chunk-PAWJFY3S.mjs +7 -0
- package/dist/chunk-YR5ZIMNO.mjs +27 -0
- package/dist/cli.js +75 -8
- package/dist/cli.mjs +15 -7
- package/dist/process-manager.d.mts +4 -1
- package/dist/process-manager.d.ts +4 -1
- package/dist/process-manager.js +10 -5
- package/dist/process-manager.mjs +1 -1
- package/dist/tools.d.mts +12 -0
- package/dist/tools.d.ts +12 -0
- package/dist/tools.js +92 -0
- package/dist/tools.mjs +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
+
|
|
5
|
+
// src/watch-manager.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
var JS_OUTPUT_FILE_REGEX = /\.(cjs|mjs|js)$/;
|
|
8
|
+
function shouldRestartOnFileChange(fileName) {
|
|
9
|
+
return JS_OUTPUT_FILE_REGEX.test(fileName);
|
|
10
|
+
}
|
|
11
|
+
__name(shouldRestartOnFileChange, "shouldRestartOnFileChange");
|
|
12
|
+
function createWatcher(watchPath, onChange) {
|
|
13
|
+
if (!fs.existsSync(watchPath)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return fs.watch(watchPath, {
|
|
17
|
+
recursive: true
|
|
18
|
+
}, (_eventType, filename) => {
|
|
19
|
+
if (!filename) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (shouldRestartOnFileChange(filename.toString())) {
|
|
23
|
+
onChange();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
__name(createWatcher, "createWatcher");
|
|
28
|
+
function closeWatchers(watchers) {
|
|
29
|
+
watchers.forEach((watcher) => watcher?.close());
|
|
30
|
+
}
|
|
31
|
+
__name(closeWatchers, "closeWatchers");
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
createWatcher,
|
|
35
|
+
closeWatchers
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=chunk-7EO6CNQD.mjs.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectBffPackageDistPaths
|
|
3
|
+
} from "./chunk-YR5ZIMNO.mjs";
|
|
4
|
+
import {
|
|
5
|
+
closeWatchers,
|
|
6
|
+
createWatcher
|
|
7
|
+
} from "./chunk-7EO6CNQD.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__name
|
|
10
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
11
|
+
|
|
12
|
+
// src/process-manager.ts
|
|
13
|
+
import { execSync, spawn } from "child_process";
|
|
14
|
+
import path from "path";
|
|
15
|
+
var FILE_CHANGE_DEBOUNCE_MS = 300;
|
|
16
|
+
var RESTART_GUARD_MS = 5e3;
|
|
17
|
+
function spawnCommand(command) {
|
|
18
|
+
return spawn(command, {
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
env: process.env,
|
|
21
|
+
shell: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
__name(spawnCommand, "spawnCommand");
|
|
25
|
+
function runNestBuild(argsString) {
|
|
26
|
+
execSync(`nest build ${argsString}`, {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
env: process.env
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
__name(runNestBuild, "runNestBuild");
|
|
32
|
+
function startAppProcess(options) {
|
|
33
|
+
const runtimeFlags = [];
|
|
34
|
+
if (options.nodeInspectFlag) {
|
|
35
|
+
runtimeFlags.push("--enable-source-maps", options.nodeInspectFlag);
|
|
36
|
+
}
|
|
37
|
+
const runtimePrefix = runtimeFlags.length > 0 ? `${runtimeFlags.join(" ")} ` : "";
|
|
38
|
+
return spawnCommand(`node ${runtimePrefix}dist/main.js`);
|
|
39
|
+
}
|
|
40
|
+
__name(startAppProcess, "startAppProcess");
|
|
41
|
+
function killProcess(child) {
|
|
42
|
+
if (!child.killed) {
|
|
43
|
+
child.kill("SIGTERM");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
__name(killProcess, "killProcess");
|
|
47
|
+
function runDevCommand(argsString, options = {}) {
|
|
48
|
+
const cwd = process.cwd();
|
|
49
|
+
runNestBuild(argsString);
|
|
50
|
+
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
51
|
+
let appProcess = startAppProcess(options);
|
|
52
|
+
let isClosing = false;
|
|
53
|
+
let isRestarting = false;
|
|
54
|
+
let restartTimer = null;
|
|
55
|
+
const ignoreRestartBefore = Date.now() + RESTART_GUARD_MS;
|
|
56
|
+
const appDistWatcher = createWatcher(path.resolve(cwd, "dist"), scheduleRestart);
|
|
57
|
+
const packageWatchers = collectBffPackageDistPaths(cwd).map((watchPath) => createWatcher(watchPath, scheduleRestart)).filter((watcher) => Boolean(watcher));
|
|
58
|
+
function exitAll(code = 0) {
|
|
59
|
+
isClosing = true;
|
|
60
|
+
if (restartTimer) {
|
|
61
|
+
clearTimeout(restartTimer);
|
|
62
|
+
restartTimer = null;
|
|
63
|
+
}
|
|
64
|
+
closeWatchers([
|
|
65
|
+
appDistWatcher,
|
|
66
|
+
...packageWatchers
|
|
67
|
+
]);
|
|
68
|
+
killProcess(appProcess);
|
|
69
|
+
killProcess(buildWatcherProcess);
|
|
70
|
+
process.exit(code);
|
|
71
|
+
}
|
|
72
|
+
__name(exitAll, "exitAll");
|
|
73
|
+
function attachAppExitGuard() {
|
|
74
|
+
appProcess.on("exit", (code) => {
|
|
75
|
+
if (isClosing || isRestarting) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (code !== 0) {
|
|
79
|
+
console.error(`node dist/main.js \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
80
|
+
exitAll(code ?? 1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
__name(attachAppExitGuard, "attachAppExitGuard");
|
|
85
|
+
function restartApp() {
|
|
86
|
+
if (isClosing || isRestarting) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
isRestarting = true;
|
|
90
|
+
const startNextApp = /* @__PURE__ */ __name(() => {
|
|
91
|
+
if (isClosing) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
appProcess = startAppProcess(options);
|
|
95
|
+
attachAppExitGuard();
|
|
96
|
+
isRestarting = false;
|
|
97
|
+
}, "startNextApp");
|
|
98
|
+
if (appProcess.killed) {
|
|
99
|
+
startNextApp();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
appProcess.once("exit", startNextApp);
|
|
103
|
+
killProcess(appProcess);
|
|
104
|
+
}
|
|
105
|
+
__name(restartApp, "restartApp");
|
|
106
|
+
function scheduleRestart() {
|
|
107
|
+
if (Date.now() < ignoreRestartBefore) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (restartTimer) {
|
|
111
|
+
clearTimeout(restartTimer);
|
|
112
|
+
}
|
|
113
|
+
restartTimer = setTimeout(restartApp, FILE_CHANGE_DEBOUNCE_MS);
|
|
114
|
+
}
|
|
115
|
+
__name(scheduleRestart, "scheduleRestart");
|
|
116
|
+
process.on("SIGINT", () => exitAll(0));
|
|
117
|
+
process.on("SIGTERM", () => exitAll(0));
|
|
118
|
+
buildWatcherProcess.on("exit", (code) => {
|
|
119
|
+
if (isClosing) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (code !== 0) {
|
|
123
|
+
console.error(`nest build --watch \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
124
|
+
exitAll(code ?? 1);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
attachAppExitGuard();
|
|
128
|
+
}
|
|
129
|
+
__name(runDevCommand, "runDevCommand");
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
runNestBuild,
|
|
133
|
+
runDevCommand
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=chunk-GK3IPRWV.mjs.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
+
|
|
5
|
+
// src/tools.ts
|
|
6
|
+
function createArgsString(args) {
|
|
7
|
+
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
8
|
+
}
|
|
9
|
+
__name(createArgsString, "createArgsString");
|
|
10
|
+
function toBoolean(value) {
|
|
11
|
+
if (typeof value === "boolean") {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === "number") {
|
|
15
|
+
return value !== 0;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
return [
|
|
19
|
+
"1",
|
|
20
|
+
"true",
|
|
21
|
+
"yes",
|
|
22
|
+
"on"
|
|
23
|
+
].includes(value.trim().toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
__name(toBoolean, "toBoolean");
|
|
28
|
+
function toInspectFlag(flagName, value) {
|
|
29
|
+
if (value === void 0 || value === null || value === false) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
33
|
+
return `--${flagName}=${value.trim()}`;
|
|
34
|
+
}
|
|
35
|
+
if (toBoolean(value) || value === true) {
|
|
36
|
+
return `--${flagName}`;
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
__name(toInspectFlag, "toInspectFlag");
|
|
41
|
+
function parseDevOptions(rawArgs) {
|
|
42
|
+
const inspectBrkFlag = toInspectFlag("inspect-brk", rawArgs["inspect-brk"]);
|
|
43
|
+
if (inspectBrkFlag) {
|
|
44
|
+
return {
|
|
45
|
+
nodeInspectFlag: inspectBrkFlag
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const inspectFlag = toInspectFlag("inspect", rawArgs.inspect);
|
|
49
|
+
if (inspectFlag) {
|
|
50
|
+
return {
|
|
51
|
+
nodeInspectFlag: inspectFlag
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (toBoolean(rawArgs.debug)) {
|
|
55
|
+
return {
|
|
56
|
+
nodeInspectFlag: "--inspect"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
__name(parseDevOptions, "parseDevOptions");
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
createArgsString,
|
|
65
|
+
toBoolean,
|
|
66
|
+
toInspectFlag,
|
|
67
|
+
parseDevOptions
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=chunk-I32XDVIW.mjs.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-O6YSETKJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/tools.ts
|
|
6
|
+
function createArgsString(args) {
|
|
7
|
+
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
8
|
+
}
|
|
9
|
+
__name(createArgsString, "createArgsString");
|
|
10
|
+
function toBoolean(value) {
|
|
11
|
+
if (typeof value === "boolean") {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === "number") {
|
|
15
|
+
return value !== 0;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
return [
|
|
19
|
+
"1",
|
|
20
|
+
"true",
|
|
21
|
+
"yes",
|
|
22
|
+
"on"
|
|
23
|
+
].includes(value.trim().toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
__name(toBoolean, "toBoolean");
|
|
28
|
+
function toInspectFlag(flagName, value) {
|
|
29
|
+
if (value === void 0 || value === null || value === false) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
33
|
+
return `--${flagName}=${value.trim()}`;
|
|
34
|
+
}
|
|
35
|
+
if (toBoolean(value) || value === true) {
|
|
36
|
+
return `--${flagName}`;
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
__name(toInspectFlag, "toInspectFlag");
|
|
41
|
+
function parseDevOptions(rawArgs) {
|
|
42
|
+
const inspectBrkFlag = toInspectFlag("inspect-brk", rawArgs["inspect-brk"]);
|
|
43
|
+
if (inspectBrkFlag) {
|
|
44
|
+
return {
|
|
45
|
+
nodeInspectFlag: inspectBrkFlag
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const inspectFlag = toInspectFlag("inspect", rawArgs.inspect);
|
|
49
|
+
if (inspectFlag) {
|
|
50
|
+
return {
|
|
51
|
+
nodeInspectFlag: inspectFlag
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (toBoolean(rawArgs.debug)) {
|
|
55
|
+
return {
|
|
56
|
+
nodeInspectFlag: "--inspect"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
__name(parseDevOptions, "parseDevOptions");
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
createArgsString,
|
|
65
|
+
toBoolean,
|
|
66
|
+
toInspectFlag,
|
|
67
|
+
parseDevOptions
|
|
68
|
+
};
|
|
@@ -29,8 +29,13 @@ function runNestBuild(argsString) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
__name(runNestBuild, "runNestBuild");
|
|
32
|
-
function startAppProcess() {
|
|
33
|
-
|
|
32
|
+
function startAppProcess(options) {
|
|
33
|
+
const runtimeFlags = [];
|
|
34
|
+
if (options.nodeInspectFlag) {
|
|
35
|
+
runtimeFlags.push("--enable-source-maps", options.nodeInspectFlag);
|
|
36
|
+
}
|
|
37
|
+
const runtimePrefix = runtimeFlags.length > 0 ? `${runtimeFlags.join(" ")} ` : "";
|
|
38
|
+
return spawnCommand(`node ${runtimePrefix}dist/main.js`);
|
|
34
39
|
}
|
|
35
40
|
__name(startAppProcess, "startAppProcess");
|
|
36
41
|
function killProcess(child) {
|
|
@@ -39,11 +44,11 @@ function killProcess(child) {
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
__name(killProcess, "killProcess");
|
|
42
|
-
function runDevCommand(argsString) {
|
|
47
|
+
function runDevCommand(argsString, options = {}) {
|
|
43
48
|
const cwd = process.cwd();
|
|
44
49
|
runNestBuild(argsString);
|
|
45
50
|
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
46
|
-
let appProcess = startAppProcess();
|
|
51
|
+
let appProcess = startAppProcess(options);
|
|
47
52
|
let isClosing = false;
|
|
48
53
|
let isRestarting = false;
|
|
49
54
|
let restartTimer = null;
|
|
@@ -86,7 +91,7 @@ function runDevCommand(argsString) {
|
|
|
86
91
|
if (isClosing) {
|
|
87
92
|
return;
|
|
88
93
|
}
|
|
89
|
-
appProcess = startAppProcess();
|
|
94
|
+
appProcess = startAppProcess(options);
|
|
90
95
|
attachAppExitGuard();
|
|
91
96
|
isRestarting = false;
|
|
92
97
|
}, "startNextApp");
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
+
|
|
5
|
+
// src/config.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import yaml from "yaml";
|
|
9
|
+
var loadXfeConfig = /* @__PURE__ */ __name(() => {
|
|
10
|
+
const xfeConfigPath = "./xfe.json";
|
|
11
|
+
if (!fs.existsSync(xfeConfigPath)) {
|
|
12
|
+
throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
|
|
13
|
+
}
|
|
14
|
+
const xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
|
|
15
|
+
return JSON.parse(xfeConfigContent);
|
|
16
|
+
}, "loadXfeConfig");
|
|
17
|
+
var configDeploy = /* @__PURE__ */ __name(() => {
|
|
18
|
+
const xfeConfig = loadXfeConfig();
|
|
19
|
+
if (!xfeConfig?.deploy) return;
|
|
20
|
+
const droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
21
|
+
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
22
|
+
const valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
23
|
+
const valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
24
|
+
const valuesYaml = yaml.parse(valuesYamlFile);
|
|
25
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
26
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
27
|
+
test: [],
|
|
28
|
+
stage: [],
|
|
29
|
+
prod: []
|
|
30
|
+
};
|
|
31
|
+
const { virtualServiceEnabled = true, hostsProd = [], hostsStage = [], hostsTest = [], gateways = [
|
|
32
|
+
"common-gateway-eshetang"
|
|
33
|
+
] } = xfeConfig.deploy;
|
|
34
|
+
const { targetK8s = "saas", targetNamespace = "" } = xfeConfig.deploy;
|
|
35
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
36
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
37
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
38
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
39
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
40
|
+
valuesYaml.targetK8s = targetK8s;
|
|
41
|
+
valuesYaml.namespace = targetNamespace;
|
|
42
|
+
const valuesYamlStr = yaml.stringify(valuesYaml, {
|
|
43
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
44
|
+
defaultKeyType: "PLAIN"
|
|
45
|
+
});
|
|
46
|
+
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
47
|
+
}, "configDeploy");
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
loadXfeConfig,
|
|
51
|
+
configDeploy
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=chunk-NUV437MC.mjs.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
+
|
|
5
|
+
// src/path-resolver.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
function collectScopedPackageDistPaths(cwd) {
|
|
9
|
+
const SCOPE_PACKAGES_DIR = "node_modules/@xfe-repo";
|
|
10
|
+
const scopedPackagesPath = path.resolve(cwd, SCOPE_PACKAGES_DIR);
|
|
11
|
+
if (!fs.existsSync(scopedPackagesPath)) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return fs.readdirSync(scopedPackagesPath).filter((packageName) => packageName.startsWith("bff-") && packageName !== "bff-app").map((packageName) => path.join(scopedPackagesPath, packageName)).filter((packageLinkPath) => fs.existsSync(packageLinkPath)).map((packageLinkPath) => fs.realpathSync(packageLinkPath)).map((packageRootPath) => path.join(packageRootPath, "dist")).filter((distPath) => fs.existsSync(distPath));
|
|
15
|
+
}
|
|
16
|
+
__name(collectScopedPackageDistPaths, "collectScopedPackageDistPaths");
|
|
17
|
+
function collectBffPackageDistPaths(cwd) {
|
|
18
|
+
const watchTargets = /* @__PURE__ */ new Set();
|
|
19
|
+
collectScopedPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
20
|
+
return Array.from(watchTargets);
|
|
21
|
+
}
|
|
22
|
+
__name(collectBffPackageDistPaths, "collectBffPackageDistPaths");
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
collectBffPackageDistPaths
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-YR5ZIMNO.mjs.map
|
package/dist/cli.js
CHANGED
|
@@ -139,8 +139,13 @@ function runNestBuild(argsString) {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
__name(runNestBuild, "runNestBuild");
|
|
142
|
-
function startAppProcess() {
|
|
143
|
-
|
|
142
|
+
function startAppProcess(options) {
|
|
143
|
+
const runtimeFlags = [];
|
|
144
|
+
if (options.nodeInspectFlag) {
|
|
145
|
+
runtimeFlags.push("--enable-source-maps", options.nodeInspectFlag);
|
|
146
|
+
}
|
|
147
|
+
const runtimePrefix = runtimeFlags.length > 0 ? `${runtimeFlags.join(" ")} ` : "";
|
|
148
|
+
return spawnCommand(`node ${runtimePrefix}dist/main.js`);
|
|
144
149
|
}
|
|
145
150
|
__name(startAppProcess, "startAppProcess");
|
|
146
151
|
function killProcess(child) {
|
|
@@ -149,11 +154,11 @@ function killProcess(child) {
|
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
__name(killProcess, "killProcess");
|
|
152
|
-
function runDevCommand(argsString) {
|
|
157
|
+
function runDevCommand(argsString, options = {}) {
|
|
153
158
|
const cwd = process.cwd();
|
|
154
159
|
runNestBuild(argsString);
|
|
155
160
|
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
156
|
-
let appProcess = startAppProcess();
|
|
161
|
+
let appProcess = startAppProcess(options);
|
|
157
162
|
let isClosing = false;
|
|
158
163
|
let isRestarting = false;
|
|
159
164
|
let restartTimer = null;
|
|
@@ -196,7 +201,7 @@ function runDevCommand(argsString) {
|
|
|
196
201
|
if (isClosing) {
|
|
197
202
|
return;
|
|
198
203
|
}
|
|
199
|
-
appProcess = startAppProcess();
|
|
204
|
+
appProcess = startAppProcess(options);
|
|
200
205
|
attachAppExitGuard();
|
|
201
206
|
isRestarting = false;
|
|
202
207
|
}, "startNextApp");
|
|
@@ -233,17 +238,79 @@ function runDevCommand(argsString) {
|
|
|
233
238
|
}
|
|
234
239
|
__name(runDevCommand, "runDevCommand");
|
|
235
240
|
|
|
236
|
-
// src/
|
|
241
|
+
// src/tools.ts
|
|
237
242
|
function createArgsString(args) {
|
|
238
243
|
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
239
244
|
}
|
|
240
245
|
__name(createArgsString, "createArgsString");
|
|
246
|
+
function toBoolean(value) {
|
|
247
|
+
if (typeof value === "boolean") {
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
if (typeof value === "number") {
|
|
251
|
+
return value !== 0;
|
|
252
|
+
}
|
|
253
|
+
if (typeof value === "string") {
|
|
254
|
+
return [
|
|
255
|
+
"1",
|
|
256
|
+
"true",
|
|
257
|
+
"yes",
|
|
258
|
+
"on"
|
|
259
|
+
].includes(value.trim().toLowerCase());
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
__name(toBoolean, "toBoolean");
|
|
264
|
+
function toInspectFlag(flagName, value) {
|
|
265
|
+
if (value === void 0 || value === null || value === false) {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
269
|
+
return `--${flagName}=${value.trim()}`;
|
|
270
|
+
}
|
|
271
|
+
if (toBoolean(value) || value === true) {
|
|
272
|
+
return `--${flagName}`;
|
|
273
|
+
}
|
|
274
|
+
return void 0;
|
|
275
|
+
}
|
|
276
|
+
__name(toInspectFlag, "toInspectFlag");
|
|
277
|
+
function parseDevOptions(rawArgs) {
|
|
278
|
+
const inspectBrkFlag = toInspectFlag("inspect-brk", rawArgs["inspect-brk"]);
|
|
279
|
+
if (inspectBrkFlag) {
|
|
280
|
+
return {
|
|
281
|
+
nodeInspectFlag: inspectBrkFlag
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const inspectFlag = toInspectFlag("inspect", rawArgs.inspect);
|
|
285
|
+
if (inspectFlag) {
|
|
286
|
+
return {
|
|
287
|
+
nodeInspectFlag: inspectFlag
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (toBoolean(rawArgs.debug)) {
|
|
291
|
+
return {
|
|
292
|
+
nodeInspectFlag: "--inspect"
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return {};
|
|
296
|
+
}
|
|
297
|
+
__name(parseDevOptions, "parseDevOptions");
|
|
298
|
+
|
|
299
|
+
// src/cli.ts
|
|
241
300
|
function parseCliContext() {
|
|
242
301
|
const argv = (0, import_minimist.default)(process.argv.slice(2));
|
|
243
302
|
const { _: commands, ...rawArgs } = argv;
|
|
303
|
+
const RUNTIME_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
304
|
+
"debug",
|
|
305
|
+
"inspect",
|
|
306
|
+
"inspect-brk"
|
|
307
|
+
]);
|
|
308
|
+
const devOptions = parseDevOptions(rawArgs);
|
|
309
|
+
const buildArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => !RUNTIME_ARG_KEYS.has(key)));
|
|
244
310
|
return {
|
|
245
311
|
command: commands[0],
|
|
246
|
-
argsString: createArgsString(
|
|
312
|
+
argsString: createArgsString(buildArgs),
|
|
313
|
+
devOptions
|
|
247
314
|
};
|
|
248
315
|
}
|
|
249
316
|
__name(parseCliContext, "parseCliContext");
|
|
@@ -257,7 +324,7 @@ function runConfig() {
|
|
|
257
324
|
__name(runConfig, "runConfig");
|
|
258
325
|
function runCommandByType(context) {
|
|
259
326
|
if (context.command === "dev") {
|
|
260
|
-
runDevCommand(context.argsString);
|
|
327
|
+
runDevCommand(context.argsString, context.devOptions);
|
|
261
328
|
return;
|
|
262
329
|
}
|
|
263
330
|
if (context.command === "build") {
|
package/dist/cli.mjs
CHANGED
|
@@ -4,8 +4,12 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
runDevCommand,
|
|
6
6
|
runNestBuild
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NJP3V6ZT.mjs";
|
|
8
8
|
import "./chunk-4YNMCK7Y.mjs";
|
|
9
|
+
import {
|
|
10
|
+
createArgsString,
|
|
11
|
+
parseDevOptions
|
|
12
|
+
} from "./chunk-MP3KTLGW.mjs";
|
|
9
13
|
import "./chunk-BAUM5HSG.mjs";
|
|
10
14
|
import {
|
|
11
15
|
__name
|
|
@@ -13,16 +17,20 @@ import {
|
|
|
13
17
|
|
|
14
18
|
// src/cli.ts
|
|
15
19
|
import minimist from "minimist";
|
|
16
|
-
function createArgsString(args) {
|
|
17
|
-
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
18
|
-
}
|
|
19
|
-
__name(createArgsString, "createArgsString");
|
|
20
20
|
function parseCliContext() {
|
|
21
21
|
const argv = minimist(process.argv.slice(2));
|
|
22
22
|
const { _: commands, ...rawArgs } = argv;
|
|
23
|
+
const RUNTIME_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
24
|
+
"debug",
|
|
25
|
+
"inspect",
|
|
26
|
+
"inspect-brk"
|
|
27
|
+
]);
|
|
28
|
+
const devOptions = parseDevOptions(rawArgs);
|
|
29
|
+
const buildArgs = Object.fromEntries(Object.entries(rawArgs).filter(([key]) => !RUNTIME_ARG_KEYS.has(key)));
|
|
23
30
|
return {
|
|
24
31
|
command: commands[0],
|
|
25
|
-
argsString: createArgsString(
|
|
32
|
+
argsString: createArgsString(buildArgs),
|
|
33
|
+
devOptions
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
36
|
__name(parseCliContext, "parseCliContext");
|
|
@@ -36,7 +44,7 @@ function runConfig() {
|
|
|
36
44
|
__name(runConfig, "runConfig");
|
|
37
45
|
function runCommandByType(context) {
|
|
38
46
|
if (context.command === "dev") {
|
|
39
|
-
runDevCommand(context.argsString);
|
|
47
|
+
runDevCommand(context.argsString, context.devOptions);
|
|
40
48
|
return;
|
|
41
49
|
}
|
|
42
50
|
if (context.command === "build") {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { RunDevOptions } from './tools.mjs';
|
|
2
|
+
import 'minimist';
|
|
3
|
+
|
|
1
4
|
declare function runNestBuild(argsString: string): void;
|
|
2
|
-
declare function runDevCommand(argsString: string): void;
|
|
5
|
+
declare function runDevCommand(argsString: string, options?: RunDevOptions): void;
|
|
3
6
|
|
|
4
7
|
export { runDevCommand, runNestBuild };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { RunDevOptions } from './tools.js';
|
|
2
|
+
import 'minimist';
|
|
3
|
+
|
|
1
4
|
declare function runNestBuild(argsString: string): void;
|
|
2
|
-
declare function runDevCommand(argsString: string): void;
|
|
5
|
+
declare function runDevCommand(argsString: string, options?: RunDevOptions): void;
|
|
3
6
|
|
|
4
7
|
export { runDevCommand, runNestBuild };
|
package/dist/process-manager.js
CHANGED
|
@@ -103,8 +103,13 @@ function runNestBuild(argsString) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
__name(runNestBuild, "runNestBuild");
|
|
106
|
-
function startAppProcess() {
|
|
107
|
-
|
|
106
|
+
function startAppProcess(options) {
|
|
107
|
+
const runtimeFlags = [];
|
|
108
|
+
if (options.nodeInspectFlag) {
|
|
109
|
+
runtimeFlags.push("--enable-source-maps", options.nodeInspectFlag);
|
|
110
|
+
}
|
|
111
|
+
const runtimePrefix = runtimeFlags.length > 0 ? `${runtimeFlags.join(" ")} ` : "";
|
|
112
|
+
return spawnCommand(`node ${runtimePrefix}dist/main.js`);
|
|
108
113
|
}
|
|
109
114
|
__name(startAppProcess, "startAppProcess");
|
|
110
115
|
function killProcess(child) {
|
|
@@ -113,11 +118,11 @@ function killProcess(child) {
|
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
__name(killProcess, "killProcess");
|
|
116
|
-
function runDevCommand(argsString) {
|
|
121
|
+
function runDevCommand(argsString, options = {}) {
|
|
117
122
|
const cwd = process.cwd();
|
|
118
123
|
runNestBuild(argsString);
|
|
119
124
|
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
120
|
-
let appProcess = startAppProcess();
|
|
125
|
+
let appProcess = startAppProcess(options);
|
|
121
126
|
let isClosing = false;
|
|
122
127
|
let isRestarting = false;
|
|
123
128
|
let restartTimer = null;
|
|
@@ -160,7 +165,7 @@ function runDevCommand(argsString) {
|
|
|
160
165
|
if (isClosing) {
|
|
161
166
|
return;
|
|
162
167
|
}
|
|
163
|
-
appProcess = startAppProcess();
|
|
168
|
+
appProcess = startAppProcess(options);
|
|
164
169
|
attachAppExitGuard();
|
|
165
170
|
isRestarting = false;
|
|
166
171
|
}, "startNextApp");
|
package/dist/process-manager.mjs
CHANGED
package/dist/tools.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
|
|
3
|
+
type CliArgs = Record<string, string | number | boolean>;
|
|
4
|
+
declare function createArgsString(args: CliArgs): string;
|
|
5
|
+
declare function toBoolean(value: unknown): boolean;
|
|
6
|
+
declare function toInspectFlag(flagName: string, value: unknown): string | undefined;
|
|
7
|
+
interface RunDevOptions {
|
|
8
|
+
nodeInspectFlag?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function parseDevOptions(rawArgs: minimist.ParsedArgs): RunDevOptions;
|
|
11
|
+
|
|
12
|
+
export { type CliArgs, type RunDevOptions, createArgsString, parseDevOptions, toBoolean, toInspectFlag };
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
|
|
3
|
+
type CliArgs = Record<string, string | number | boolean>;
|
|
4
|
+
declare function createArgsString(args: CliArgs): string;
|
|
5
|
+
declare function toBoolean(value: unknown): boolean;
|
|
6
|
+
declare function toInspectFlag(flagName: string, value: unknown): string | undefined;
|
|
7
|
+
interface RunDevOptions {
|
|
8
|
+
nodeInspectFlag?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function parseDevOptions(rawArgs: minimist.ParsedArgs): RunDevOptions;
|
|
11
|
+
|
|
12
|
+
export { type CliArgs, type RunDevOptions, createArgsString, parseDevOptions, toBoolean, toInspectFlag };
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/tools.ts
|
|
22
|
+
var tools_exports = {};
|
|
23
|
+
__export(tools_exports, {
|
|
24
|
+
createArgsString: () => createArgsString,
|
|
25
|
+
parseDevOptions: () => parseDevOptions,
|
|
26
|
+
toBoolean: () => toBoolean,
|
|
27
|
+
toInspectFlag: () => toInspectFlag
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(tools_exports);
|
|
30
|
+
function createArgsString(args) {
|
|
31
|
+
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
32
|
+
}
|
|
33
|
+
__name(createArgsString, "createArgsString");
|
|
34
|
+
function toBoolean(value) {
|
|
35
|
+
if (typeof value === "boolean") {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === "number") {
|
|
39
|
+
return value !== 0;
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
return [
|
|
43
|
+
"1",
|
|
44
|
+
"true",
|
|
45
|
+
"yes",
|
|
46
|
+
"on"
|
|
47
|
+
].includes(value.trim().toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
__name(toBoolean, "toBoolean");
|
|
52
|
+
function toInspectFlag(flagName, value) {
|
|
53
|
+
if (value === void 0 || value === null || value === false) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
57
|
+
return `--${flagName}=${value.trim()}`;
|
|
58
|
+
}
|
|
59
|
+
if (toBoolean(value) || value === true) {
|
|
60
|
+
return `--${flagName}`;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
__name(toInspectFlag, "toInspectFlag");
|
|
65
|
+
function parseDevOptions(rawArgs) {
|
|
66
|
+
const inspectBrkFlag = toInspectFlag("inspect-brk", rawArgs["inspect-brk"]);
|
|
67
|
+
if (inspectBrkFlag) {
|
|
68
|
+
return {
|
|
69
|
+
nodeInspectFlag: inspectBrkFlag
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const inspectFlag = toInspectFlag("inspect", rawArgs.inspect);
|
|
73
|
+
if (inspectFlag) {
|
|
74
|
+
return {
|
|
75
|
+
nodeInspectFlag: inspectFlag
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (toBoolean(rawArgs.debug)) {
|
|
79
|
+
return {
|
|
80
|
+
nodeInspectFlag: "--inspect"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
__name(parseDevOptions, "parseDevOptions");
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
createArgsString,
|
|
89
|
+
parseDevOptions,
|
|
90
|
+
toBoolean,
|
|
91
|
+
toInspectFlag
|
|
92
|
+
});
|
package/dist/tools.mjs
ADDED