@joystick.js/cli-canary 0.0.0-canary.143 → 0.0.0-canary.145
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/lib/dev/index.js +33 -22
- package/package.json +1 -1
- package/src/lib/dev/index.js +32 -23
package/dist/lib/dev/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { SETTINGS_FILE_NAME_REGEX } from "../regexes.js";
|
|
|
19
19
|
import getCodependenciesForFile from "./getCodependenciesForFile.js";
|
|
20
20
|
import removeDeletedDependenciesFromMap from "../build/removeDeletedDependenciesFromMap.js";
|
|
21
21
|
import chalk from "chalk";
|
|
22
|
+
const processIds = [];
|
|
22
23
|
const getDatabaseProcessIds = () => {
|
|
23
24
|
try {
|
|
24
25
|
const databaseProcessIds = [];
|
|
@@ -43,7 +44,7 @@ const getDatabaseProcessIds = () => {
|
|
|
43
44
|
throw new Error(`[dev.getDatabaseProcessIds] ${exception.message}`);
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
|
-
const handleSignalEvents = (
|
|
47
|
+
const handleSignalEvents = (processIds2 = [], nodeMajorVersion = 0, __dirname = "") => {
|
|
47
48
|
try {
|
|
48
49
|
const execArgv = ["--no-warnings"];
|
|
49
50
|
if (nodeMajorVersion < 19) {
|
|
@@ -65,12 +66,12 @@ const handleSignalEvents = (processIds = [], nodeMajorVersion = 0, __dirname = "
|
|
|
65
66
|
process.cleanupProcess = cleanupProcess;
|
|
66
67
|
process.on("SIGINT", async () => {
|
|
67
68
|
const databaseProcessIds = getDatabaseProcessIds();
|
|
68
|
-
cleanupProcess.send(JSON.stringify({ processIds: [...
|
|
69
|
+
cleanupProcess.send(JSON.stringify({ processIds: [...processIds2, ...databaseProcessIds] }));
|
|
69
70
|
process.exit();
|
|
70
71
|
});
|
|
71
72
|
process.on("SIGTERM", async () => {
|
|
72
73
|
const databaseProcessIds = getDatabaseProcessIds();
|
|
73
|
-
cleanupProcess.send(JSON.stringify({ processIds: [...
|
|
74
|
+
cleanupProcess.send(JSON.stringify({ processIds: [...processIds2, ...databaseProcessIds] }));
|
|
74
75
|
process.exit();
|
|
75
76
|
});
|
|
76
77
|
} catch (exception) {
|
|
@@ -257,13 +258,7 @@ const handleRestartApplicationProcess = async (options = {}) => {
|
|
|
257
258
|
process.loader.text("Restarting app...");
|
|
258
259
|
}
|
|
259
260
|
process.serverProcess.kill();
|
|
260
|
-
await
|
|
261
|
-
nodeMajorVersion: options?.nodeMajorVersion,
|
|
262
|
-
port: options?.port,
|
|
263
|
-
sessionsBeforeHMRUpdate: options?.sessionsBeforeHMRUpdate
|
|
264
|
-
});
|
|
265
|
-
handleServerProcessSTDIO();
|
|
266
|
-
handleServerProcessMessages();
|
|
261
|
+
await handleStartAppServer(options);
|
|
267
262
|
return Promise.resolve();
|
|
268
263
|
}
|
|
269
264
|
process.loader.text("Starting app...");
|
|
@@ -275,6 +270,23 @@ const handleRestartApplicationProcess = async (options = {}) => {
|
|
|
275
270
|
throw new Error(`[dev.handleRestartApplicationProcess] ${exception.message}`);
|
|
276
271
|
}
|
|
277
272
|
};
|
|
273
|
+
const handleStartAppServer = async (options = {}) => {
|
|
274
|
+
try {
|
|
275
|
+
const serverProcess = await startApp({
|
|
276
|
+
nodeMajorVersion: options?.nodeMajorVersion,
|
|
277
|
+
port: options?.port,
|
|
278
|
+
sessionsBeforeHMRUpdate: options?.sessionsBeforeHMRUpdate
|
|
279
|
+
});
|
|
280
|
+
if (serverProcess) {
|
|
281
|
+
processIds.push(serverProcess.pid);
|
|
282
|
+
process.serverProcess = serverProcess;
|
|
283
|
+
handleServerProcessSTDIO();
|
|
284
|
+
handleServerProcessMessages();
|
|
285
|
+
}
|
|
286
|
+
} catch (exception) {
|
|
287
|
+
throw new Error(`[actionName.handleStartAppServer] ${exception.message}`);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
278
290
|
const handleNotifyHMRClients = async (indexHTMLChanged = false) => {
|
|
279
291
|
try {
|
|
280
292
|
if (process.hmrProcess) {
|
|
@@ -491,18 +503,14 @@ const dev = async (options, { resolve, reject }) => {
|
|
|
491
503
|
settings: settings.parsed
|
|
492
504
|
});
|
|
493
505
|
await runInitialBuild(settings?.parsed?.config?.build);
|
|
494
|
-
await startFileWatcher(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
506
|
+
await startFileWatcher({
|
|
507
|
+
...options,
|
|
508
|
+
nodeMajorVersion
|
|
509
|
+
});
|
|
510
|
+
await handleStartAppServer({
|
|
511
|
+
...options,
|
|
512
|
+
nodeMajorVersion
|
|
499
513
|
});
|
|
500
|
-
if (serverProcess) {
|
|
501
|
-
processIds.push(serverProcess.pid);
|
|
502
|
-
process.serverProcess = serverProcess;
|
|
503
|
-
handleServerProcessSTDIO();
|
|
504
|
-
handleServerProcessMessages();
|
|
505
|
-
}
|
|
506
514
|
if (options?.environment !== "test") {
|
|
507
515
|
const hmrProcess = await startHMR({
|
|
508
516
|
nodeMajorVersion,
|
|
@@ -511,7 +519,10 @@ const dev = async (options, { resolve, reject }) => {
|
|
|
511
519
|
processIds.push(hmrProcess.pid);
|
|
512
520
|
process.hmrProcess = hmrProcess;
|
|
513
521
|
handleHMRProcessSTDIO();
|
|
514
|
-
handleHMRProcessMessages(
|
|
522
|
+
handleHMRProcessMessages({
|
|
523
|
+
...options,
|
|
524
|
+
nodeMajorVersion
|
|
525
|
+
});
|
|
515
526
|
}
|
|
516
527
|
handleSignalEvents(
|
|
517
528
|
processIds,
|
package/package.json
CHANGED
package/src/lib/dev/index.js
CHANGED
|
@@ -22,6 +22,8 @@ import getCodependenciesForFile from "./getCodependenciesForFile.js";
|
|
|
22
22
|
import removeDeletedDependenciesFromMap from "../build/removeDeletedDependenciesFromMap.js";
|
|
23
23
|
import chalk from "chalk";
|
|
24
24
|
|
|
25
|
+
const processIds = [];
|
|
26
|
+
|
|
25
27
|
const getDatabaseProcessIds = () => {
|
|
26
28
|
try {
|
|
27
29
|
const databaseProcessIds = [];
|
|
@@ -313,16 +315,7 @@ const handleRestartApplicationProcess = async (options = {}) => {
|
|
|
313
315
|
|
|
314
316
|
process.serverProcess.kill();
|
|
315
317
|
|
|
316
|
-
await
|
|
317
|
-
nodeMajorVersion: options?.nodeMajorVersion,
|
|
318
|
-
port: options?.port,
|
|
319
|
-
sessionsBeforeHMRUpdate: options?.sessionsBeforeHMRUpdate,
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// NOTE: Reattach process event handlers here because the ones down below
|
|
323
|
-
// are stale after a restart.
|
|
324
|
-
handleServerProcessSTDIO();
|
|
325
|
-
handleServerProcessMessages();
|
|
318
|
+
await handleStartAppServer(options);
|
|
326
319
|
|
|
327
320
|
return Promise.resolve();
|
|
328
321
|
}
|
|
@@ -339,6 +332,25 @@ const handleRestartApplicationProcess = async (options = {}) => {
|
|
|
339
332
|
}
|
|
340
333
|
};
|
|
341
334
|
|
|
335
|
+
const handleStartAppServer = async (options = {}) => {
|
|
336
|
+
try {
|
|
337
|
+
const serverProcess = await startApp({
|
|
338
|
+
nodeMajorVersion: options?.nodeMajorVersion,
|
|
339
|
+
port: options?.port,
|
|
340
|
+
sessionsBeforeHMRUpdate: options?.sessionsBeforeHMRUpdate,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
if (serverProcess) {
|
|
344
|
+
processIds.push(serverProcess.pid);
|
|
345
|
+
process.serverProcess = serverProcess;
|
|
346
|
+
handleServerProcessSTDIO();
|
|
347
|
+
handleServerProcessMessages();
|
|
348
|
+
}
|
|
349
|
+
} catch (exception) {
|
|
350
|
+
throw new Error(`[actionName.handleStartAppServer] ${exception.message}`);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
342
354
|
const handleNotifyHMRClients = async (indexHTMLChanged = false) => {
|
|
343
355
|
try {
|
|
344
356
|
if (process.hmrProcess) {
|
|
@@ -590,21 +602,15 @@ const dev = async (options, { resolve, reject }) => {
|
|
|
590
602
|
});
|
|
591
603
|
|
|
592
604
|
await runInitialBuild(settings?.parsed?.config?.build);
|
|
593
|
-
await startFileWatcher(
|
|
594
|
-
|
|
595
|
-
const processIds = [];
|
|
596
|
-
|
|
597
|
-
const serverProcess = await startApp({
|
|
605
|
+
await startFileWatcher({
|
|
606
|
+
...options,
|
|
598
607
|
nodeMajorVersion,
|
|
599
|
-
port: options?.port,
|
|
600
608
|
});
|
|
601
609
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
handleServerProcessMessages();
|
|
607
|
-
}
|
|
610
|
+
await handleStartAppServer({
|
|
611
|
+
...options,
|
|
612
|
+
nodeMajorVersion,
|
|
613
|
+
});
|
|
608
614
|
|
|
609
615
|
if (options?.environment !== 'test') {
|
|
610
616
|
const hmrProcess = await startHMR({
|
|
@@ -616,7 +622,10 @@ const dev = async (options, { resolve, reject }) => {
|
|
|
616
622
|
process.hmrProcess = hmrProcess;
|
|
617
623
|
|
|
618
624
|
handleHMRProcessSTDIO();
|
|
619
|
-
handleHMRProcessMessages(
|
|
625
|
+
handleHMRProcessMessages({
|
|
626
|
+
...options,
|
|
627
|
+
nodeMajorVersion,
|
|
628
|
+
});
|
|
620
629
|
}
|
|
621
630
|
|
|
622
631
|
|