rootless-config 1.4.4 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rootless-config",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
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": {
@@ -5,20 +5,38 @@ import { readdir, 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'
8
- import { patchPackageScripts, isRootRequired, isPatchable, isWebAsset, NEVER_MIGRATE } from '../../core/scriptPatcher.js'
8
+ import { patchPackageScripts, isPatchable, NEVER_MIGRATE } from '../../core/scriptPatcher.js'
9
9
 
10
- // A file is migratable when rootless knows what to do with it:
11
- // - isRootRequired must be in root (will be copied there by prepare)
12
- // - isPatchable → can be redirected via --config flag in package.json scripts
13
- // Anything that's NEVER_MIGRATE (lock files, package.json) is excluded.
10
+ // Files that are OS/editor/VCS noise never migrate, never touch
11
+ const SYSTEM_FILES = new Set([
12
+ '.DS_Store', 'Thumbs.db', 'desktop.ini', '.git', '.svn',
13
+ ])
14
14
 
15
+ /**
16
+ * Determine which .root sub-folder a file should land in:
17
+ * env/ — .env* files (always copied to root by prepare)
18
+ * configs/ — tool configs that support --config flags (scripts get patched)
19
+ * assets/ — everything else (always copied to root by prepare)
20
+ */
21
+ function getDestSubdir(filename) {
22
+ if (/^\.env/.test(filename)) return 'env'
23
+ if (isPatchable(filename)) return 'configs'
24
+ return 'assets'
25
+ }
26
+
27
+ /**
28
+ * Returns ALL files in projectRoot that should be migrated.
29
+ * Excludes: directories, package manager lock files, OS noise.
30
+ */
15
31
  async function findMigratableFiles(projectRoot) {
16
32
  const entries = await readdir(projectRoot, { withFileTypes: true })
17
33
  return entries
18
34
  .filter(e => {
19
35
  if (!e.isFile()) return false
20
36
  if (NEVER_MIGRATE.has(e.name)) return false
21
- return isRootRequired(e.name) || isPatchable(e.name)
37
+ if (SYSTEM_FILES.has(e.name)) return false
38
+ if (e.name === '.root') return false
39
+ return true // migrate EVERYTHING else
22
40
  })
23
41
  .map(e => e.name)
24
42
  .sort()
@@ -66,8 +84,7 @@ export default {
66
84
 
67
85
  for (const name of candidates) {
68
86
  const src = path.join(projectRoot, name)
69
- const isEnv = /^\.env/.test(name)
70
- const destSubdir = isEnv ? 'env' : (isWebAsset(name) ? 'assets' : 'configs')
87
+ const destSubdir = getDestSubdir(name)
71
88
  const destDir = path.join(containerPath, destSubdir)
72
89
 
73
90
  await ensureDir(destDir)