rootless-config 1.8.1 → 1.8.2
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/package.json +1 -1
- package/src/cli/commands/migrate.js +18 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*-------- rootless migrate — moves existing root configs into .root container --------*/
|
|
2
2
|
|
|
3
3
|
import path from 'node:path'
|
|
4
|
-
import { readdir, unlink } from 'node:fs/promises'
|
|
4
|
+
import { readdir, readFile, unlink } from 'node:fs/promises'
|
|
5
5
|
import { createLogger } from '../../utils/logger.js'
|
|
6
6
|
import { fileExists, ensureDir, atomicWrite, copyFile, readJsonFile } from '../../utils/fsUtils.js'
|
|
7
7
|
import { confirm } from '../../utils/prompt.js'
|
|
@@ -94,7 +94,7 @@ export default {
|
|
|
94
94
|
if (isCleanMode) {
|
|
95
95
|
// For PS1 server scripts: patch $root before writing to .root/assets/
|
|
96
96
|
if (name.endsWith('.ps1')) {
|
|
97
|
-
const raw = await
|
|
97
|
+
const raw = await readFile(src, 'utf8')
|
|
98
98
|
const patched = patchServerScript(raw)
|
|
99
99
|
if (patched) {
|
|
100
100
|
await atomicWrite(dest, patched)
|
|
@@ -103,6 +103,22 @@ export default {
|
|
|
103
103
|
continue
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
// For .cmd/.bat launcher scripts: fix relative path to .ps1 → use %~dp0
|
|
107
|
+
// so the ps1 is found relative to the cmd file's own location
|
|
108
|
+
if (name.endsWith('.cmd') || name.endsWith('.bat')) {
|
|
109
|
+
const raw = await readFile(src, 'utf8')
|
|
110
|
+
// Replace: -File .server.ps1 → -File "%~dp0.server.ps1"
|
|
111
|
+
const patched = raw.replace(
|
|
112
|
+
/(-File\s+)(?!")([^\s"]+\.ps1)/gi,
|
|
113
|
+
(_, flag, ps1) => `${flag}"%~dp0${ps1}"`
|
|
114
|
+
)
|
|
115
|
+
if (patched !== raw) {
|
|
116
|
+
await atomicWrite(dest, patched)
|
|
117
|
+
await unlink(src)
|
|
118
|
+
logger.success(`Moved+patched .root/${destSubdir}/${name} (ps1 path → %~dp0-relative)`)
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
}
|
|
106
122
|
// Binary-safe stream copy — works for .png, .js, .css, etc.
|
|
107
123
|
await copyFile(src, dest)
|
|
108
124
|
await unlink(src)
|