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.
- package/README.md +47 -42
- package/dist/cli/actions/check.d.ts +6 -0
- package/dist/cli/actions/check.d.ts.map +1 -0
- package/dist/cli/actions/check.js +45 -0
- package/dist/cli/actions/check.js.map +1 -0
- package/dist/cli/actions/extract.d.ts +7 -0
- package/dist/cli/actions/extract.d.ts.map +1 -0
- package/dist/cli/actions/extract.js +67 -0
- package/dist/cli/actions/extract.js.map +1 -0
- package/dist/cli/actions/init.d.ts +6 -0
- package/dist/cli/actions/init.d.ts.map +1 -0
- package/dist/cli/actions/init.js +30 -0
- package/dist/cli/actions/init.js.map +1 -0
- package/dist/cli/actions/list.d.ts +7 -0
- package/dist/cli/actions/list.d.ts.map +1 -0
- package/dist/cli/actions/list.js +36 -0
- package/dist/cli/actions/list.js.map +1 -0
- package/dist/cli/actions/purge.d.ts +6 -0
- package/dist/cli/actions/purge.d.ts.map +1 -0
- package/dist/cli/actions/purge.js +33 -0
- package/dist/cli/actions/purge.js.map +1 -0
- package/dist/cli/argv.d.ts +35 -0
- package/dist/cli/argv.d.ts.map +1 -0
- package/dist/cli/argv.js +125 -0
- package/dist/cli/argv.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +11 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/binpkg.d.ts +8 -0
- package/dist/cli/binpkg.d.ts.map +1 -0
- package/dist/cli/binpkg.js +24 -0
- package/dist/cli/binpkg.js.map +1 -0
- package/dist/cli/cli.d.ts +10 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +72 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/usage.d.ts +6 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +126 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/fileset/check.d.ts +15 -0
- package/dist/fileset/check.d.ts.map +1 -0
- package/dist/fileset/check.js +68 -0
- package/dist/fileset/check.js.map +1 -0
- package/dist/fileset/constants.d.ts +13 -0
- package/dist/fileset/constants.d.ts.map +1 -0
- package/dist/fileset/constants.js +22 -0
- package/dist/fileset/constants.js.map +1 -0
- package/dist/fileset/diff.d.ts +16 -0
- package/dist/fileset/diff.d.ts.map +1 -0
- package/dist/fileset/diff.js +116 -0
- package/dist/fileset/diff.js.map +1 -0
- package/dist/fileset/execute.d.ts +29 -0
- package/dist/fileset/execute.d.ts.map +1 -0
- package/dist/fileset/execute.js +136 -0
- package/dist/fileset/execute.js.map +1 -0
- package/dist/fileset/gitignore.d.ts +16 -0
- package/dist/fileset/gitignore.d.ts.map +1 -0
- package/dist/fileset/gitignore.js +82 -0
- package/dist/fileset/gitignore.js.map +1 -0
- package/dist/fileset/index.d.ts +5 -0
- package/dist/fileset/index.d.ts.map +1 -0
- package/dist/fileset/index.js +21 -0
- package/dist/fileset/index.js.map +1 -0
- package/dist/fileset/list.d.ts +6 -0
- package/dist/fileset/list.d.ts.map +1 -0
- package/dist/fileset/list.js +11 -0
- package/dist/fileset/list.js.map +1 -0
- package/dist/fileset/markers.d.ts +22 -0
- package/dist/fileset/markers.d.ts.map +1 -0
- package/dist/fileset/markers.js +68 -0
- package/dist/fileset/markers.js.map +1 -0
- package/dist/fileset/package-files.d.ts +14 -0
- package/dist/fileset/package-files.d.ts.map +1 -0
- package/dist/fileset/package-files.js +81 -0
- package/dist/fileset/package-files.js.map +1 -0
- package/dist/fileset/purge.d.ts +12 -0
- package/dist/fileset/purge.d.ts.map +1 -0
- package/dist/fileset/purge.js +95 -0
- package/dist/fileset/purge.js.map +1 -0
- package/dist/fileset/test-utils.d.ts +12 -0
- package/dist/fileset/test-utils.d.ts.map +1 -0
- package/dist/fileset/test-utils.js +65 -0
- package/dist/fileset/test-utils.js.map +1 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -20
- package/dist/index.js.map +1 -1
- package/dist/npmdata-0.0.1.tgz +0 -0
- package/dist/package/action-check.d.ts +20 -0
- package/dist/package/action-check.d.ts.map +1 -0
- package/dist/package/action-check.js +61 -0
- package/dist/package/action-check.js.map +1 -0
- package/dist/package/action-extract.d.ts +21 -0
- package/dist/package/action-extract.d.ts.map +1 -0
- package/dist/package/action-extract.js +186 -0
- package/dist/package/action-extract.js.map +1 -0
- package/dist/package/action-init.d.ts +13 -0
- package/dist/package/action-init.d.ts.map +1 -0
- package/dist/package/action-init.js +77 -0
- package/dist/package/action-init.js.map +1 -0
- package/dist/package/action-list.d.ts +14 -0
- package/dist/package/action-list.d.ts.map +1 -0
- package/dist/package/action-list.js +46 -0
- package/dist/package/action-list.js.map +1 -0
- package/dist/package/action-purge.d.ts +21 -0
- package/dist/package/action-purge.d.ts.map +1 -0
- package/dist/package/action-purge.js +60 -0
- package/dist/package/action-purge.js.map +1 -0
- package/dist/package/config-merge.d.ts +18 -0
- package/dist/package/config-merge.d.ts.map +1 -0
- package/dist/package/config-merge.js +48 -0
- package/dist/package/config-merge.js.map +1 -0
- package/dist/package/config.d.ts +13 -0
- package/dist/package/config.d.ts.map +1 -0
- package/dist/package/config.js +29 -0
- package/dist/package/config.js.map +1 -0
- package/dist/package/content-replacements.d.ts +21 -0
- package/dist/package/content-replacements.d.ts.map +1 -0
- package/dist/package/content-replacements.js +96 -0
- package/dist/package/content-replacements.js.map +1 -0
- package/dist/package/index.d.ts +10 -0
- package/dist/package/index.d.ts.map +1 -0
- package/dist/package/index.js +16 -0
- package/dist/package/index.js.map +1 -0
- package/dist/package/symlinks.d.ts +17 -0
- package/dist/package/symlinks.d.ts.map +1 -0
- package/dist/package/symlinks.js +125 -0
- package/dist/package/symlinks.js.map +1 -0
- package/dist/types.d.ts +181 -277
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +25 -55
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +82 -181
- package/dist/utils.js.map +1 -1
- package/package.json +5 -3
- package/bin/npmdata.js +0 -4
- package/dist/cli.d.ts +0 -6
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -570
- package/dist/cli.js.map +0 -1
- package/dist/consumer.d.ts +0 -74
- package/dist/consumer.d.ts.map +0 -1
- package/dist/consumer.js +0 -820
- package/dist/consumer.js.map +0 -1
- package/dist/main.d.ts +0 -3
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -21
- package/dist/main.js.map +0 -1
- package/dist/publisher.d.ts +0 -38
- package/dist/publisher.d.ts.map +0 -1
- package/dist/publisher.js +0 -164
- package/dist/publisher.js.map +0 -1
- package/dist/runner.d.ts +0 -117
- package/dist/runner.d.ts.map +0 -1
- package/dist/runner.js +0 -812
- package/dist/runner.js.map +0 -1
package/dist/cli/argv.js
ADDED
|
@@ -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,CAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,SAAkB,EAAsB,EAAE;QACxE,wCAAwC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;QAC9F,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,wCAAwC;YACxC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,MAAM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Ac,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 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
5
|
+
const cli_1 = require("./cli");
|
|
6
|
+
(0, cli_1.cli)(['node', 'npmdata', ...process.argv.slice(2)], process.cwd()).catch((error) => {
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
console.error(error.message);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";;;AACA,sDAAsD;AACtD,+BAA4B;AAE5B,IAAA,SAAG,EAAC,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACzF,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic entry point for data-package bin shims generated by `npmdata init`.
|
|
3
|
+
*
|
|
4
|
+
* @param binDir - The bin/ directory of the data package (__dirname from the shim).
|
|
5
|
+
* @param args - CLI arguments (without node + script, i.e. process.argv.slice(2)).
|
|
6
|
+
*/
|
|
7
|
+
export declare function binpkg(binDir: string, args: string[]): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=binpkg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binpkg.d.ts","sourceRoot":"","sources":["../../src/cli/binpkg.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAS1E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.binpkg = binpkg;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const cli_1 = require("./cli");
|
|
10
|
+
/**
|
|
11
|
+
* Programmatic entry point for data-package bin shims generated by `npmdata init`.
|
|
12
|
+
*
|
|
13
|
+
* @param binDir - The bin/ directory of the data package (__dirname from the shim).
|
|
14
|
+
* @param args - CLI arguments (without node + script, i.e. process.argv.slice(2)).
|
|
15
|
+
*/
|
|
16
|
+
async function binpkg(binDir, args) {
|
|
17
|
+
if (args.includes('--packages')) {
|
|
18
|
+
throw new Error('Cannot use --packages when invoked from a data package bin shim');
|
|
19
|
+
}
|
|
20
|
+
const pkgRootDir = node_path_1.default.join(binDir, '..');
|
|
21
|
+
const pkgJson = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(pkgRootDir, 'package.json')).toString());
|
|
22
|
+
await (0, cli_1.cli)(['node', 'npmdata', ...args, '--packages', pkgJson.name], process.cwd(), pkgRootDir);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=binpkg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binpkg.js","sourceRoot":"","sources":["../../src/cli/binpkg.ts"],"names":[],"mappings":";;;;;AAWA,wBASC;AApBD,sDAAyB;AACzB,0DAA6B;AAE7B,+BAA4B;AAE5B;;;;;GAKG;AACI,KAAK,UAAU,MAAM,CAAC,MAAc,EAAE,IAAc;IACzD,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IACD,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAE3F,CAAC;IACF,MAAM,IAAA,SAAG,EAAC,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 for output path resolution (defaults to process.cwd()).
|
|
7
|
+
* @param configCwd - Directory to search for npmdata config (defaults to cwd).
|
|
8
|
+
*/
|
|
9
|
+
export declare function cli(argv: string[], cwd?: string, configCwd?: string): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDzF"}
|
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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 for output path resolution (defaults to process.cwd()).
|
|
19
|
+
* @param configCwd - Directory to search for npmdata config (defaults to cwd).
|
|
20
|
+
*/
|
|
21
|
+
async function cli(argv, cwd, configCwd) {
|
|
22
|
+
const args = argv.slice(2); // strip node + script
|
|
23
|
+
// Handle global --help with no command
|
|
24
|
+
if (args.includes('--help') && args.length === 1) {
|
|
25
|
+
(0, usage_1.printUsage)();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Handle global --version
|
|
29
|
+
if (args.includes('--version')) {
|
|
30
|
+
(0, usage_1.printVersion)();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Detect action
|
|
34
|
+
let action;
|
|
35
|
+
let cmdArgs;
|
|
36
|
+
const firstArg = args[0];
|
|
37
|
+
if (firstArg && KNOWN_COMMANDS.has(firstArg)) {
|
|
38
|
+
action = firstArg;
|
|
39
|
+
cmdArgs = args.slice(1);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Default to extract
|
|
43
|
+
action = 'extract';
|
|
44
|
+
cmdArgs = args;
|
|
45
|
+
}
|
|
46
|
+
// Load config from cwd, unless --packages is specified (CLI-only mode)
|
|
47
|
+
const effectiveCwd = cwd ?? process.cwd();
|
|
48
|
+
const effectiveConfigCwd = configCwd ?? effectiveCwd;
|
|
49
|
+
const config = cmdArgs.includes('--packages')
|
|
50
|
+
? null // eslint-disable-line unicorn/no-null
|
|
51
|
+
: await (0, config_1.loadNpmdataConfig)(effectiveConfigCwd);
|
|
52
|
+
switch (action) {
|
|
53
|
+
case 'extract':
|
|
54
|
+
await (0, extract_1.runExtract)(config, cmdArgs, effectiveCwd);
|
|
55
|
+
break;
|
|
56
|
+
case 'check':
|
|
57
|
+
await (0, check_1.runCheck)(config, cmdArgs, effectiveCwd);
|
|
58
|
+
break;
|
|
59
|
+
case 'list':
|
|
60
|
+
await (0, list_1.runList)(config, cmdArgs, effectiveCwd);
|
|
61
|
+
break;
|
|
62
|
+
case 'purge':
|
|
63
|
+
await (0, purge_1.runPurge)(config, cmdArgs, effectiveCwd);
|
|
64
|
+
break;
|
|
65
|
+
case 'init':
|
|
66
|
+
await (0, init_1.runInit)(config, cmdArgs, effectiveCwd);
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
throw new Error(`Unknown command: ${action}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;AAoBA,kBAuDC;AA3ED,+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;;;;;;;GAOG;AACI,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,GAAY,EAAE,SAAkB;IACxE,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,oBAAY,GAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,gBAAgB;IAChB,IAAI,MAAc,CAAC;IACnB,IAAI,OAA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M,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
|
@@ -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,CAAC;IAE/F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,wBAAwB;QACxB,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YAClC,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAA8B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3F,0CAA0C;IAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,qCAAqB,EAAC,OAAO,EAAE,QAAQ,CAAC,C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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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/fileset/diff.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAMlB;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CACxB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,mBAAmB,EAAE,EACrC,mBAAmB,EAAE,wBAAwB,EAAE,GAC9C,OAAO,CAAC,aAAa,CAAC,CAuFxB"}
|