npmdata 0.11.0 → 0.13.0

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 (160) hide show
  1. package/README.md +47 -42
  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 +45 -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 +67 -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 +36 -0
  17. package/dist/cli/actions/list.js.map +1 -0
  18. package/dist/cli/actions/purge.d.ts +6 -0
  19. package/dist/cli/actions/purge.d.ts.map +1 -0
  20. package/dist/cli/actions/purge.js +33 -0
  21. package/dist/cli/actions/purge.js.map +1 -0
  22. package/dist/cli/argv.d.ts +35 -0
  23. package/dist/cli/argv.d.ts.map +1 -0
  24. package/dist/cli/argv.js +125 -0
  25. package/dist/cli/argv.js.map +1 -0
  26. package/dist/cli/bin.d.ts +3 -0
  27. package/dist/cli/bin.d.ts.map +1 -0
  28. package/dist/cli/bin.js +11 -0
  29. package/dist/cli/bin.js.map +1 -0
  30. package/dist/cli/binpkg.d.ts +8 -0
  31. package/dist/cli/binpkg.d.ts.map +1 -0
  32. package/dist/cli/binpkg.js +24 -0
  33. package/dist/cli/binpkg.js.map +1 -0
  34. package/dist/cli/cli.d.ts +10 -0
  35. package/dist/cli/cli.d.ts.map +1 -0
  36. package/dist/cli/cli.js +72 -0
  37. package/dist/cli/cli.js.map +1 -0
  38. package/dist/cli/usage.d.ts +6 -0
  39. package/dist/cli/usage.d.ts.map +1 -0
  40. package/dist/cli/usage.js +126 -0
  41. package/dist/cli/usage.js.map +1 -0
  42. package/dist/fileset/check.d.ts +15 -0
  43. package/dist/fileset/check.d.ts.map +1 -0
  44. package/dist/fileset/check.js +68 -0
  45. package/dist/fileset/check.js.map +1 -0
  46. package/dist/fileset/constants.d.ts +13 -0
  47. package/dist/fileset/constants.d.ts.map +1 -0
  48. package/dist/fileset/constants.js +22 -0
  49. package/dist/fileset/constants.js.map +1 -0
  50. package/dist/fileset/diff.d.ts +16 -0
  51. package/dist/fileset/diff.d.ts.map +1 -0
  52. package/dist/fileset/diff.js +116 -0
  53. package/dist/fileset/diff.js.map +1 -0
  54. package/dist/fileset/execute.d.ts +29 -0
  55. package/dist/fileset/execute.d.ts.map +1 -0
  56. package/dist/fileset/execute.js +136 -0
  57. package/dist/fileset/execute.js.map +1 -0
  58. package/dist/fileset/gitignore.d.ts +16 -0
  59. package/dist/fileset/gitignore.d.ts.map +1 -0
  60. package/dist/fileset/gitignore.js +82 -0
  61. package/dist/fileset/gitignore.js.map +1 -0
  62. package/dist/fileset/index.d.ts +5 -0
  63. package/dist/fileset/index.d.ts.map +1 -0
  64. package/dist/fileset/index.js +21 -0
  65. package/dist/fileset/index.js.map +1 -0
  66. package/dist/fileset/list.d.ts +6 -0
  67. package/dist/fileset/list.d.ts.map +1 -0
  68. package/dist/fileset/list.js +11 -0
  69. package/dist/fileset/list.js.map +1 -0
  70. package/dist/fileset/markers.d.ts +22 -0
  71. package/dist/fileset/markers.d.ts.map +1 -0
  72. package/dist/fileset/markers.js +68 -0
  73. package/dist/fileset/markers.js.map +1 -0
  74. package/dist/fileset/package-files.d.ts +14 -0
  75. package/dist/fileset/package-files.d.ts.map +1 -0
  76. package/dist/fileset/package-files.js +81 -0
  77. package/dist/fileset/package-files.js.map +1 -0
  78. package/dist/fileset/purge.d.ts +12 -0
  79. package/dist/fileset/purge.d.ts.map +1 -0
  80. package/dist/fileset/purge.js +95 -0
  81. package/dist/fileset/purge.js.map +1 -0
  82. package/dist/fileset/test-utils.d.ts +12 -0
  83. package/dist/fileset/test-utils.d.ts.map +1 -0
  84. package/dist/fileset/test-utils.js +65 -0
  85. package/dist/fileset/test-utils.js.map +1 -0
  86. package/dist/index.d.ts +10 -8
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +12 -20
  89. package/dist/index.js.map +1 -1
  90. package/dist/npmdata-0.0.1.tgz +0 -0
  91. package/dist/package/action-check.d.ts +20 -0
  92. package/dist/package/action-check.d.ts.map +1 -0
  93. package/dist/package/action-check.js +61 -0
  94. package/dist/package/action-check.js.map +1 -0
  95. package/dist/package/action-extract.d.ts +21 -0
  96. package/dist/package/action-extract.d.ts.map +1 -0
  97. package/dist/package/action-extract.js +186 -0
  98. package/dist/package/action-extract.js.map +1 -0
  99. package/dist/package/action-init.d.ts +13 -0
  100. package/dist/package/action-init.d.ts.map +1 -0
  101. package/dist/package/action-init.js +77 -0
  102. package/dist/package/action-init.js.map +1 -0
  103. package/dist/package/action-list.d.ts +14 -0
  104. package/dist/package/action-list.d.ts.map +1 -0
  105. package/dist/package/action-list.js +46 -0
  106. package/dist/package/action-list.js.map +1 -0
  107. package/dist/package/action-purge.d.ts +21 -0
  108. package/dist/package/action-purge.d.ts.map +1 -0
  109. package/dist/package/action-purge.js +60 -0
  110. package/dist/package/action-purge.js.map +1 -0
  111. package/dist/package/config-merge.d.ts +18 -0
  112. package/dist/package/config-merge.d.ts.map +1 -0
  113. package/dist/package/config-merge.js +48 -0
  114. package/dist/package/config-merge.js.map +1 -0
  115. package/dist/package/config.d.ts +13 -0
  116. package/dist/package/config.d.ts.map +1 -0
  117. package/dist/package/config.js +29 -0
  118. package/dist/package/config.js.map +1 -0
  119. package/dist/package/content-replacements.d.ts +21 -0
  120. package/dist/package/content-replacements.d.ts.map +1 -0
  121. package/dist/package/content-replacements.js +96 -0
  122. package/dist/package/content-replacements.js.map +1 -0
  123. package/dist/package/index.d.ts +10 -0
  124. package/dist/package/index.d.ts.map +1 -0
  125. package/dist/package/index.js +16 -0
  126. package/dist/package/index.js.map +1 -0
  127. package/dist/package/symlinks.d.ts +17 -0
  128. package/dist/package/symlinks.d.ts.map +1 -0
  129. package/dist/package/symlinks.js +125 -0
  130. package/dist/package/symlinks.js.map +1 -0
  131. package/dist/types.d.ts +181 -277
  132. package/dist/types.d.ts.map +1 -1
  133. package/dist/types.js +0 -12
  134. package/dist/types.js.map +1 -1
  135. package/dist/utils.d.ts +25 -55
  136. package/dist/utils.d.ts.map +1 -1
  137. package/dist/utils.js +82 -181
  138. package/dist/utils.js.map +1 -1
  139. package/package.json +5 -3
  140. package/bin/npmdata.js +0 -4
  141. package/dist/cli.d.ts +0 -6
  142. package/dist/cli.d.ts.map +0 -1
  143. package/dist/cli.js +0 -570
  144. package/dist/cli.js.map +0 -1
  145. package/dist/consumer.d.ts +0 -74
  146. package/dist/consumer.d.ts.map +0 -1
  147. package/dist/consumer.js +0 -820
  148. package/dist/consumer.js.map +0 -1
  149. package/dist/main.d.ts +0 -3
  150. package/dist/main.d.ts.map +0 -1
  151. package/dist/main.js +0 -21
  152. package/dist/main.js.map +0 -1
  153. package/dist/publisher.d.ts +0 -38
  154. package/dist/publisher.d.ts.map +0 -1
  155. package/dist/publisher.js +0 -164
  156. package/dist/publisher.js.map +0 -1
  157. package/dist/runner.d.ts +0 -117
  158. package/dist/runner.d.ts.map +0 -1
  159. package/dist/runner.js +0 -812
  160. package/dist/runner.js.map +0 -1
