@prompd/core 0.5.0-beta.13 → 0.5.0-beta.15
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/index.cjs +43 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +43 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3384,6 +3384,35 @@ function normalizeSegments(p) {
|
|
|
3384
3384
|
}
|
|
3385
3385
|
return out.join("/");
|
|
3386
3386
|
}
|
|
3387
|
+
function resolveInstallDir(root, type, name) {
|
|
3388
|
+
return joinPosix3(root, ".prompd", getInstallDirForType(type), name);
|
|
3389
|
+
}
|
|
3390
|
+
async function addWorkspaceDependency(store, root, name, version) {
|
|
3391
|
+
if (!store.readFile) return;
|
|
3392
|
+
const manifestPath = joinPosix3(root, "prompd.json");
|
|
3393
|
+
try {
|
|
3394
|
+
const existing = await store.readFile(manifestPath);
|
|
3395
|
+
const manifest = existing && existing.trim() ? JSON.parse(existing) : {};
|
|
3396
|
+
if (!manifest.dependencies || typeof manifest.dependencies !== "object") manifest.dependencies = {};
|
|
3397
|
+
manifest.dependencies[name] = version;
|
|
3398
|
+
await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
3399
|
+
} catch {
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
async function removeWorkspaceDependency(store, root, name) {
|
|
3403
|
+
if (!store.readFile) return;
|
|
3404
|
+
const manifestPath = joinPosix3(root, "prompd.json");
|
|
3405
|
+
try {
|
|
3406
|
+
const existing = await store.readFile(manifestPath);
|
|
3407
|
+
if (!existing || !existing.trim()) return;
|
|
3408
|
+
const manifest = JSON.parse(existing);
|
|
3409
|
+
const deps = manifest.dependencies;
|
|
3410
|
+
if (!deps || typeof deps !== "object") return;
|
|
3411
|
+
delete deps[name];
|
|
3412
|
+
await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
3413
|
+
} catch {
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3387
3416
|
async function installPackage(opts) {
|
|
3388
3417
|
const { ref, type, root, store, download } = opts;
|
|
3389
3418
|
const parsed = parsePackageReference(ref);
|
|
@@ -3406,7 +3435,7 @@ async function installPackage(opts) {
|
|
|
3406
3435
|
} catch {
|
|
3407
3436
|
}
|
|
3408
3437
|
}
|
|
3409
|
-
const installedPath =
|
|
3438
|
+
const installedPath = resolveInstallDir(root, type, name);
|
|
3410
3439
|
const baseSegments = normalizeSegments(installedPath);
|
|
3411
3440
|
await store.removeDir?.(installedPath);
|
|
3412
3441
|
const written = [];
|
|
@@ -3419,8 +3448,20 @@ async function installPackage(opts) {
|
|
|
3419
3448
|
await store.writeFile(dest, content);
|
|
3420
3449
|
written.push(rel);
|
|
3421
3450
|
}
|
|
3451
|
+
await addWorkspaceDependency(store, root, name, version);
|
|
3422
3452
|
return { name, version, scope: parsed.scope, installedPath, files: written };
|
|
3423
3453
|
}
|
|
3454
|
+
async function uninstallPackage(opts) {
|
|
3455
|
+
const { ref, type, root, store } = opts;
|
|
3456
|
+
if (!store.removeDir) {
|
|
3457
|
+
throw new Error("Uninstall requires a PackageStore with removeDir.");
|
|
3458
|
+
}
|
|
3459
|
+
const parsed = parsePackageReference(ref);
|
|
3460
|
+
const installedPath = resolveInstallDir(root, type, parsed.name);
|
|
3461
|
+
await store.removeDir(installedPath);
|
|
3462
|
+
await removeWorkspaceDependency(store, root, parsed.name);
|
|
3463
|
+
return { name: parsed.name, scope: parsed.scope, installedPath };
|
|
3464
|
+
}
|
|
3424
3465
|
|
|
3425
3466
|
// src/lib/compiler/index.ts
|
|
3426
3467
|
function createCoreStages() {
|
|
@@ -4880,6 +4921,7 @@ exports.resolvePackageFile = resolvePackageFile;
|
|
|
4880
4921
|
exports.resolvePosix = resolvePosix;
|
|
4881
4922
|
exports.serializeWorkflow = serializeWorkflow;
|
|
4882
4923
|
exports.stripFilePath = stripFilePath;
|
|
4924
|
+
exports.uninstallPackage = uninstallPackage;
|
|
4883
4925
|
exports.validateWorkflow = validateWorkflow;
|
|
4884
4926
|
exports.validateWorkflowQuick = validateWorkflowQuick;
|
|
4885
4927
|
//# sourceMappingURL=index.cjs.map
|