@gxp-dev/tools 2.0.89 → 2.0.91
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/bin/lib/cli.js +12 -0
- package/bin/lib/commands/dev.js +4 -1
- package/bin/lib/utils/paths.js +8 -2
- package/package.json +1 -1
- package/runtime/vite.config.js +24 -0
package/bin/lib/cli.js
CHANGED
|
@@ -51,6 +51,18 @@ const cli = yargs
|
|
|
51
51
|
default: false,
|
|
52
52
|
global: true,
|
|
53
53
|
})
|
|
54
|
+
.option("use-global", {
|
|
55
|
+
describe:
|
|
56
|
+
"Force-use the global @gxp-dev/tools install (runtime, vite config, templates) and ignore any local node_modules copy",
|
|
57
|
+
type: "boolean",
|
|
58
|
+
default: false,
|
|
59
|
+
global: true,
|
|
60
|
+
})
|
|
61
|
+
.middleware((argv) => {
|
|
62
|
+
if (argv["use-global"]) {
|
|
63
|
+
process.env.GXDEV_USE_GLOBAL = "true"
|
|
64
|
+
}
|
|
65
|
+
})
|
|
54
66
|
.command(
|
|
55
67
|
"ui",
|
|
56
68
|
"Open the interactive Terminal UI without auto-starting anything",
|
package/bin/lib/commands/dev.js
CHANGED
|
@@ -229,8 +229,11 @@ function devCommand(argv) {
|
|
|
229
229
|
)
|
|
230
230
|
const installLocation =
|
|
231
231
|
paths.packageRoot === localToolkitDir ? "local" : "package"
|
|
232
|
+
const forcedGlobal = process.env.GXDEV_USE_GLOBAL === "true"
|
|
232
233
|
logger.info(
|
|
233
|
-
`📦 Using ${installLocation} toolkit install: ${paths.packageRoot}
|
|
234
|
+
`📦 Using ${installLocation} toolkit install: ${paths.packageRoot}${
|
|
235
|
+
forcedGlobal ? " (forced via --use-global)" : ""
|
|
236
|
+
}`,
|
|
234
237
|
)
|
|
235
238
|
|
|
236
239
|
// Load .env file if it exists for default values
|
package/bin/lib/utils/paths.js
CHANGED
|
@@ -45,9 +45,15 @@ function findProjectRoot() {
|
|
|
45
45
|
function resolveGxPaths() {
|
|
46
46
|
const projectRoot = findProjectRoot()
|
|
47
47
|
|
|
48
|
-
//
|
|
48
|
+
// Honor --use-global (propagated by cli.js as GXDEV_USE_GLOBAL=true) to
|
|
49
|
+
// force the CLI's own install location, even if a local node_modules copy
|
|
50
|
+
// of @gxp-dev/tools exists. Useful when the local version is stale or
|
|
51
|
+
// being debugged against the globally installed toolkit.
|
|
52
|
+
const forceGlobal = process.env.GXDEV_USE_GLOBAL === "true"
|
|
53
|
+
|
|
54
|
+
// Try local installation first (unless --use-global)
|
|
49
55
|
const localNodeModules = path.join(projectRoot, "node_modules", PACKAGE_NAME)
|
|
50
|
-
if (fs.existsSync(localNodeModules)) {
|
|
56
|
+
if (!forceGlobal && fs.existsSync(localNodeModules)) {
|
|
51
57
|
return {
|
|
52
58
|
gentoPath: path.join(localNodeModules, "bin", getBinaryName()),
|
|
53
59
|
viteConfigPath: path.join(localNodeModules, "runtime", "vite.config.js"),
|
package/package.json
CHANGED
package/runtime/vite.config.js
CHANGED
|
@@ -191,6 +191,30 @@ export default defineConfig(async (ctx) => {
|
|
|
191
191
|
// Create plugin to serve runtime files (index.html and main.js) if no local ones exist
|
|
192
192
|
const runtimeFilesPlugin = {
|
|
193
193
|
name: "runtime-files",
|
|
194
|
+
// Resolve the legacy `/@gx-runtime/*` absolute-URL form used by
|
|
195
|
+
// runtime/index.html (and by any project index.html that hasn't
|
|
196
|
+
// migrated to the bare `@gx-runtime/...` specifier). Vite's
|
|
197
|
+
// resolve.alias map only catches bare specifiers, and the
|
|
198
|
+
// configureServer middleware below only catches HTTP requests —
|
|
199
|
+
// Vite's internal pre-transform of script-src URLs takes
|
|
200
|
+
// neither path and ends up logging
|
|
201
|
+
// "Pre-transform error: Failed to load url /@gx-runtime/main.js"
|
|
202
|
+
// every render tick. Returning the real filesystem path here
|
|
203
|
+
// short-circuits the resolution entirely so pre-transform, the
|
|
204
|
+
// dep optimizer, and SSR all agree on where the file lives.
|
|
205
|
+
resolveId(id) {
|
|
206
|
+
if (typeof id !== "string") return null
|
|
207
|
+
if (id.startsWith("/@gx-runtime/")) {
|
|
208
|
+
const relative = id.slice("/@gx-runtime/".length)
|
|
209
|
+
if (!relative) return null
|
|
210
|
+
// Strip any query string (e.g. ?t=12345 from HMR) before
|
|
211
|
+
// resolving against the filesystem.
|
|
212
|
+
const [bare, query] = relative.split("?")
|
|
213
|
+
const resolved = path.resolve(runtimeDir, bare)
|
|
214
|
+
return query ? `${resolved}?${query}` : resolved
|
|
215
|
+
}
|
|
216
|
+
return null
|
|
217
|
+
},
|
|
194
218
|
configureServer(server) {
|
|
195
219
|
server.middlewares.use((req, res, next) => {
|
|
196
220
|
// Serve runtime index.html for root requests and SPA navigation requests
|