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,203 @@
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.createSymlinks = createSymlinks;
7
+ exports.collectManagedSymlinkEntries = collectManagedSymlinkEntries;
8
+ exports.removeStaleSymlinks = removeStaleSymlinks;
9
+ exports.isManagedSymlinkEntry = isManagedSymlinkEntry;
10
+ exports.isManagedFileEntry = isManagedFileEntry;
11
+ exports.findManagedSymlinkEntries = findManagedSymlinkEntries;
12
+ exports.uniqueSymlinkConfigs = uniqueSymlinkConfigs;
13
+ exports.removeAllSymlinks = removeAllSymlinks;
14
+ const node_fs_1 = __importDefault(require("node:fs"));
15
+ const node_path_1 = __importDefault(require("node:path"));
16
+ const minimatch_1 = require("minimatch");
17
+ const utils_1 = require("../utils");
18
+ /**
19
+ * Create symlinks for all files/dirs in outputDir matching source globs.
20
+ * Each matching source is symlinked into the target directory.
21
+ * Symlinks are created as relative paths.
22
+ */
23
+ async function createSymlinks(outputDir, configs) {
24
+ for (const config of configs) {
25
+ const targetDir = node_path_1.default.resolve(outputDir, config.target);
26
+ (0, utils_1.ensureDir)(targetDir);
27
+ const matches = findMatchingPaths(outputDir, config.source);
28
+ for (const relPath of matches) {
29
+ const srcAbsPath = node_path_1.default.join(outputDir, relPath);
30
+ const linkName = node_path_1.default.basename(relPath);
31
+ const linkPath = node_path_1.default.join(targetDir, linkName);
32
+ const relTarget = node_path_1.default.relative(targetDir, srcAbsPath);
33
+ if (isSymlink(linkPath)) {
34
+ try {
35
+ if (node_fs_1.default.readlinkSync(linkPath) === relTarget) {
36
+ continue;
37
+ }
38
+ }
39
+ catch {
40
+ // fall through and recreate the symlink below
41
+ }
42
+ }
43
+ // Remove existing symlink if present
44
+ if (node_fs_1.default.existsSync(linkPath) || isSymlink(linkPath)) {
45
+ node_fs_1.default.unlinkSync(linkPath);
46
+ }
47
+ // Create relative symlink
48
+ node_fs_1.default.symlinkSync(relTarget, linkPath);
49
+ }
50
+ }
51
+ }
52
+ /**
53
+ * Collect marker entries for managed symlinks created in an output directory.
54
+ *
55
+ * Symlink ownership is attributed to the package/config combination that declared
56
+ * the symlink operation. Duplicate output paths keep the first discovered owner.
57
+ */
58
+ function collectManagedSymlinkEntries(outputDir, files) {
59
+ const uniqueConfigs = new Map();
60
+ for (const file of files) {
61
+ if (!file.managed)
62
+ continue;
63
+ for (const config of file.symlinks) {
64
+ const key = `${file.packageName}|${file.packageVersion}|${JSON.stringify(config)}`;
65
+ if (!uniqueConfigs.has(key)) {
66
+ uniqueConfigs.set(key, {
67
+ packageName: file.packageName,
68
+ packageVersion: file.packageVersion,
69
+ config,
70
+ });
71
+ }
72
+ }
73
+ }
74
+ const byPath = new Map();
75
+ for (const { packageName, packageVersion, config } of uniqueConfigs.values()) {
76
+ const targetDir = node_path_1.default.resolve(outputDir, config.target);
77
+ const matches = findMatchingPaths(outputDir, config.source);
78
+ for (const relPath of matches) {
79
+ const linkPath = node_path_1.default.join(targetDir, node_path_1.default.basename(relPath));
80
+ const linkRelPath = node_path_1.default.relative(outputDir, linkPath);
81
+ if (!byPath.has(linkRelPath)) {
82
+ byPath.set(linkRelPath, {
83
+ path: linkRelPath,
84
+ packageName,
85
+ packageVersion,
86
+ kind: 'symlink',
87
+ });
88
+ }
89
+ }
90
+ }
91
+ return [...byPath.values()];
92
+ }
93
+ /** Remove only marker-managed symlinks that are no longer desired for this run. */
94
+ async function removeStaleSymlinks(outputDir, managedEntries, desiredPaths) {
95
+ const removed = [];
96
+ const seen = new Set();
97
+ for (const entry of managedEntries) {
98
+ if ((entry.kind ?? 'file') !== 'symlink' || seen.has(entry.path))
99
+ continue;
100
+ seen.add(entry.path);
101
+ if (desiredPaths.has(entry.path))
102
+ continue;
103
+ const linkPath = node_path_1.default.join(outputDir, entry.path);
104
+ if (!isSymlink(linkPath))
105
+ continue;
106
+ try {
107
+ node_fs_1.default.unlinkSync(linkPath);
108
+ removed.push(entry.path);
109
+ }
110
+ catch {
111
+ // eslint-disable-next-line no-console
112
+ console.log(`Failed to remove stale symlink at ${linkPath}`);
113
+ // ignore
114
+ }
115
+ }
116
+ return removed;
117
+ }
118
+ function isManagedSymlinkEntry(entry) {
119
+ return (entry.kind ?? 'file') === 'symlink';
120
+ }
121
+ function isManagedFileEntry(entry) {
122
+ return (entry.kind ?? 'file') !== 'symlink';
123
+ }
124
+ function findManagedSymlinkEntries(entries, relevantPackages) {
125
+ return entries.filter((entry) => isManagedSymlinkEntry(entry) &&
126
+ (!relevantPackages || relevantPackages.has(entry.packageName)));
127
+ }
128
+ function uniqueSymlinkConfigs(files) {
129
+ const seen = new Set();
130
+ const result = [];
131
+ for (const f of files) {
132
+ for (const s of f.symlinks) {
133
+ const key = JSON.stringify(s);
134
+ if (!seen.has(key)) {
135
+ seen.add(key);
136
+ result.push(s);
137
+ }
138
+ }
139
+ }
140
+ return result;
141
+ }
142
+ /**
143
+ * Remove ALL symlinks pointing into outputDir (used during purge).
144
+ */
145
+ async function removeAllSymlinks(outputDir) {
146
+ let count = 0;
147
+ const walk = (dir) => {
148
+ if (!node_fs_1.default.existsSync(dir))
149
+ return;
150
+ for (const entry of node_fs_1.default.readdirSync(dir)) {
151
+ const fullPath = node_path_1.default.join(dir, entry);
152
+ if (isSymlink(fullPath)) {
153
+ try {
154
+ const target = node_fs_1.default.readlinkSync(fullPath);
155
+ const absTarget = node_path_1.default.resolve(node_path_1.default.dirname(fullPath), target);
156
+ if (absTarget.startsWith(outputDir)) {
157
+ node_fs_1.default.unlinkSync(fullPath);
158
+ count += 1;
159
+ }
160
+ }
161
+ catch {
162
+ // ignore
163
+ }
164
+ }
165
+ else if (node_fs_1.default.statSync(fullPath).isDirectory()) {
166
+ walk(fullPath);
167
+ }
168
+ }
169
+ };
170
+ walk(outputDir);
171
+ return count;
172
+ }
173
+ function findMatchingPaths(outputDir, glob) {
174
+ const results = [];
175
+ const walk = (dir, baseDir) => {
176
+ if (!node_fs_1.default.existsSync(dir))
177
+ return;
178
+ for (const entry of node_fs_1.default.readdirSync(dir)) {
179
+ const fullPath = node_path_1.default.join(dir, entry);
180
+ const relPath = node_path_1.default.relative(baseDir, fullPath);
181
+ const lstat = node_fs_1.default.lstatSync(fullPath);
182
+ if (lstat.isSymbolicLink())
183
+ continue;
184
+ if ((0, minimatch_1.minimatch)(relPath, glob, { dot: true })) {
185
+ results.push(relPath);
186
+ }
187
+ if (lstat.isDirectory()) {
188
+ walk(fullPath, baseDir);
189
+ }
190
+ }
191
+ };
192
+ walk(outputDir, outputDir);
193
+ return results;
194
+ }
195
+ function isSymlink(filePath) {
196
+ try {
197
+ return node_fs_1.default.lstatSync(filePath).isSymbolicLink();
198
+ }
199
+ catch {
200
+ return false;
201
+ }
202
+ }
203
+ //# sourceMappingURL=symlinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symlinks.js","sourceRoot":"","sources":["../../src/package/symlinks.ts"],"names":[],"mappings":";;;;;AAaA,wCAgCC;AAQD,oEA0CC;AAGD,kDA2BC;AAED,sDAEC;AAED,gDAEC;AAED,8DASC;AAED,oDAcC;AAKD,8CAwBC;AA7LD,sDAAyB;AACzB,0DAA6B;AAE7B,yCAAsC;AAGtC,oCAAqC;AAErC;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,OAAwB;IAC9E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACzD,IAAA,iBAAS,EAAC,SAAS,CAAC,CAAC;QAErB,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5D,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACjD,MAAM,QAAQ,GAAG,mBAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAEhD,MAAM,SAAS,GAAG,mBAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAEvD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC;oBACH,IAAI,iBAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,KAA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ed representation of an npm package specifier.
3
+ */
4
+ export type SourceKind = 'auto' | 'npm' | 'git';
5
+ /**
6
+ * Internal parsed representation of a package specifier.
7
+ */
8
+ export type PackageConfig = {
9
+ /** Package name or repository URL. */
10
+ name: string;
11
+ /** Version/range for npm packages, or git ref for git sources. */
12
+ version?: string;
13
+ };
14
+ export type BasicPackageOptions = {
15
+ entries: FiledistExtractEntry[];
16
+ cwd: string;
17
+ dryRun?: boolean;
18
+ verbose?: boolean;
19
+ silent?: boolean;
20
+ };
21
+ /**
22
+ * Controls which files are selected from a package and install behaviour.
23
+ */
24
+ export type SelectorConfig = {
25
+ /**
26
+ * Glob patterns; files must match at least one.
27
+ * Default: all files except package.json, bin/**, README.md, node_modules/**
28
+ */
29
+ files?: string[];
30
+ /**
31
+ * Internal: grouped file patterns that must all match during recursive selector merges.
32
+ */
33
+ filePatternGroups?: string[][];
34
+ /**
35
+ * Glob patterns; files matching any of these are excluded even if they match `files`.
36
+ */
37
+ exclude?: string[];
38
+ /**
39
+ * Regex strings; files must match at least one. Binary files always skip regex check.
40
+ */
41
+ contentRegexes?: string[];
42
+ /**
43
+ * Filters which of the target package's own nested `filedist.sets` are recursively
44
+ * extracted. Only sets in the target package whose `presets` field includes at least
45
+ * one of these tags will be processed. When omitted or empty, all nested sets are
46
+ * extracted. Not applied to the files selected from the target package itself.
47
+ */
48
+ presets?: string[];
49
+ /**
50
+ * Force fresh package install even if a satisfying version is installed.
51
+ */
52
+ upgrade?: boolean;
53
+ };
54
+ /**
55
+ * Controls where and how extracted files are written.
56
+ */
57
+ export type OutputConfig = {
58
+ /**
59
+ * Output directory relative to cwd. Concatenated across recursion levels.
60
+ * Defaults to '.' (current working directory) when omitted.
61
+ */
62
+ path?: string;
63
+ /**
64
+ * Overwrite existing unmanaged files. Overridden by --force and --keep-existing.
65
+ */
66
+ force?: boolean;
67
+ /**
68
+ * Skip files that already exist; create missing ones. Cannot combine with force.
69
+ */
70
+ keepExisting?: boolean;
71
+ /**
72
+ * Create/update .gitignore alongside each .filedist marker.
73
+ */
74
+ gitignore?: boolean;
75
+ /**
76
+ * When set to false: write without .filedist marker, no gitignore update, no read-only. Existing files skipped.
77
+ * Takes precedence over force. Defaults to true (managed).
78
+ */
79
+ managed?: boolean;
80
+ /**
81
+ * Keep stale managed files on disk instead of deleting them during extract.
82
+ * Check still reports them as extra drift until they are removed or synced.
83
+ */
84
+ noSync?: boolean;
85
+ /**
86
+ * Report what would change; no disk writes.
87
+ */
88
+ dryRun?: boolean;
89
+ /**
90
+ * Post-extract symlink operations. Appended across recursion levels.
91
+ */
92
+ symlinks?: SymlinkConfig[];
93
+ /**
94
+ * Post-extract content replacements. Appended across recursion levels.
95
+ */
96
+ contentReplacements?: ContentReplacementConfig[];
97
+ };
98
+ /**
99
+ * Controls runtime output verbosity.
100
+ */
101
+ export type ExecutionConfig = {
102
+ /** Suppress per-file output; print only final summary line. */
103
+ silent?: boolean;
104
+ /** Print detailed step information. */
105
+ verbose?: boolean;
106
+ };
107
+ /**
108
+ * Defines one post-extract symlink operation.
109
+ */
110
+ export type SymlinkConfig = {
111
+ /** Glob relative to outputDir. Matching files/dirs get symlinked into `target`. */
112
+ source: string;
113
+ /** Directory where symlinks are created, relative to outputDir. Supports ../ paths. */
114
+ target: string;
115
+ };
116
+ /**
117
+ * Defines one post-extract content replacement operation.
118
+ */
119
+ export type ContentReplacementConfig = {
120
+ /** Glob relative to cwd selecting workspace files to modify. */
121
+ files: string;
122
+ /** Regex string; all non-overlapping occurrences replaced (global flag applied). */
123
+ match: string;
124
+ /** Replacement string; may contain back-references ($1, $2). */
125
+ replace: string;
126
+ };
127
+ /**
128
+ * One entry in the filedist.sets array. Represents a single extraction target.
129
+ *
130
+ * Two variants:
131
+ * - Self-package entry (no `package` field): leaf of recursion; files come from the
132
+ * package whose filedist.sets contains this entry.
133
+ * - External-package entry (`package` field set): recurses into the named package's own
134
+ * filedist.sets (or enumerates its files directly when it has no sets).
135
+ */
136
+ export type FiledistExtractEntry = {
137
+ /**
138
+ * Flat package spec string ("my-pkg@^1.2.3"). When absent the entry is a
139
+ * self-package entry — files are drawn from the package that owns this sets array.
140
+ */
141
+ package?: string;
142
+ /** Resolve package from npm, git, or auto-detect from the package spec. */
143
+ source?: SourceKind;
144
+ /** Where/how to write files. Defaults to current directory with no special flags. */
145
+ output?: OutputConfig;
146
+ /** Which files to select and install options. */
147
+ selector?: SelectorConfig;
148
+ /**
149
+ * Preset tags for --presets CLI filtering. An entry is included when at least
150
+ * one of its presets appears in the requested preset list.
151
+ * Not forwarded to dependency packages.
152
+ */
153
+ presets?: string[];
154
+ /** Suppress per-file output. Root-level (not nested). */
155
+ silent?: boolean;
156
+ /** Print detailed step information. Root-level (not nested). */
157
+ verbose?: boolean;
158
+ };
159
+ /**
160
+ * Top-level structure stored under filedist key in package.json or in any cosmiconfig source.
161
+ */
162
+ export type FiledistConfig = {
163
+ /** All extraction entries. */
164
+ sets: FiledistExtractEntry[];
165
+ /**
166
+ * Shell command run after successful extract (not during --dry-run).
167
+ * Executed in process.cwd(). Full argv appended as arguments.
168
+ */
169
+ postExtractScript?: string;
170
+ };
171
+ /**
172
+ * A single file operation in the diff/execute pipeline.
173
+ */
174
+ export type FileOperation = {
175
+ relPath: string;
176
+ sourcePath: string;
177
+ destPath: string;
178
+ hash: string;
179
+ };
180
+ /**
181
+ * A file skipped during extraction with the reason.
182
+ */
183
+ export type SkippedFile = {
184
+ relPath: string;
185
+ reason: 'conflict' | 'keep-existing' | 'not-managed';
186
+ };
187
+ /**
188
+ * A file in outputDir that is not tracked by filedist and blocks extraction.
189
+ */
190
+ export type ConflictFile = {
191
+ relPath: string;
192
+ /** Set when file is managed by a different package. */
193
+ existingOwner?: string;
194
+ };
195
+ /**
196
+ * Internal read-only structure produced by fileset/diff.ts. Not persisted.
197
+ */
198
+ export type ExtractionMap = {
199
+ /** Files present in package source but absent from outputDir. */
200
+ toAdd: FileOperation[];
201
+ /** Files whose hash differs between package source and outputDir. */
202
+ toModify: FileOperation[];
203
+ /** Relative paths of managed files no longer present in filtered package source. */
204
+ toDelete: string[];
205
+ /** Files skipped with reason. */
206
+ toSkip: SkippedFile[];
207
+ /** Files in outputDir not tracked by filedist that block extraction. */
208
+ conflicts: ConflictFile[];
209
+ };
210
+ /**
211
+ * One row in a .filedist CSV marker file.
212
+ * Format: path|packageName|packageVersion — one row per file, no header.
213
+ */
214
+ export type ManagedFileMetadata = {
215
+ /** Relative path from marker file directory. */
216
+ path: string;
217
+ /** Source npm package name. */
218
+ packageName: string;
219
+ /** Installed version at extraction time. */
220
+ packageVersion: string;
221
+ /** Managed path type. Omitted in marker files for regular files. */
222
+ kind?: 'file' | 'symlink';
223
+ };
224
+ /**
225
+ * Event emitted by extract/check/purge for UI progress reporting.
226
+ */
227
+ export type FileProgressEvent = {
228
+ type: 'file-added' | 'file-modified' | 'file-deleted' | 'file-skipped';
229
+ packageName: string;
230
+ file: string;
231
+ managed: boolean;
232
+ gitignore: boolean;
233
+ };
234
+ export type ProgressEvent = {
235
+ type: 'package-start';
236
+ packageName: string;
237
+ packageVersion: string;
238
+ } | {
239
+ type: 'package-end';
240
+ packageName: string;
241
+ packageVersion: string;
242
+ } | FileProgressEvent;
243
+ /**
244
+ * Result of a check operation for a single fileset.
245
+ */
246
+ export type CheckResult = {
247
+ /** Files in .filedist marker but absent from output dir. */
248
+ missing: string[];
249
+ /** Files whose content hash differs from package source. */
250
+ modified: string[];
251
+ /** Files in filtered package source but never extracted. */
252
+ extra: string[];
253
+ };
254
+ /**
255
+ * Result of purging one fileset.
256
+ */
257
+ export type PurgeResult = {
258
+ /** Number of files deleted. */
259
+ deleted: number;
260
+ /** Number of symlinks removed. */
261
+ symlinksRemoved: number;
262
+ /** Number of empty dirs removed. */
263
+ dirsRemoved: number;
264
+ };
265
+ /**
266
+ * Result of executing an ExtractionMap.
267
+ */
268
+ export type ExecuteResult = {
269
+ /** Paths of newly created files (for rollback purposes). */
270
+ newlyCreated: string[];
271
+ /** Number of files added. */
272
+ added: number;
273
+ /** Number of files modified. */
274
+ modified: number;
275
+ /** Number of files deleted. */
276
+ deleted: number;
277
+ /** Number of files skipped. */
278
+ skipped: number;
279
+ };
280
+ /**
281
+ * A single resolved file produced by resolveFiles().
282
+ * Carries all metadata needed to apply disk changes without further config lookups.
283
+ */
284
+ export type ResolvedFile = {
285
+ /** Relative path within the output directory. */
286
+ relPath: string;
287
+ /** Absolute path of the source file in the installed package directory. */
288
+ sourcePath: string;
289
+ /** Name of the npm package that owns this file. */
290
+ packageName: string;
291
+ /** Installed version of the source package. */
292
+ packageVersion: string;
293
+ /** Absolute path of the output directory where the file should be written. */
294
+ outputDir: string;
295
+ /** Whether the file should be tracked in the .filedist marker. Default: true. */
296
+ managed: boolean;
297
+ /** Whether the file should be added to .gitignore. Default: true. */
298
+ gitignore: boolean;
299
+ /** Whether to overwrite an existing unmanaged file. Default: false. */
300
+ force: boolean;
301
+ /** Whether to skip files that already exist in the output. Default: false. */
302
+ ignoreIfExisting: boolean;
303
+ /** Whether extract should leave stale managed files in place for this output. */
304
+ noSync: boolean;
305
+ /** Content replacement rules applied to this file before comparison. */
306
+ contentReplacements: ContentReplacementConfig[];
307
+ /** Symlink operations to apply in the output directory after extraction. */
308
+ symlinks: SymlinkConfig[];
309
+ };
310
+ /** Classification of a single file in the calculateDiff result. */
311
+ export type DiffStatus = 'ok' | 'missing' | 'extra' | 'conflict';
312
+ /**
313
+ * One entry in a DiffResult.
314
+ * - ok: desired file exists, content and state match
315
+ * - missing: desired file is absent from the output directory
316
+ * - extra: managed file in the marker is not present in the desired file list
317
+ * - conflict: desired file exists but content, managed state, or gitignore state differs
318
+ */
319
+ export type DiffEntry = {
320
+ status: DiffStatus;
321
+ /** Relative path within the output directory. */
322
+ relPath: string;
323
+ /** Absolute path to the output directory. */
324
+ outputDir: string;
325
+ /** Desired file metadata (absent for 'extra' entries). */
326
+ desired?: ResolvedFile;
327
+ /** Existing marker entry (absent for 'missing' entries and unmanaged conflicts). */
328
+ existing?: ManagedFileMetadata;
329
+ /** Reasons for conflict (only set for 'conflict' status). */
330
+ conflictReasons?: Array<'content' | 'managed' | 'gitignore'>;
331
+ };
332
+ /**
333
+ * Aggregate result of calculateDiff().
334
+ */
335
+ export type DiffResult = {
336
+ /** Desired files that already match the output directory. */
337
+ ok: DiffEntry[];
338
+ /** Desired files absent from the output directory. */
339
+ missing: DiffEntry[];
340
+ /** Managed files in the marker that are not in the desired file list. */
341
+ extra: DiffEntry[];
342
+ /** Desired files with content, managed-state, or gitignore-state mismatch. */
343
+ conflict: DiffEntry[];
344
+ };
345
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,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AC;CAC9D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,6DAA6D;IAC7D,EAAE,EAAE,SAAS,EAAE,CAAC;IAChB,sDAAsD;IACtD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,yEAAyE;IACzE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,8EAA8E;IAC9E,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { FiledistExtractEntry, PackageConfig } from './types';
3
+ /**
4
+ * Parse a package spec like "my-pkg@^1.2.3" or "@scope/pkg@2.x" into name and version.
5
+ * The version separator is the LAST "@" so that scoped packages ("@scope/name") are handled.
6
+ */
7
+ export declare function parsePackageSpec(spec: string): PackageConfig;
8
+ /**
9
+ * Compute the SHA-256 hash of a file.
10
+ */
11
+ export declare function hashFile(filePath: string): Promise<string>;
12
+ /**
13
+ * Compute the SHA-256 hash of an in-memory buffer or string.
14
+ * Used to hash content that has been transformed in memory before comparison.
15
+ */
16
+ export declare function hashBuffer(content: Buffer | string): string;
17
+ /**
18
+ * Synchronous file hash (SHA-256).
19
+ */
20
+ export declare function hashFileSync(filePath: string): string;
21
+ /**
22
+ * Detect whether a file is binary by scanning it for null bytes.
23
+ * Reads up to the first 8 KB only.
24
+ */
25
+ export declare function isBinaryFile(filePath: string): boolean;
26
+ /**
27
+ * Return the installed package path if already present and satisfies the requested version.
28
+ */
29
+ export declare function getInstalledIfSatisfies(name: string, version: string | undefined, workDir: string): string | null;
30
+ /**
31
+ * Install and/or upgrade a package using the detected package manager.
32
+ * Returns the installed package path under node_modules.
33
+ * If no package.json exists in the working directory, one is initialised automatically.
34
+ */
35
+ export declare function installOrUpgradePackage(name: string, version: string | undefined, upgrade: boolean, cwd?: string, verbose?: boolean): Promise<string>;
36
+ /**
37
+ * Return the installed package path under cwd/node_modules, or null if not installed.
38
+ */
39
+ export declare function getInstalledPackagePath(name: string, cwd?: string): string | null;
40
+ /**
41
+ * Ensure a directory exists, creating it recursively if needed.
42
+ */
43
+ export declare function ensureDir(dir: string): void;
44
+ /**
45
+ * Format a path for logs relative to the current working directory used by the action.
46
+ */
47
+ export declare function formatDisplayPath(targetPath: string, cwd?: string): string;
48
+ /**
49
+ * Filter entries by requested presets.
50
+ * When no presets are requested, all entries pass through.
51
+ */
52
+ export declare function filterEntriesByPresets(entries: FiledistExtractEntry[], presets: string[] | undefined): FiledistExtractEntry[];
53
+ /**
54
+ * Initialise a minimal package.json and ensure node_modules is listed in .gitignore
55
+ * for the given working directory.
56
+ */
57
+ export declare function initTempPackageJson(workDir: string, verbose?: boolean): void;
58
+ export declare function cleanupTempPackageJson(cwd: string, verbose?: boolean): void;
59
+ export declare function spawnWithLog(command: string, args: string[], workDir: string, verbose: boolean | undefined, failOnError: boolean): ReturnType<typeof spawnSync>;
60
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM/C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAY9D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAO5D;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE3D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