@prompd/core 0.5.0-beta.14 → 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 +28 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3387,6 +3387,32 @@ function normalizeSegments(p) {
|
|
|
3387
3387
|
function resolveInstallDir(root, type, name) {
|
|
3388
3388
|
return joinPosix3(root, ".prompd", getInstallDirForType(type), name);
|
|
3389
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
|
+
}
|
|
3390
3416
|
async function installPackage(opts) {
|
|
3391
3417
|
const { ref, type, root, store, download } = opts;
|
|
3392
3418
|
const parsed = parsePackageReference(ref);
|
|
@@ -3422,6 +3448,7 @@ async function installPackage(opts) {
|
|
|
3422
3448
|
await store.writeFile(dest, content);
|
|
3423
3449
|
written.push(rel);
|
|
3424
3450
|
}
|
|
3451
|
+
await addWorkspaceDependency(store, root, name, version);
|
|
3425
3452
|
return { name, version, scope: parsed.scope, installedPath, files: written };
|
|
3426
3453
|
}
|
|
3427
3454
|
async function uninstallPackage(opts) {
|
|
@@ -3432,6 +3459,7 @@ async function uninstallPackage(opts) {
|
|
|
3432
3459
|
const parsed = parsePackageReference(ref);
|
|
3433
3460
|
const installedPath = resolveInstallDir(root, type, parsed.name);
|
|
3434
3461
|
await store.removeDir(installedPath);
|
|
3462
|
+
await removeWorkspaceDependency(store, root, parsed.name);
|
|
3435
3463
|
return { name: parsed.name, scope: parsed.scope, installedPath };
|
|
3436
3464
|
}
|
|
3437
3465
|
|