rootless-config 1.4.2 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rootless-config",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Store project config files outside the project root, auto-deploy them where tools expect them.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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, readFile } from 'node:fs/promises'
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 content = await readFile(src, 'utf8')
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
- const rel = path.relative(path.dirname(src), path.join(destDir, name)).replace(/\\/g, '/')
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}`)
@@ -30,7 +30,10 @@ async function generateFile({ source, target, mode = 'proxy', plugin, options =
30
30
 
31
31
  if (plugin?.generate) {
32
32
  const content = await plugin.generate(source, { mode, target, options })
33
- await atomicWrite(target, content)
33
+ // null/undefined means the plugin wrote the file itself (e.g. assetPlugin binary copy)
34
+ if (content != null) {
35
+ await atomicWrite(target, content)
36
+ }
34
37
  } else if (mode === 'proxy') {
35
38
  const rel = path.relative(path.dirname(target), source).replace(/\\/g, '/')
36
39
  const relPath = rel.startsWith('.') ? rel : `./${rel}`