npmdata 0.11.0 → 0.12.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 (153) 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 +57 -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 +84 -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 +36 -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 +42 -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 +47 -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/cli.d.ts +9 -0
  27. package/dist/cli/cli.d.ts.map +1 -0
  28. package/dist/cli/cli.js +69 -0
  29. package/dist/cli/cli.js.map +1 -0
  30. package/dist/cli/runner.d.ts +9 -0
  31. package/dist/cli/runner.d.ts.map +1 -0
  32. package/dist/cli/runner.js +106 -0
  33. package/dist/cli/runner.js.map +1 -0
  34. package/dist/cli/usage.d.ts +6 -0
  35. package/dist/cli/usage.d.ts.map +1 -0
  36. package/dist/cli/usage.js +126 -0
  37. package/dist/cli/usage.js.map +1 -0
  38. package/dist/fileset/check.d.ts +15 -0
  39. package/dist/fileset/check.d.ts.map +1 -0
  40. package/dist/fileset/check.js +68 -0
  41. package/dist/fileset/check.js.map +1 -0
  42. package/dist/fileset/constants.d.ts +13 -0
  43. package/dist/fileset/constants.d.ts.map +1 -0
  44. package/dist/fileset/constants.js +22 -0
  45. package/dist/fileset/constants.js.map +1 -0
  46. package/dist/fileset/diff.d.ts +16 -0
  47. package/dist/fileset/diff.d.ts.map +1 -0
  48. package/dist/fileset/diff.js +116 -0
  49. package/dist/fileset/diff.js.map +1 -0
  50. package/dist/fileset/execute.d.ts +29 -0
  51. package/dist/fileset/execute.d.ts.map +1 -0
  52. package/dist/fileset/execute.js +136 -0
  53. package/dist/fileset/execute.js.map +1 -0
  54. package/dist/fileset/gitignore.d.ts +16 -0
  55. package/dist/fileset/gitignore.d.ts.map +1 -0
  56. package/dist/fileset/gitignore.js +82 -0
  57. package/dist/fileset/gitignore.js.map +1 -0
  58. package/dist/fileset/index.d.ts +5 -0
  59. package/dist/fileset/index.d.ts.map +1 -0
  60. package/dist/fileset/index.js +21 -0
  61. package/dist/fileset/index.js.map +1 -0
  62. package/dist/fileset/list.d.ts +6 -0
  63. package/dist/fileset/list.d.ts.map +1 -0
  64. package/dist/fileset/list.js +11 -0
  65. package/dist/fileset/list.js.map +1 -0
  66. package/dist/fileset/markers.d.ts +22 -0
  67. package/dist/fileset/markers.d.ts.map +1 -0
  68. package/dist/fileset/markers.js +68 -0
  69. package/dist/fileset/markers.js.map +1 -0
  70. package/dist/fileset/package-files.d.ts +14 -0
  71. package/dist/fileset/package-files.d.ts.map +1 -0
  72. package/dist/fileset/package-files.js +81 -0
  73. package/dist/fileset/package-files.js.map +1 -0
  74. package/dist/fileset/purge.d.ts +12 -0
  75. package/dist/fileset/purge.d.ts.map +1 -0
  76. package/dist/fileset/purge.js +95 -0
  77. package/dist/fileset/purge.js.map +1 -0
  78. package/dist/fileset/test-utils.d.ts +12 -0
  79. package/dist/fileset/test-utils.d.ts.map +1 -0
  80. package/dist/fileset/test-utils.js +65 -0
  81. package/dist/fileset/test-utils.js.map +1 -0
  82. package/dist/index.d.ts +10 -8
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +11 -19
  85. package/dist/index.js.map +1 -1
  86. package/dist/main.js +9 -17
  87. package/dist/main.js.map +1 -1
  88. package/dist/npmdata-0.0.1.tgz +0 -0
  89. package/dist/package/action-check.d.ts +20 -0
  90. package/dist/package/action-check.d.ts.map +1 -0
  91. package/dist/package/action-check.js +61 -0
  92. package/dist/package/action-check.js.map +1 -0
  93. package/dist/package/action-extract.d.ts +21 -0
  94. package/dist/package/action-extract.d.ts.map +1 -0
  95. package/dist/package/action-extract.js +186 -0
  96. package/dist/package/action-extract.js.map +1 -0
  97. package/dist/package/action-init.d.ts +13 -0
  98. package/dist/package/action-init.d.ts.map +1 -0
  99. package/dist/package/action-init.js +77 -0
  100. package/dist/package/action-init.js.map +1 -0
  101. package/dist/package/action-list.d.ts +14 -0
  102. package/dist/package/action-list.d.ts.map +1 -0
  103. package/dist/package/action-list.js +46 -0
  104. package/dist/package/action-list.js.map +1 -0
  105. package/dist/package/action-purge.d.ts +21 -0
  106. package/dist/package/action-purge.d.ts.map +1 -0
  107. package/dist/package/action-purge.js +60 -0
  108. package/dist/package/action-purge.js.map +1 -0
  109. package/dist/package/config-merge.d.ts +18 -0
  110. package/dist/package/config-merge.d.ts.map +1 -0
  111. package/dist/package/config-merge.js +48 -0
  112. package/dist/package/config-merge.js.map +1 -0
  113. package/dist/package/config.d.ts +13 -0
  114. package/dist/package/config.d.ts.map +1 -0
  115. package/dist/package/config.js +29 -0
  116. package/dist/package/config.js.map +1 -0
  117. package/dist/package/content-replacements.d.ts +21 -0
  118. package/dist/package/content-replacements.d.ts.map +1 -0
  119. package/dist/package/content-replacements.js +96 -0
  120. package/dist/package/content-replacements.js.map +1 -0
  121. package/dist/package/index.d.ts +10 -0
  122. package/dist/package/index.d.ts.map +1 -0
  123. package/dist/package/index.js +16 -0
  124. package/dist/package/index.js.map +1 -0
  125. package/dist/package/symlinks.d.ts +17 -0
  126. package/dist/package/symlinks.d.ts.map +1 -0
  127. package/dist/package/symlinks.js +125 -0
  128. package/dist/package/symlinks.js.map +1 -0
  129. package/dist/types.d.ts +181 -277
  130. package/dist/types.d.ts.map +1 -1
  131. package/dist/types.js +0 -12
  132. package/dist/types.js.map +1 -1
  133. package/dist/utils.d.ts +25 -55
  134. package/dist/utils.d.ts.map +1 -1
  135. package/dist/utils.js +82 -181
  136. package/dist/utils.js.map +1 -1
  137. package/package.json +4 -2
  138. package/dist/cli.d.ts +0 -6
  139. package/dist/cli.d.ts.map +0 -1
  140. package/dist/cli.js +0 -570
  141. package/dist/cli.js.map +0 -1
  142. package/dist/consumer.d.ts +0 -74
  143. package/dist/consumer.d.ts.map +0 -1
  144. package/dist/consumer.js +0 -820
  145. package/dist/consumer.js.map +0 -1
  146. package/dist/publisher.d.ts +0 -38
  147. package/dist/publisher.d.ts.map +0 -1
  148. package/dist/publisher.js +0 -164
  149. package/dist/publisher.js.map +0 -1
  150. package/dist/runner.d.ts +0 -117
  151. package/dist/runner.d.ts.map +0 -1
  152. package/dist/runner.js +0 -812
  153. package/dist/runner.js.map +0 -1
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseArgv = parseArgv;
4
+ exports.buildEntriesFromArgv = buildEntriesFromArgv;
5
+ exports.applyArgvOverrides = applyArgvOverrides;
6
+ const utils_1 = require("../utils");
7
+ /**
8
+ * Parse all supported CLI flags from an argv array.
9
+ * Validates mutually exclusive combinations and throws on invalid input.
10
+ */
11
+ function parseArgv(argv) {
12
+ const getFlag = (flag) => argv.includes(flag);
13
+ const getValue = (flag, shortFlag) => {
14
+ // eslint-disable-next-line no-undefined
15
+ const idx = argv.findIndex((a) => a === flag || (shortFlag !== undefined && a === shortFlag));
16
+ if (idx === -1 || idx + 1 >= argv.length) {
17
+ // eslint-disable-next-line no-undefined
18
+ return undefined;
19
+ }
20
+ return argv[idx + 1];
21
+ };
22
+ const getCommaSplit = (flag, shortFlag) => {
23
+ const val = getValue(flag, shortFlag);
24
+ // eslint-disable-next-line no-undefined
25
+ if (val === undefined) {
26
+ // eslint-disable-next-line no-undefined
27
+ return undefined;
28
+ }
29
+ return val
30
+ .split(',')
31
+ .map((s) => s.trim())
32
+ .filter(Boolean);
33
+ };
34
+ const force = getFlag('--force');
35
+ const keepExisting = getFlag('--keep-existing');
36
+ if (force && keepExisting) {
37
+ throw new Error('--force and --keep-existing are mutually exclusive');
38
+ }
39
+ const packagesRaw = getCommaSplit('--packages');
40
+ const packages = packagesRaw?.map((s) => (0, utils_1.parsePackageSpec)(s));
41
+ return {
42
+ packages,
43
+ output: getValue('--output', '-o'),
44
+ files: getCommaSplit('--files'),
45
+ contentRegexes: getCommaSplit('--content-regex'),
46
+ presets: getCommaSplit('--presets'),
47
+ force,
48
+ keepExisting,
49
+ noGitignore: getFlag('--no-gitignore'),
50
+ unmanaged: getFlag('--unmanaged'),
51
+ dryRun: getFlag('--dry-run'),
52
+ upgrade: getFlag('--upgrade'),
53
+ silent: getFlag('--silent'),
54
+ verbose: getFlag('--verbose') || getFlag('-v'),
55
+ };
56
+ }
57
+ /**
58
+ * Build NpmdataExtractEntry objects from --packages + --output CLI flags.
59
+ * Returns null if --packages is not set.
60
+ */
61
+ function buildEntriesFromArgv(parsed) {
62
+ if (!parsed.packages || parsed.packages.length === 0) {
63
+ // eslint-disable-next-line unicorn/no-null
64
+ return null;
65
+ }
66
+ const selector = {};
67
+ if (parsed.files)
68
+ selector.files = parsed.files;
69
+ if (parsed.contentRegexes)
70
+ selector.contentRegexes = parsed.contentRegexes;
71
+ if (parsed.presets)
72
+ selector.presets = parsed.presets;
73
+ if (parsed.upgrade)
74
+ selector.upgrade = true;
75
+ const output = {
76
+ path: parsed.output ?? '.',
77
+ force: parsed.force,
78
+ keepExisting: parsed.keepExisting,
79
+ gitignore: !parsed.noGitignore,
80
+ unmanaged: parsed.unmanaged,
81
+ dryRun: parsed.dryRun,
82
+ };
83
+ return parsed.packages.map((pkg) => ({
84
+ package: pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name,
85
+ output,
86
+ selector,
87
+ silent: parsed.silent,
88
+ verbose: parsed.verbose,
89
+ }));
90
+ }
91
+ /**
92
+ * Apply CLI overrides from ParsedArgv to each NpmdataExtractEntry.
93
+ * CLI flags always take precedence over config file values.
94
+ */
95
+ function applyArgvOverrides(entries, parsed) {
96
+ return entries.map((entry) => {
97
+ const updatedOutput = {
98
+ ...entry.output,
99
+ // eslint-disable-next-line no-undefined
100
+ ...(parsed.output !== undefined
101
+ ? // eslint-disable-next-line no-undefined
102
+ { path: parsed.output }
103
+ : {}),
104
+ ...(parsed.force ? { force: true } : {}),
105
+ ...(parsed.keepExisting ? { keepExisting: true } : {}),
106
+ ...(parsed.noGitignore ? { gitignore: false } : {}),
107
+ ...(parsed.unmanaged ? { unmanaged: true } : {}),
108
+ ...(parsed.dryRun ? { dryRun: true } : {}),
109
+ };
110
+ const updatedSelector = {
111
+ ...entry.selector,
112
+ ...(parsed.files ? { files: parsed.files } : {}),
113
+ ...(parsed.contentRegexes ? { contentRegexes: parsed.contentRegexes } : {}),
114
+ ...(parsed.upgrade ? { upgrade: true } : {}),
115
+ };
116
+ return {
117
+ ...entry,
118
+ output: updatedOutput,
119
+ selector: updatedSelector,
120
+ ...(parsed.silent ? { silent: true } : {}),
121
+ ...(parsed.verbose ? { verbose: true } : {}),
122
+ };
123
+ });
124
+ }
125
+ //# sourceMappingURL=argv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv.js","sourceRoot":"","sources":["../../src/cli/argv.ts"],"names":[],"mappings":";;AA0BA,8BAiDC;AAMD,oDA4BC;AAMD,gDAkCC;AApJD,oCAA4C;AAqB5C;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAc;IACtC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ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AE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3C,CAAC;QAEF,MAAM,eAAe,GAAmB;YACtC,GAAG,KAAK,CAAC,QAAQ;YACjB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C,CAAC;QAEF,OAAO;YACL,GAAG,KAAK;YACR,MAAM,EAAE,aAAa;YACrB,QAAQ,EAAE,eAAe;YACzB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1C,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Top-level CLI router.
3
+ * Detects command from argv, loads config, and dispatches to appropriate handler.
4
+ *
5
+ * @param argv - Process argument vector (argv[0] = node, argv[1] = script).
6
+ * @param cwd - Working directory override (defaults to process.cwd()).
7
+ */
8
+ export declare function cli(argv: string[], cwd?: string): Promise<void>;
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDrE"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cli = cli;
4
+ /* eslint-disable no-console */
5
+ const config_1 = require("../package/config");
6
+ const usage_1 = require("./usage");
7
+ const extract_1 = require("./actions/extract");
8
+ const check_1 = require("./actions/check");
9
+ const list_1 = require("./actions/list");
10
+ const purge_1 = require("./actions/purge");
11
+ const init_1 = require("./actions/init");
12
+ const KNOWN_COMMANDS = new Set(['extract', 'check', 'list', 'purge', 'init']);
13
+ /**
14
+ * Top-level CLI router.
15
+ * Detects command from argv, loads config, and dispatches to appropriate handler.
16
+ *
17
+ * @param argv - Process argument vector (argv[0] = node, argv[1] = script).
18
+ * @param cwd - Working directory override (defaults to process.cwd()).
19
+ */
20
+ async function cli(argv, cwd) {
21
+ const args = argv.slice(2); // strip node + script
22
+ // Handle global --help with no command
23
+ if (args.includes('--help') && args.length === 1) {
24
+ (0, usage_1.printUsage)();
25
+ return;
26
+ }
27
+ // Handle global --version
28
+ if (args.includes('--version')) {
29
+ (0, usage_1.printVersion)();
30
+ return;
31
+ }
32
+ // Detect action
33
+ let action;
34
+ let cmdArgs;
35
+ const firstArg = args[0];
36
+ if (firstArg && KNOWN_COMMANDS.has(firstArg)) {
37
+ action = firstArg;
38
+ cmdArgs = args.slice(1);
39
+ }
40
+ else {
41
+ // Default to extract
42
+ action = 'extract';
43
+ cmdArgs = args;
44
+ }
45
+ // Load config from cwd
46
+ const effectiveCwd = cwd ?? process.cwd();
47
+ const config = await (0, config_1.loadNpmdataConfig)(effectiveCwd);
48
+ switch (action) {
49
+ case 'extract':
50
+ await (0, extract_1.runExtract)(config, cmdArgs, effectiveCwd);
51
+ break;
52
+ case 'check':
53
+ await (0, check_1.runCheck)(config, cmdArgs, effectiveCwd);
54
+ break;
55
+ case 'list':
56
+ await (0, list_1.runList)(config, cmdArgs, effectiveCwd);
57
+ break;
58
+ case 'purge':
59
+ await (0, purge_1.runPurge)(config, cmdArgs, effectiveCwd);
60
+ break;
61
+ case 'init':
62
+ await (0, init_1.runInit)(config, cmdArgs, effectiveCwd);
63
+ break;
64
+ default:
65
+ console.error(`Unknown command: ${action}`);
66
+ process.exitCode = 1;
67
+ }
68
+ }
69
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;AAmBA,kBAqDC;AAxED,+BAA+B;AAC/B,8CAAsD;AAEtD,mCAAmD;AACnD,+CAA+C;AAC/C,2CAA2C;AAC3C,yCAAyC;AACzC,2CAA2C;AAC3C,yCAAyC;AAEzC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,GAAY;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB;IAElD,uCAAuC;IACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,IAAA,kBAAU,GAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,0BAA0B;IAC1B,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,IAAA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AC,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Entry point for self-installable packages generated by `init`.
3
+ * Called from bin/npmdata.js: require('npmdata').run(__dirname, process.argv.slice(2))
4
+ *
5
+ * @param binDir Absolute path to the bin/ directory of the hosting package.
6
+ * @param argv CLI arguments (process.argv.slice(2) from bin shim).
7
+ */
8
+ export declare function run(binDir: string, argv?: string[]): Promise<void>;
9
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/cli/runner.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AAEH,wBAAsB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAsF5E"}
@@ -0,0 +1,106 @@
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.run = run;
7
+ /* eslint-disable functional/no-try-statements */
8
+ /* eslint-disable no-console */
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const action_extract_1 = require("../package/action-extract");
12
+ const action_check_1 = require("../package/action-check");
13
+ const action_list_1 = require("../package/action-list");
14
+ const action_purge_1 = require("../package/action-purge");
15
+ const utils_1 = require("../utils");
16
+ const argv_1 = require("./argv");
17
+ /**
18
+ * Entry point for self-installable packages generated by `init`.
19
+ * Called from bin/npmdata.js: require('npmdata').run(__dirname, process.argv.slice(2))
20
+ *
21
+ * @param binDir Absolute path to the bin/ directory of the hosting package.
22
+ * @param argv CLI arguments (process.argv.slice(2) from bin shim).
23
+ */
24
+ // eslint-disable-next-line complexity
25
+ async function run(binDir, argv = []) {
26
+ const pkgDir = node_path_1.default.dirname(binDir);
27
+ const pkgJsonPath = node_path_1.default.join(pkgDir, 'package.json');
28
+ let pkgName = node_path_1.default.basename(pkgDir);
29
+ let sets;
30
+ try {
31
+ const pkgJson = JSON.parse(node_fs_1.default.readFileSync(pkgJsonPath).toString());
32
+ pkgName = pkgJson.name ?? pkgName;
33
+ sets = pkgJson.npmdata?.sets;
34
+ }
35
+ catch {
36
+ // No package.json or parse error
37
+ }
38
+ // Fallback: synthetic single-entry when no sets defined
39
+ const entries = sets ?? [{ package: pkgName, output: { path: '.' } }];
40
+ const config = { sets: entries };
41
+ const cwd = process.cwd();
42
+ // Parse command from argv (same as CLI)
43
+ const firstArg = argv[0];
44
+ const KNOWN_COMMANDS = new Set(['extract', 'check', 'list', 'purge']);
45
+ let command = 'extract';
46
+ let cmdArgs = argv;
47
+ if (firstArg && KNOWN_COMMANDS.has(firstArg)) {
48
+ command = firstArg;
49
+ cmdArgs = argv.slice(1);
50
+ }
51
+ let parsed;
52
+ try {
53
+ parsed = (0, argv_1.parseArgv)(cmdArgs);
54
+ }
55
+ catch (error) {
56
+ console.error(`Error: ${error.message}`);
57
+ process.exitCode = 1;
58
+ return;
59
+ }
60
+ // --packages overrides sets
61
+ const cliEntries = (0, argv_1.buildEntriesFromArgv)(parsed);
62
+ const activeEntries = cliEntries ?? entries;
63
+ const overridden = (0, argv_1.applyArgvOverrides)(activeEntries, parsed);
64
+ const presets = parsed.presets ?? [];
65
+ const filtered = (0, utils_1.filterEntriesByPresets)(overridden, presets);
66
+ try {
67
+ switch (command) {
68
+ case 'extract': {
69
+ await (0, action_extract_1.actionExtract)({ entries: filtered, config, cwd });
70
+ break;
71
+ }
72
+ case 'check': {
73
+ const summary = await (0, action_check_1.actionCheck)({ entries: filtered, config, cwd });
74
+ if (summary.missing.length > 0 || summary.modified.length > 0 || summary.extra.length > 0) {
75
+ for (const f of summary.missing)
76
+ console.log(`missing: ${f}`);
77
+ for (const f of summary.modified)
78
+ console.log(`modified: ${f}`);
79
+ for (const f of summary.extra)
80
+ console.log(`extra: ${f}`);
81
+ process.exitCode = 1;
82
+ }
83
+ break;
84
+ }
85
+ case 'list': {
86
+ const files = await (0, action_list_1.actionList)({ entries: filtered, config, cwd });
87
+ for (const f of files) {
88
+ console.log(`${f.path} ${f.packageName}@${f.packageVersion}`);
89
+ }
90
+ break;
91
+ }
92
+ case 'purge': {
93
+ await (0, action_purge_1.actionPurge)({ entries: filtered, config, cwd, presets, dryRun: parsed.dryRun });
94
+ break;
95
+ }
96
+ default:
97
+ console.error(`Unknown command: ${command}`);
98
+ process.exitCode = 1;
99
+ }
100
+ }
101
+ catch (error) {
102
+ console.error(`Error: ${error.message}`);
103
+ process.exitCode = 1;
104
+ }
105
+ }
106
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/cli/runner.ts"],"names":[],"mappings":";;;;;AAsBA,kBAsFC;AA5GD,iDAAiD;AACjD,+BAA+B;AAC/B,sDAAyB;AACzB,0DAA6B;AAG7B,8DAA0D;AAC1D,0DAAsD;AACtD,wDAAoD;AACpD,0DAAsD;AACtD,oCAAkD;AAElD,iCAA6E;AAE7E;;;;;;GAMG;AACH,sCAAsC;AAC/B,KAAK,UAAU,GAAG,CAAC,MAAc,EAAE,OAAiB,EAAE;IAC3D,MAAM,MAAM,GAAG,mBAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD,IAAI,OAAO,GAAG,mBAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,IAAuC,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAGjE,CAAC;QACF,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC;QAClC,IAAI,GAAG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AAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACnE,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;oBACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;gBACjE,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,MAAM,IAAA,0BAAW,EAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBACtF,MAAM;YACR,CAAC;YACD;gBACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;gBAC7C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,UAAW,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Print usage/help text for the given command to stdout.
3
+ */
4
+ export declare function printUsage(command?: string): void;
5
+ export declare function printVersion(): void;
6
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAqHjD;AAED,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /* eslint-disable no-console */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.printUsage = printUsage;
5
+ exports.printVersion = printVersion;
6
+ const VERSION = '2.0.0';
7
+ /**
8
+ * Print usage/help text for the given command to stdout.
9
+ */
10
+ function printUsage(command) {
11
+ const cmd = command ?? 'extract';
12
+ switch (cmd) {
13
+ case 'extract':
14
+ console.log(`
15
+ Usage: npmdata [extract] [options]
16
+
17
+ Extract files from one or more npm packages into a local output directory.
18
+
19
+ Options:
20
+ --packages <specs> Comma-separated package specs (e.g. my-pkg@^1.2.3). Overrides config sets.
21
+ --output, -o <dir> Output directory path. Required when --packages is used.
22
+ --files <globs> Comma-separated glob patterns for file selection.
23
+ --content-regex <re> Comma-separated regex strings for content filtering.
24
+ --force Overwrite existing unmanaged files.
25
+ --keep-existing Skip files that already exist; create missing ones.
26
+ --no-gitignore Disable .gitignore update alongside each marker.
27
+ --unmanaged Write without .npmdata marker; no gitignore; no read-only.
28
+ --dry-run Report changes without writing to disk.
29
+ --upgrade Force fresh package install even if satisfying version installed.
30
+ --presets <tags> Comma-separated preset tags; only matching entries are processed.
31
+ --silent Suppress per-file output; print only final summary line.
32
+ --verbose, -v Print detailed step information.
33
+ --help Print this help text.
34
+ --version Print version.
35
+
36
+ Exit codes: 0 success | 1 error
37
+ `);
38
+ break;
39
+ case 'check':
40
+ console.log(`
41
+ Usage: npmdata check [options]
42
+
43
+ Verify that locally extracted files match their package sources.
44
+
45
+ Options:
46
+ --packages <specs> Comma-separated package specs. Overrides config sets.
47
+ --output, -o <dir> Output directory path.
48
+ --files <globs> Glob patterns for file selection.
49
+ --content-regex <re> Regex strings for content filtering.
50
+ --unmanaged Silently skip unmanaged entries.
51
+ --presets <tags> Comma-separated preset tags; only matching entries are checked.
52
+ --verbose, -v Print detailed comparison information.
53
+ --help Print this help text.
54
+
55
+ Exit codes: 0 all in sync | 1 drift detected or error
56
+ `);
57
+ break;
58
+ case 'list':
59
+ console.log(`
60
+ Usage: npmdata list [options]
61
+
62
+ Print all files currently managed by npmdata in the output directory.
63
+
64
+ Options:
65
+ --output, -o <dir> Output directory to inspect.
66
+ --verbose, -v Print additional metadata per file.
67
+ --help Print this help text.
68
+
69
+ Output format: <relPath> <packageName>@<packageVersion>
70
+ Exit codes: 0 always
71
+ `);
72
+ break;
73
+ case 'purge':
74
+ console.log(`
75
+ Usage: npmdata purge [options]
76
+
77
+ Remove all managed files from the output directory.
78
+
79
+ Options:
80
+ --packages <specs> Comma-separated package specs. Limits purge to matching entries.
81
+ --output, -o <dir> Output directory to purge.
82
+ --presets <tags> Comma-separated preset tags; only matching entries are purged.
83
+ --dry-run Print what would be removed without deleting.
84
+ --silent Suppress per-file output.
85
+ --verbose, -v Print detailed deletion steps.
86
+ --help Print this help text.
87
+
88
+ Exit codes: 0 purge complete | 1 error during deletion
89
+ `);
90
+ break;
91
+ case 'init':
92
+ console.log(`
93
+ Usage: npmdata init [options]
94
+
95
+ Scaffold a new publishable npm data package.
96
+
97
+ Options:
98
+ --output, -o <dir> Directory to scaffold into (default: current dir).
99
+ --verbose, -v Print scaffolding steps.
100
+ --help Print this help text.
101
+
102
+ Created files: package.json, bin/npmdata.js
103
+ Exit codes: 0 success | 1 target dir has conflicting files
104
+ `);
105
+ break;
106
+ default:
107
+ console.log(`
108
+ Usage: npmdata [command] [options]
109
+
110
+ Commands:
111
+ extract (default) Extract files from npm packages
112
+ check Verify extracted files match package sources
113
+ list List all managed files
114
+ purge Remove managed files
115
+ init Scaffold a publishable data package
116
+
117
+ Run 'npmdata <command> --help' for command-specific help.
118
+ Version: ${VERSION}
119
+ `);
120
+ }
121
+ }
122
+ function printVersion() {
123
+ // Try to read version from package.json
124
+ console.log(`npmdata v${VERSION}`);
125
+ }
126
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":";AAAA,+BAA+B;;AAO/B,gCAqHC;AAED,oCAGC;AA/HD,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB;;GAEG;AACH,SAAgB,UAAU,CAAC,OAAgB;IACzC,MAAM,GAAG,GAAG,OAAO,IAAI,SAAS,CAAC;IAEjC,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuBjB,CAAC,CAAC;YACG,MAAM;QAER,KAAK,OAAO;YACV,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;CAgBjB,CAAC,CAAC;YACG,MAAM;QAER,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;CAYjB,CAAC,CAAC;YACG,MAAM;QAER,KAAK,OAAO;YACV,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;CAejB,CAAC,CAAC;YACG,MAAM;QAER,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;CAYjB,CAAC,CAAC;YACG,MAAM;QAER;YACE,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;WAWP,OAAO;CACjB,CAAC,CAAC;IACD,CAAC;AACH,CAAC;AAED,SAAgB,YAAY;IAC1B,wCAAwC;IACxC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { SelectorConfig, OutputConfig, ManagedFileMetadata, CheckResult } from '../types';
2
+ /**
3
+ * Check whether locally extracted files are in sync with their package source.
4
+ * Reuses diff logic to classify files as missing, modified, or extra.
5
+ * Applies contentReplacements before hash comparison.
6
+ *
7
+ * @param pkgPath Absolute path to the installed package directory, or null if not installed.
8
+ * @param outputDir Absolute path to the output directory.
9
+ * @param selector SelectorConfig controlling which package files are in scope.
10
+ * @param outputConfig OutputConfig (used for contentReplacements).
11
+ * @param marker Managed file entries from the .npmdata marker.
12
+ * @returns CheckResult with missing, modified, and extra arrays.
13
+ */
14
+ export declare function checkFileset(pkgPath: string | null, outputDir: string, selector: SelectorConfig, outputConfig: OutputConfig, marker: ManagedFileMetadata[]): Promise<CheckResult>;
15
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/fileset/check.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,WAAW,EAEZ,MAAM,UAAU,CAAC;AAMlB;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAAE,GAC5B,OAAO,CAAC,WAAW,CAAC,CAmDtB"}
@@ -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.checkFileset = checkFileset;
7
+ /* eslint-disable no-restricted-syntax */
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const utils_1 = require("../utils");
11
+ const content_replacements_1 = require("../package/content-replacements");
12
+ const package_files_1 = require("./package-files");
13
+ /**
14
+ * Check whether locally extracted files are in sync with their package source.
15
+ * Reuses diff logic to classify files as missing, modified, or extra.
16
+ * Applies contentReplacements before hash comparison.
17
+ *
18
+ * @param pkgPath Absolute path to the installed package directory, or null if not installed.
19
+ * @param outputDir Absolute path to the output directory.
20
+ * @param selector SelectorConfig controlling which package files are in scope.
21
+ * @param outputConfig OutputConfig (used for contentReplacements).
22
+ * @param marker Managed file entries from the .npmdata marker.
23
+ * @returns CheckResult with missing, modified, and extra arrays.
24
+ */
25
+ async function checkFileset(pkgPath, outputDir, selector, outputConfig, marker) {
26
+ const contentReplacements = outputConfig.contentReplacements ?? [];
27
+ if (!pkgPath) {
28
+ // Package not installed
29
+ return {
30
+ missing: marker.map((m) => m.path),
31
+ modified: [],
32
+ extra: [],
33
+ };
34
+ }
35
+ const managedByPath = new Map(marker.map((m) => [m.path, m]));
36
+ // Enumerate files from package (in scope)
37
+ const pkgFiles = await (0, package_files_1.enumeratePackageFiles)(pkgPath, selector);
38
+ const pkgFileSet = new Set(pkgFiles);
39
+ const result = { missing: [], modified: [], extra: [] };
40
+ // Check each managed file
41
+ for (const m of marker) {
42
+ const destPath = node_path_1.default.join(outputDir, m.path);
43
+ if (!node_fs_1.default.existsSync(destPath)) {
44
+ result.missing.push(m.path);
45
+ continue;
46
+ }
47
+ // Compare hash with content replacements applied
48
+ if (pkgFileSet.has(m.path)) {
49
+ const srcPath = node_path_1.default.join(pkgPath, m.path);
50
+ const srcContent = node_fs_1.default.readFileSync(srcPath, 'utf8');
51
+ const transformed = (0, content_replacements_1.applyContentReplacementsToBuffer)(srcContent, contentReplacements);
52
+ const srcHash = (0, utils_1.hashBuffer)(transformed);
53
+ // eslint-disable-next-line no-await-in-loop
54
+ const destHash = await (0, utils_1.hashFile)(destPath);
55
+ if (srcHash !== destHash) {
56
+ result.modified.push(m.path);
57
+ }
58
+ }
59
+ }
60
+ // Find extra files: in filtered package source but never extracted (not in marker)
61
+ for (const relPath of pkgFiles) {
62
+ if (!managedByPath.has(relPath)) {
63
+ result.extra.push(relPath);
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/fileset/check.ts"],"names":[],"mappings":";;;;;AA4BA,oCAyDC;AArFD,yCAAyC;AACzC,0DAA6B;AAC7B,sDAAyB;AASzB,oCAAgD;AAChD,0EAAmF;AAEnF,mDAAwD;AAExD;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CAChC,OAAsB,EACtB,SAAiB,EACjB,QAAwB,EACxB,YAA0B,EAC1B,MAA6B;IAE7B,MAAM,mBAAmB,GAA+B,YAAY,CAAC,mBAAmB,IAAI,EAAE,C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,CAAC,CAAC;YACpD,MAAM,WAAW,GAAG,IAAA,uDAAgC,EAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;YACtF,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;YACxC,4CAA4C;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,gBAAQ,EAAC,QAAQ,CAAC,CAAC;YAE1C,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACzB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,mFAAmF;IACnF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Name of the npmdata marker file that tracks managed files.
3
+ */
4
+ export declare const MARKER_FILE = ".npmdata";
5
+ /**
6
+ * Default filename patterns applied when no `files` glob patterns are specified in SelectorConfig.
7
+ * Excludes common package metadata files that are not meant to be extracted by consumers.
8
+ */
9
+ export declare const DEFAULT_FILENAME_PATTERNS: string[];
10
+ export declare const GITIGNORE_FILE = ".gitignore";
11
+ export declare const GITIGNORE_START = "# npmdata:start";
12
+ export declare const GITIGNORE_END = "# npmdata:end";
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/fileset/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,yBAAyB,UAMrC,CAAC;AAEF,eAAO,MAAM,cAAc,eAAe,CAAC;AAC3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,aAAa,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GITIGNORE_END = exports.GITIGNORE_START = exports.GITIGNORE_FILE = exports.DEFAULT_FILENAME_PATTERNS = exports.MARKER_FILE = void 0;
4
+ /**
5
+ * Name of the npmdata marker file that tracks managed files.
6
+ */
7
+ exports.MARKER_FILE = '.npmdata';
8
+ /**
9
+ * Default filename patterns applied when no `files` glob patterns are specified in SelectorConfig.
10
+ * Excludes common package metadata files that are not meant to be extracted by consumers.
11
+ */
12
+ exports.DEFAULT_FILENAME_PATTERNS = [
13
+ '**',
14
+ '!package.json',
15
+ '!bin/**',
16
+ '!README.md',
17
+ '!node_modules/**',
18
+ ];
19
+ exports.GITIGNORE_FILE = '.gitignore';
20
+ exports.GITIGNORE_START = '# npmdata:start';
21
+ exports.GITIGNORE_END = '# npmdata:end';
22
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/fileset/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG,UAAU,CAAC;AAEtC;;;GAGG;AACU,QAAA,yBAAyB,GAAG;IACvC,IAAI;IACJ,eAAe;IACf,SAAS;IACT,YAAY;IACZ,kBAAkB;CACnB,CAAC;AAEW,QAAA,cAAc,GAAG,YAAY,CAAC;AAC9B,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,aAAa,GAAG,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { SelectorConfig, OutputConfig, ExtractionMap, ManagedFileMetadata, ContentReplacementConfig } from '../types';
2
+ /**
3
+ * Pure read-only diff between package source files and an output directory.
4
+ * Classifies each file as toAdd, toModify, toDelete, toSkip, or conflicts.
5
+ * Makes NO disk writes.
6
+ *
7
+ * @param pkgPath Absolute path to the installed package directory.
8
+ * @param outputDir Absolute path to the output directory.
9
+ * @param selector SelectorConfig controlling which package files are included.
10
+ * @param outputConfig OutputConfig controlling extraction behaviour.
11
+ * @param existingMarker Current managed file entries from the .npmdata marker.
12
+ * @param contentReplacements Content replacement configs to apply before hash comparison.
13
+ * @returns ExtractionMap classifying all file operations.
14
+ */
15
+ export declare function diff(pkgPath: string, outputDir: string, selector: SelectorConfig, outputConfig: OutputConfig, existingMarker: ManagedFileMetadata[], contentReplacements: ContentReplacementConfig[]): Promise<ExtractionMap>;
16
+ //# sourceMappingURL=diff.d.ts.map