filedist 0.31.0 → 0.33.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 +301 -254
- package/dist/cli/actions/check.d.ts +5 -2
- package/dist/cli/actions/check.d.ts.map +1 -1
- package/dist/cli/actions/check.js +9 -3
- package/dist/cli/actions/check.js.map +1 -1
- package/dist/cli/actions/init.d.ts.map +1 -1
- package/dist/cli/actions/init.js +10 -3
- package/dist/cli/actions/init.js.map +1 -1
- package/dist/cli/actions/install.d.ts +7 -0
- package/dist/cli/actions/install.d.ts.map +1 -0
- package/dist/cli/actions/{extract.js → install.js} +15 -13
- package/dist/cli/actions/install.js.map +1 -0
- package/dist/cli/actions/list.d.ts +1 -1
- package/dist/cli/actions/list.d.ts.map +1 -1
- package/dist/cli/actions/list.js +4 -2
- package/dist/cli/actions/list.js.map +1 -1
- package/dist/cli/actions/remove.d.ts +20 -0
- package/dist/cli/actions/remove.d.ts.map +1 -0
- package/dist/cli/actions/remove.js +133 -0
- package/dist/cli/actions/remove.js.map +1 -0
- package/dist/cli/actions/update.d.ts +8 -0
- package/dist/cli/actions/update.d.ts.map +1 -0
- package/dist/cli/actions/update.js +40 -0
- package/dist/cli/actions/update.js.map +1 -0
- package/dist/cli/argv.d.ts +8 -5
- package/dist/cli/argv.d.ts.map +1 -1
- package/dist/cli/argv.js +40 -15
- package/dist/cli/argv.js.map +1 -1
- package/dist/cli/binpkg.d.ts +1 -12
- package/dist/cli/binpkg.d.ts.map +1 -1
- package/dist/cli/binpkg.js +64 -12
- package/dist/cli/binpkg.js.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +80 -41
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/usage.d.ts.map +1 -1
- package/dist/cli/usage.js +65 -33
- package/dist/cli/usage.js.map +1 -1
- package/dist/fileset/check.d.ts +0 -1
- package/dist/fileset/check.d.ts.map +1 -1
- package/dist/fileset/check.js +7 -8
- package/dist/fileset/check.js.map +1 -1
- package/dist/fileset/constants.d.ts.map +1 -1
- package/dist/fileset/constants.js +3 -2
- package/dist/fileset/constants.js.map +1 -1
- package/dist/fileset/execute.d.ts.map +1 -1
- package/dist/fileset/execute.js +2 -1
- package/dist/fileset/execute.js.map +1 -1
- package/dist/fileset/gitignore.js +3 -3
- package/dist/fileset/gitignore.js.map +1 -1
- package/dist/fileset/markers.d.ts +1 -2
- package/dist/fileset/markers.d.ts.map +1 -1
- package/dist/fileset/markers.js +6 -14
- package/dist/fileset/markers.js.map +1 -1
- package/dist/fileset/test-utils.d.ts.map +1 -1
- package/dist/fileset/test-utils.js +2 -1
- package/dist/fileset/test-utils.js.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/package/action-check.d.ts +19 -9
- package/dist/package/action-check.d.ts.map +1 -1
- package/dist/package/action-check.js +76 -32
- package/dist/package/action-check.js.map +1 -1
- package/dist/package/action-init.d.ts +6 -2
- package/dist/package/action-init.d.ts.map +1 -1
- package/dist/package/action-init.js +26 -15
- package/dist/package/action-init.js.map +1 -1
- package/dist/package/action-install.d.ts +22 -0
- package/dist/package/action-install.d.ts.map +1 -0
- package/dist/package/{action-extract.js → action-install.js} +205 -32
- package/dist/package/action-install.js.map +1 -0
- package/dist/package/action-list.d.ts +5 -2
- package/dist/package/action-list.d.ts.map +1 -1
- package/dist/package/action-list.js +5 -4
- package/dist/package/action-list.js.map +1 -1
- package/dist/package/action-remove.d.ts +65 -0
- package/dist/package/action-remove.d.ts.map +1 -0
- package/dist/package/action-remove.js +171 -0
- package/dist/package/action-remove.js.map +1 -0
- package/dist/package/action-update.d.ts +28 -0
- package/dist/package/action-update.d.ts.map +1 -0
- package/dist/package/action-update.js +45 -0
- package/dist/package/action-update.js.map +1 -0
- package/dist/package/calculate-diff.d.ts +1 -1
- package/dist/package/calculate-diff.d.ts.map +1 -1
- package/dist/package/calculate-diff.js +11 -13
- package/dist/package/calculate-diff.js.map +1 -1
- package/dist/package/config.d.ts +40 -27
- package/dist/package/config.d.ts.map +1 -1
- package/dist/package/config.js +164 -113
- package/dist/package/config.js.map +1 -1
- package/dist/package/index.d.ts +6 -4
- package/dist/package/index.d.ts.map +1 -1
- package/dist/package/index.js +7 -5
- package/dist/package/index.js.map +1 -1
- package/dist/package/lockfile.d.ts +69 -0
- package/dist/package/lockfile.d.ts.map +1 -0
- package/dist/package/lockfile.js +191 -0
- package/dist/package/lockfile.js.map +1 -0
- package/dist/package/resolve-files.d.ts +14 -0
- package/dist/package/resolve-files.d.ts.map +1 -1
- package/dist/package/resolve-files.js +5 -1
- package/dist/package/resolve-files.js.map +1 -1
- package/dist/package/source.d.ts +13 -0
- package/dist/package/source.d.ts.map +1 -1
- package/dist/package/source.js +32 -11
- package/dist/package/source.js.map +1 -1
- package/dist/package/symlinks.d.ts.map +1 -1
- package/dist/package/symlinks.js +8 -3
- package/dist/package/symlinks.js.map +1 -1
- package/dist/types.d.ts +7 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -2
- package/dist/cli/actions/extract.d.ts +0 -7
- package/dist/cli/actions/extract.d.ts.map +0 -1
- package/dist/cli/actions/extract.js.map +0 -1
- package/dist/cli/actions/purge.d.ts +0 -6
- package/dist/cli/actions/purge.d.ts.map +0 -1
- package/dist/cli/actions/purge.js +0 -42
- package/dist/cli/actions/purge.js.map +0 -1
- package/dist/package/action-extract.d.ts +0 -20
- package/dist/package/action-extract.d.ts.map +0 -1
- package/dist/package/action-extract.js.map +0 -1
- package/dist/package/action-purge.d.ts +0 -19
- package/dist/package/action-purge.d.ts.map +0 -1
- package/dist/package/action-purge.js +0 -135
- package/dist/package/action-purge.js.map +0 -1
package/dist/package/config.js
CHANGED
|
@@ -3,25 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.PACKAGE_CONFIG_FILENAME = exports.DEFAULT_CONFIG_FILENAME = void 0;
|
|
7
|
+
exports.loadDefaultConfig = loadDefaultConfig;
|
|
7
8
|
exports.loadFiledistConfigFile = loadFiledistConfigFile;
|
|
8
|
-
exports.
|
|
9
|
-
exports.loadFiledistLocalConfig = loadFiledistLocalConfig;
|
|
9
|
+
exports.loadPackageConfig = loadPackageConfig;
|
|
10
10
|
exports.upsertFiledistConfigEntries = upsertFiledistConfigEntries;
|
|
11
|
+
exports.packageNameWithoutRef = packageNameWithoutRef;
|
|
12
|
+
exports.removeFiledistConfigEntries = removeFiledistConfigEntries;
|
|
11
13
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
14
15
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
15
16
|
const POST_EXTRACT_CMD_EXAMPLE = '["node", "scripts/post-extract.js"]';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'.filedistrc.yml',
|
|
21
|
-
'filedist.config.js',
|
|
22
|
-
'filedist.config.cjs',
|
|
23
|
-
'package.json',
|
|
24
|
-
];
|
|
17
|
+
/** Default bootstrap config filename. */
|
|
18
|
+
exports.DEFAULT_CONFIG_FILENAME = '.filedist.yml';
|
|
19
|
+
/** Package config filename used by data packages to define their own sets. */
|
|
20
|
+
exports.PACKAGE_CONFIG_FILENAME = '.filedist-package.yml';
|
|
25
21
|
function validateFiledistConfig(cfg, sourceLabel) {
|
|
26
22
|
if (!cfg || !Array.isArray(cfg.sets)) {
|
|
27
23
|
// eslint-disable-next-line unicorn/no-null
|
|
@@ -43,79 +39,10 @@ function validateFiledistConfig(cfg, sourceLabel) {
|
|
|
43
39
|
}
|
|
44
40
|
return cfg;
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* Looks for (in priority order):
|
|
49
|
-
* - .filedistrc (JSON or YAML)
|
|
50
|
-
* - .filedistrc.json / .filedistrc.yaml / .filedistrc.js
|
|
51
|
-
* - filedist.config.js
|
|
52
|
-
* - "filedist" key in package.json
|
|
53
|
-
*
|
|
54
|
-
* Returns the FiledistConfig when found, or null when no configuration is present.
|
|
55
|
-
*/
|
|
56
|
-
async function searchAndLoadFiledistConfig(cwd) {
|
|
57
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
|
|
58
|
-
const result = await explorer.search(cwd);
|
|
59
|
-
if (!result || result.isEmpty) {
|
|
60
|
-
// eslint-disable-next-line unicorn/no-null
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return validateFiledistConfig(result.config, result.filepath);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Load a filedist configuration from an explicit file path using cosmiconfig.
|
|
67
|
-
* Supports JSON, YAML, and JS config files.
|
|
68
|
-
*
|
|
69
|
-
* Returns the FiledistConfig when found, or null when the file is empty or invalid.
|
|
70
|
-
*/
|
|
71
|
-
async function loadFiledistConfigFile(filePath) {
|
|
72
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
|
|
73
|
-
const result = await explorer.load(filePath);
|
|
74
|
-
if (!result || result.isEmpty) {
|
|
75
|
-
// eslint-disable-next-line unicorn/no-null
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
return validateFiledistConfig(result.config, result.filepath);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Load filedist config only from the given directory, without searching parent folders.
|
|
82
|
-
*/
|
|
83
|
-
async function loadFiledistConfigFromDirectory(directory) {
|
|
84
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
|
|
85
|
-
for (const basename of CONFIG_BASENAMES) {
|
|
86
|
-
let result;
|
|
87
|
-
try {
|
|
88
|
-
result = await explorer.load(`${directory}/${basename}`);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
if (error.code === 'ENOENT') {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
if (!result || result.isEmpty)
|
|
97
|
-
continue;
|
|
98
|
-
const cfg = validateFiledistConfig(result.config, result.filepath);
|
|
99
|
-
if (cfg) {
|
|
100
|
-
return cfg;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// eslint-disable-next-line unicorn/no-null
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const RC_FILENAME = '.filedistrc.yml';
|
|
107
|
-
const LOCAL_RC_FILENAME = '.filedistrc.local.yml';
|
|
108
|
-
/**
|
|
109
|
-
* Load a filedist configuration from `.filedistrc.local.yml` in the given directory.
|
|
110
|
-
* Returns the config when found, or null when the file does not exist or is empty.
|
|
111
|
-
* The local config file is intentionally not searched in parent directories.
|
|
112
|
-
*/
|
|
113
|
-
async function loadFiledistLocalConfig(directory) {
|
|
114
|
-
const filePath = node_path_1.default.join(directory, LOCAL_RC_FILENAME);
|
|
115
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)('filedist');
|
|
116
|
-
let result;
|
|
42
|
+
function loadYamlConfig(filePath) {
|
|
43
|
+
let raw;
|
|
117
44
|
try {
|
|
118
|
-
|
|
45
|
+
raw = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
119
46
|
}
|
|
120
47
|
catch (error) {
|
|
121
48
|
if (error.code === 'ENOENT') {
|
|
@@ -124,29 +51,92 @@ async function loadFiledistLocalConfig(directory) {
|
|
|
124
51
|
}
|
|
125
52
|
throw error;
|
|
126
53
|
}
|
|
127
|
-
|
|
54
|
+
const parsed = js_yaml_1.default.load(raw);
|
|
55
|
+
if (!parsed) {
|
|
128
56
|
// eslint-disable-next-line unicorn/no-null
|
|
129
57
|
return null;
|
|
130
58
|
}
|
|
131
|
-
return validateFiledistConfig(
|
|
59
|
+
return validateFiledistConfig(parsed, filePath);
|
|
132
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Load the default filedist bootstrap config (.filedist.yml) from the given directory.
|
|
63
|
+
* Returns the FiledistConfig when found, or null when absent or empty.
|
|
64
|
+
*/
|
|
65
|
+
function loadDefaultConfig(cwd) {
|
|
66
|
+
return loadYamlConfig(node_path_1.default.join(cwd, exports.DEFAULT_CONFIG_FILENAME));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Load a filedist bootstrap config from an explicit YAML file path.
|
|
70
|
+
* Returns the FiledistConfig when found, or null when the file is empty or absent.
|
|
71
|
+
*/
|
|
72
|
+
function loadFiledistConfigFile(filePath) {
|
|
73
|
+
return loadYamlConfig(filePath);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Load a filedist package config (.filedist-package.yml) from the given directory.
|
|
77
|
+
* Data packages place this file in their root to define their sets, selectors, and presets.
|
|
78
|
+
* Returns the FiledistConfig when found, or null when absent or empty.
|
|
79
|
+
*/
|
|
80
|
+
function loadPackageConfig(directory) {
|
|
81
|
+
return loadYamlConfig(node_path_1.default.join(directory, exports.PACKAGE_CONFIG_FILENAME));
|
|
82
|
+
}
|
|
83
|
+
const RC_FILENAME = exports.DEFAULT_CONFIG_FILENAME;
|
|
133
84
|
/**
|
|
134
85
|
* Upsert entries into a filedist YAML config file.
|
|
135
|
-
* - Uses the path provided (from --config) or defaults to `.
|
|
86
|
+
* - Uses the path provided (from --config) or defaults to `.filedist.yml` in `directory`.
|
|
136
87
|
* - Reads the existing file (or starts with an empty sets array).
|
|
137
88
|
* - For each provided entry, replaces an existing entry with the same `package`
|
|
138
89
|
* value, or appends it when no match is found.
|
|
139
90
|
* - Writes the merged result back as YAML.
|
|
140
91
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Upserts a single entry into the sets array. Returns true if changed.
|
|
94
|
+
*/
|
|
95
|
+
function upsertSingleEntry(sets, addEntry) {
|
|
96
|
+
if (!addEntry.package)
|
|
97
|
+
return false;
|
|
98
|
+
const baseName = packageNameWithoutRef(addEntry.package);
|
|
99
|
+
// Build a minimal entry: omit output and selector when they are empty objects
|
|
100
|
+
const entryToSave = { package: addEntry.package };
|
|
101
|
+
if (addEntry.selector && Object.keys(addEntry.selector).length > 0) {
|
|
102
|
+
entryToSave.selector = addEntry.selector;
|
|
103
|
+
}
|
|
104
|
+
if (addEntry.output && Object.keys(addEntry.output).length > 0) {
|
|
105
|
+
entryToSave.output = addEntry.output;
|
|
106
|
+
}
|
|
107
|
+
// Collect indices of all entries whose base name matches (regardless of version)
|
|
108
|
+
const matchingIndices = sets.reduce((acc, e, i) => {
|
|
109
|
+
if (e.package && packageNameWithoutRef(e.package) === baseName)
|
|
110
|
+
acc.push(i);
|
|
111
|
+
return acc;
|
|
112
|
+
}, []);
|
|
113
|
+
if (matchingIndices.length > 0) {
|
|
114
|
+
const firstIdx = matchingIndices[0];
|
|
115
|
+
// Short-circuit when there is exactly one match and it is already identical
|
|
116
|
+
if (matchingIndices.length === 1 &&
|
|
117
|
+
JSON.stringify(sets[firstIdx]) === JSON.stringify(entryToSave)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
// Remove all matching entries in reverse order (preserves unaffected indices)
|
|
121
|
+
for (let i = matchingIndices.length - 1; i >= 0; i--) {
|
|
122
|
+
sets.splice(matchingIndices[i], 1);
|
|
123
|
+
}
|
|
124
|
+
// Re-insert the single updated entry at the position of the first removed entry
|
|
125
|
+
sets.splice(firstIdx, 0, entryToSave);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
sets.push(entryToSave);
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
async function upsertFiledistConfigEntries(directory, configFilePath, addEntries) {
|
|
132
|
+
const filePath = configFilePath;
|
|
143
133
|
// Read and parse existing config, or start fresh
|
|
144
|
-
let existing = { sets: [] };
|
|
134
|
+
let existing = { version: 1, sets: [] };
|
|
145
135
|
try {
|
|
146
136
|
const raw = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
147
137
|
const parsed = js_yaml_1.default.load(raw);
|
|
148
|
-
if (parsed
|
|
149
|
-
existing = { sets: parsed.sets };
|
|
138
|
+
if (parsed?.sets) {
|
|
139
|
+
existing = { version: parsed.version, sets: parsed.sets };
|
|
150
140
|
}
|
|
151
141
|
}
|
|
152
142
|
catch (error) {
|
|
@@ -154,32 +144,93 @@ async function upsertFiledistConfigEntries(directory, addEntries, configFilePath
|
|
|
154
144
|
throw error;
|
|
155
145
|
}
|
|
156
146
|
}
|
|
157
|
-
// Upsert each entry by package name
|
|
147
|
+
// Upsert each entry by base package name (ignoring version/ref).
|
|
148
|
+
// All existing entries that share the same base name are removed and replaced
|
|
149
|
+
// with a single new entry so that stale version selectors do not accumulate.
|
|
158
150
|
let changed = false;
|
|
159
151
|
for (const addEntry of addEntries) {
|
|
160
|
-
|
|
161
|
-
// Build a minimal entry: omit output and selector when they are empty objects
|
|
162
|
-
const entryToSave = { package: addEntry.package };
|
|
163
|
-
if (addEntry.selector && Object.keys(addEntry.selector).length > 0) {
|
|
164
|
-
entryToSave.selector = addEntry.selector;
|
|
165
|
-
}
|
|
166
|
-
if (addEntry.output && Object.keys(addEntry.output).length > 0) {
|
|
167
|
-
entryToSave.output = addEntry.output;
|
|
168
|
-
}
|
|
169
|
-
if (idx !== -1) {
|
|
170
|
-
// Only replace when the entry content differs
|
|
171
|
-
if (JSON.stringify(existing.sets[idx]) !== JSON.stringify(entryToSave)) {
|
|
172
|
-
existing.sets[idx] = entryToSave;
|
|
173
|
-
changed = true;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
existing.sets.push(entryToSave);
|
|
152
|
+
if (upsertSingleEntry(existing.sets, addEntry))
|
|
178
153
|
changed = true;
|
|
179
|
-
}
|
|
180
154
|
}
|
|
181
155
|
if (!changed)
|
|
182
156
|
return;
|
|
183
157
|
node_fs_1.default.writeFileSync(filePath, js_yaml_1.default.dump(existing, { indent: 2 }), 'utf8');
|
|
184
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Strip the version/ref from a package spec string, leaving only the package name.
|
|
161
|
+
*
|
|
162
|
+
* Examples:
|
|
163
|
+
* "my-pkg@^1.2.3" → "my-pkg"
|
|
164
|
+
* "@scope/pkg@1.0.0" → "@scope/pkg"
|
|
165
|
+
* "git:github.com/org/repo.git@main" → "git:github.com/org/repo.git"
|
|
166
|
+
* "my-pkg" → "my-pkg"
|
|
167
|
+
*/
|
|
168
|
+
function packageNameWithoutRef(spec) {
|
|
169
|
+
if (!spec)
|
|
170
|
+
return spec;
|
|
171
|
+
if (spec.startsWith('git:')) {
|
|
172
|
+
// git:url@ref — strip trailing @ref
|
|
173
|
+
const atIdx = spec.lastIndexOf('@');
|
|
174
|
+
return atIdx > 4 ? spec.slice(0, atIdx) : spec;
|
|
175
|
+
}
|
|
176
|
+
if (spec.startsWith('@')) {
|
|
177
|
+
// @scope/name@version — find the @ that comes after the slash
|
|
178
|
+
const slashIdx = spec.indexOf('/');
|
|
179
|
+
if (slashIdx !== -1) {
|
|
180
|
+
const atIdx = spec.indexOf('@', slashIdx);
|
|
181
|
+
return atIdx !== -1 ? spec.slice(0, atIdx) : spec;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// unscoped npm: name@version → name
|
|
185
|
+
const atIdx = spec.indexOf('@');
|
|
186
|
+
return atIdx !== -1 ? spec.slice(0, atIdx) : spec;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Remove entries from the filedist YAML config file that match the given package name.
|
|
190
|
+
*
|
|
191
|
+
* - `packageSpec` is matched against each entry's `package` field after stripping
|
|
192
|
+
* the version/ref from both sides, so "xdrs-core@1.0.0" and "xdrs-core" both
|
|
193
|
+
* match entries whose package field starts with "xdrs-core".
|
|
194
|
+
* - When `outputPath` is supplied, only entries whose `output.path` equals
|
|
195
|
+
* `outputPath` are removed (allows targeting a specific entry when the same
|
|
196
|
+
* package is installed to multiple output directories).
|
|
197
|
+
* - Returns the number of entries removed. Zero means the config was unchanged.
|
|
198
|
+
* - When `configFilePath` is not supplied, defaults to `.filedist.yml` in `directory`.
|
|
199
|
+
* - Throws if the config file exists but cannot be parsed.
|
|
200
|
+
*/
|
|
201
|
+
function removeFiledistConfigEntries(directory, packageSpec, outputPath, configFilePath) {
|
|
202
|
+
const filePath = configFilePath ?? node_path_1.default.join(directory, RC_FILENAME);
|
|
203
|
+
let existing = { sets: [] };
|
|
204
|
+
try {
|
|
205
|
+
const raw = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
206
|
+
const parsed = js_yaml_1.default.load(raw);
|
|
207
|
+
if (parsed && Array.isArray(parsed.sets)) {
|
|
208
|
+
existing = { sets: parsed.sets };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (error.code === 'ENOENT') {
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
const targetName = packageNameWithoutRef(packageSpec);
|
|
218
|
+
const before = existing.sets.length;
|
|
219
|
+
existing.sets = existing.sets.filter((entry) => {
|
|
220
|
+
if (!entry.package)
|
|
221
|
+
return true; // self-package entries are never removed
|
|
222
|
+
const entryName = packageNameWithoutRef(entry.package);
|
|
223
|
+
if (entryName !== targetName)
|
|
224
|
+
return true; // different package — keep
|
|
225
|
+
// eslint-disable-next-line no-undefined
|
|
226
|
+
if (outputPath !== undefined && entry.output?.path !== outputPath)
|
|
227
|
+
return true; // output filter
|
|
228
|
+
return false; // matches — remove
|
|
229
|
+
});
|
|
230
|
+
const removed = before - existing.sets.length;
|
|
231
|
+
if (removed === 0)
|
|
232
|
+
return 0;
|
|
233
|
+
node_fs_1.default.writeFileSync(filePath, js_yaml_1.default.dump(existing, { indent: 2 }), 'utf8');
|
|
234
|
+
return removed;
|
|
235
|
+
}
|
|
185
236
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/package/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/package/config.ts"],"names":[],"mappings":";;;;;;AAkFA,8CAEC;AAMD,wDAEC;AAOD,8CAEC;AAuDD,kEA+BC;AAWD,sDAkBC;AAeD,kEAuCC;AA9QD,sDAAyB;AACzB,0DAA6B;AAE7B,sDAA2B;AAS3B,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AAEvE,yCAAyC;AAC5B,QAAA,uBAAuB,GAAG,eAAe,CAAC;AAQvD,8EAA8E;AACjE,QAAA,uBAAuB,GAAG,uBAAuB,CAAC;AAE/D,SAAS,sBAAsB,CAC7B,GAAyC,EACzC,WAAmB;IAEnB,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,2CAA2C;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,wCAAwC;IACxC,IAAI,GAAG,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,8BAA8B,WAAW,uCAAuC;YAC9E,2CAA2C,wBAAwB,GAAG,CACzE,CAAC;IACJ,CAAC;IAED;IACE,wCAAwC;IACxC,GAAG,CAAC,cAAc,KAAK,SAAS;QAChC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;YACjC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,EAC9D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,8BAA8B,WAAW,kDAAkD;YACzF,eAAe,wBAAwB,uBAAuB;YAC9D,mDAAmD,CACtD,CAAC;IACJ,CAAC;IAED,OAAO,GAAqB,CAAC;AAC/B,CAAC;AAED,SAAS,cAA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O,KAAK,CAAC,CAAC,mBAAmB;IACnC,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9C,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE5B,iBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,iBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/package/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { actionInstall } from './action-install';
|
|
2
|
+
export type { InstallOptions, InstallResult } from './action-install';
|
|
3
3
|
export { actionCheck } from './action-check';
|
|
4
4
|
export type { CheckOptions, CheckSummary } from './action-check';
|
|
5
5
|
export { actionList } from './action-list';
|
|
6
6
|
export type { ListOptions } from './action-list';
|
|
7
|
-
export {
|
|
8
|
-
export type {
|
|
7
|
+
export { actionRemove } from './action-remove';
|
|
8
|
+
export type { RemoveOptions, RemoveSummary } from './action-remove';
|
|
9
|
+
export { actionUpdate } from './action-update';
|
|
10
|
+
export type { UpdateOptions } from './action-update';
|
|
9
11
|
export { mergeSelectorConfig, mergeOutputConfig } from './config-merge';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/package/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeOutputConfig = exports.mergeSelectorConfig = exports.
|
|
3
|
+
exports.mergeOutputConfig = exports.mergeSelectorConfig = exports.actionUpdate = exports.actionRemove = exports.actionList = exports.actionCheck = exports.actionInstall = void 0;
|
|
4
4
|
// Public package-layer API
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(exports, "
|
|
5
|
+
var action_install_1 = require("./action-install");
|
|
6
|
+
Object.defineProperty(exports, "actionInstall", { enumerable: true, get: function () { return action_install_1.actionInstall; } });
|
|
7
7
|
var action_check_1 = require("./action-check");
|
|
8
8
|
Object.defineProperty(exports, "actionCheck", { enumerable: true, get: function () { return action_check_1.actionCheck; } });
|
|
9
9
|
var action_list_1 = require("./action-list");
|
|
10
10
|
Object.defineProperty(exports, "actionList", { enumerable: true, get: function () { return action_list_1.actionList; } });
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "
|
|
11
|
+
var action_remove_1 = require("./action-remove");
|
|
12
|
+
Object.defineProperty(exports, "actionRemove", { enumerable: true, get: function () { return action_remove_1.actionRemove; } });
|
|
13
|
+
var action_update_1 = require("./action-update");
|
|
14
|
+
Object.defineProperty(exports, "actionUpdate", { enumerable: true, get: function () { return action_update_1.actionUpdate; } });
|
|
13
15
|
var config_merge_1 = require("./config-merge");
|
|
14
16
|
Object.defineProperty(exports, "mergeSelectorConfig", { enumerable: true, get: function () { return config_merge_1.mergeSelectorConfig; } });
|
|
15
17
|
Object.defineProperty(exports, "mergeOutputConfig", { enumerable: true, get: function () { return config_merge_1.mergeOutputConfig; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAC3B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAGtB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAGnB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/package/index.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAC3B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAGtB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAGnB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAGrB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAGrB,+CAAwE;AAA/D,mHAAA,mBAAmB,OAAA;AAAE,iHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FiledistExtractEntry, ManagedFileMetadata } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Derive the lock file path from the config file path.
|
|
4
|
+
* Strips the `.yml` suffix from the config file basename and appends `.lock`.
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* `/project/.filedist.yml` → `/project/.filedist.lock`
|
|
8
|
+
* `/project/myconfig.yml` → `/project/myconfig.lock`
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLockfilePath(configFilePath: string): string;
|
|
11
|
+
export type LockfileData = {
|
|
12
|
+
version: number;
|
|
13
|
+
/** Maps package spec → resolved version/ref string. */
|
|
14
|
+
packages: Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Set definitions stored during install; used by check/purge/frozen-install
|
|
17
|
+
* to operate without reading the user configuration file.
|
|
18
|
+
*/
|
|
19
|
+
sets?: FiledistExtractEntry[];
|
|
20
|
+
/** Maps output-dir key → pipe-delimited managed-file lines. */
|
|
21
|
+
files?: Record<string, string[]>;
|
|
22
|
+
/** SHA-256 checksum of packages + files + sets sections. Validated on every read. */
|
|
23
|
+
checksum?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Compute a SHA-256 checksum over the packages, files, and sets sections of a
|
|
27
|
+
* lockfile. The input is deterministic (keys sorted) so the result is stable
|
|
28
|
+
* across writes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeLockfileChecksum(data: Pick<LockfileData, 'packages' | 'files' | 'sets'>): string;
|
|
31
|
+
/**
|
|
32
|
+
* Read a lock file from the given absolute path.
|
|
33
|
+
* Returns undefined when the file does not exist.
|
|
34
|
+
* Throws when the file exists but cannot be parsed or has a bad checksum.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readLockfile(lockfilePath: string): LockfileData | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Write a lock file to the given absolute path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeLockfile(lockfilePath: string, data: LockfileData): void;
|
|
41
|
+
/**
|
|
42
|
+
* Read the set definitions stored in a lock file.
|
|
43
|
+
* Returns undefined when the file does not exist or has no sets.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readSetsFromLockfile(lockfilePath: string): FiledistExtractEntry[] | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Build a LockfileData object from a map of spec → resolved version and source.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildLockfileData(resolvedPackages: Map<string, {
|
|
50
|
+
source: 'npm' | 'git';
|
|
51
|
+
resolvedVersion: string;
|
|
52
|
+
}>): LockfileData;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the key used in managed_files for a given output directory.
|
|
55
|
+
* The key is relative to cwd, normalised to forward slashes.
|
|
56
|
+
*/
|
|
57
|
+
export declare function outputDirKey(cwd: string, outputDir: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Read managed file entries for a specific output directory from a lock file.
|
|
60
|
+
* Returns an empty array when the lock file or directory entry does not exist.
|
|
61
|
+
*/
|
|
62
|
+
export declare function readManagedFilesForDir(lockfilePath: string, cwd: string, outputDir: string): ManagedFileMetadata[];
|
|
63
|
+
/**
|
|
64
|
+
* Write managed file entries for a specific output directory into a lock file.
|
|
65
|
+
* Reads the current lock file, updates the entry for outputDir, and writes it back.
|
|
66
|
+
* When entries is empty the key is removed.
|
|
67
|
+
*/
|
|
68
|
+
export declare function writeManagedFilesForDir(lockfilePath: string, cwd: string, outputDir: string, entries: ManagedFileMetadata[]): void;
|
|
69
|
+
//# sourceMappingURL=lockfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfile.d.ts","sourceRoot":"","sources":["../../src/package/lockfile.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAKrE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,c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