stonyx 0.2.3-alpha.21 → 0.2.3-alpha.23
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/cli/serve.d.ts +1 -0
- package/dist/cli/serve.js +16 -1
- package/package.json +4 -3
- package/scripts/postinstall.js +15 -0
package/dist/cli/serve.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type StoynxModule } from '../lifecycle.js';
|
|
2
2
|
export declare function createShutdownHandler(modules: StoynxModule[]): () => Promise<void>;
|
|
3
|
+
export declare function maybeRegisterAppShutdown(modules: StoynxModule[], appInstance: unknown, originalShutdown: () => Promise<void>): void;
|
|
3
4
|
export default function serve({ args }: {
|
|
4
5
|
args: string[];
|
|
5
6
|
}): Promise<void>;
|
package/dist/cli/serve.js
CHANGED
|
@@ -9,6 +9,19 @@ export function createShutdownHandler(modules) {
|
|
|
9
9
|
process.exit(0);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
export function maybeRegisterAppShutdown(modules, appInstance, originalShutdown) {
|
|
13
|
+
if (appInstance &&
|
|
14
|
+
typeof appInstance.shutdown === 'function') {
|
|
15
|
+
const appShutdown = createShutdownHandler([
|
|
16
|
+
...modules,
|
|
17
|
+
appInstance
|
|
18
|
+
]);
|
|
19
|
+
process.removeListener('SIGTERM', originalShutdown);
|
|
20
|
+
process.removeListener('SIGINT', originalShutdown);
|
|
21
|
+
process.on('SIGTERM', appShutdown);
|
|
22
|
+
process.on('SIGINT', appShutdown);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
12
25
|
export default async function serve({ args }) {
|
|
13
26
|
const cwd = process.cwd();
|
|
14
27
|
const entryFlag = args.indexOf('--entry');
|
|
@@ -23,7 +36,9 @@ export default async function serve({ args }) {
|
|
|
23
36
|
process.on('SIGTERM', shutdown);
|
|
24
37
|
process.on('SIGINT', shutdown);
|
|
25
38
|
const entryModule = await import(`${cwd}/${entryPoint}`);
|
|
39
|
+
let appInstance;
|
|
26
40
|
if (entryModule.default) {
|
|
27
|
-
new entryModule.default();
|
|
41
|
+
appInstance = new entryModule.default();
|
|
28
42
|
}
|
|
43
|
+
maybeRegisterAppShutdown(modules, appInstance, shutdown);
|
|
29
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stonyx",
|
|
3
|
-
"version": "0.2.3-alpha.
|
|
3
|
+
"version": "0.2.3-alpha.23",
|
|
4
4
|
"description": "Base stonyx framework module",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|
|
39
39
|
"config",
|
|
40
|
+
"scripts",
|
|
40
41
|
"README.md"
|
|
41
42
|
],
|
|
42
43
|
"publishConfig": {
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"url": "https://github.com/abofs/stonyx/issues"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@stonyx/utils": "0.2.3-beta.
|
|
55
|
-
"@stonyx/logs": "1.0.1-beta.
|
|
55
|
+
"@stonyx/utils": "0.2.3-beta.21",
|
|
56
|
+
"@stonyx/logs": "1.0.1-beta.14"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@types/node": "^25.5.2",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Skip postinstall for global installations
|
|
2
|
+
const isGlobal = !process.env.INIT_CWD || process.env.npm_config_global === 'true';
|
|
3
|
+
if (isGlobal) process.exit(0);
|
|
4
|
+
|
|
5
|
+
const { copyFile, createDirectory } = await import('@stonyx/utils/file');
|
|
6
|
+
|
|
7
|
+
const projectDir = process.env.INIT_CWD;
|
|
8
|
+
const configDir = `${projectDir}/config`;
|
|
9
|
+
const envFile = 'environment.js';
|
|
10
|
+
|
|
11
|
+
createDirectory(configDir);
|
|
12
|
+
|
|
13
|
+
copyFile(`./config/environment copy.js`, `${configDir}/${envFile}`).then(result => {
|
|
14
|
+
if (result) console.log(`Stonyx: ${envFile} has been successfully created. Please see README.md for more information.`);
|
|
15
|
+
});
|