rootless-config 1.4.1 → 1.4.3
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
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*-------- rootless migrate — moves existing root configs into .root container --------*/
|
|
2
2
|
|
|
3
3
|
import path from 'node:path'
|
|
4
|
-
import { readdir, unlink
|
|
4
|
+
import { readdir, unlink } from 'node:fs/promises'
|
|
5
5
|
import { createLogger } from '../../utils/logger.js'
|
|
6
|
-
import { fileExists, ensureDir, atomicWrite, readJsonFile } from '../../utils/fsUtils.js'
|
|
6
|
+
import { fileExists, ensureDir, atomicWrite, copyFile, readJsonFile } from '../../utils/fsUtils.js'
|
|
7
7
|
import { confirm } from '../../utils/prompt.js'
|
|
8
8
|
import { patchPackageScripts, isRootRequired, isPatchable, isWebAsset, NEVER_MIGRATE } from '../../core/scriptPatcher.js'
|
|
9
9
|
|
|
@@ -71,14 +71,16 @@ export default {
|
|
|
71
71
|
const destDir = path.join(containerPath, destSubdir)
|
|
72
72
|
|
|
73
73
|
await ensureDir(destDir)
|
|
74
|
-
const
|
|
75
|
-
await atomicWrite(path.join(destDir, name), content)
|
|
74
|
+
const dest = path.join(destDir, name)
|
|
76
75
|
|
|
77
76
|
if (isCleanMode) {
|
|
77
|
+
// Binary-safe stream copy — works for .png, .js, .css, etc.
|
|
78
|
+
await copyFile(src, dest)
|
|
78
79
|
await unlink(src)
|
|
79
80
|
logger.success(`Moved to .root/${destSubdir}/${name} (deleted from root)`)
|
|
80
81
|
} else {
|
|
81
|
-
|
|
82
|
+
await copyFile(src, dest)
|
|
83
|
+
const rel = path.relative(path.dirname(src), dest).replace(/\\/g, '/')
|
|
82
84
|
const relPath = rel.startsWith('.') ? rel : `./${rel}`
|
|
83
85
|
await atomicWrite(src, `export { default } from "${relPath}"\n`)
|
|
84
86
|
logger.success(`Migrated: ${name}`)
|
package/src/core/configSchema.js
CHANGED
|
@@ -17,8 +17,8 @@ function validateConfig(rawConfig) {
|
|
|
17
17
|
errors.push(new ValidationError('"containerPath" must be a string', 'containerPath'))
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
if (rawConfig.mode !== undefined && !['proxy', 'copy'].includes(rawConfig.mode)) {
|
|
21
|
-
errors.push(new ValidationError('"mode" must be "proxy" or "
|
|
20
|
+
if (rawConfig.mode !== undefined && !['proxy', 'copy', 'clean'].includes(rawConfig.mode)) {
|
|
21
|
+
errors.push(new ValidationError('"mode" must be "proxy", "copy", or "clean"', 'mode'))
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (rawConfig.plugins !== undefined && !Array.isArray(rawConfig.plugins)) {
|
|
@@ -287,6 +287,18 @@ const WEB_ASSET_PATTERNS = [
|
|
|
287
287
|
/^health\.json$/,
|
|
288
288
|
/^_redirects$/,
|
|
289
289
|
/^_headers$/,
|
|
290
|
+
// Generic web pages served from root (GitHub Pages, static sites)
|
|
291
|
+
/\.html?$/,
|
|
292
|
+
/\.php$/,
|
|
293
|
+
/\.md$/,
|
|
294
|
+
// Scripts that must run from root
|
|
295
|
+
/\.ps1$/,
|
|
296
|
+
/\.sh$/,
|
|
297
|
+
/\.(bat|cmd)$/,
|
|
298
|
+
// GitHub Pages markers
|
|
299
|
+
/^\.nojekyll$/,
|
|
300
|
+
/^CNAME$/i,
|
|
301
|
+
/^CXNAME$/i,
|
|
290
302
|
]
|
|
291
303
|
|
|
292
304
|
/**
|
|
@@ -342,7 +354,6 @@ function isRootRequired(filename) {
|
|
|
342
354
|
if (NEVER_MIGRATE.has(filename)) return false
|
|
343
355
|
if (ROOT_REQUIRED_FILES.has(filename)) return true
|
|
344
356
|
if (ROOT_REQUIRED_PATTERNS.some(p => p.test(filename))) return true
|
|
345
|
-
if (!isPatchable(filename)) return true // unknown file → safe default: copy to root
|
|
346
357
|
return false
|
|
347
358
|
}
|
|
348
359
|
|