filedist 0.21.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.
Files changed (154) hide show
  1. package/README.md +631 -0
  2. package/dist/cli/actions/check.d.ts +6 -0
  3. package/dist/cli/actions/check.d.ts.map +1 -0
  4. package/dist/cli/actions/check.js +36 -0
  5. package/dist/cli/actions/check.js.map +1 -0
  6. package/dist/cli/actions/extract.d.ts +7 -0
  7. package/dist/cli/actions/extract.d.ts.map +1 -0
  8. package/dist/cli/actions/extract.js +60 -0
  9. package/dist/cli/actions/extract.js.map +1 -0
  10. package/dist/cli/actions/init.d.ts +6 -0
  11. package/dist/cli/actions/init.d.ts.map +1 -0
  12. package/dist/cli/actions/init.js +30 -0
  13. package/dist/cli/actions/init.js.map +1 -0
  14. package/dist/cli/actions/list.d.ts +7 -0
  15. package/dist/cli/actions/list.d.ts.map +1 -0
  16. package/dist/cli/actions/list.js +30 -0
  17. package/dist/cli/actions/list.js.map +1 -0
  18. package/dist/cli/actions/presets.d.ts +7 -0
  19. package/dist/cli/actions/presets.d.ts.map +1 -0
  20. package/dist/cli/actions/presets.js +34 -0
  21. package/dist/cli/actions/presets.js.map +1 -0
  22. package/dist/cli/actions/purge.d.ts +6 -0
  23. package/dist/cli/actions/purge.d.ts.map +1 -0
  24. package/dist/cli/actions/purge.js +39 -0
  25. package/dist/cli/actions/purge.js.map +1 -0
  26. package/dist/cli/argv.d.ts +52 -0
  27. package/dist/cli/argv.d.ts.map +1 -0
  28. package/dist/cli/argv.js +172 -0
  29. package/dist/cli/argv.js.map +1 -0
  30. package/dist/cli/bin.d.ts +3 -0
  31. package/dist/cli/bin.d.ts.map +1 -0
  32. package/dist/cli/bin.js +10 -0
  33. package/dist/cli/bin.js.map +1 -0
  34. package/dist/cli/binpkg.d.ts +13 -0
  35. package/dist/cli/binpkg.d.ts.map +1 -0
  36. package/dist/cli/binpkg.js +38 -0
  37. package/dist/cli/binpkg.js.map +1 -0
  38. package/dist/cli/cli.d.ts +11 -0
  39. package/dist/cli/cli.d.ts.map +1 -0
  40. package/dist/cli/cli.js +118 -0
  41. package/dist/cli/cli.js.map +1 -0
  42. package/dist/cli/progress.d.ts +6 -0
  43. package/dist/cli/progress.d.ts.map +1 -0
  44. package/dist/cli/progress.js +12 -0
  45. package/dist/cli/progress.js.map +1 -0
  46. package/dist/cli/usage.d.ts +6 -0
  47. package/dist/cli/usage.d.ts.map +1 -0
  48. package/dist/cli/usage.js +151 -0
  49. package/dist/cli/usage.js.map +1 -0
  50. package/dist/fileset/check.d.ts +15 -0
  51. package/dist/fileset/check.d.ts.map +1 -0
  52. package/dist/fileset/check.js +70 -0
  53. package/dist/fileset/check.js.map +1 -0
  54. package/dist/fileset/constants.d.ts +18 -0
  55. package/dist/fileset/constants.d.ts.map +1 -0
  56. package/dist/fileset/constants.js +30 -0
  57. package/dist/fileset/constants.js.map +1 -0
  58. package/dist/fileset/diff.d.ts +16 -0
  59. package/dist/fileset/diff.d.ts.map +1 -0
  60. package/dist/fileset/diff.js +111 -0
  61. package/dist/fileset/diff.js.map +1 -0
  62. package/dist/fileset/execute.d.ts +29 -0
  63. package/dist/fileset/execute.d.ts.map +1 -0
  64. package/dist/fileset/execute.js +153 -0
  65. package/dist/fileset/execute.js.map +1 -0
  66. package/dist/fileset/gitignore.d.ts +20 -0
  67. package/dist/fileset/gitignore.d.ts.map +1 -0
  68. package/dist/fileset/gitignore.js +94 -0
  69. package/dist/fileset/gitignore.js.map +1 -0
  70. package/dist/fileset/index.d.ts +5 -0
  71. package/dist/fileset/index.d.ts.map +1 -0
  72. package/dist/fileset/index.js +22 -0
  73. package/dist/fileset/index.js.map +1 -0
  74. package/dist/fileset/markers.d.ts +22 -0
  75. package/dist/fileset/markers.d.ts.map +1 -0
  76. package/dist/fileset/markers.js +74 -0
  77. package/dist/fileset/markers.js.map +1 -0
  78. package/dist/fileset/package-files.d.ts +21 -0
  79. package/dist/fileset/package-files.d.ts.map +1 -0
  80. package/dist/fileset/package-files.js +102 -0
  81. package/dist/fileset/package-files.js.map +1 -0
  82. package/dist/fileset/purge.d.ts +18 -0
  83. package/dist/fileset/purge.d.ts.map +1 -0
  84. package/dist/fileset/purge.js +94 -0
  85. package/dist/fileset/purge.js.map +1 -0
  86. package/dist/fileset/test-utils.d.ts +21 -0
  87. package/dist/fileset/test-utils.d.ts.map +1 -0
  88. package/dist/fileset/test-utils.js +94 -0
  89. package/dist/fileset/test-utils.js.map +1 -0
  90. package/dist/index.d.ts +14 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +19 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/package/action-check.d.ts +20 -0
  95. package/dist/package/action-check.d.ts.map +1 -0
  96. package/dist/package/action-check.js +65 -0
  97. package/dist/package/action-check.js.map +1 -0
  98. package/dist/package/action-extract.d.ts +20 -0
  99. package/dist/package/action-extract.d.ts.map +1 -0
  100. package/dist/package/action-extract.js +280 -0
  101. package/dist/package/action-extract.js.map +1 -0
  102. package/dist/package/action-init.d.ts +13 -0
  103. package/dist/package/action-init.d.ts.map +1 -0
  104. package/dist/package/action-init.js +83 -0
  105. package/dist/package/action-init.js.map +1 -0
  106. package/dist/package/action-list.d.ts +11 -0
  107. package/dist/package/action-list.d.ts.map +1 -0
  108. package/dist/package/action-list.js +12 -0
  109. package/dist/package/action-list.js.map +1 -0
  110. package/dist/package/action-purge.d.ts +19 -0
  111. package/dist/package/action-purge.d.ts.map +1 -0
  112. package/dist/package/action-purge.js +135 -0
  113. package/dist/package/action-purge.js.map +1 -0
  114. package/dist/package/calculate-diff.d.ts +12 -0
  115. package/dist/package/calculate-diff.d.ts.map +1 -0
  116. package/dist/package/calculate-diff.js +129 -0
  117. package/dist/package/calculate-diff.js.map +1 -0
  118. package/dist/package/config-merge.d.ts +19 -0
  119. package/dist/package/config-merge.d.ts.map +1 -0
  120. package/dist/package/config-merge.js +65 -0
  121. package/dist/package/config-merge.js.map +1 -0
  122. package/dist/package/config.d.ts +24 -0
  123. package/dist/package/config.d.ts.map +1 -0
  124. package/dist/package/config.js +86 -0
  125. package/dist/package/config.js.map +1 -0
  126. package/dist/package/content-replacements.d.ts +21 -0
  127. package/dist/package/content-replacements.d.ts.map +1 -0
  128. package/dist/package/content-replacements.js +94 -0
  129. package/dist/package/content-replacements.js.map +1 -0
  130. package/dist/package/index.d.ts +10 -0
  131. package/dist/package/index.d.ts.map +1 -0
  132. package/dist/package/index.js +16 -0
  133. package/dist/package/index.js.map +1 -0
  134. package/dist/package/resolve-files.d.ts +29 -0
  135. package/dist/package/resolve-files.d.ts.map +1 -0
  136. package/dist/package/resolve-files.js +225 -0
  137. package/dist/package/resolve-files.js.map +1 -0
  138. package/dist/package/source.d.ts +20 -0
  139. package/dist/package/source.d.ts.map +1 -0
  140. package/dist/package/source.js +193 -0
  141. package/dist/package/source.js.map +1 -0
  142. package/dist/package/symlinks.d.ts +25 -0
  143. package/dist/package/symlinks.d.ts.map +1 -0
  144. package/dist/package/symlinks.js +203 -0
  145. package/dist/package/symlinks.js.map +1 -0
  146. package/dist/types.d.ts +345 -0
  147. package/dist/types.d.ts.map +1 -0
  148. package/dist/types.js +3 -0
  149. package/dist/types.js.map +1 -0
  150. package/dist/utils.d.ts +60 -0
  151. package/dist/utils.d.ts.map +1 -0
  152. package/dist/utils.js +341 -0
  153. package/dist/utils.js.map +1 -0
  154. package/package.json +58 -0
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculateDiff = calculateDiff;
7
+ /* eslint-disable no-console */
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const gitignore_1 = require("../fileset/gitignore");
11
+ const utils_1 = require("../utils");
12
+ const markers_1 = require("../fileset/markers");
13
+ const content_replacements_1 = require("./content-replacements");
14
+ /**
15
+ * Calculate the diff between the desired file list (from resolveFiles) and the
16
+ * actual state of each output directory.
17
+ *
18
+ * Only managed files (tracked in .filedist markers) are included in the 'extra'
19
+ * analysis, scoped to the packages represented in `resolvedFiles`.
20
+ *
21
+ * @returns DiffResult classifying each file as ok, missing, extra, or conflict.
22
+ */
23
+ async function calculateDiff(resolvedFiles, verbose, cwd, relevantPackagesByOutputDir) {
24
+ const result = { ok: [], missing: [], extra: [], conflict: [] };
25
+ if (resolvedFiles.length === 0 &&
26
+ (!relevantPackagesByOutputDir || relevantPackagesByOutputDir.size === 0)) {
27
+ return result;
28
+ }
29
+ // Group resolved files by output directory
30
+ const byOutputDir = new Map();
31
+ for (const f of resolvedFiles) {
32
+ const arr = byOutputDir.get(f.outputDir) ?? [];
33
+ arr.push(f);
34
+ byOutputDir.set(f.outputDir, arr);
35
+ }
36
+ const outputDirs = new Set([
37
+ ...byOutputDir.keys(),
38
+ ...(relevantPackagesByOutputDir?.keys() ?? []),
39
+ ]);
40
+ for (const outputDir of outputDirs) {
41
+ await appendOutputDirDiff(outputDir, byOutputDir.get(outputDir) ?? [], result, relevantPackagesByOutputDir?.get(outputDir));
42
+ if (verbose) {
43
+ console.log(`[verbose] calculateDiff: ${(0, utils_1.formatDisplayPath)(outputDir, cwd)}: ` +
44
+ `ok=${result.ok.length} missing=${result.missing.length} ` +
45
+ `conflict=${result.conflict.length} extra=${result.extra.length}`);
46
+ }
47
+ }
48
+ return result;
49
+ }
50
+ async function appendOutputDirDiff(outputDir, desiredFiles, result, relevantPackages) {
51
+ const existingMarker = await (0, markers_1.readOutputDirMarker)(outputDir);
52
+ const managedByPath = new Map(existingMarker.map((m) => [m.path, m]));
53
+ const desiredByPath = new Map(desiredFiles.map((f) => [f.relPath, f]));
54
+ const gitignorePaths = (0, gitignore_1.readManagedGitignoreEntries)(outputDir);
55
+ const outputRelevantPackages = relevantPackages ?? new Set(desiredFiles.map((f) => f.packageName));
56
+ for (const desired of desiredFiles) {
57
+ await classifyDesiredFile(desired, outputDir, managedByPath, gitignorePaths, result);
58
+ }
59
+ for (const markerEntry of existingMarker) {
60
+ if (outputRelevantPackages.has(markerEntry.packageName) &&
61
+ !desiredByPath.has(markerEntry.path)) {
62
+ result.extra.push({
63
+ status: 'extra',
64
+ relPath: markerEntry.path,
65
+ outputDir,
66
+ existing: markerEntry,
67
+ });
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Classify a single desired file against the current output directory state.
73
+ * Appends to the appropriate result bucket (ok, missing, or conflict).
74
+ */
75
+ async function classifyDesiredFile(desired, outputDir, managedByPath, gitignorePaths, result) {
76
+ const destPath = node_path_1.default.join(outputDir, desired.relPath);
77
+ const destExists = node_fs_1.default.existsSync(destPath);
78
+ if (!destExists) {
79
+ result.missing.push({ status: 'missing', relPath: desired.relPath, outputDir, desired });
80
+ return;
81
+ }
82
+ const conflictReasons = [];
83
+ // Content check
84
+ let srcHash;
85
+ try {
86
+ if (desired.contentReplacements.length > 0) {
87
+ const srcContent = node_fs_1.default.readFileSync(desired.sourcePath, 'utf8');
88
+ const transformed = (0, content_replacements_1.applyContentReplacementsToBuffer)(srcContent, desired.contentReplacements);
89
+ srcHash = (0, utils_1.hashBuffer)(transformed);
90
+ }
91
+ else {
92
+ srcHash = await (0, utils_1.hashFile)(desired.sourcePath);
93
+ }
94
+ }
95
+ catch {
96
+ srcHash = await (0, utils_1.hashFile)(desired.sourcePath);
97
+ }
98
+ const destHash = await (0, utils_1.hashFile)(destPath);
99
+ if (srcHash !== destHash)
100
+ conflictReasons.push('content');
101
+ // Managed-state check
102
+ const isManaged = managedByPath.has(desired.relPath);
103
+ if (desired.managed !== isManaged)
104
+ conflictReasons.push('managed');
105
+ // Gitignore-state check
106
+ const isGitignored = gitignorePaths.has(desired.relPath);
107
+ if (desired.gitignore !== isGitignored)
108
+ conflictReasons.push('gitignore');
109
+ if (conflictReasons.length === 0) {
110
+ result.ok.push({
111
+ status: 'ok',
112
+ relPath: desired.relPath,
113
+ outputDir,
114
+ desired,
115
+ existing: managedByPath.get(desired.relPath),
116
+ });
117
+ }
118
+ else {
119
+ result.conflict.push({
120
+ status: 'conflict',
121
+ relPath: desired.relPath,
122
+ outputDir,
123
+ desired,
124
+ existing: managedByPath.get(desired.relPath),
125
+ conflictReasons,
126
+ });
127
+ }
128
+ }
129
+ //# sourceMappingURL=calculate-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-diff.js","sourceRoot":"","sources":["../../src/package/calculate-diff.ts"],"names":[],"mappings":";;;;;AAoBA,sCA8CC;AAlED,+BAA+B;AAC/B,sDAAyB;AACzB,0DAA6B;AAG7B,oDAAmE;AACnE,oCAAmE;AACnE,gDAAyD;AAEzD,iEAA0E;AAE1E;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CACjC,aAA6B,EAC7B,OAAiB,EACjB,GAAY,EACZ,2BAAsD;IAEtD,MAAM,MAAM,GAAe,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAE5E,IACE,aAAa,CAAC,MAAM,KAAK,CAAC;QAC1B,CAAC,CAAC,2BAA2B,IAAI,2BAA2B,CAAC,IAAI,KAAK,CAAC,CAAC,EACxE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,2CAA2C;IAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA0B,CAAC;IACtD,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS;QACjC,GAAG,WAAW,CA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GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YACnB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS;YACT,OAAO;YACP,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;YAC5C,eAAe;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { SelectorConfig, OutputConfig } from '../types';
2
+ /**
3
+ * Merge two SelectorConfig objects across recursion levels.
4
+ * - files: ANDed (intersection); when either is absent, use the other's list
5
+ * - exclude: concatenated (both exclusion lists apply)
6
+ * - contentRegexes: ANDed (both must match)
7
+ * - presets: NOT inherited (caller's presets not forwarded to dependency)
8
+ * - upgrade: each level evaluated independently (not merged)
9
+ */
10
+ export declare function mergeSelectorConfig(parent: SelectorConfig, child: SelectorConfig): SelectorConfig;
11
+ /**
12
+ * Merge two OutputConfig objects for recursive extraction.
13
+ * - force, keepExisting, gitignore, managed, noSync, dryRun: caller value overrides child
14
+ * - path: concatenated (parent/child), undefined treated as '.'
15
+ * - symlinks: appended (parent + child)
16
+ * - contentReplacements: appended (parent + child)
17
+ */
18
+ export declare function mergeOutputConfig(caller: OutputConfig, child: OutputConfig): OutputConfig;
19
+ //# sourceMappingURL=config-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-merge.d.ts","sourceRoot":"","sources":["../../src/package/config-merge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,GAAG,cAAc,CAwBjG;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,YAAY,CAoBzF"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mergeSelectorConfig = mergeSelectorConfig;
7
+ exports.mergeOutputConfig = mergeOutputConfig;
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ /**
10
+ * Merge two SelectorConfig objects across recursion levels.
11
+ * - files: ANDed (intersection); when either is absent, use the other's list
12
+ * - exclude: concatenated (both exclusion lists apply)
13
+ * - contentRegexes: ANDed (both must match)
14
+ * - presets: NOT inherited (caller's presets not forwarded to dependency)
15
+ * - upgrade: each level evaluated independently (not merged)
16
+ */
17
+ function mergeSelectorConfig(parent, child) {
18
+ const parentGroups = parent.filePatternGroups ?? (parent.files ? [parent.files] : []);
19
+ const childGroups = child.filePatternGroups ?? (child.files ? [child.files] : []);
20
+ const filePatternGroups = [...parentGroups, ...childGroups];
21
+ const files = filePatternGroups.length > 0
22
+ ? [...new Set(filePatternGroups.flat())]
23
+ : (parent.files ?? child.files);
24
+ const contentRegexes = parent.contentRegexes && child.contentRegexes
25
+ ? [...parent.contentRegexes, ...child.contentRegexes]
26
+ : (parent.contentRegexes ?? child.contentRegexes);
27
+ const exclude = [...(parent.exclude ?? []), ...(child.exclude ?? [])];
28
+ return {
29
+ files,
30
+ ...(filePatternGroups.length > 0 ? { filePatternGroups } : {}),
31
+ exclude,
32
+ contentRegexes,
33
+ presets: child.presets, // not inherited from parent
34
+ upgrade: child.upgrade, // each level independent
35
+ };
36
+ }
37
+ /**
38
+ * Merge two OutputConfig objects for recursive extraction.
39
+ * - force, keepExisting, gitignore, managed, noSync, dryRun: caller value overrides child
40
+ * - path: concatenated (parent/child), undefined treated as '.'
41
+ * - symlinks: appended (parent + child)
42
+ * - contentReplacements: appended (parent + child)
43
+ */
44
+ function mergeOutputConfig(caller, child) {
45
+ const callerPath = caller.path ?? '.';
46
+ const childPath = child.path ?? '.';
47
+ // When childPath is absolute it overrides the inherited path entirely.
48
+ // path.join('.', '/absolute') would strip the leading slash, so we check explicitly.
49
+ const mergedPath = node_path_1.default.isAbsolute(childPath) ? childPath : node_path_1.default.join(callerPath, childPath);
50
+ return {
51
+ path: mergedPath,
52
+ force: caller.force ?? child.force,
53
+ keepExisting: caller.keepExisting ?? child.keepExisting,
54
+ gitignore: caller.gitignore ?? child.gitignore,
55
+ managed: caller.managed ?? child.managed,
56
+ noSync: caller.noSync ?? child.noSync,
57
+ dryRun: caller.dryRun ?? child.dryRun,
58
+ symlinks: [...(caller.symlinks ?? []), ...(child.symlinks ?? [])],
59
+ contentReplacements: [
60
+ ...(caller.contentReplacements ?? []),
61
+ ...(child.contentReplacements ?? []),
62
+ ],
63
+ };
64
+ }
65
+ //# sourceMappingURL=config-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-merge.js","sourceRoot":"","sources":["../../src/package/config-merge.ts"],"names":[],"mappings":";;;;;AAYA,kDAwBC;AASD,8CAoBC;AAjED,0DAA6B;AAI7B;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,MAAsB,EAAE,KAAqB;IAC/E,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtF,MAAM,WAAW,GAAG,KAAK,CAAC,iBAAiB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClF,MAAM,iBAAiB,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,WAAW,CAAC,CAAC;IAC5D,MAAM,KAAK,GACT,iBAAiB,CAAC,MAAM,GAAG,CAAC;QAC1B,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;QAChB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK;QAClC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY;QACvD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS;QAC9C,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;QACxC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM;QACrC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM;QACrC,QAAQ,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QACjE,mBAAmB,EAAE;YACnB,GAAG,CAAC,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC;YACrC,GAAG,CAAC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC;SACrC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { FiledistConfig } from '../types';
2
+ /**
3
+ * Search for a filedist configuration using cosmiconfig, starting from the given cwd.
4
+ * Looks for (in priority order):
5
+ * - .filedistrc (JSON or YAML)
6
+ * - .filedistrc.json / .filedistrc.yaml / .filedistrc.js
7
+ * - filedist.config.js
8
+ * - "filedist" key in package.json
9
+ *
10
+ * Returns the FiledistConfig when found, or null when no configuration is present.
11
+ */
12
+ export declare function searchAndLoadFiledistConfig(cwd: string): Promise<FiledistConfig | null>;
13
+ /**
14
+ * Load a filedist configuration from an explicit file path using cosmiconfig.
15
+ * Supports JSON, YAML, and JS config files.
16
+ *
17
+ * Returns the FiledistConfig when found, or null when the file is empty or invalid.
18
+ */
19
+ export declare function loadFiledistConfigFile(filePath: string): Promise<FiledistConfig | null>;
20
+ /**
21
+ * Load filedist config only from the given directory, without searching parent folders.
22
+ */
23
+ export declare function loadFiledistConfigFromDirectory(directory: string): Promise<FiledistConfig | null>;
24
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/package/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAY1C;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAa7F;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAa7F;AAED;;GAEG;AACH,wBAAsB,+BAA+B,CACnD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAuBhC"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchAndLoadFiledistConfig = searchAndLoadFiledistConfig;
4
+ exports.loadFiledistConfigFile = loadFiledistConfigFile;
5
+ exports.loadFiledistConfigFromDirectory = loadFiledistConfigFromDirectory;
6
+ const cosmiconfig_1 = require("cosmiconfig");
7
+ const CONFIG_BASENAMES = [
8
+ '.filedistrc',
9
+ '.filedistrc.json',
10
+ '.filedistrc.yaml',
11
+ '.filedistrc.yml',
12
+ 'filedist.config.js',
13
+ 'filedist.config.cjs',
14
+ 'package.json',
15
+ ];
16
+ /**
17
+ * Search for a filedist configuration using cosmiconfig, starting from the given cwd.
18
+ * Looks for (in priority order):
19
+ * - .filedistrc (JSON or YAML)
20
+ * - .filedistrc.json / .filedistrc.yaml / .filedistrc.js
21
+ * - filedist.config.js
22
+ * - "filedist" key in package.json
23
+ *
24
+ * Returns the FiledistConfig when found, or null when no configuration is present.
25
+ */
26
+ async function searchAndLoadFiledistConfig(cwd) {
27
+ const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
28
+ const result = await explorer.search(cwd);
29
+ if (!result || result.isEmpty) {
30
+ // eslint-disable-next-line unicorn/no-null
31
+ return null;
32
+ }
33
+ const cfg = result.config;
34
+ if (!cfg || !Array.isArray(cfg.sets)) {
35
+ // eslint-disable-next-line unicorn/no-null
36
+ return null;
37
+ }
38
+ return cfg;
39
+ }
40
+ /**
41
+ * Load a filedist configuration from an explicit file path using cosmiconfig.
42
+ * Supports JSON, YAML, and JS config files.
43
+ *
44
+ * Returns the FiledistConfig when found, or null when the file is empty or invalid.
45
+ */
46
+ async function loadFiledistConfigFile(filePath) {
47
+ const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
48
+ const result = await explorer.load(filePath);
49
+ if (!result || result.isEmpty) {
50
+ // eslint-disable-next-line unicorn/no-null
51
+ return null;
52
+ }
53
+ const cfg = result.config;
54
+ if (!cfg || !Array.isArray(cfg.sets)) {
55
+ // eslint-disable-next-line unicorn/no-null
56
+ return null;
57
+ }
58
+ return cfg;
59
+ }
60
+ /**
61
+ * Load filedist config only from the given directory, without searching parent folders.
62
+ */
63
+ async function loadFiledistConfigFromDirectory(directory) {
64
+ const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
65
+ for (const basename of CONFIG_BASENAMES) {
66
+ let result;
67
+ try {
68
+ result = await explorer.load(`${directory}/${basename}`);
69
+ }
70
+ catch (error) {
71
+ if (error.code === 'ENOENT') {
72
+ continue;
73
+ }
74
+ throw error;
75
+ }
76
+ if (!result || result.isEmpty)
77
+ continue;
78
+ const cfg = result.config;
79
+ if (cfg && Array.isArray(cfg.sets)) {
80
+ return cfg;
81
+ }
82
+ }
83
+ // eslint-disable-next-line unicorn/no-null
84
+ return null;
85
+ }
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/package/config.ts"],"names":[],"mappings":";;AAwBA,kEAaC;AAQD,wDAaC;AAKD,0EAyBC;AAxFD,6CAA0C;AAI1C,MAAM,gBAAgB,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iB;IAEjB,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,UAAU,CAAC,CAAC;IAEzC,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE,CAAC;QACxC,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACvD,SAAS;YACX,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO;YAAE,SAAS;QAExC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAwB,CAAC;QAC5C,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,2CAA2C;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { ContentReplacementConfig } from '../types';
2
+ /**
3
+ * Apply content replacement rules to an in-memory string (pure function).
4
+ * Used during check comparison to apply the same transformations before hashing,
5
+ * so replaced files are not falsely reported as modified.
6
+ *
7
+ * @param content The file content as a string.
8
+ * @param replacements List of ContentReplacementConfig to apply.
9
+ * @returns Transformed content string.
10
+ */
11
+ export declare function applyContentReplacementsToBuffer(content: string, replacements: ContentReplacementConfig[]): string;
12
+ /**
13
+ * Apply content replacement rules to files on disk matching the given glob patterns.
14
+ * Skips binary files.
15
+ *
16
+ * @param files List of absolute file paths to apply replacements to.
17
+ * Pre-resolved by the caller via glob matching.
18
+ * @param replacements List of ContentReplacementConfig to apply.
19
+ */
20
+ export declare function applyContentReplacements(cwd: string, replacements: ContentReplacementConfig[]): Promise<void>;
21
+ //# sourceMappingURL=content-replacements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-replacements.d.ts","sourceRoot":"","sources":["../../src/package/content-replacements.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,wBAAwB,EAAE,GACvC,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,wBAAwB,EAAE,GACvC,OAAO,CAAC,IAAI,CAAC,CAwBf"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.applyContentReplacementsToBuffer = applyContentReplacementsToBuffer;
7
+ exports.applyContentReplacements = applyContentReplacements;
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const minimatch_1 = require("minimatch");
11
+ const utils_1 = require("../utils");
12
+ /**
13
+ * Apply content replacement rules to an in-memory string (pure function).
14
+ * Used during check comparison to apply the same transformations before hashing,
15
+ * so replaced files are not falsely reported as modified.
16
+ *
17
+ * @param content The file content as a string.
18
+ * @param replacements List of ContentReplacementConfig to apply.
19
+ * @returns Transformed content string.
20
+ */
21
+ function applyContentReplacementsToBuffer(content, replacements) {
22
+ let result = content;
23
+ for (const replacement of replacements) {
24
+ const regex = new RegExp(replacement.match, 'g');
25
+ result = result.replace(regex, replacement.replace);
26
+ }
27
+ return result;
28
+ }
29
+ /**
30
+ * Apply content replacement rules to files on disk matching the given glob patterns.
31
+ * Skips binary files.
32
+ *
33
+ * @param files List of absolute file paths to apply replacements to.
34
+ * Pre-resolved by the caller via glob matching.
35
+ * @param replacements List of ContentReplacementConfig to apply.
36
+ */
37
+ async function applyContentReplacements(cwd, replacements) {
38
+ if (replacements.length === 0)
39
+ return;
40
+ // Find all files matching any replacement's files glob under cwd
41
+ const allFiles = collectFilesForReplacements(cwd, replacements);
42
+ for (const filePath of allFiles) {
43
+ if ((0, utils_1.isBinaryFile)(filePath))
44
+ continue;
45
+ try {
46
+ const content = node_fs_1.default.readFileSync(filePath, 'utf8');
47
+ const transformed = applyContentReplacementsToBuffer(content, replacements);
48
+ if (transformed !== content) {
49
+ // Make writable, write, restore writability status
50
+ const stat = node_fs_1.default.statSync(filePath);
51
+ const wasReadOnly = (stat.mode & 0o200) === 0;
52
+ if (wasReadOnly)
53
+ node_fs_1.default.chmodSync(filePath, 0o644);
54
+ node_fs_1.default.writeFileSync(filePath, transformed, 'utf8');
55
+ if (wasReadOnly)
56
+ node_fs_1.default.chmodSync(filePath, 0o444);
57
+ }
58
+ }
59
+ catch {
60
+ // Skip unreadable files
61
+ }
62
+ }
63
+ }
64
+ /**
65
+ * Collect all files under cwd matching at least one replacement's files glob.
66
+ */
67
+ function collectFilesForReplacements(cwd, replacements) {
68
+ const globs = replacements.map((r) => r.files);
69
+ const results = [];
70
+ const walk = (dir) => {
71
+ for (const entry of node_fs_1.default.readdirSync(dir)) {
72
+ const fullPath = node_path_1.default.join(dir, entry);
73
+ const stat = node_fs_1.default.lstatSync(fullPath);
74
+ if (stat.isSymbolicLink())
75
+ continue;
76
+ if (stat.isDirectory()) {
77
+ walk(fullPath);
78
+ continue;
79
+ }
80
+ const relPath = node_path_1.default.relative(cwd, fullPath);
81
+ if (globs.some((glob) => (0, minimatch_1.minimatch)(relPath, glob, { dot: true }))) {
82
+ results.push(fullPath);
83
+ }
84
+ }
85
+ };
86
+ try {
87
+ walk(cwd);
88
+ }
89
+ catch {
90
+ // ignore
91
+ }
92
+ return results;
93
+ }
94
+ //# sourceMappingURL=content-replacements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-replacements.js","sourceRoot":"","sources":["../../src/package/content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QACH,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { actionExtract } from './action-extract';
2
+ export type { ExtractOptions, ExtractResult } from './action-extract';
3
+ export { actionCheck } from './action-check';
4
+ export type { CheckOptions, CheckSummary } from './action-check';
5
+ export { actionList } from './action-list';
6
+ export type { ListOptions } from './action-list';
7
+ export { actionPurge } from './action-purge';
8
+ export type { PurgeOptions, PurgeSummary } from './action-purge';
9
+ export { mergeSelectorConfig, mergeOutputConfig } from './config-merge';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeOutputConfig = exports.mergeSelectorConfig = exports.actionPurge = exports.actionList = exports.actionCheck = exports.actionExtract = void 0;
4
+ // Public package-layer API
5
+ var action_extract_1 = require("./action-extract");
6
+ Object.defineProperty(exports, "actionExtract", { enumerable: true, get: function () { return action_extract_1.actionExtract; } });
7
+ var action_check_1 = require("./action-check");
8
+ Object.defineProperty(exports, "actionCheck", { enumerable: true, get: function () { return action_check_1.actionCheck; } });
9
+ var action_list_1 = require("./action-list");
10
+ Object.defineProperty(exports, "actionList", { enumerable: true, get: function () { return action_list_1.actionList; } });
11
+ var action_purge_1 = require("./action-purge");
12
+ Object.defineProperty(exports, "actionPurge", { enumerable: true, get: function () { return action_purge_1.actionPurge; } });
13
+ var config_merge_1 = require("./config-merge");
14
+ Object.defineProperty(exports, "mergeSelectorConfig", { enumerable: true, get: function () { return config_merge_1.mergeSelectorConfig; } });
15
+ Object.defineProperty(exports, "mergeOutputConfig", { enumerable: true, get: function () { return config_merge_1.mergeOutputConfig; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAC3B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAGtB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAGnB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,+CAAwE;AAA/D,mHAAA,mBAAmB,OAAA;AAAE,iHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,29 @@
1
+ import { FiledistExtractEntry, ResolvedFile, ProgressEvent } from '../types';
2
+ import { SourceRuntime } from './source';
3
+ export type ResolveOptions = {
4
+ cwd: string;
5
+ verbose?: boolean;
6
+ onProgress?: (event: ProgressEvent) => void;
7
+ sourceRuntime?: SourceRuntime;
8
+ };
9
+ export type ResolveFilesDetailedResult = {
10
+ files: ResolvedFile[];
11
+ relevantPackagesByOutputDir: Map<string, Set<string>>;
12
+ noSyncOutputDirs: Set<string>;
13
+ };
14
+ /**
15
+ * Recursively resolve all entries into a flat list of desired files.
16
+ *
17
+ * Two entry types are handled:
18
+ * - Self-package entry (no `package` field): enumerates files directly from the
19
+ * package context provided by the parent recursion level.
20
+ * - External-package entry (`package` field set): installs the package, reads its
21
+ * filedist.sets, and recurses; when the package has no sets, files are enumerated
22
+ * directly (leaf behaviour).
23
+ *
24
+ * Duplicate (outputDir, relPath) pairs are deduplicated; conflicting managed/gitignore
25
+ * settings for the same destination path throw an error.
26
+ */
27
+ export declare function resolveFiles(entries: FiledistExtractEntry[], options: ResolveOptions): Promise<ResolvedFile[]>;
28
+ export declare function resolveFilesDetailed(entries: FiledistExtractEntry[], options: ResolveOptions): Promise<ResolveFilesDetailedResult>;
29
+ //# sourceMappingURL=resolve-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-files.d.ts","sourceRoot":"","sources":["../../src/package/resolve-files.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EAGpB,YAAY,EACZ,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB,OAAO,EAA2C,aAAa,EAAE,MAAM,UAAU,CAAC;AAElF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AA6BF;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,oBAAoB,EAAE,EAC/B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC,CAGzB;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,EAAE,EAC/B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,0BAA0B,CAAC,CAyBrC"}