@@ -0,0 +1,116 @@
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.diff = diff;
7
+ /* eslint-disable functional/no-try-statements */
8
+ /* eslint-disable no-restricted-syntax */
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const node_crypto_1 = __importDefault(require("node:crypto"));
12
+ const utils_1 = require("../utils");
13
+ const content_replacements_1 = require("../package/content-replacements");
14
+ const package_files_1 = require("./package-files");
15
+ /**
16
+ * Pure read-only diff between package source files and an output directory.
17
+ * Classifies each file as toAdd, toModify, toDelete, toSkip, or conflicts.
18
+ * Makes NO disk writes.
19
+ *
20
+ * @param pkgPath Absolute path to the installed package directory.
21
+ * @param outputDir Absolute path to the output directory.
22
+ * @param selector SelectorConfig controlling which package files are included.
23
+ * @param outputConfig OutputConfig controlling extraction behaviour.
24
+ * @param existingMarker Current managed file entries from the .npmdata marker.
25
+ * @param contentReplacements Content replacement configs to apply before hash comparison.
26
+ * @returns ExtractionMap classifying all file operations.
27
+ */
28
+ async function diff(pkgPath, outputDir, selector, outputConfig, existingMarker, contentReplacements) {
29
+ const result = {
30
+ toAdd: [],
31
+ toModify: [],
32
+ toDelete: [],
33
+ toSkip: [],
34
+ conflicts: [],
35
+ };
36
+ // Build map of existing managed files by relPath -> metadata
37
+ const managedByPath = new Map(existingMarker.map((m) => [m.path, m]));
38
+ // Enumerate files from package
39
+ const pkgFiles = await (0, package_files_1.enumeratePackageFiles)(pkgPath, selector);
40
+ const pkgFileSet = new Set(pkgFiles);
41
+ for (const relPath of pkgFiles) {
42
+ const srcPath = node_path_1.default.join(pkgPath, relPath);
43
+ const destPath = node_path_1.default.join(outputDir, relPath);
44
+ const destExists = node_fs_1.default.existsSync(destPath);
45
+ const isManaged = managedByPath.has(relPath);
46
+ if (outputConfig.unmanaged) {
47
+ if (destExists) {
48
+ result.toSkip.push({ relPath, reason: 'unmanaged' });
49
+ }
50
+ else {
51
+ // In unmanaged mode, new files are still added (without marker)
52
+ // eslint-disable-next-line no-await-in-loop
53
+ const srcHash = await (0, utils_1.hashFile)(srcPath);
54
+ result.toAdd.push({ relPath, sourcePath: srcPath, destPath, hash: srcHash });
55
+ }
56
+ continue;
57
+ }
58
+ if (outputConfig.keepExisting && destExists) {
59
+ result.toSkip.push({ relPath, reason: 'keep-existing' });
60
+ continue;
61
+ }
62
+ if (!destExists) {
63
+ // eslint-disable-next-line no-await-in-loop
64
+ const srcHash = await (0, utils_1.hashFile)(srcPath);
65
+ result.toAdd.push({ relPath, sourcePath: srcPath, destPath, hash: srcHash });
66
+ continue;
67
+ }
68
+ // Dest exists
69
+ if (!isManaged) {
70
+ // File exists but not in marker — it's unmanaged/foreign
71
+ if (outputConfig.force) {
72
+ // Override: treat as toModify
73
+ // eslint-disable-next-line no-await-in-loop
74
+ const srcHash = await hashSrcWithReplacements(srcPath, contentReplacements);
75
+ result.toModify.push({ relPath, sourcePath: srcPath, destPath, hash: srcHash });
76
+ }
77
+ else {
78
+ result.conflicts.push({ relPath });
79
+ }
80
+ continue;
81
+ }
82
+ // Managed file — compare hashes
83
+ const srcContent = node_fs_1.default.readFileSync(srcPath);
84
+ const transformedContent = (0, content_replacements_1.applyContentReplacementsToBuffer)(srcContent.toString(), contentReplacements);
85
+ const srcHash = hashBuffer(transformedContent);
86
+ // eslint-disable-next-line no-await-in-loop
87
+ const destHash = await (0, utils_1.hashFile)(destPath);
88
+ if (srcHash === destHash) {
89
+ result.toSkip.push({ relPath, reason: 'keep-existing' });
90
+ }
91
+ else {
92
+ result.toModify.push({ relPath, sourcePath: srcPath, destPath, hash: srcHash });
93
+ }
94
+ }
95
+ // Find managed files that are no longer in the filtered package source
96
+ for (const managed of existingMarker) {
97
+ if (!pkgFileSet.has(managed.path)) {
98
+ result.toDelete.push(managed.path);
99
+ }
100
+ }
101
+ return result;
102
+ }
103
+ async function hashSrcWithReplacements(srcPath, contentReplacements) {
104
+ if (contentReplacements.length === 0)
105
+ return (0, utils_1.hashFile)(srcPath);
106
+ const content = node_fs_1.default.readFileSync(srcPath, 'utf8');
107
+ const transformed = (0, content_replacements_1.applyContentReplacementsToBuffer)(content, contentReplacements);
108
+ return hashString(transformed);
109
+ }
110
+ function hashString(content) {
111
+ return node_crypto_1.default.createHash('sha256').update(content).digest('hex');
112
+ }
113
+ function hashBuffer(content) {
114
+ return hashString(content);
115
+ }
116
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/fileset/diff.ts"],"names":[],"mappings":";;;;;AA+BA,oBA8FC;AA7HD,iDAAiD;AACjD,yCAAyC;AACzC,sDAAyB;AACzB,0DAA6B;AAC7B,8DAAiC;AASjC,oCAAoC;AACpC,0EAAmF;AAEnF,mDAAwD;AAExD;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,IAAI,CACxB,OAAe,EACf,SAAiB,EACjB,QAAwB,EACxB,YAA0B,EAC1B,cAAqC,EACrC,mBAA+C;IAE/C,MAAM,MAAM,GAAkB;QAC5B,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE;KACd,CAAC;IAEF,6DAA6D;IAC7D,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CACvC,CAAC;IAEF,+BAA+B;IAC/B,MAAM,QAAQ,GAAG,MAAM,IAAA,qCAAqB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAErC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,aAAa,CAAC,GA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,EAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,iBAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,IAAA,uDAAgC,EAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IACnF,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,qBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { ExtractionMap, OutputConfig, PackageConfig, ExecuteResult, ManagedFileMetadata } from '../types';
2
+ /**
3
+ * Apply an ExtractionMap to disk:
4
+ * - Copy toAdd and toModify files from source to dest
5
+ * - Make managed files read-only (unless unmanaged mode)
6
+ * - Delete toDelete files
7
+ * - Update .npmdata marker file (unless dryRun or unmanaged)
8
+ * - Update .gitignore (unless dryRun, unmanaged, or gitignore=false)
9
+ *
10
+ * @param map The ExtractionMap produced by diff().
11
+ * @param outputDir Absolute path to the output directory.
12
+ * @param outputConfig OutputConfig controlling write behaviour.
13
+ * @param pkg PackageConfig for marker metadata.
14
+ * @param pkgVersion Installed package version for marker metadata.
15
+ * @param existingMarker Existing managed file entries (for incremental update).
16
+ * @param cwd Working directory (kept for API compatibility).
17
+ * @returns ExecuteResult with counts and list of newly created files for rollback.
18
+ */
19
+ export declare function execute(map: ExtractionMap, outputDir: string, outputConfig: OutputConfig, pkg: PackageConfig, pkgVersion: string, existingMarker: ManagedFileMetadata[], _cwd?: string): Promise<ExecuteResult>;
20
+ /**
21
+ * Delete a list of files from disk and make them writable first.
22
+ * Used for deferred deletions after all filesets have been processed.
23
+ */
24
+ export declare function deleteFiles(filePaths: string[]): Promise<void>;
25
+ /**
26
+ * Rollback: delete newly created files (those that did not exist before this run).
27
+ */
28
+ export declare function rollback(newlyCreated: string[]): Promise<void>;
29
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/fileset/execute.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAOlB;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,mBAAmB,EAAE,EAErC,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,CAAC,CAuFxB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAUpE;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
@@ -0,0 +1,136 @@
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.execute = execute;
7
+ exports.deleteFiles = deleteFiles;
8
+ exports.rollback = rollback;
9
+ /* eslint-disable functional/no-try-statements */
10
+ /* eslint-disable no-restricted-syntax */
11
+ /* eslint-disable no-console */
12
+ const node_fs_1 = __importDefault(require("node:fs"));
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ const utils_1 = require("../utils");
15
+ const content_replacements_1 = require("../package/content-replacements");
16
+ const markers_1 = require("./markers");
17
+ const gitignore_1 = require("./gitignore");
18
+ /**
19
+ * Apply an ExtractionMap to disk:
20
+ * - Copy toAdd and toModify files from source to dest
21
+ * - Make managed files read-only (unless unmanaged mode)
22
+ * - Delete toDelete files
23
+ * - Update .npmdata marker file (unless dryRun or unmanaged)
24
+ * - Update .gitignore (unless dryRun, unmanaged, or gitignore=false)
25
+ *
26
+ * @param map The ExtractionMap produced by diff().
27
+ * @param outputDir Absolute path to the output directory.
28
+ * @param outputConfig OutputConfig controlling write behaviour.
29
+ * @param pkg PackageConfig for marker metadata.
30
+ * @param pkgVersion Installed package version for marker metadata.
31
+ * @param existingMarker Existing managed file entries (for incremental update).
32
+ * @param cwd Working directory (kept for API compatibility).
33
+ * @returns ExecuteResult with counts and list of newly created files for rollback.
34
+ */
35
+ // eslint-disable-next-line complexity
36
+ async function execute(map, outputDir, outputConfig, pkg, pkgVersion, existingMarker,
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ _cwd) {
39
+ const dryRun = outputConfig.dryRun ?? false;
40
+ const unmanaged = outputConfig.unmanaged ?? false;
41
+ const updateGitignore = outputConfig.gitignore !== false;
42
+ const result = {
43
+ newlyCreated: [],
44
+ added: 0,
45
+ modified: 0,
46
+ deleted: 0,
47
+ skipped: map.toSkip.length,
48
+ };
49
+ // Write toAdd files
50
+ for (const op of map.toAdd) {
51
+ if (!dryRun) {
52
+ (0, utils_1.ensureDir)(node_path_1.default.dirname(op.destPath));
53
+ // Make writable if it exists (should be rare for toAdd, but defensive)
54
+ if (node_fs_1.default.existsSync(op.destPath)) {
55
+ node_fs_1.default.chmodSync(op.destPath, 0o644);
56
+ }
57
+ node_fs_1.default.copyFileSync(op.sourcePath, op.destPath);
58
+ if (!unmanaged) {
59
+ node_fs_1.default.chmodSync(op.destPath, 0o444); // read-only
60
+ }
61
+ result.newlyCreated.push(op.destPath);
62
+ }
63
+ result.added += 1;
64
+ }
65
+ // Write toModify files
66
+ for (const op of map.toModify) {
67
+ if (!dryRun) {
68
+ (0, utils_1.ensureDir)(node_path_1.default.dirname(op.destPath));
69
+ if (node_fs_1.default.existsSync(op.destPath)) {
70
+ node_fs_1.default.chmodSync(op.destPath, 0o644); // make writable before overwriting
71
+ }
72
+ node_fs_1.default.copyFileSync(op.sourcePath, op.destPath);
73
+ if (!unmanaged) {
74
+ node_fs_1.default.chmodSync(op.destPath, 0o444); // read-only
75
+ }
76
+ }
77
+ result.modified += 1;
78
+ }
79
+ // Delete toDelete files (deferred — called by action-extract after all filesets)
80
+ // Here we just count them; actual deletion is done by the orchestrator
81
+ result.deleted = map.toDelete.length;
82
+ // Update marker and gitignore
83
+ if (!dryRun && !unmanaged) {
84
+ const marker = (0, markers_1.markerPath)(outputDir);
85
+ // Add newly extracted files to marker
86
+ const addedPaths = new Set([
87
+ ...map.toAdd.map((op) => op.relPath),
88
+ ...map.toModify.map((op) => op.relPath),
89
+ ]);
90
+ // Remove deleted paths, add/update new paths
91
+ const updatedEntries = existingMarker.filter((m) => !map.toDelete.includes(m.path) && !addedPaths.has(m.path));
92
+ for (const op of [...map.toAdd, ...map.toModify]) {
93
+ updatedEntries.push({
94
+ path: op.relPath,
95
+ packageName: pkg.name,
96
+ packageVersion: pkgVersion,
97
+ });
98
+ }
99
+ // eslint-disable-next-line no-await-in-loop
100
+ await (0, markers_1.writeMarker)(marker, updatedEntries);
101
+ if (updateGitignore) {
102
+ const managedPaths = updatedEntries.map((m) => m.path);
103
+ // eslint-disable-next-line no-await-in-loop
104
+ await (0, gitignore_1.addToGitignore)(outputDir, managedPaths);
105
+ }
106
+ }
107
+ // Apply content replacements
108
+ if (!dryRun && outputConfig.contentReplacements && outputConfig.contentReplacements.length > 0) {
109
+ await (0, content_replacements_1.applyContentReplacements)(outputDir, outputConfig.contentReplacements);
110
+ }
111
+ return result;
112
+ }
113
+ /**
114
+ * Delete a list of files from disk and make them writable first.
115
+ * Used for deferred deletions after all filesets have been processed.
116
+ */
117
+ async function deleteFiles(filePaths) {
118
+ for (const filePath of filePaths) {
119
+ if (!node_fs_1.default.existsSync(filePath))
120
+ continue;
121
+ try {
122
+ node_fs_1.default.chmodSync(filePath, 0o644);
123
+ node_fs_1.default.unlinkSync(filePath);
124
+ }
125
+ catch {
126
+ // Ignore errors for files that could not be deleted
127
+ }
128
+ }
129
+ }
130
+ /**
131
+ * Rollback: delete newly created files (those that did not exist before this run).
132
+ */
133
+ async function rollback(newlyCreated) {
134
+ await deleteFiles(newlyCreated);
135
+ }
136
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/fileset/execute.ts"],"names":[],"mappings":";;;;;AAqCA,0BAgGC;AAMD,kCAUC;AAKD,4BAEC;AA5JD,iDAAiD;AACjD,yCAAyC;AACzC,+BAA+B;AAC/B,sDAAyB;AACzB,0DAA6B;AAS7B,oCAAqC;AACrC,0EAA2E;AAE3E,uCAAoD;AACpD,2CAA6C;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,sCAAsC;AAC/B,KAAK,UAAU,OAAO,CAC3B,GAAkB,EAClB,SAAiB,EACjB,YAA0B,EAC1B,GAAkB,EAClB,UAAkB,EAClB,cAAqC;AACrC,6DAA6D;AAC7D,IAAa;IAEb,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,KAAK,CAAC;IAC5C,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,IAAI,KAAK,CAAC;IAClD,MAAM,eAAe,GAAG,YAAY,CAAC,SAAS,KAAK,KAAK,CAAC;IAEzD,MAAM,MAAM,GAAkB;QAC5B,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM;KAC3B,CAAC;IAEF,oBAAoB;IACpB,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;Y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AC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACvD,4CAA4C;YAC5C,MAAM,IAAA,0BAAc,EAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,mBAAmB,IAAI,YAAY,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAA,+CAAwB,EAAC,SAAS,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,SAAmB;IACnD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,SAAS;QACvC,IAAI,CAAC;YACH,iBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC9B,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,oDAAoD;QACtD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,QAAQ,CAAC,YAAsB;IACnD,MAAM,WAAW,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Add paths to the npmdata-managed section in .gitignore.
3
+ * Creates the file if it does not exist.
4
+ * Always includes the MARKER_FILE itself in the managed section.
5
+ */
6
+ export declare function addToGitignore(markerDir: string, paths: string[]): Promise<void>;
7
+ /**
8
+ * Remove specific paths from the npmdata-managed section in .gitignore.
9
+ * Removes the entire section if no paths remain. Deletes the file if empty.
10
+ */
11
+ export declare function removeFromGitignore(markerDir: string, paths: string[]): Promise<void>;
12
+ /**
13
+ * Replace the entire npmdata-managed gitignore section with a new set of paths.
14
+ */
15
+ export declare function updateGitignoreSection(markerDir: string, managedPaths: string[], createIfMissing: boolean): void;
16
+ //# sourceMappingURL=gitignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../../src/fileset/gitignore.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAY3F;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EAAE,EACtB,eAAe,EAAE,OAAO,GACvB,IAAI,CAaN"}
@@ -0,0 +1,82 @@
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.addToGitignore = addToGitignore;
7
+ exports.removeFromGitignore = removeFromGitignore;
8
+ exports.updateGitignoreSection = updateGitignoreSection;
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const constants_1 = require("./constants");
12
+ /**
13
+ * Add paths to the npmdata-managed section in .gitignore.
14
+ * Creates the file if it does not exist.
15
+ * Always includes the MARKER_FILE itself in the managed section.
16
+ */
17
+ async function addToGitignore(markerDir, paths) {
18
+ updateGitignoreSection(markerDir, paths, true);
19
+ }
20
+ /**
21
+ * Remove specific paths from the npmdata-managed section in .gitignore.
22
+ * Removes the entire section if no paths remain. Deletes the file if empty.
23
+ */
24
+ async function removeFromGitignore(markerDir, paths) {
25
+ const gitignorePath = node_path_1.default.join(markerDir, constants_1.GITIGNORE_FILE);
26
+ if (!node_fs_1.default.existsSync(gitignorePath))
27
+ return;
28
+ const existingContent = node_fs_1.default.readFileSync(gitignorePath, 'utf8');
29
+ const { beforeSection, managedEntries, afterSection } = parseSections(existingContent);
30
+ // Remove specified paths from the managed section
31
+ const pathSet = new Set(paths);
32
+ const remaining = managedEntries.filter((e) => !pathSet.has(e) && e !== constants_1.MARKER_FILE);
33
+ writeGitignore(gitignorePath, beforeSection, remaining, afterSection);
34
+ }
35
+ /**
36
+ * Replace the entire npmdata-managed gitignore section with a new set of paths.
37
+ */
38
+ function updateGitignoreSection(markerDir, managedPaths, createIfMissing) {
39
+ const gitignorePath = node_path_1.default.join(markerDir, constants_1.GITIGNORE_FILE);
40
+ let existingContent = '';
41
+ if (node_fs_1.default.existsSync(gitignorePath)) {
42
+ existingContent = node_fs_1.default.readFileSync(gitignorePath, 'utf8');
43
+ }
44
+ const { beforeSection, afterSection, hasSection } = parseSections(existingContent);
45
+ if (!createIfMissing && !hasSection)
46
+ return;
47
+ writeGitignore(gitignorePath, beforeSection, managedPaths, afterSection);
48
+ }
49
+ function parseSections(content) {
50
+ const startIdx = content.indexOf(constants_1.GITIGNORE_START);
51
+ const endIdx = content.indexOf(constants_1.GITIGNORE_END);
52
+ const hasSection = startIdx !== -1 && endIdx !== -1 && startIdx < endIdx;
53
+ if (!hasSection) {
54
+ return { beforeSection: content, managedEntries: [], afterSection: '', hasSection: false };
55
+ }
56
+ const beforeSection = content.slice(0, startIdx).trimEnd();
57
+ const sectionContent = content.slice(startIdx + constants_1.GITIGNORE_START.length, endIdx);
58
+ const managedEntries = sectionContent
59
+ .split('\n')
60
+ .map((l) => l.trim())
61
+ .filter((l) => l.length > 0 && l !== constants_1.MARKER_FILE);
62
+ const afterSection = content.slice(endIdx + constants_1.GITIGNORE_END.length).trimStart();
63
+ return { beforeSection, managedEntries, afterSection, hasSection: true };
64
+ }
65
+ function writeGitignore(gitignorePath, beforeSection, managedPaths, afterSection) {
66
+ if (managedPaths.length === 0) {
67
+ // Remove the managed section entirely
68
+ const updatedContent = [beforeSection, afterSection].filter(Boolean).join('\n');
69
+ if (updatedContent.trim()) {
70
+ node_fs_1.default.writeFileSync(gitignorePath, `${updatedContent.trimEnd()}\n`, 'utf8');
71
+ }
72
+ else if (node_fs_1.default.existsSync(gitignorePath)) {
73
+ node_fs_1.default.unlinkSync(gitignorePath);
74
+ }
75
+ return;
76
+ }
77
+ const section = [constants_1.GITIGNORE_START, constants_1.MARKER_FILE, ...managedPaths.sort(), constants_1.GITIGNORE_END].join('\n');
78
+ const parts = [beforeSection, section, afterSection].filter(Boolean);
79
+ const updatedContent = `${parts.join('\n')}\n`;
80
+ node_fs_1.default.writeFileSync(gitignorePath, updatedContent, 'utf8');
81
+ }
82
+ //# sourceMappingURL=gitignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../../src/fileset/gitignore.ts"],"names":[],"mappings":";;;;;AAUA,wCAEC;AAMD,kDAYC;AAKD,wDAiBC;AApDD,sDAAyB;AACzB,0DAA6B;AAE7B,2CAA0F;AAE1F;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,KAAe;IACrE,sBAAsB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,SAAiB,EAAE,KAAe;IAC1E,MAAM,aAAa,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,0BAAc,CAAC,CAAC;IAC3D,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,aAAa,CAAC;QAAE,OAAO;IAE1C,MAAM,eAAe,GAAG,iBAAE,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;IAEvF,kDAAkD;IAClD,MAAM,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C,iBAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,2BAAe,EAAE,uBAAW,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,yBAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjG,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/C,iBAAE,CAAC,aAAa,CAAC,aAAa,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { readMarker, writeMarker, markerPath, readOutputDirMarker } from './markers';
2
+ export { addToGitignore, removeFromGitignore, updateGitignoreSection } from './gitignore';
3
+ export { installedPackagePath, enumeratePackageFiles } from './package-files';
4
+ export { MARKER_FILE, DEFAULT_FILENAME_PATTERNS, GITIGNORE_FILE } from './constants';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fileset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GITIGNORE_FILE = exports.DEFAULT_FILENAME_PATTERNS = exports.MARKER_FILE = exports.enumeratePackageFiles = exports.installedPackagePath = exports.updateGitignoreSection = exports.removeFromGitignore = exports.addToGitignore = exports.readOutputDirMarker = exports.markerPath = exports.writeMarker = exports.readMarker = void 0;
4
+ // Public fileset-layer API
5
+ var markers_1 = require("./markers");
6
+ Object.defineProperty(exports, "readMarker", { enumerable: true, get: function () { return markers_1.readMarker; } });
7
+ Object.defineProperty(exports, "writeMarker", { enumerable: true, get: function () { return markers_1.writeMarker; } });
8
+ Object.defineProperty(exports, "markerPath", { enumerable: true, get: function () { return markers_1.markerPath; } });
9
+ Object.defineProperty(exports, "readOutputDirMarker", { enumerable: true, get: function () { return markers_1.readOutputDirMarker; } });
10
+ var gitignore_1 = require("./gitignore");
11
+ Object.defineProperty(exports, "addToGitignore", { enumerable: true, get: function () { return gitignore_1.addToGitignore; } });
12
+ Object.defineProperty(exports, "removeFromGitignore", { enumerable: true, get: function () { return gitignore_1.removeFromGitignore; } });
13
+ Object.defineProperty(exports, "updateGitignoreSection", { enumerable: true, get: function () { return gitignore_1.updateGitignoreSection; } });
14
+ var package_files_1 = require("./package-files");
15
+ Object.defineProperty(exports, "installedPackagePath", { enumerable: true, get: function () { return package_files_1.installedPackagePath; } });
16
+ Object.defineProperty(exports, "enumeratePackageFiles", { enumerable: true, get: function () { return package_files_1.enumeratePackageFiles; } });
17
+ var constants_1 = require("./constants");
18
+ Object.defineProperty(exports, "MARKER_FILE", { enumerable: true, get: function () { return constants_1.MARKER_FILE; } });
19
+ Object.defineProperty(exports, "DEFAULT_FILENAME_PATTERNS", { enumerable: true, get: function () { return constants_1.DEFAULT_FILENAME_PATTERNS; } });
20
+ Object.defineProperty(exports, "GITIGNORE_FILE", { enumerable: true, get: function () { return constants_1.GITIGNORE_FILE; } });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fileset/index.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAC3B,qCAAqF;AAA5E,qGAAA,UAAU,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AACjE,yCAA0F;AAAjF,2GAAA,cAAc,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAAE,mHAAA,sBAAsB,OAAA;AACpE,iDAA8E;AAArE,qHAAA,oBAAoB,OAAA;AAAE,sHAAA,qBAAqB,OAAA;AACpD,yCAAqF;AAA5E,wGAAA,WAAW,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AAAE,2GAAA,cAAc,OAAA"}
@@ -0,0 +1,6 @@
1
+ import { ManagedFileMetadata } from '../types';
2
+ /**
3
+ * Read all managed files from a single output directory's .npmdata marker.
4
+ */
5
+ export declare function listManagedFiles(outputDir: string): Promise<ManagedFileMetadata[]>;
6
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/fileset/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAExF"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listManagedFiles = listManagedFiles;
4
+ const markers_1 = require("./markers");
5
+ /**
6
+ * Read all managed files from a single output directory's .npmdata marker.
7
+ */
8
+ async function listManagedFiles(outputDir) {
9
+ return (0, markers_1.readOutputDirMarker)(outputDir);
10
+ }
11
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/fileset/list.ts"],"names":[],"mappings":";;AAOA,4CAEC;AAPD,uCAAgD;AAEhD;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,SAAiB;IACtD,OAAO,IAAA,6BAAmB,EAAC,SAAS,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ManagedFileMetadata } from '../types';
2
+ /**
3
+ * Read all managed file entries from a .npmdata marker file.
4
+ * CSV format: path,packageName,packageVersion — one row per file, no header.
5
+ * Compatible with v1 marker files.
6
+ */
7
+ export declare function readMarker(markerFilePath: string): Promise<ManagedFileMetadata[]>;
8
+ /**
9
+ * Write managed file entries to a .npmdata marker file.
10
+ * CSV format: path,packageName,packageVersion — one row per file, no header.
11
+ * Makes the file read-only after writing.
12
+ */
13
+ export declare function writeMarker(markerFilePath: string, entries: ManagedFileMetadata[]): Promise<void>;
14
+ /**
15
+ * Returns the path of the .npmdata marker file for a given output directory.
16
+ */
17
+ export declare function markerPath(outputDir: string): string;
18
+ /**
19
+ * Read all managed file entries from an output directory's .npmdata marker.
20
+ */
21
+ export declare function readOutputDirMarker(outputDir: string): Promise<ManagedFileMetadata[]>;
22
+ //# sourceMappingURL=markers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../src/fileset/markers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAK/C;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAcvF;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,mBAAmB,EAAE,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAE3F"}
@@ -0,0 +1,68 @@
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.readMarker = readMarker;
7
+ exports.writeMarker = writeMarker;
8
+ exports.markerPath = markerPath;
9
+ exports.readOutputDirMarker = readOutputDirMarker;
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const utils_1 = require("../utils");
13
+ const constants_1 = require("./constants");
14
+ /**
15
+ * Read all managed file entries from a .npmdata marker file.
16
+ * CSV format: path,packageName,packageVersion — one row per file, no header.
17
+ * Compatible with v1 marker files.
18
+ */
19
+ async function readMarker(markerFilePath) {
20
+ if (!node_fs_1.default.existsSync(markerFilePath)) {
21
+ return [];
22
+ }
23
+ const content = node_fs_1.default.readFileSync(markerFilePath, 'utf8');
24
+ const lines = content.split('\n').filter((line) => line.trim() !== '');
25
+ return lines.map((line) => {
26
+ const fields = line.split(',');
27
+ return {
28
+ path: fields[0] ?? '',
29
+ packageName: fields[1] ?? '',
30
+ packageVersion: fields[2] ?? '',
31
+ };
32
+ });
33
+ }
34
+ /**
35
+ * Write managed file entries to a .npmdata marker file.
36
+ * CSV format: path,packageName,packageVersion — one row per file, no header.
37
+ * Makes the file read-only after writing.
38
+ */
39
+ async function writeMarker(markerFilePath, entries) {
40
+ (0, utils_1.ensureDir)(node_path_1.default.dirname(markerFilePath));
41
+ // Make writable if it already exists
42
+ if (node_fs_1.default.existsSync(markerFilePath)) {
43
+ node_fs_1.default.chmodSync(markerFilePath, 0o644);
44
+ }
45
+ if (entries.length === 0) {
46
+ // Remove empty marker
47
+ if (node_fs_1.default.existsSync(markerFilePath)) {
48
+ node_fs_1.default.unlinkSync(markerFilePath);
49
+ }
50
+ return;
51
+ }
52
+ const rows = entries.map((e) => `${e.path},${e.packageName},${e.packageVersion}`);
53
+ node_fs_1.default.writeFileSync(markerFilePath, `${rows.join('\n')}\n`, 'utf8');
54
+ node_fs_1.default.chmodSync(markerFilePath, 0o444);
55
+ }
56
+ /**
57
+ * Returns the path of the .npmdata marker file for a given output directory.
58
+ */
59
+ function markerPath(outputDir) {
60
+ return node_path_1.default.join(outputDir, constants_1.MARKER_FILE);
61
+ }
62
+ /**
63
+ * Read all managed file entries from an output directory's .npmdata marker.
64
+ */
65
+ async function readOutputDirMarker(outputDir) {
66
+ return readMarker(markerPath(outputDir));
67
+ }
68
+ //# sourceMappingURL=markers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.js","sourceRoot":"","sources":["../../src/fileset/markers.ts"],"names":[],"mappings":";;;;;AAaA,gCAcC;AAOD,kCAmBC;AAKD,gCAEC;AAKD,kDAEC;AAnED,sDAAyB;AACzB,0DAA6B;AAG7B,oCAAqC;AAErC,2CAA0C;AAE1C;;;;GAIG;AACI,KAAK,UAAU,UAAU,CAAC,cAAsB;IACrD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAG,iBAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;YACrB,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;YAC5B,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;SAChC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAsB,EACtB,OAA8B;IAE9B,IAAA,iBAAS,EAAC,mBAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IACxC,qCAAqC;IACrC,IAAI,iBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAClC,iBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,sBAAsB;QACtB,IAAI,iBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YAClC,iBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;QACD,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;IAClF,iBAAE,CAAC,aAAa,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACjE,iBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,SAAiB;IAC1C,OAAO,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uBAAW,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,SAAiB;IACzD,OAAO,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { SelectorConfig } from '../types';
2
+ /**
3
+ * Returns the installed package path from node_modules in cwd, or null if not found.
4
+ */
5
+ export declare function installedPackagePath(name: string, cwd?: string): string | null;
6
+ /**
7
+ * Enumerate all files in a package directory that match the selector.
8
+ * Applies DEFAULT_FILENAME_PATTERNS when `files` is absent.
9
+ * Binary files always skip contentRegexes check (but are included by glob).
10
+ *
11
+ * @returns Array of relative file paths from the package root.
12
+ */
13
+ export declare function enumeratePackageFiles(pkgPath: string, selector: SelectorConfig): Promise<string[]>;
14
+ //# sourceMappingURL=package-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-files.d.ts","sourceRoot":"","sources":["../../src/fileset/package-files.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ9E;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CAuCnB"}