@ai-primitives-hub/app 0.1.0 → 0.2.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/dist/collection/read-collection.d.ts +3 -1
- package/dist/collection/read-collection.d.ts.map +1 -1
- package/dist/collection/read-collection.js +27 -2
- package/dist/collection/read-collection.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/install/index.d.ts +2 -1
- package/dist/install/index.d.ts.map +1 -1
- package/dist/install/index.js +4 -1
- package/dist/install/index.js.map +1 -1
- package/dist/install/pipeline.d.ts +8 -0
- package/dist/install/pipeline.d.ts.map +1 -1
- package/dist/install/pipeline.js +3 -2
- package/dist/install/pipeline.js.map +1 -1
- package/dist/install/target-write.d.ts +77 -1
- package/dist/install/target-write.d.ts.map +1 -1
- package/dist/install/target-write.js +195 -0
- package/dist/install/target-write.js.map +1 -1
- package/dist/install/uninstall-pipeline.d.ts +1 -0
- package/dist/install/uninstall-pipeline.d.ts.map +1 -1
- package/dist/install/uninstall-pipeline.js +10 -4
- package/dist/install/uninstall-pipeline.js.map +1 -1
- package/dist/registry/create-source-adapter.d.ts +11 -1
- package/dist/registry/create-source-adapter.d.ts.map +1 -1
- package/dist/registry/create-source-adapter.js +37 -6
- package/dist/registry/create-source-adapter.js.map +1 -1
- package/dist/registry/hub-manager.d.ts +19 -0
- package/dist/registry/hub-manager.d.ts.map +1 -1
- package/dist/registry/hub-manager.js +58 -5
- package/dist/registry/hub-manager.js.map +1 -1
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/load-hub-sources.d.ts +42 -8
- package/dist/registry/load-hub-sources.d.ts.map +1 -1
- package/dist/registry/load-hub-sources.js +198 -21
- package/dist/registry/load-hub-sources.js.map +1 -1
- package/dist/registry/profile-lifecycle.d.ts +5 -1
- package/dist/registry/profile-lifecycle.d.ts.map +1 -1
- package/dist/registry/profile-lifecycle.js +20 -2
- package/dist/registry/profile-lifecycle.js.map +1 -1
- package/dist/registry/remap-bundle-source.d.ts +33 -0
- package/dist/registry/remap-bundle-source.d.ts.map +1 -0
- package/dist/registry/remap-bundle-source.js +66 -0
- package/dist/registry/remap-bundle-source.js.map +1 -0
- package/dist/registry/resolve-install-source.d.ts +52 -0
- package/dist/registry/resolve-install-source.d.ts.map +1 -0
- package/dist/registry/resolve-install-source.js +126 -0
- package/dist/registry/resolve-install-source.js.map +1 -0
- package/dist/registry/source-sync-queue.d.ts +8 -1
- package/dist/registry/source-sync-queue.d.ts.map +1 -1
- package/dist/registry/source-sync-queue.js +24 -5
- package/dist/registry/source-sync-queue.js.map +1 -1
- package/dist/registry/user-config-paths.d.ts.map +1 -1
- package/dist/registry/user-config-paths.js +5 -7
- package/dist/registry/user-config-paths.js.map +1 -1
- package/dist/release/index.d.ts +6 -0
- package/dist/release/index.d.ts.map +1 -0
- package/dist/release/index.js +22 -0
- package/dist/release/index.js.map +1 -0
- package/dist/release/plan-bundle-release.d.ts +33 -0
- package/dist/release/plan-bundle-release.d.ts.map +1 -0
- package/dist/release/plan-bundle-release.js +42 -0
- package/dist/release/plan-bundle-release.js.map +1 -0
- package/dist/replicate/replicate.d.ts +20 -0
- package/dist/replicate/replicate.d.ts.map +1 -0
- package/dist/replicate/replicate.js +122 -0
- package/dist/replicate/replicate.js.map +1 -0
- package/dist/search/build-index.d.ts +11 -0
- package/dist/search/build-index.d.ts.map +1 -1
- package/dist/search/build-index.js +170 -9
- package/dist/search/build-index.js.map +1 -1
- package/dist/search/bundle-search-keys.d.ts +37 -0
- package/dist/search/bundle-search-keys.d.ts.map +1 -1
- package/dist/search/bundle-search-keys.js +73 -7
- package/dist/search/bundle-search-keys.js.map +1 -1
- package/dist/search/search-index.d.ts.map +1 -1
- package/dist/search/search-index.js +10 -0
- package/dist/search/search-index.js.map +1 -1
- package/dist/search/search-profile.d.ts +19 -0
- package/dist/search/search-profile.d.ts.map +1 -1
- package/dist/search/search-profile.js +4 -2
- package/dist/search/search-profile.js.map +1 -1
- package/dist/stores/json-lockfile-store.d.ts +29 -2
- package/dist/stores/json-lockfile-store.d.ts.map +1 -1
- package/dist/stores/json-lockfile-store.js +37 -4
- package/dist/stores/json-lockfile-store.js.map +1 -1
- package/dist/writers/file-tree-writer.d.ts +39 -12
- package/dist/writers/file-tree-writer.d.ts.map +1 -1
- package/dist/writers/file-tree-writer.js +238 -68
- package/dist/writers/file-tree-writer.js.map +1 -1
- package/package.json +7 -6
|
@@ -23,6 +23,14 @@ export interface LockfileFileEntry {
|
|
|
23
23
|
* added (issue #357 Stage 2).
|
|
24
24
|
*/
|
|
25
25
|
checksum: string;
|
|
26
|
+
/**
|
|
27
|
+
* Where the file was installed, relative to the target's base directory.
|
|
28
|
+
* Optional: recorded only when the location cannot be recomputed from
|
|
29
|
+
* `path` (manifest-driven placement renames files and skill directories
|
|
30
|
+
* by manifest item id). Uninstall removes this path when present and
|
|
31
|
+
* falls back to routing `path` otherwise, so older entries keep working.
|
|
32
|
+
*/
|
|
33
|
+
installedPath?: string;
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Bundle entry in the lockfile.
|
|
@@ -59,6 +67,12 @@ export interface LockfileSourceEntry {
|
|
|
59
67
|
branch?: string;
|
|
60
68
|
/** Optional collections subdirectory, for `awesome-copilot`-type sources. */
|
|
61
69
|
collectionsPath?: string;
|
|
70
|
+
/** Optional Artifactory index file. */
|
|
71
|
+
indexFile?: string;
|
|
72
|
+
/** Optional Artifactory authentication mode. */
|
|
73
|
+
authMode?: 'anonymous' | 'bearer';
|
|
74
|
+
/** Optional external Artifactory credential reference; never a secret. */
|
|
75
|
+
credentialRef?: string;
|
|
62
76
|
}
|
|
63
77
|
/**
|
|
64
78
|
* Hub configuration entry.
|
|
@@ -168,6 +182,17 @@ export declare const removeBundleEntry: (lock: Lockfile, bundleId: string) => Lo
|
|
|
168
182
|
* @returns New Lockfile (input is not mutated).
|
|
169
183
|
*/
|
|
170
184
|
export declare const upsertSource: (lock: Lockfile, sourceId: string, source: LockfileSourceEntry) => Lockfile;
|
|
185
|
+
/**
|
|
186
|
+
* Remap all bundle entries referencing `oldSourceId` to point at
|
|
187
|
+
* `newSourceId`, and move the source descriptor accordingly. Pure;
|
|
188
|
+
* doesn't touch disk.
|
|
189
|
+
* @param lock - Existing Lockfile.
|
|
190
|
+
* @param oldSourceId - Source id being retired.
|
|
191
|
+
* @param newSourceId - Replacement source id.
|
|
192
|
+
* @param newSourceDescriptor - Source descriptor for the replacement.
|
|
193
|
+
* @returns New Lockfile (input is not mutated).
|
|
194
|
+
*/
|
|
195
|
+
export declare const remapSourceId: (lock: Lockfile, oldSourceId: string, newSourceId: string, newSourceDescriptor: LockfileSourceEntry) => Lockfile;
|
|
171
196
|
/**
|
|
172
197
|
* Remove a source descriptor if no remaining bundle references it.
|
|
173
198
|
* Pure; doesn't touch disk.
|
|
@@ -182,10 +207,12 @@ export declare const cleanupOrphanedSource: (lock: Lockfile, sourceId: string) =
|
|
|
182
207
|
* expects. Excludes `deployment-manifest.yml` — it is bundle metadata,
|
|
183
208
|
* not an installed file — matching every writer's own exclusion of it.
|
|
184
209
|
* @param files - Extracted bundle files (path -> raw bytes).
|
|
185
|
-
* @param includedPaths
|
|
210
|
+
* @param includedPaths - Bundle paths to include (default: all).
|
|
211
|
+
* @param installedPaths - Optional `TargetWriteResult.installedPaths`;
|
|
212
|
+
* each listed path's entry records its `installedPath`.
|
|
186
213
|
* @returns Per-file checksum entries, manifest excluded.
|
|
187
214
|
*/
|
|
188
|
-
export declare const checksumFiles: (files: ExtractedFiles, includedPaths?: Iterable<string
|
|
215
|
+
export declare const checksumFiles: (files: ExtractedFiles, includedPaths?: Iterable<string>, installedPaths?: Readonly<Record<string, string>>) => LockfileFileEntry[];
|
|
189
216
|
/**
|
|
190
217
|
* Find a project-scope lockfile by walking up from `startDir`, then
|
|
191
218
|
* optionally falling back to a user-level path. Checks for either
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-lockfile-store.d.ts","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,eAAO,MAAM,aAAa,8BAA8B,CAAC;AACzD,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,oCAAoC,CAAC;AACrE,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"json-lockfile-store.d.ts","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,eAAO,MAAM,aAAa,8BAA8B,CAAC;AACzD,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,oCAAoC,CAAC;AACrE,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,OAAO,EAA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AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,IAAI,UAAU,KAAG,OAAO,CAAC,IAAI,CAW/E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,QAAQ,EACd,UAAU,MAAM,EAChB,OAAO,mBAAmB,KACzB,QAKD,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,QAAQ,EAAE,UAAU,MAAM,KAAG,QASpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,QAAQ,EACd,UAAU,MAAM,EAChB,QAAQ,mBAAmB,KAC1B,QAID,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,QAAQ,EACd,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,qBAAqB,mBAAmB,KACvC,QAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM,QAAQ,EAAE,UAAU,MAAM,KAAG,QAQxE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,cAAc,EACrB,gBAAgB,QAAQ,CAAC,MAAM,CAAC,EAChC,iBAAiB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAChD,iBAAiB,EAkBnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,MAAM,EAChB,IAAI,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC9B,eAAe,MAAM,KACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBvB,CAAC"}
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.findLockfile = exports.checksumFiles = exports.cleanupOrphanedSource = exports.upsertSource = exports.removeBundleEntry = exports.upsertBundleEntry = exports.deleteLockfile = exports.writeLockfile = exports.readLockfile = exports.getLockfilePathForMode = exports.emptyLockfile = exports.LOCKFILE_SCHEMA_VERSION = exports.LOCAL_LOCKFILE_NAME = exports.LOCKFILE_NAME = void 0;
|
|
36
|
+
exports.findLockfile = exports.checksumFiles = exports.cleanupOrphanedSource = exports.remapSourceId = exports.upsertSource = exports.removeBundleEntry = exports.upsertBundleEntry = exports.deleteLockfile = exports.writeLockfile = exports.readLockfile = exports.getLockfilePathForMode = exports.emptyLockfile = exports.LOCKFILE_SCHEMA_VERSION = exports.LOCAL_LOCKFILE_NAME = exports.LOCKFILE_NAME = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* Install lockfile (repository scope only).
|
|
39
39
|
*
|
|
@@ -194,6 +194,35 @@ const upsertSource = (lock, sourceId, source) => ({
|
|
|
194
194
|
sources: { ...lock.sources, [sourceId]: source }
|
|
195
195
|
});
|
|
196
196
|
exports.upsertSource = upsertSource;
|
|
197
|
+
/**
|
|
198
|
+
* Remap all bundle entries referencing `oldSourceId` to point at
|
|
199
|
+
* `newSourceId`, and move the source descriptor accordingly. Pure;
|
|
200
|
+
* doesn't touch disk.
|
|
201
|
+
* @param lock - Existing Lockfile.
|
|
202
|
+
* @param oldSourceId - Source id being retired.
|
|
203
|
+
* @param newSourceId - Replacement source id.
|
|
204
|
+
* @param newSourceDescriptor - Source descriptor for the replacement.
|
|
205
|
+
* @returns New Lockfile (input is not mutated).
|
|
206
|
+
*/
|
|
207
|
+
const remapSourceId = (lock, oldSourceId, newSourceId, newSourceDescriptor) => {
|
|
208
|
+
const bundles = {};
|
|
209
|
+
for (const [id, entry] of Object.entries(lock.bundles)) {
|
|
210
|
+
bundles[id] = entry.sourceId === oldSourceId
|
|
211
|
+
? { ...entry, sourceId: newSourceId }
|
|
212
|
+
: entry;
|
|
213
|
+
}
|
|
214
|
+
const sources = { ...lock.sources };
|
|
215
|
+
delete sources[oldSourceId];
|
|
216
|
+
sources[newSourceId] = newSourceDescriptor;
|
|
217
|
+
return {
|
|
218
|
+
...lock,
|
|
219
|
+
version: exports.LOCKFILE_SCHEMA_VERSION,
|
|
220
|
+
generatedAt: new Date().toISOString(),
|
|
221
|
+
bundles,
|
|
222
|
+
sources
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
exports.remapSourceId = remapSourceId;
|
|
197
226
|
/**
|
|
198
227
|
* Remove a source descriptor if no remaining bundle references it.
|
|
199
228
|
* Pure; doesn't touch disk.
|
|
@@ -217,10 +246,12 @@ exports.cleanupOrphanedSource = cleanupOrphanedSource;
|
|
|
217
246
|
* expects. Excludes `deployment-manifest.yml` — it is bundle metadata,
|
|
218
247
|
* not an installed file — matching every writer's own exclusion of it.
|
|
219
248
|
* @param files - Extracted bundle files (path -> raw bytes).
|
|
220
|
-
* @param includedPaths
|
|
249
|
+
* @param includedPaths - Bundle paths to include (default: all).
|
|
250
|
+
* @param installedPaths - Optional `TargetWriteResult.installedPaths`;
|
|
251
|
+
* each listed path's entry records its `installedPath`.
|
|
221
252
|
* @returns Per-file checksum entries, manifest excluded.
|
|
222
253
|
*/
|
|
223
|
-
const checksumFiles = (files, includedPaths) => {
|
|
254
|
+
const checksumFiles = (files, includedPaths, installedPaths) => {
|
|
224
255
|
const entries = [];
|
|
225
256
|
const included = includedPaths === undefined ? null : new Set(includedPaths);
|
|
226
257
|
for (const [filePath, bytes] of files) {
|
|
@@ -230,9 +261,11 @@ const checksumFiles = (files, includedPaths) => {
|
|
|
230
261
|
if (included !== null && !included.has(filePath)) {
|
|
231
262
|
continue;
|
|
232
263
|
}
|
|
264
|
+
const installedPath = installedPaths?.[filePath];
|
|
233
265
|
entries.push({
|
|
234
266
|
path: filePath,
|
|
235
|
-
checksum: (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex')
|
|
267
|
+
checksum: (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex'),
|
|
268
|
+
...(installedPath === undefined ? {} : { installedPath })
|
|
236
269
|
});
|
|
237
270
|
}
|
|
238
271
|
return entries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-lockfile-store.js","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,6CAEqB;AACrB,gDAAkC;AAKlC,sEAAsE;AACzD,QAAA,aAAa,GAAG,2BAA2B,CAAC;AACzD,oEAAoE;AACvD,QAAA,mBAAmB,GAAG,iCAAiC,CAAC;AACrE,sEAAsE;AACzD,QAAA,uBAAuB,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"json-lockfile-store.js","sourceRoot":"","sources":["../../src/stores/json-lockfile-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,6CAEqB;AACrB,gDAAkC;AAKlC,sEAAsE;AACzD,QAAA,aAAa,GAAG,2BAA2B,CAAC;AACzD,oEAAoE;AACvD,QAAA,mBAAmB,GAAG,iCAAiC,CAAC;AACrE,sEAAsE;AACzD,QAAA,uBAAuB,GAAG,OAAO,CAAC;AAsH/C,MAAM,mBAAmB,GAAG,kFAAkF,CAAC;AAE/G;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAY,EAAE,CAAC,CAAC;IAC/D,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,+BAAuB;IAChC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IACrC,WAAW;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC;AAPU,QAAA,aAAa,iBAOvB;AAUH;;;;;GAKG;AACI,MAAM,sBAAsB,GAAG,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AAC,qBAAa,EAAE,2BAAmB,CAAC,EAAE,CAAC;YACxD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACvC,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC/B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM;QACR,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,IAAI,YAAY,KAAK,SAAS,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAChE,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvBW,QAAA,YAAY,gBAuBvB"}
|
|
@@ -155,25 +155,52 @@ export declare class FileTreeTargetWriter implements TargetWriter {
|
|
|
155
155
|
* @returns TargetWriteResult.
|
|
156
156
|
*/
|
|
157
157
|
writeManifestItems(target: Target, files: ExtractedFiles, items: readonly ManifestPlacementItem[]): Promise<TargetWriteResult>;
|
|
158
|
-
private resolveLayout;
|
|
159
158
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @param baseDir - Expanded target base directory.
|
|
164
|
-
* @param outPrefix - Layout output subdirectory for the `skill` kind.
|
|
165
|
-
* @param item - Skill placement item (its `file` points at the skill's
|
|
166
|
-
* manifest file, e.g. `skills/my-skill/SKILL.md`).
|
|
159
|
+
* Determine, without touching the filesystem, which manifest items
|
|
160
|
+
* {@link writeManifestItems} can place.
|
|
161
|
+
* @param target - Target chosen via `--target <name>`.
|
|
167
162
|
* @param files - Extracted bundle files.
|
|
168
|
-
* @param
|
|
169
|
-
* @returns
|
|
163
|
+
* @param items - Manifest-derived placement instructions.
|
|
164
|
+
* @returns `writable` lists every bundle path the items would write
|
|
165
|
+
* (a skill item contributes every file of its directory); `skipped`
|
|
166
|
+
* lists the `file` of each item that cannot be placed, including an
|
|
167
|
+
* item whose destination an earlier item already takes.
|
|
170
168
|
*/
|
|
171
|
-
|
|
169
|
+
preflightManifestItems(target: Target, files: ExtractedFiles, items: readonly ManifestPlacementItem[]): Promise<TargetWritePlan>;
|
|
170
|
+
private resolveLayout;
|
|
171
|
+
/**
|
|
172
|
+
* Compute, without touching the filesystem, where each recorded file
|
|
173
|
+
* lives relative to the target's base directory: its `installedPath`
|
|
174
|
+
* when present, otherwise the path-routed destination of `path` — the
|
|
175
|
+
* same location {@link remove} would delete.
|
|
176
|
+
* @param target - Target chosen via `--target <name>`.
|
|
177
|
+
* @param files - Recorded files (lockfile `path` + optional `installedPath`).
|
|
178
|
+
* @returns One `/`-separated base-relative location per file, or `null`
|
|
179
|
+
* for a path-routed file the layout does not route.
|
|
180
|
+
*/
|
|
181
|
+
installedLocations(target: Target, files: readonly {
|
|
182
|
+
path: string;
|
|
183
|
+
installedPath?: string;
|
|
184
|
+
}[]): Promise<(string | null)[]>;
|
|
172
185
|
/**
|
|
173
186
|
* Remove a file from the target.
|
|
174
187
|
* @param target - Target chosen via `--target <name>`.
|
|
175
188
|
* @param filePath - Relative file path to remove (from bundle root).
|
|
189
|
+
* @param installedPath - Output path relative to the target's base
|
|
190
|
+
* directory, as recorded from `installedPaths` by a manifest-driven
|
|
191
|
+
* install. When given, it is removed instead of the path recomputed
|
|
192
|
+
* from `filePath`; a path that leaves the base directory is refused.
|
|
176
193
|
*/
|
|
177
|
-
remove(target: Target, filePath: string): Promise<void>;
|
|
194
|
+
remove(target: Target, filePath: string, installedPath?: string): Promise<void>;
|
|
178
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* The bundle-path prefix of a skill item's directory: everything up to
|
|
198
|
+
* and including `skills/<name>/`, whether the item names the directory
|
|
199
|
+
* itself (`skills/foo`, `skills/foo/`) or a file inside it
|
|
200
|
+
* (`.github/skills/foo/SKILL.md`). Mirrors `getSkillName`'s match.
|
|
201
|
+
* @param file - Skill item `file`.
|
|
202
|
+
* @returns The `/`-terminated prefix, or `null` when the path is not under
|
|
203
|
+
* a `skills/<name>` directory.
|
|
204
|
+
*/
|
|
205
|
+
export declare const skillSourcePrefix: (file: string) => string | null;
|
|
179
206
|
//# sourceMappingURL=file-tree-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tree-writer.d.ts","sourceRoot":"","sources":["../../src/writers/file-tree-writer.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,kBAAkB,EAElB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAkBjC,YAAY,EACV,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,YAAY,EACZ,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD;;;;OAIG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,uEAAuE;IACvE,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,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M,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAc7F;AAkGD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAWzD,CAAC"}
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FileTreeTargetWriter = exports.expandPath = exports.resolveLayoutAsync = exports.resolveLayout = exports.KIND_TO_ROUTE_KEY = void 0;
|
|
36
|
+
exports.skillSourcePrefix = exports.FileTreeTargetWriter = exports.expandPath = exports.resolveLayoutAsync = exports.resolveLayout = exports.KIND_TO_ROUTE_KEY = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* TargetWriter interface + FileTreeTargetWriter.
|
|
39
39
|
*
|
|
@@ -300,51 +300,84 @@ class FileTreeTargetWriter {
|
|
|
300
300
|
async writeManifestItems(target, files, items) {
|
|
301
301
|
const layout = await this.resolveLayout(target);
|
|
302
302
|
const baseDir = (0, core_1.expandPath)(layout.baseDir, this.opts.env);
|
|
303
|
-
const allowed = target
|
|
304
|
-
? null
|
|
305
|
-
: new Set(target.allowedKinds.map((kind) => (0, core_1.normalizePrimitiveKind)(kind) ?? kind));
|
|
303
|
+
const allowed = allowedKindSet(target);
|
|
306
304
|
const written = [];
|
|
307
305
|
const writtenBundlePaths = [];
|
|
306
|
+
const installedPaths = {};
|
|
308
307
|
const skipped = [];
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
if (type === 'skill') {
|
|
323
|
-
const wroteAny = await this.writeSkillItem(baseDir, outPrefix, item, files, written);
|
|
324
|
-
if (wroteAny) {
|
|
325
|
-
for (const bundlePath of files.keys()) {
|
|
326
|
-
const sourcePrefix = `${path.posix.dirname(item.file)}/`;
|
|
327
|
-
if (bundlePath.startsWith(sourcePrefix)) {
|
|
328
|
-
writtenBundlePaths.push(bundlePath);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
308
|
+
const record = (bundlePath, outPath) => {
|
|
309
|
+
written.push(outPath);
|
|
310
|
+
writtenBundlePaths.push(bundlePath);
|
|
311
|
+
installedPaths[bundlePath] = toInstalledPath(baseDir, outPath);
|
|
312
|
+
};
|
|
313
|
+
let pendingWritePath = null;
|
|
314
|
+
const taken = new Set();
|
|
315
|
+
try {
|
|
316
|
+
for (const item of items) {
|
|
317
|
+
const placement = placeManifestItem(item, files, layout, allowed);
|
|
318
|
+
// Never let a later item silently overwrite an earlier item's file.
|
|
319
|
+
if (placement === null || !claimDestinations(placement, taken)) {
|
|
333
320
|
skipped.push(item.file);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
for (const { bundlePath, tail } of placement.sources) {
|
|
324
|
+
const outPath = path.join(baseDir, placement.outDir, tail);
|
|
325
|
+
const bytes = files.get(bundlePath);
|
|
326
|
+
// Keep the path visible to the catch block before write starts:
|
|
327
|
+
// a filesystem can persist the file and then throw.
|
|
328
|
+
pendingWritePath = outPath;
|
|
329
|
+
if (placement.type === 'skill') {
|
|
330
|
+
// Skill directories carry arbitrary assets (scripts, images,
|
|
331
|
+
// office documents) — copy byte-for-byte, never transform.
|
|
332
|
+
await this.opts.fs.mkdir(path.dirname(outPath), { recursive: true });
|
|
333
|
+
await this.opts.fs.writeFileBytes(outPath, bytes);
|
|
334
|
+
await (0, core_1.verifyWrittenBytes)(this.opts.fs, outPath, bytes);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
await this.writeContent(target, bundlePath, bytes, outPath);
|
|
338
|
+
}
|
|
339
|
+
pendingWritePath = null;
|
|
340
|
+
record(bundlePath, outPath);
|
|
334
341
|
}
|
|
335
|
-
continue;
|
|
336
342
|
}
|
|
337
|
-
|
|
338
|
-
|
|
343
|
+
}
|
|
344
|
+
catch (cause) {
|
|
345
|
+
const rollbackPaths = pendingWritePath === null
|
|
346
|
+
? written
|
|
347
|
+
: [...written, pendingWritePath];
|
|
348
|
+
await this.rollback(target, rollbackPaths);
|
|
349
|
+
throw cause;
|
|
350
|
+
}
|
|
351
|
+
return { written, skipped, writtenBundlePaths, installedPaths };
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Determine, without touching the filesystem, which manifest items
|
|
355
|
+
* {@link writeManifestItems} can place.
|
|
356
|
+
* @param target - Target chosen via `--target <name>`.
|
|
357
|
+
* @param files - Extracted bundle files.
|
|
358
|
+
* @param items - Manifest-derived placement instructions.
|
|
359
|
+
* @returns `writable` lists every bundle path the items would write
|
|
360
|
+
* (a skill item contributes every file of its directory); `skipped`
|
|
361
|
+
* lists the `file` of each item that cannot be placed, including an
|
|
362
|
+
* item whose destination an earlier item already takes.
|
|
363
|
+
*/
|
|
364
|
+
async preflightManifestItems(target, files, items) {
|
|
365
|
+
const layout = await this.resolveLayout(target);
|
|
366
|
+
const allowed = allowedKindSet(target);
|
|
367
|
+
const writable = [];
|
|
368
|
+
const skipped = [];
|
|
369
|
+
const taken = new Set();
|
|
370
|
+
for (const item of items) {
|
|
371
|
+
const placement = placeManifestItem(item, files, layout, allowed);
|
|
372
|
+
// Two items mapping to one destination (e.g. ids `alpha` and
|
|
373
|
+
// `alpha.instructions`) would overwrite each other: skip the later one.
|
|
374
|
+
if (placement === null || !claimDestinations(placement, taken)) {
|
|
339
375
|
skipped.push(item.file);
|
|
340
376
|
continue;
|
|
341
377
|
}
|
|
342
|
-
|
|
343
|
-
await this.writeContent(target, item.file, bytes, outPath);
|
|
344
|
-
written.push(outPath);
|
|
345
|
-
writtenBundlePaths.push(item.file);
|
|
378
|
+
writable.push(...placement.sources.map((source) => source.bundlePath));
|
|
346
379
|
}
|
|
347
|
-
return {
|
|
380
|
+
return { writable, skipped };
|
|
348
381
|
}
|
|
349
382
|
async resolveLayout(target) {
|
|
350
383
|
if (this.opts.layoutLoader === undefined) {
|
|
@@ -353,48 +386,43 @@ class FileTreeTargetWriter {
|
|
|
353
386
|
return await (0, exports.resolveLayoutAsync)(target, this.opts.layoutLoader);
|
|
354
387
|
}
|
|
355
388
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* @param
|
|
361
|
-
* @param
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* @param written - Accumulator for written absolute paths.
|
|
365
|
-
* @returns true if at least one file was written.
|
|
389
|
+
* Compute, without touching the filesystem, where each recorded file
|
|
390
|
+
* lives relative to the target's base directory: its `installedPath`
|
|
391
|
+
* when present, otherwise the path-routed destination of `path` — the
|
|
392
|
+
* same location {@link remove} would delete.
|
|
393
|
+
* @param target - Target chosen via `--target <name>`.
|
|
394
|
+
* @param files - Recorded files (lockfile `path` + optional `installedPath`).
|
|
395
|
+
* @returns One `/`-separated base-relative location per file, or `null`
|
|
396
|
+
* for a path-routed file the layout does not route.
|
|
366
397
|
*/
|
|
367
|
-
async
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const sourcePrefix = `${path.posix.dirname(item.file)}/`;
|
|
373
|
-
let wroteAny = false;
|
|
374
|
-
for (const [bundlePath, bytes] of files) {
|
|
375
|
-
if (!bundlePath.startsWith(sourcePrefix)) {
|
|
376
|
-
continue;
|
|
398
|
+
async installedLocations(target, files) {
|
|
399
|
+
const layout = await this.resolveLayout(target);
|
|
400
|
+
return files.map((file) => {
|
|
401
|
+
if (file.installedPath !== undefined) {
|
|
402
|
+
return path.posix.normalize(file.installedPath.replaceAll('\\', '/'));
|
|
377
403
|
}
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
await this.opts.fs.writeFileBytes(outPath, bytes);
|
|
384
|
-
await (0, core_1.verifyWrittenBytes)(this.opts.fs, outPath, bytes);
|
|
385
|
-
written.push(outPath);
|
|
386
|
-
wroteAny = true;
|
|
387
|
-
}
|
|
388
|
-
return wroteAny;
|
|
404
|
+
const route = pickRoute(file.path, layout.kindRoutes);
|
|
405
|
+
return route === null
|
|
406
|
+
? null
|
|
407
|
+
: path.posix.normalize(path.posix.join(route.outPrefix.replaceAll('\\', '/'), route.tail));
|
|
408
|
+
});
|
|
389
409
|
}
|
|
390
410
|
/**
|
|
391
411
|
* Remove a file from the target.
|
|
392
412
|
* @param target - Target chosen via `--target <name>`.
|
|
393
413
|
* @param filePath - Relative file path to remove (from bundle root).
|
|
414
|
+
* @param installedPath - Output path relative to the target's base
|
|
415
|
+
* directory, as recorded from `installedPaths` by a manifest-driven
|
|
416
|
+
* install. When given, it is removed instead of the path recomputed
|
|
417
|
+
* from `filePath`; a path that leaves the base directory is refused.
|
|
394
418
|
*/
|
|
395
|
-
async remove(target, filePath) {
|
|
419
|
+
async remove(target, filePath, installedPath) {
|
|
396
420
|
const layout = await this.resolveLayout(target);
|
|
397
421
|
const baseDir = (0, core_1.expandPath)(layout.baseDir, this.opts.env);
|
|
422
|
+
if (installedPath !== undefined) {
|
|
423
|
+
await this.opts.fs.remove(resolveInstalledPath(baseDir, installedPath));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
398
426
|
const route = pickRoute(filePath, layout.kindRoutes);
|
|
399
427
|
if (route === null) {
|
|
400
428
|
return; // Unrouted file, nothing to do
|
|
@@ -404,6 +432,148 @@ class FileTreeTargetWriter {
|
|
|
404
432
|
}
|
|
405
433
|
}
|
|
406
434
|
exports.FileTreeTargetWriter = FileTreeTargetWriter;
|
|
435
|
+
const allowedKindSet = (target) => target.allowedKinds === undefined
|
|
436
|
+
? null
|
|
437
|
+
: new Set(target.allowedKinds.map((kind) => (0, core_1.normalizePrimitiveKind)(kind) ?? kind));
|
|
438
|
+
/**
|
|
439
|
+
* Decide where a manifest item is written, or `null` when the target
|
|
440
|
+
* cannot place it: its kind is excluded by `allowedKinds`, the layout has
|
|
441
|
+
* no route for its type, a skill item does not point into a `skills/`
|
|
442
|
+
* directory or that directory has no files, or the item's file is missing.
|
|
443
|
+
* The type (explicit or auto-detected from `file`/`tags`) selects the
|
|
444
|
+
* layout route via {@link KIND_TO_ROUTE_KEY}. Non-skill files are renamed
|
|
445
|
+
* to `{id}.{type-extension}`; a skill's whole source directory is copied
|
|
446
|
+
* into `{route}/{normalizedId}/`.
|
|
447
|
+
* @param item - Manifest placement item.
|
|
448
|
+
* @param files - Extracted bundle files.
|
|
449
|
+
* @param layout - Resolved target layout.
|
|
450
|
+
* @param allowed - Normalized `allowedKinds`, or `null` for all kinds.
|
|
451
|
+
* @returns The placement, or `null` when the item is skipped.
|
|
452
|
+
*/
|
|
453
|
+
const placeManifestItem = (item, files, layout, allowed) => {
|
|
454
|
+
const type = item.type ?? (0, core_1.determineFileType)(item.file, item.tags);
|
|
455
|
+
if (allowed !== null && !allowed.has(copilotTypeToPrimitiveKind(type))) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const outPrefix = layout.kindRoutes[exports.KIND_TO_ROUTE_KEY[type]];
|
|
459
|
+
if (outPrefix === undefined) {
|
|
460
|
+
// Target's layout has no route for this kind at all.
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
if (type === 'skill') {
|
|
464
|
+
const sourcePrefix = (0, exports.skillSourcePrefix)(item.file);
|
|
465
|
+
if (sourcePrefix === null) {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
const sources = [...files.keys()]
|
|
469
|
+
.filter((bundlePath) => bundlePath.startsWith(sourcePrefix))
|
|
470
|
+
.map((bundlePath) => ({ bundlePath, tail: bundlePath.slice(sourcePrefix.length) }));
|
|
471
|
+
return sources.length === 0
|
|
472
|
+
? null
|
|
473
|
+
: staysInside({ type, outDir: path.join(outPrefix, (0, core_1.normalizePromptId)(item.id)), sources });
|
|
474
|
+
}
|
|
475
|
+
if (!files.has(item.file) || !isPlainFileName(item.id)) {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
return staysInside({
|
|
479
|
+
type,
|
|
480
|
+
outDir: outPrefix,
|
|
481
|
+
sources: [{ bundlePath: item.file, tail: (0, core_1.getTargetFileName)(item.id, type) }]
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* Whether a manifest item id can be used as a single file name: no path
|
|
486
|
+
* separators and not `.`/`..`. The manifest is untrusted input, so an id
|
|
487
|
+
* like `../../x` must never pick the output location.
|
|
488
|
+
* @param id - Manifest item id.
|
|
489
|
+
* @returns Whether the id is a plain file name.
|
|
490
|
+
*/
|
|
491
|
+
const isPlainFileName = (id) => id.length > 0 && !/[/\\]/.test(id) && id !== '.' && id !== '..';
|
|
492
|
+
/**
|
|
493
|
+
* Keep a placement only when every destination stays below the layout
|
|
494
|
+
* base directory (relative, no `..` segment after normalization).
|
|
495
|
+
* @param placement - Candidate placement.
|
|
496
|
+
* @returns The placement, or `null` when a destination would escape.
|
|
497
|
+
*/
|
|
498
|
+
const staysInside = (placement) => {
|
|
499
|
+
for (const { tail } of placement.sources) {
|
|
500
|
+
const relative = path.normalize(path.join(placement.outDir, tail));
|
|
501
|
+
if (path.isAbsolute(relative) || relative === '..' || relative.startsWith(`..${path.sep}`)) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return placement;
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* The bundle-path prefix of a skill item's directory: everything up to
|
|
509
|
+
* and including `skills/<name>/`, whether the item names the directory
|
|
510
|
+
* itself (`skills/foo`, `skills/foo/`) or a file inside it
|
|
511
|
+
* (`.github/skills/foo/SKILL.md`). Mirrors `getSkillName`'s match.
|
|
512
|
+
* @param file - Skill item `file`.
|
|
513
|
+
* @returns The `/`-terminated prefix, or `null` when the path is not under
|
|
514
|
+
* a `skills/<name>` directory.
|
|
515
|
+
*/
|
|
516
|
+
const skillSourcePrefix = (file) => {
|
|
517
|
+
if ((0, core_1.getSkillName)(file) === null) {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
const normalized = file.replaceAll('\\', '/');
|
|
521
|
+
const match = /(?:^|\/)skills\/[^/]+(?:\/|$)/i.exec(normalized);
|
|
522
|
+
if (match === null) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
const root = normalized.slice(0, match.index + match[0].length).replace(/\/$/, '');
|
|
526
|
+
return `${root}/`;
|
|
527
|
+
};
|
|
528
|
+
exports.skillSourcePrefix = skillSourcePrefix;
|
|
529
|
+
/**
|
|
530
|
+
* Reserve every destination of a placement (relative to the layout base
|
|
531
|
+
* directory), unless one is already reserved by an earlier item.
|
|
532
|
+
* @param placement - Placement to reserve.
|
|
533
|
+
* @param taken - Destinations reserved so far; updated on success.
|
|
534
|
+
* @returns `false` (reserving nothing) when any destination is taken.
|
|
535
|
+
*/
|
|
536
|
+
const claimDestinations = (placement, taken) => {
|
|
537
|
+
const destinations = placement.sources.map(({ tail }) => path.join(placement.outDir, tail));
|
|
538
|
+
if (destinations.some((destination) => taken.has(destination))) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
for (const destination of destinations) {
|
|
542
|
+
taken.add(destination);
|
|
543
|
+
}
|
|
544
|
+
return true;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Express an absolute output path relative to the layout base directory,
|
|
548
|
+
* `/`-separated so lockfiles are portable across platforms.
|
|
549
|
+
* @param baseDir - Expanded layout base directory.
|
|
550
|
+
* @param outPath - Absolute output path below it.
|
|
551
|
+
* @returns The base-relative path.
|
|
552
|
+
*/
|
|
553
|
+
const toInstalledPath = (baseDir, outPath) => path.relative(baseDir, outPath).split(path.sep).join('/');
|
|
554
|
+
/**
|
|
555
|
+
* Resolve a recorded base-relative output path, refusing anything that
|
|
556
|
+
* would leave the base directory (the lockfile is user-editable).
|
|
557
|
+
* @param baseDir - Expanded layout base directory.
|
|
558
|
+
* @param installedPath - Recorded base-relative path.
|
|
559
|
+
* @returns Absolute output path.
|
|
560
|
+
* @throws {Error} When the path is absolute or escapes `baseDir`.
|
|
561
|
+
*/
|
|
562
|
+
const resolveInstalledPath = (baseDir, installedPath) => {
|
|
563
|
+
// Build the path exactly as the write did (`path.join(baseDir, …)`), so it
|
|
564
|
+
// names the same file. `path.resolve` is used only for the escape check: on
|
|
565
|
+
// Windows it adds a drive letter to a drive-less base like `\home\u`.
|
|
566
|
+
const outPath = path.join(baseDir, installedPath);
|
|
567
|
+
const relative = path.relative(path.resolve(baseDir), path.resolve(outPath));
|
|
568
|
+
if (path.isAbsolute(installedPath)
|
|
569
|
+
|| relative.length === 0
|
|
570
|
+
|| relative === '..'
|
|
571
|
+
|| relative.startsWith(`..${path.sep}`)
|
|
572
|
+
|| path.isAbsolute(relative)) {
|
|
573
|
+
throw new Error(`installed path "${installedPath}" is outside the target directory`);
|
|
574
|
+
}
|
|
575
|
+
return outPath;
|
|
576
|
+
};
|
|
407
577
|
const pickRoute = (bundlePath, routes) => {
|
|
408
578
|
const normalizedBundlePath = normalizeBundlePath(bundlePath);
|
|
409
579
|
const sorted = Object.entries(routes).toSorted((a, b) => b[0].length - a[0].length);
|