@dword-design/nuxt-custom-cli 2.0.3 → 2.0.5
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.d.ts +1 -0
- package/dist/module.js +18 -0
- package/package.json +6 -2
package/dist/module.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const CUSTOM_CLI_ERROR_MESSAGE = "Default export from server/cli.ts must be wrapped with defineCustomCli(...).";
|
|
2
|
+
export declare const PROD_NITRO_PATCH_ERROR_MESSAGE = "Failed to patch Nitro server startup code. Nuxt internals may have changed and nuxt-custom-cli needs an update.";
|
|
2
3
|
declare const _default: import("@nuxt/schema").NuxtModule<import("@nuxt/schema").ModuleOptions, import("@nuxt/schema").ModuleOptions, false>;
|
|
3
4
|
export default _default;
|
package/dist/module.js
CHANGED
|
@@ -2,6 +2,7 @@ import pathLib from "node:path";
|
|
|
2
2
|
import { addServerImports, addServerPlugin, addTemplate, defineNuxtModule } from "@nuxt/kit";
|
|
3
3
|
import endent from "endent";
|
|
4
4
|
export const CUSTOM_CLI_ERROR_MESSAGE = "Default export from server/cli.ts must be wrapped with defineCustomCli(...).";
|
|
5
|
+
export const PROD_NITRO_PATCH_ERROR_MESSAGE = "Failed to patch Nitro server startup code. Nuxt internals may have changed and nuxt-custom-cli needs an update.";
|
|
5
6
|
const DEFINE_WRAPPER_USED_MARKER = "__defineCustomCliUsed";
|
|
6
7
|
const TEMPLATE_FOLDER = "custom-cli";
|
|
7
8
|
export default defineNuxtModule({
|
|
@@ -106,6 +107,23 @@ export default defineNuxtModule({
|
|
|
106
107
|
...rollupConfig.input,
|
|
107
108
|
cli: entry.dst
|
|
108
109
|
};
|
|
110
|
+
const noListenPlugin = {
|
|
111
|
+
name: "nuxt-custom-cli-no-listen",
|
|
112
|
+
renderChunk: (code, chunk) => {
|
|
113
|
+
if (!chunk.fileName.endsWith("/nitro/nitro.mjs")) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const listenSnippet = "const listener = server.listen(path ? { path } : { port, host }, (err) => {";
|
|
117
|
+
const shutdownSnippet = "setupGracefulShutdown(listener, nitroApp);";
|
|
118
|
+
const listenReplacement = "const isCliEntry = (process.argv[1] || '').replaceAll('\\\\', '/').endsWith('/cli.mjs');\nconst listener = isCliEntry ? null : server.listen(path ? { path } : { port, host }, (err) => {";
|
|
119
|
+
const shutdownReplacement = "if (listener) {\n setupGracefulShutdown(listener, nitroApp);\n}";
|
|
120
|
+
if (!code.includes(listenSnippet) || !code.includes(shutdownSnippet)) {
|
|
121
|
+
throw new Error(PROD_NITRO_PATCH_ERROR_MESSAGE);
|
|
122
|
+
}
|
|
123
|
+
return code.replace(listenSnippet, listenReplacement).replace(shutdownSnippet, shutdownReplacement);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
rollupConfig.plugins = Array.isArray(rollupConfig.plugins) ? [...rollupConfig.plugins, noListenPlugin] : rollupConfig.plugins ? [rollupConfig.plugins, noListenPlugin] : [noListenPlugin];
|
|
109
127
|
rollupConfig.output.entryFileNames = chunkInfo => {
|
|
110
128
|
if (chunkInfo.facadeModuleId === entry.dst) return "cli.mjs";
|
|
111
129
|
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.5",
|
|
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": {
|