@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.d.cts
CHANGED
|
@@ -679,6 +679,9 @@ interface PackageStore {
|
|
|
679
679
|
writeFile(path: string, content: string): void | Promise<void>;
|
|
680
680
|
/** Remove a directory and its contents if present, for a clean reinstall. */
|
|
681
681
|
removeDir?(path: string): void | Promise<void>;
|
|
682
|
+
/** Read a UTF-8 file, or null if absent — used to merge the workspace prompd.json
|
|
683
|
+
* dependency list. When omitted, dependency tracking is skipped (non-fatal). */
|
|
684
|
+
readFile?(path: string): Promise<string | null> | string | null;
|
|
682
685
|
}
|
|
683
686
|
interface InstallPackageOptions {
|
|
684
687
|
/** "@scope/name@version" or "@scope/name" (defaults to latest). */
|
package/dist/index.d.ts
CHANGED
|
@@ -679,6 +679,9 @@ interface PackageStore {
|
|
|
679
679
|
writeFile(path: string, content: string): void | Promise<void>;
|
|
680
680
|
/** Remove a directory and its contents if present, for a clean reinstall. */
|
|
681
681
|
removeDir?(path: string): void | Promise<void>;
|
|
682
|
+
/** Read a UTF-8 file, or null if absent — used to merge the workspace prompd.json
|
|
683
|
+
* dependency list. When omitted, dependency tracking is skipped (non-fatal). */
|
|
684
|
+
readFile?(path: string): Promise<string | null> | string | null;
|
|
682
685
|
}
|
|
683
686
|
interface InstallPackageOptions {
|
|
684
687
|
/** "@scope/name@version" or "@scope/name" (defaults to latest). */
|
package/dist/index.js
CHANGED
|
@@ -3360,6 +3360,32 @@ function normalizeSegments(p) {
|
|
|
3360
3360
|
function resolveInstallDir(root, type, name) {
|
|
3361
3361
|
return joinPosix3(root, ".prompd", getInstallDirForType(type), name);
|
|
3362
3362
|
}
|
|
3363
|
+
async function addWorkspaceDependency(store, root, name, version) {
|
|
3364
|
+
if (!store.readFile) return;
|
|
3365
|
+
const manifestPath = joinPosix3(root, "prompd.json");
|
|
3366
|
+
try {
|
|
3367
|
+
const existing = await store.readFile(manifestPath);
|
|
3368
|
+
const manifest = existing && existing.trim() ? JSON.parse(existing) : {};
|
|
3369
|
+
if (!manifest.dependencies || typeof manifest.dependencies !== "object") manifest.dependencies = {};
|
|
3370
|
+
manifest.dependencies[name] = version;
|
|
3371
|
+
await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
3372
|
+
} catch {
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
async function removeWorkspaceDependency(store, root, name) {
|
|
3376
|
+
if (!store.readFile) return;
|
|
3377
|
+
const manifestPath = joinPosix3(root, "prompd.json");
|
|
3378
|
+
try {
|
|
3379
|
+
const existing = await store.readFile(manifestPath);
|
|
3380
|
+
if (!existing || !existing.trim()) return;
|
|
3381
|
+
const manifest = JSON.parse(existing);
|
|
3382
|
+
const deps = manifest.dependencies;
|
|
3383
|
+
if (!deps || typeof deps !== "object") return;
|
|
3384
|
+
delete deps[name];
|
|
3385
|
+
await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
3386
|
+
} catch {
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3363
3389
|
async function installPackage(opts) {
|
|
3364
3390
|
const { ref, type, root, store, download } = opts;
|
|
3365
3391
|
const parsed = parsePackageReference(ref);
|
|
@@ -3395,6 +3421,7 @@ async function installPackage(opts) {
|
|
|
3395
3421
|
await store.writeFile(dest, content);
|
|
3396
3422
|
written.push(rel);
|
|
3397
3423
|
}
|
|
3424
|
+
await addWorkspaceDependency(store, root, name, version);
|
|
3398
3425
|
return { name, version, scope: parsed.scope, installedPath, files: written };
|
|
3399
3426
|
}
|
|
3400
3427
|
async function uninstallPackage(opts) {
|
|
@@ -3405,6 +3432,7 @@ async function uninstallPackage(opts) {
|
|
|
3405
3432
|
const parsed = parsePackageReference(ref);
|
|
3406
3433
|
const installedPath = resolveInstallDir(root, type, parsed.name);
|
|
3407
3434
|
await store.removeDir(installedPath);
|
|
3435
|
+
await removeWorkspaceDependency(store, root, parsed.name);
|
|
3408
3436
|
return { name: parsed.name, scope: parsed.scope, installedPath };
|
|
3409
3437
|
}
|
|
3410
3438
|
|