@dword-design/nuxt-custom-cli 2.0.2 → 2.0.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/module.js +22 -4
- package/package.json +6 -2
package/dist/module.js
CHANGED
|
@@ -7,11 +7,9 @@ const TEMPLATE_FOLDER = "custom-cli";
|
|
|
7
7
|
export default defineNuxtModule({
|
|
8
8
|
setup: (options, nuxt) => {
|
|
9
9
|
const defineCustomCliTemplate = addTemplate({
|
|
10
|
-
filename: pathLib.join(TEMPLATE_FOLDER, "define-custom-cli.
|
|
10
|
+
filename: pathLib.join(TEMPLATE_FOLDER, "define-custom-cli.mjs"),
|
|
11
11
|
getContents: () => endent`
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
export const defineCustomCli = (handler: CustomCliHandler) =>
|
|
12
|
+
export const defineCustomCli = handler =>
|
|
15
13
|
Object.defineProperty(handler, '${DEFINE_WRAPPER_USED_MARKER}', {
|
|
16
14
|
configurable: false,
|
|
17
15
|
enumerable: false,
|
|
@@ -21,6 +19,15 @@ export default defineNuxtModule({
|
|
|
21
19
|
`,
|
|
22
20
|
write: true
|
|
23
21
|
});
|
|
22
|
+
addTemplate({
|
|
23
|
+
filename: pathLib.join(TEMPLATE_FOLDER, "define-custom-cli.d.mts"),
|
|
24
|
+
getContents: () => endent`
|
|
25
|
+
export type CustomCliHandler = () => unknown;
|
|
26
|
+
|
|
27
|
+
export const defineCustomCli: (handler: CustomCliHandler) => CustomCliHandler;
|
|
28
|
+
`,
|
|
29
|
+
write: true
|
|
30
|
+
});
|
|
24
31
|
addServerImports({
|
|
25
32
|
as: "defineCustomCli",
|
|
26
33
|
from: defineCustomCliTemplate.dst,
|
|
@@ -99,6 +106,17 @@ export default defineNuxtModule({
|
|
|
99
106
|
...rollupConfig.input,
|
|
100
107
|
cli: entry.dst
|
|
101
108
|
};
|
|
109
|
+
const noListenPlugin = {
|
|
110
|
+
name: "nuxt-custom-cli-no-listen",
|
|
111
|
+
renderChunk: (code, chunk) => {
|
|
112
|
+
if (!chunk.fileName.endsWith("/nitro/nitro.mjs")) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const noListenPatchedCode = code.replace("const listener = server.listen(path ? { path } : { port, host }, (err) => {", "const isCliEntry = (process.argv[1] || '').replaceAll('\\\\', '/').endsWith('/cli.mjs');\nconst listener = isCliEntry ? null : server.listen(path ? { path } : { port, host }, (err) => {").replace("setupGracefulShutdown(listener, nitroApp);", "if (listener) {\n setupGracefulShutdown(listener, nitroApp);\n}");
|
|
116
|
+
return noListenPatchedCode === code ? null : noListenPatchedCode;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
rollupConfig.plugins = Array.isArray(rollupConfig.plugins) ? [...rollupConfig.plugins, noListenPlugin] : rollupConfig.plugins ? [rollupConfig.plugins, noListenPlugin] : [noListenPlugin];
|
|
102
120
|
rollupConfig.output.entryFileNames = chunkInfo => {
|
|
103
121
|
if (chunkInfo.facadeModuleId === entry.dst) return "cli.mjs";
|
|
104
122
|
if (chunkInfo.name === "node-server") return "index.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dword-design/nuxt-custom-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"repository": "dword-design/nuxt-custom-cli",
|
|
5
5
|
"funding": "https://github.com/sponsors/dword-design",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,13 +37,17 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@dword-design/base": "^16.2.3",
|
|
39
39
|
"@dword-design/base-config-nuxt-module": "^5.0.1",
|
|
40
|
+
"@playwright/browser-chromium": "^1.58.2",
|
|
40
41
|
"@playwright/test": "^1.58.2",
|
|
41
42
|
"@types/fs-extra": "^11.0.4",
|
|
42
43
|
"@types/node": "^25.3.2",
|
|
43
44
|
"fs-extra": "^11.3.3",
|
|
45
|
+
"get-port": "^7.1.0",
|
|
44
46
|
"nuxt": "^4.3.1",
|
|
45
47
|
"output-files": "^4.0.0",
|
|
46
|
-
"
|
|
48
|
+
"port-ready": "npm:@dword-design/port-ready-fork@^0.0.3",
|
|
49
|
+
"strip-ansi": "^7.2.0",
|
|
50
|
+
"tree-kill-promise": "^5.0.0"
|
|
47
51
|
},
|
|
48
52
|
"packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017",
|
|
49
53
|
"engines": {
|