@xfe-repo/bff-app 1.5.0 → 1.5.2
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-67SKOZPM.mjs +37 -0
- package/dist/chunk-BAUM5HSG.mjs +36 -0
- package/dist/{chunk-7MBWBSGL.mjs → chunk-CUZB5IYH.mjs} +3 -3
- package/dist/chunk-IX37L3FU.mjs +129 -0
- package/dist/chunk-O6YSETKJ.mjs +6 -0
- package/dist/cli.js +212 -23
- package/dist/cli.mjs +48 -25
- package/dist/config.mjs +2 -1
- package/dist/path-resolver.d.mts +3 -0
- package/dist/path-resolver.d.ts +3 -0
- package/dist/path-resolver.js +68 -0
- package/dist/path-resolver.mjs +7 -0
- package/dist/process-manager.d.mts +4 -0
- package/dist/process-manager.d.ts +4 -0
- package/dist/process-manager.js +214 -0
- package/dist/process-manager.mjs +11 -0
- package/dist/watch-manager.d.mts +6 -0
- package/dist/watch-manager.d.ts +6 -0
- package/dist/watch-manager.js +68 -0
- package/dist/watch-manager.mjs +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-O6YSETKJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/path-resolver.ts
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
var INTERNAL_BFF_PACKAGES_DIR = "../../packages/bff";
|
|
9
|
+
var SCOPE_PACKAGES_DIR = "node_modules/@xfe-repo";
|
|
10
|
+
var IGNORED_PACKAGE_NAME = "bff-app";
|
|
11
|
+
function collectScopedPackageDistPaths(cwd) {
|
|
12
|
+
const scopedPackagesPath = path.resolve(cwd, SCOPE_PACKAGES_DIR);
|
|
13
|
+
if (!fs.existsSync(scopedPackagesPath)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return fs.readdirSync(scopedPackagesPath).filter((packageName) => packageName.startsWith("bff-") && packageName !== IGNORED_PACKAGE_NAME).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));
|
|
17
|
+
}
|
|
18
|
+
__name(collectScopedPackageDistPaths, "collectScopedPackageDistPaths");
|
|
19
|
+
function collectInternalPackageDistPaths(cwd) {
|
|
20
|
+
const packagesRootPath = path.resolve(cwd, INTERNAL_BFF_PACKAGES_DIR);
|
|
21
|
+
if (!fs.existsSync(packagesRootPath)) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return fs.readdirSync(packagesRootPath).filter((packageName) => packageName !== "app").map((packageName) => path.join(packagesRootPath, packageName, "dist")).filter((distPath) => fs.existsSync(distPath));
|
|
25
|
+
}
|
|
26
|
+
__name(collectInternalPackageDistPaths, "collectInternalPackageDistPaths");
|
|
27
|
+
function collectBffPackageDistPaths(cwd) {
|
|
28
|
+
const watchTargets = /* @__PURE__ */ new Set();
|
|
29
|
+
collectScopedPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
30
|
+
collectInternalPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
31
|
+
return Array.from(watchTargets);
|
|
32
|
+
}
|
|
33
|
+
__name(collectBffPackageDistPaths, "collectBffPackageDistPaths");
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
collectBffPackageDistPaths
|
|
37
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-O6YSETKJ.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
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-O6YSETKJ.mjs";
|
|
3
4
|
|
|
4
5
|
// src/config.ts
|
|
5
6
|
import fs from "fs";
|
|
@@ -46,7 +47,6 @@ var configDeploy = /* @__PURE__ */ __name(() => {
|
|
|
46
47
|
}, "configDeploy");
|
|
47
48
|
|
|
48
49
|
export {
|
|
49
|
-
__name,
|
|
50
50
|
loadXfeConfig,
|
|
51
51
|
configDeploy
|
|
52
52
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectBffPackageDistPaths
|
|
3
|
+
} from "./chunk-67SKOZPM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
closeWatchers,
|
|
6
|
+
createWatcher
|
|
7
|
+
} from "./chunk-BAUM5HSG.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__name
|
|
10
|
+
} from "./chunk-O6YSETKJ.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() {
|
|
33
|
+
return spawnCommand("node dist/main.js");
|
|
34
|
+
}
|
|
35
|
+
__name(startAppProcess, "startAppProcess");
|
|
36
|
+
function killProcess(child) {
|
|
37
|
+
if (!child.killed) {
|
|
38
|
+
child.kill("SIGTERM");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
__name(killProcess, "killProcess");
|
|
42
|
+
function runDevCommand(argsString) {
|
|
43
|
+
const cwd = process.cwd();
|
|
44
|
+
runNestBuild(argsString);
|
|
45
|
+
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
46
|
+
let appProcess = startAppProcess();
|
|
47
|
+
let isClosing = false;
|
|
48
|
+
let isRestarting = false;
|
|
49
|
+
let restartTimer = null;
|
|
50
|
+
const ignoreRestartBefore = Date.now() + RESTART_GUARD_MS;
|
|
51
|
+
const appDistWatcher = createWatcher(path.resolve(cwd, "dist"), scheduleRestart);
|
|
52
|
+
const packageWatchers = collectBffPackageDistPaths(cwd).map((watchPath) => createWatcher(watchPath, scheduleRestart)).filter((watcher) => Boolean(watcher));
|
|
53
|
+
function exitAll(code = 0) {
|
|
54
|
+
isClosing = true;
|
|
55
|
+
if (restartTimer) {
|
|
56
|
+
clearTimeout(restartTimer);
|
|
57
|
+
restartTimer = null;
|
|
58
|
+
}
|
|
59
|
+
closeWatchers([
|
|
60
|
+
appDistWatcher,
|
|
61
|
+
...packageWatchers
|
|
62
|
+
]);
|
|
63
|
+
killProcess(appProcess);
|
|
64
|
+
killProcess(buildWatcherProcess);
|
|
65
|
+
process.exit(code);
|
|
66
|
+
}
|
|
67
|
+
__name(exitAll, "exitAll");
|
|
68
|
+
function attachAppExitGuard() {
|
|
69
|
+
appProcess.on("exit", (code) => {
|
|
70
|
+
if (isClosing || isRestarting) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (code !== 0) {
|
|
74
|
+
console.error(`node dist/main.js \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
75
|
+
exitAll(code ?? 1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
__name(attachAppExitGuard, "attachAppExitGuard");
|
|
80
|
+
function restartApp() {
|
|
81
|
+
if (isClosing || isRestarting) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
isRestarting = true;
|
|
85
|
+
const startNextApp = /* @__PURE__ */ __name(() => {
|
|
86
|
+
if (isClosing) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
appProcess = startAppProcess();
|
|
90
|
+
attachAppExitGuard();
|
|
91
|
+
isRestarting = false;
|
|
92
|
+
}, "startNextApp");
|
|
93
|
+
if (appProcess.killed) {
|
|
94
|
+
startNextApp();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
appProcess.once("exit", startNextApp);
|
|
98
|
+
killProcess(appProcess);
|
|
99
|
+
}
|
|
100
|
+
__name(restartApp, "restartApp");
|
|
101
|
+
function scheduleRestart() {
|
|
102
|
+
if (Date.now() < ignoreRestartBefore) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (restartTimer) {
|
|
106
|
+
clearTimeout(restartTimer);
|
|
107
|
+
}
|
|
108
|
+
restartTimer = setTimeout(restartApp, FILE_CHANGE_DEBOUNCE_MS);
|
|
109
|
+
}
|
|
110
|
+
__name(scheduleRestart, "scheduleRestart");
|
|
111
|
+
process.on("SIGINT", () => exitAll(0));
|
|
112
|
+
process.on("SIGTERM", () => exitAll(0));
|
|
113
|
+
buildWatcherProcess.on("exit", (code) => {
|
|
114
|
+
if (isClosing) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (code !== 0) {
|
|
118
|
+
console.error(`nest build --watch \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
119
|
+
exitAll(code ?? 1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
attachAppExitGuard();
|
|
123
|
+
}
|
|
124
|
+
__name(runDevCommand, "runDevCommand");
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
runNestBuild,
|
|
128
|
+
runDevCommand
|
|
129
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/cli.ts
|
|
27
|
-
var import_child_process = require("child_process");
|
|
28
27
|
var import_minimist = __toESM(require("minimist"));
|
|
29
28
|
|
|
30
29
|
// src/config.ts
|
|
@@ -71,31 +70,221 @@ var configDeploy = /* @__PURE__ */ __name(() => {
|
|
|
71
70
|
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
72
71
|
}, "configDeploy");
|
|
73
72
|
|
|
74
|
-
// src/
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
// src/process-manager.ts
|
|
74
|
+
var import_child_process = require("child_process");
|
|
75
|
+
var import_path3 = __toESM(require("path"));
|
|
76
|
+
|
|
77
|
+
// src/path-resolver.ts
|
|
78
|
+
var import_fs2 = __toESM(require("fs"));
|
|
79
|
+
var import_path2 = __toESM(require("path"));
|
|
80
|
+
var INTERNAL_BFF_PACKAGES_DIR = "../../packages/bff";
|
|
81
|
+
var SCOPE_PACKAGES_DIR = "node_modules/@xfe-repo";
|
|
82
|
+
var IGNORED_PACKAGE_NAME = "bff-app";
|
|
83
|
+
function collectScopedPackageDistPaths(cwd) {
|
|
84
|
+
const scopedPackagesPath = import_path2.default.resolve(cwd, SCOPE_PACKAGES_DIR);
|
|
85
|
+
if (!import_fs2.default.existsSync(scopedPackagesPath)) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
return import_fs2.default.readdirSync(scopedPackagesPath).filter((packageName) => packageName.startsWith("bff-") && packageName !== IGNORED_PACKAGE_NAME).map((packageName) => import_path2.default.join(scopedPackagesPath, packageName)).filter((packageLinkPath) => import_fs2.default.existsSync(packageLinkPath)).map((packageLinkPath) => import_fs2.default.realpathSync(packageLinkPath)).map((packageRootPath) => import_path2.default.join(packageRootPath, "dist")).filter((distPath) => import_fs2.default.existsSync(distPath));
|
|
89
|
+
}
|
|
90
|
+
__name(collectScopedPackageDistPaths, "collectScopedPackageDistPaths");
|
|
91
|
+
function collectInternalPackageDistPaths(cwd) {
|
|
92
|
+
const packagesRootPath = import_path2.default.resolve(cwd, INTERNAL_BFF_PACKAGES_DIR);
|
|
93
|
+
if (!import_fs2.default.existsSync(packagesRootPath)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return import_fs2.default.readdirSync(packagesRootPath).filter((packageName) => packageName !== "app").map((packageName) => import_path2.default.join(packagesRootPath, packageName, "dist")).filter((distPath) => import_fs2.default.existsSync(distPath));
|
|
97
|
+
}
|
|
98
|
+
__name(collectInternalPackageDistPaths, "collectInternalPackageDistPaths");
|
|
99
|
+
function collectBffPackageDistPaths(cwd) {
|
|
100
|
+
const watchTargets = /* @__PURE__ */ new Set();
|
|
101
|
+
collectScopedPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
102
|
+
collectInternalPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
103
|
+
return Array.from(watchTargets);
|
|
104
|
+
}
|
|
105
|
+
__name(collectBffPackageDistPaths, "collectBffPackageDistPaths");
|
|
106
|
+
|
|
107
|
+
// src/watch-manager.ts
|
|
108
|
+
var import_fs3 = __toESM(require("fs"));
|
|
109
|
+
var JS_OUTPUT_FILE_REGEX = /\.(cjs|mjs|js)$/;
|
|
110
|
+
function shouldRestartOnFileChange(fileName) {
|
|
111
|
+
return JS_OUTPUT_FILE_REGEX.test(fileName);
|
|
112
|
+
}
|
|
113
|
+
__name(shouldRestartOnFileChange, "shouldRestartOnFileChange");
|
|
114
|
+
function createWatcher(watchPath, onChange) {
|
|
115
|
+
if (!import_fs3.default.existsSync(watchPath)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return import_fs3.default.watch(watchPath, {
|
|
119
|
+
recursive: true
|
|
120
|
+
}, (_eventType, filename) => {
|
|
121
|
+
if (!filename) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (shouldRestartOnFileChange(filename.toString())) {
|
|
125
|
+
onChange();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
__name(createWatcher, "createWatcher");
|
|
130
|
+
function closeWatchers(watchers) {
|
|
131
|
+
watchers.forEach((watcher) => watcher?.close());
|
|
132
|
+
}
|
|
133
|
+
__name(closeWatchers, "closeWatchers");
|
|
134
|
+
|
|
135
|
+
// src/process-manager.ts
|
|
136
|
+
var FILE_CHANGE_DEBOUNCE_MS = 300;
|
|
137
|
+
var RESTART_GUARD_MS = 5e3;
|
|
138
|
+
function spawnCommand(command) {
|
|
139
|
+
return (0, import_child_process.spawn)(command, {
|
|
140
|
+
stdio: "inherit",
|
|
141
|
+
env: process.env,
|
|
142
|
+
shell: true
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
__name(spawnCommand, "spawnCommand");
|
|
146
|
+
function runNestBuild(argsString) {
|
|
147
|
+
(0, import_child_process.execSync)(`nest build ${argsString}`, {
|
|
148
|
+
stdio: "inherit",
|
|
149
|
+
env: process.env
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
__name(runNestBuild, "runNestBuild");
|
|
153
|
+
function startAppProcess() {
|
|
154
|
+
return spawnCommand("node dist/main.js");
|
|
155
|
+
}
|
|
156
|
+
__name(startAppProcess, "startAppProcess");
|
|
157
|
+
function killProcess(child) {
|
|
158
|
+
if (!child.killed) {
|
|
159
|
+
child.kill("SIGTERM");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
__name(killProcess, "killProcess");
|
|
163
|
+
function runDevCommand(argsString) {
|
|
164
|
+
const cwd = process.cwd();
|
|
165
|
+
runNestBuild(argsString);
|
|
166
|
+
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
167
|
+
let appProcess = startAppProcess();
|
|
168
|
+
let isClosing = false;
|
|
169
|
+
let isRestarting = false;
|
|
170
|
+
let restartTimer = null;
|
|
171
|
+
const ignoreRestartBefore = Date.now() + RESTART_GUARD_MS;
|
|
172
|
+
const appDistWatcher = createWatcher(import_path3.default.resolve(cwd, "dist"), scheduleRestart);
|
|
173
|
+
const packageWatchers = collectBffPackageDistPaths(cwd).map((watchPath) => createWatcher(watchPath, scheduleRestart)).filter((watcher) => Boolean(watcher));
|
|
174
|
+
function exitAll(code = 0) {
|
|
175
|
+
isClosing = true;
|
|
176
|
+
if (restartTimer) {
|
|
177
|
+
clearTimeout(restartTimer);
|
|
178
|
+
restartTimer = null;
|
|
179
|
+
}
|
|
180
|
+
closeWatchers([
|
|
181
|
+
appDistWatcher,
|
|
182
|
+
...packageWatchers
|
|
183
|
+
]);
|
|
184
|
+
killProcess(appProcess);
|
|
185
|
+
killProcess(buildWatcherProcess);
|
|
186
|
+
process.exit(code);
|
|
187
|
+
}
|
|
188
|
+
__name(exitAll, "exitAll");
|
|
189
|
+
function attachAppExitGuard() {
|
|
190
|
+
appProcess.on("exit", (code) => {
|
|
191
|
+
if (isClosing || isRestarting) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (code !== 0) {
|
|
195
|
+
console.error(`node dist/main.js \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
196
|
+
exitAll(code ?? 1);
|
|
197
|
+
}
|
|
90
198
|
});
|
|
91
|
-
} else if (command === "config") {
|
|
92
|
-
configDeploy();
|
|
93
199
|
}
|
|
200
|
+
__name(attachAppExitGuard, "attachAppExitGuard");
|
|
201
|
+
function restartApp() {
|
|
202
|
+
if (isClosing || isRestarting) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
isRestarting = true;
|
|
206
|
+
const startNextApp = /* @__PURE__ */ __name(() => {
|
|
207
|
+
if (isClosing) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
appProcess = startAppProcess();
|
|
211
|
+
attachAppExitGuard();
|
|
212
|
+
isRestarting = false;
|
|
213
|
+
}, "startNextApp");
|
|
214
|
+
if (appProcess.killed) {
|
|
215
|
+
startNextApp();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
appProcess.once("exit", startNextApp);
|
|
219
|
+
killProcess(appProcess);
|
|
220
|
+
}
|
|
221
|
+
__name(restartApp, "restartApp");
|
|
222
|
+
function scheduleRestart() {
|
|
223
|
+
if (Date.now() < ignoreRestartBefore) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (restartTimer) {
|
|
227
|
+
clearTimeout(restartTimer);
|
|
228
|
+
}
|
|
229
|
+
restartTimer = setTimeout(restartApp, FILE_CHANGE_DEBOUNCE_MS);
|
|
230
|
+
}
|
|
231
|
+
__name(scheduleRestart, "scheduleRestart");
|
|
232
|
+
process.on("SIGINT", () => exitAll(0));
|
|
233
|
+
process.on("SIGTERM", () => exitAll(0));
|
|
234
|
+
buildWatcherProcess.on("exit", (code) => {
|
|
235
|
+
if (isClosing) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (code !== 0) {
|
|
239
|
+
console.error(`nest build --watch \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
240
|
+
exitAll(code ?? 1);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
attachAppExitGuard();
|
|
244
|
+
}
|
|
245
|
+
__name(runDevCommand, "runDevCommand");
|
|
246
|
+
|
|
247
|
+
// src/cli.ts
|
|
248
|
+
function createArgsString(args) {
|
|
249
|
+
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
250
|
+
}
|
|
251
|
+
__name(createArgsString, "createArgsString");
|
|
252
|
+
function parseCliContext() {
|
|
253
|
+
const argv = (0, import_minimist.default)(process.argv.slice(2));
|
|
254
|
+
const { _: commands, ...rawArgs } = argv;
|
|
255
|
+
return {
|
|
256
|
+
command: commands[0],
|
|
257
|
+
argsString: createArgsString(rawArgs)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
__name(parseCliContext, "parseCliContext");
|
|
261
|
+
function runBuild(argsString) {
|
|
262
|
+
runNestBuild(argsString);
|
|
263
|
+
}
|
|
264
|
+
__name(runBuild, "runBuild");
|
|
265
|
+
function runConfig() {
|
|
266
|
+
configDeploy();
|
|
267
|
+
}
|
|
268
|
+
__name(runConfig, "runConfig");
|
|
269
|
+
function runCommandByType(context) {
|
|
270
|
+
if (context.command === "dev") {
|
|
271
|
+
runDevCommand(context.argsString);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (context.command === "build") {
|
|
275
|
+
runBuild(context.argsString);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (context.command === "config") {
|
|
279
|
+
runConfig();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
throw new Error(`Unsupported command: ${context.command ?? "undefined"}`);
|
|
94
283
|
}
|
|
95
|
-
__name(
|
|
284
|
+
__name(runCommandByType, "runCommandByType");
|
|
96
285
|
try {
|
|
97
|
-
|
|
98
|
-
} catch (
|
|
99
|
-
console.error("XFE
|
|
286
|
+
runCommandByType(parseCliContext());
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error("XFE BFF CLI \u6267\u884C\u51FA\u9519:", error);
|
|
100
289
|
process.exit(1);
|
|
101
290
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,35 +1,58 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__name,
|
|
3
2
|
configDeploy
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CUZB5IYH.mjs";
|
|
4
|
+
import {
|
|
5
|
+
runDevCommand,
|
|
6
|
+
runNestBuild
|
|
7
|
+
} from "./chunk-IX37L3FU.mjs";
|
|
8
|
+
import "./chunk-67SKOZPM.mjs";
|
|
9
|
+
import "./chunk-BAUM5HSG.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__name
|
|
12
|
+
} from "./chunk-O6YSETKJ.mjs";
|
|
5
13
|
|
|
6
14
|
// src/cli.ts
|
|
7
|
-
import { execSync } from "child_process";
|
|
8
15
|
import minimist from "minimist";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
function createArgsString(args) {
|
|
17
|
+
return Object.entries(args).map(([key, value]) => `--${key}=${value}`).join(" ");
|
|
18
|
+
}
|
|
19
|
+
__name(createArgsString, "createArgsString");
|
|
20
|
+
function parseCliContext() {
|
|
21
|
+
const argv = minimist(process.argv.slice(2));
|
|
22
|
+
const { _: commands, ...rawArgs } = argv;
|
|
23
|
+
return {
|
|
24
|
+
command: commands[0],
|
|
25
|
+
argsString: createArgsString(rawArgs)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
__name(parseCliContext, "parseCliContext");
|
|
29
|
+
function runBuild(argsString) {
|
|
30
|
+
runNestBuild(argsString);
|
|
31
|
+
}
|
|
32
|
+
__name(runBuild, "runBuild");
|
|
33
|
+
function runConfig() {
|
|
34
|
+
configDeploy();
|
|
35
|
+
}
|
|
36
|
+
__name(runConfig, "runConfig");
|
|
37
|
+
function runCommandByType(context) {
|
|
38
|
+
if (context.command === "dev") {
|
|
39
|
+
runDevCommand(context.argsString);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (context.command === "build") {
|
|
43
|
+
runBuild(context.argsString);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (context.command === "config") {
|
|
47
|
+
runConfig();
|
|
48
|
+
return;
|
|
27
49
|
}
|
|
50
|
+
throw new Error(`Unsupported command: ${context.command ?? "undefined"}`);
|
|
28
51
|
}
|
|
29
|
-
__name(
|
|
52
|
+
__name(runCommandByType, "runCommandByType");
|
|
30
53
|
try {
|
|
31
|
-
|
|
32
|
-
} catch (
|
|
33
|
-
console.error("XFE
|
|
54
|
+
runCommandByType(parseCliContext());
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("XFE BFF CLI \u6267\u884C\u51FA\u9519:", error);
|
|
34
57
|
process.exit(1);
|
|
35
58
|
}
|
package/dist/config.mjs
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/path-resolver.ts
|
|
32
|
+
var path_resolver_exports = {};
|
|
33
|
+
__export(path_resolver_exports, {
|
|
34
|
+
collectBffPackageDistPaths: () => collectBffPackageDistPaths
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(path_resolver_exports);
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var INTERNAL_BFF_PACKAGES_DIR = "../../packages/bff";
|
|
40
|
+
var SCOPE_PACKAGES_DIR = "node_modules/@xfe-repo";
|
|
41
|
+
var IGNORED_PACKAGE_NAME = "bff-app";
|
|
42
|
+
function collectScopedPackageDistPaths(cwd) {
|
|
43
|
+
const scopedPackagesPath = import_path.default.resolve(cwd, SCOPE_PACKAGES_DIR);
|
|
44
|
+
if (!import_fs.default.existsSync(scopedPackagesPath)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return import_fs.default.readdirSync(scopedPackagesPath).filter((packageName) => packageName.startsWith("bff-") && packageName !== IGNORED_PACKAGE_NAME).map((packageName) => import_path.default.join(scopedPackagesPath, packageName)).filter((packageLinkPath) => import_fs.default.existsSync(packageLinkPath)).map((packageLinkPath) => import_fs.default.realpathSync(packageLinkPath)).map((packageRootPath) => import_path.default.join(packageRootPath, "dist")).filter((distPath) => import_fs.default.existsSync(distPath));
|
|
48
|
+
}
|
|
49
|
+
__name(collectScopedPackageDistPaths, "collectScopedPackageDistPaths");
|
|
50
|
+
function collectInternalPackageDistPaths(cwd) {
|
|
51
|
+
const packagesRootPath = import_path.default.resolve(cwd, INTERNAL_BFF_PACKAGES_DIR);
|
|
52
|
+
if (!import_fs.default.existsSync(packagesRootPath)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return import_fs.default.readdirSync(packagesRootPath).filter((packageName) => packageName !== "app").map((packageName) => import_path.default.join(packagesRootPath, packageName, "dist")).filter((distPath) => import_fs.default.existsSync(distPath));
|
|
56
|
+
}
|
|
57
|
+
__name(collectInternalPackageDistPaths, "collectInternalPackageDistPaths");
|
|
58
|
+
function collectBffPackageDistPaths(cwd) {
|
|
59
|
+
const watchTargets = /* @__PURE__ */ new Set();
|
|
60
|
+
collectScopedPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
61
|
+
collectInternalPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
62
|
+
return Array.from(watchTargets);
|
|
63
|
+
}
|
|
64
|
+
__name(collectBffPackageDistPaths, "collectBffPackageDistPaths");
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
collectBffPackageDistPaths
|
|
68
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/process-manager.ts
|
|
32
|
+
var process_manager_exports = {};
|
|
33
|
+
__export(process_manager_exports, {
|
|
34
|
+
runDevCommand: () => runDevCommand,
|
|
35
|
+
runNestBuild: () => runNestBuild
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(process_manager_exports);
|
|
38
|
+
var import_child_process = require("child_process");
|
|
39
|
+
var import_path2 = __toESM(require("path"));
|
|
40
|
+
|
|
41
|
+
// src/path-resolver.ts
|
|
42
|
+
var import_fs = __toESM(require("fs"));
|
|
43
|
+
var import_path = __toESM(require("path"));
|
|
44
|
+
var INTERNAL_BFF_PACKAGES_DIR = "../../packages/bff";
|
|
45
|
+
var SCOPE_PACKAGES_DIR = "node_modules/@xfe-repo";
|
|
46
|
+
var IGNORED_PACKAGE_NAME = "bff-app";
|
|
47
|
+
function collectScopedPackageDistPaths(cwd) {
|
|
48
|
+
const scopedPackagesPath = import_path.default.resolve(cwd, SCOPE_PACKAGES_DIR);
|
|
49
|
+
if (!import_fs.default.existsSync(scopedPackagesPath)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return import_fs.default.readdirSync(scopedPackagesPath).filter((packageName) => packageName.startsWith("bff-") && packageName !== IGNORED_PACKAGE_NAME).map((packageName) => import_path.default.join(scopedPackagesPath, packageName)).filter((packageLinkPath) => import_fs.default.existsSync(packageLinkPath)).map((packageLinkPath) => import_fs.default.realpathSync(packageLinkPath)).map((packageRootPath) => import_path.default.join(packageRootPath, "dist")).filter((distPath) => import_fs.default.existsSync(distPath));
|
|
53
|
+
}
|
|
54
|
+
__name(collectScopedPackageDistPaths, "collectScopedPackageDistPaths");
|
|
55
|
+
function collectInternalPackageDistPaths(cwd) {
|
|
56
|
+
const packagesRootPath = import_path.default.resolve(cwd, INTERNAL_BFF_PACKAGES_DIR);
|
|
57
|
+
if (!import_fs.default.existsSync(packagesRootPath)) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return import_fs.default.readdirSync(packagesRootPath).filter((packageName) => packageName !== "app").map((packageName) => import_path.default.join(packagesRootPath, packageName, "dist")).filter((distPath) => import_fs.default.existsSync(distPath));
|
|
61
|
+
}
|
|
62
|
+
__name(collectInternalPackageDistPaths, "collectInternalPackageDistPaths");
|
|
63
|
+
function collectBffPackageDistPaths(cwd) {
|
|
64
|
+
const watchTargets = /* @__PURE__ */ new Set();
|
|
65
|
+
collectScopedPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
66
|
+
collectInternalPackageDistPaths(cwd).forEach((watchPath) => watchTargets.add(watchPath));
|
|
67
|
+
return Array.from(watchTargets);
|
|
68
|
+
}
|
|
69
|
+
__name(collectBffPackageDistPaths, "collectBffPackageDistPaths");
|
|
70
|
+
|
|
71
|
+
// src/watch-manager.ts
|
|
72
|
+
var import_fs2 = __toESM(require("fs"));
|
|
73
|
+
var JS_OUTPUT_FILE_REGEX = /\.(cjs|mjs|js)$/;
|
|
74
|
+
function shouldRestartOnFileChange(fileName) {
|
|
75
|
+
return JS_OUTPUT_FILE_REGEX.test(fileName);
|
|
76
|
+
}
|
|
77
|
+
__name(shouldRestartOnFileChange, "shouldRestartOnFileChange");
|
|
78
|
+
function createWatcher(watchPath, onChange) {
|
|
79
|
+
if (!import_fs2.default.existsSync(watchPath)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return import_fs2.default.watch(watchPath, {
|
|
83
|
+
recursive: true
|
|
84
|
+
}, (_eventType, filename) => {
|
|
85
|
+
if (!filename) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (shouldRestartOnFileChange(filename.toString())) {
|
|
89
|
+
onChange();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
__name(createWatcher, "createWatcher");
|
|
94
|
+
function closeWatchers(watchers) {
|
|
95
|
+
watchers.forEach((watcher) => watcher?.close());
|
|
96
|
+
}
|
|
97
|
+
__name(closeWatchers, "closeWatchers");
|
|
98
|
+
|
|
99
|
+
// src/process-manager.ts
|
|
100
|
+
var FILE_CHANGE_DEBOUNCE_MS = 300;
|
|
101
|
+
var RESTART_GUARD_MS = 5e3;
|
|
102
|
+
function spawnCommand(command) {
|
|
103
|
+
return (0, import_child_process.spawn)(command, {
|
|
104
|
+
stdio: "inherit",
|
|
105
|
+
env: process.env,
|
|
106
|
+
shell: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
__name(spawnCommand, "spawnCommand");
|
|
110
|
+
function runNestBuild(argsString) {
|
|
111
|
+
(0, import_child_process.execSync)(`nest build ${argsString}`, {
|
|
112
|
+
stdio: "inherit",
|
|
113
|
+
env: process.env
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
__name(runNestBuild, "runNestBuild");
|
|
117
|
+
function startAppProcess() {
|
|
118
|
+
return spawnCommand("node dist/main.js");
|
|
119
|
+
}
|
|
120
|
+
__name(startAppProcess, "startAppProcess");
|
|
121
|
+
function killProcess(child) {
|
|
122
|
+
if (!child.killed) {
|
|
123
|
+
child.kill("SIGTERM");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
__name(killProcess, "killProcess");
|
|
127
|
+
function runDevCommand(argsString) {
|
|
128
|
+
const cwd = process.cwd();
|
|
129
|
+
runNestBuild(argsString);
|
|
130
|
+
const buildWatcherProcess = spawnCommand(`nest build --watch --preserveWatchOutput ${argsString}`);
|
|
131
|
+
let appProcess = startAppProcess();
|
|
132
|
+
let isClosing = false;
|
|
133
|
+
let isRestarting = false;
|
|
134
|
+
let restartTimer = null;
|
|
135
|
+
const ignoreRestartBefore = Date.now() + RESTART_GUARD_MS;
|
|
136
|
+
const appDistWatcher = createWatcher(import_path2.default.resolve(cwd, "dist"), scheduleRestart);
|
|
137
|
+
const packageWatchers = collectBffPackageDistPaths(cwd).map((watchPath) => createWatcher(watchPath, scheduleRestart)).filter((watcher) => Boolean(watcher));
|
|
138
|
+
function exitAll(code = 0) {
|
|
139
|
+
isClosing = true;
|
|
140
|
+
if (restartTimer) {
|
|
141
|
+
clearTimeout(restartTimer);
|
|
142
|
+
restartTimer = null;
|
|
143
|
+
}
|
|
144
|
+
closeWatchers([
|
|
145
|
+
appDistWatcher,
|
|
146
|
+
...packageWatchers
|
|
147
|
+
]);
|
|
148
|
+
killProcess(appProcess);
|
|
149
|
+
killProcess(buildWatcherProcess);
|
|
150
|
+
process.exit(code);
|
|
151
|
+
}
|
|
152
|
+
__name(exitAll, "exitAll");
|
|
153
|
+
function attachAppExitGuard() {
|
|
154
|
+
appProcess.on("exit", (code) => {
|
|
155
|
+
if (isClosing || isRestarting) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (code !== 0) {
|
|
159
|
+
console.error(`node dist/main.js \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
160
|
+
exitAll(code ?? 1);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
__name(attachAppExitGuard, "attachAppExitGuard");
|
|
165
|
+
function restartApp() {
|
|
166
|
+
if (isClosing || isRestarting) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
isRestarting = true;
|
|
170
|
+
const startNextApp = /* @__PURE__ */ __name(() => {
|
|
171
|
+
if (isClosing) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
appProcess = startAppProcess();
|
|
175
|
+
attachAppExitGuard();
|
|
176
|
+
isRestarting = false;
|
|
177
|
+
}, "startNextApp");
|
|
178
|
+
if (appProcess.killed) {
|
|
179
|
+
startNextApp();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
appProcess.once("exit", startNextApp);
|
|
183
|
+
killProcess(appProcess);
|
|
184
|
+
}
|
|
185
|
+
__name(restartApp, "restartApp");
|
|
186
|
+
function scheduleRestart() {
|
|
187
|
+
if (Date.now() < ignoreRestartBefore) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (restartTimer) {
|
|
191
|
+
clearTimeout(restartTimer);
|
|
192
|
+
}
|
|
193
|
+
restartTimer = setTimeout(restartApp, FILE_CHANGE_DEBOUNCE_MS);
|
|
194
|
+
}
|
|
195
|
+
__name(scheduleRestart, "scheduleRestart");
|
|
196
|
+
process.on("SIGINT", () => exitAll(0));
|
|
197
|
+
process.on("SIGTERM", () => exitAll(0));
|
|
198
|
+
buildWatcherProcess.on("exit", (code) => {
|
|
199
|
+
if (isClosing) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (code !== 0) {
|
|
203
|
+
console.error(`nest build --watch \u9000\u51FA\uFF0Ccode: ${code ?? -1}`);
|
|
204
|
+
exitAll(code ?? 1);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
attachAppExitGuard();
|
|
208
|
+
}
|
|
209
|
+
__name(runDevCommand, "runDevCommand");
|
|
210
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
211
|
+
0 && (module.exports = {
|
|
212
|
+
runDevCommand,
|
|
213
|
+
runNestBuild
|
|
214
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/watch-manager.ts
|
|
32
|
+
var watch_manager_exports = {};
|
|
33
|
+
__export(watch_manager_exports, {
|
|
34
|
+
closeWatchers: () => closeWatchers,
|
|
35
|
+
createWatcher: () => createWatcher
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(watch_manager_exports);
|
|
38
|
+
var import_fs = __toESM(require("fs"));
|
|
39
|
+
var JS_OUTPUT_FILE_REGEX = /\.(cjs|mjs|js)$/;
|
|
40
|
+
function shouldRestartOnFileChange(fileName) {
|
|
41
|
+
return JS_OUTPUT_FILE_REGEX.test(fileName);
|
|
42
|
+
}
|
|
43
|
+
__name(shouldRestartOnFileChange, "shouldRestartOnFileChange");
|
|
44
|
+
function createWatcher(watchPath, onChange) {
|
|
45
|
+
if (!import_fs.default.existsSync(watchPath)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return import_fs.default.watch(watchPath, {
|
|
49
|
+
recursive: true
|
|
50
|
+
}, (_eventType, filename) => {
|
|
51
|
+
if (!filename) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (shouldRestartOnFileChange(filename.toString())) {
|
|
55
|
+
onChange();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
__name(createWatcher, "createWatcher");
|
|
60
|
+
function closeWatchers(watchers) {
|
|
61
|
+
watchers.forEach((watcher) => watcher?.close());
|
|
62
|
+
}
|
|
63
|
+
__name(closeWatchers, "closeWatchers");
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
closeWatchers,
|
|
67
|
+
createWatcher
|
|
68
|
+
});
|