prpm 2.1.8 → 2.1.9

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.js CHANGED
@@ -204,6 +204,15 @@ function removeCollectionFromLockfile(lockfile, collectionKey) {
204
204
  delete lockfile.collections[collectionKey];
205
205
  lockfile.generated = (/* @__PURE__ */ new Date()).toISOString();
206
206
  }
207
+ function listCollectionsFromLockfile(lockfile) {
208
+ if (!lockfile || !lockfile.collections) {
209
+ return [];
210
+ }
211
+ return Object.entries(lockfile.collections).map(([key, collection]) => ({
212
+ key,
213
+ ...collection
214
+ }));
215
+ }
207
216
  var import_fs, import_path, import_crypto, LOCKFILE_NAME, LOCKFILE_VERSION;
208
217
  var init_lockfile = __esm({
209
218
  "src/core/lockfile.ts"() {
@@ -17589,7 +17598,9 @@ async function installFromLockfile(options) {
17589
17598
  // Force reinstall when installing from lockfile
17590
17599
  location: locationOverride,
17591
17600
  manifestFile,
17592
- hookMapping: options.hookMapping
17601
+ hookMapping: options.hookMapping,
17602
+ fromCollection: lockEntry.fromCollection
17603
+ // Preserve collection metadata
17593
17604
  });
17594
17605
  successCount++;
17595
17606
  } catch (error) {
@@ -21302,6 +21313,9 @@ function getManifestSchema() {
21302
21313
  }
21303
21314
 
21304
21315
  // src/utils/manifest-loader.ts
21316
+ function toOrganizationSlug(value) {
21317
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-");
21318
+ }
21305
21319
  async function findAndLoadManifests() {
21306
21320
  const prpmJsonPath = (0, import_path17.join)(process.cwd(), "prpm.json");
21307
21321
  let prpmJsonExists = false;
@@ -21502,8 +21516,8 @@ function normalizeFilePaths2(files) {
21502
21516
  function predictScopedPackageName(manifestName, username, organization) {
21503
21517
  const usernameLowercase = username.toLowerCase();
21504
21518
  if (organization) {
21505
- const orgNameLowercase = organization.toLowerCase();
21506
- const expectedPrefix = `@${orgNameLowercase}/`;
21519
+ const orgSlug = toOrganizationSlug(organization);
21520
+ const expectedPrefix = `@${orgSlug}/`;
21507
21521
  if (!manifestName.startsWith(expectedPrefix)) {
21508
21522
  return `${expectedPrefix}${manifestName}`;
21509
21523
  }
@@ -21598,6 +21612,7 @@ function formatTarballSize(sizeInBytes) {
21598
21612
 
21599
21613
  // src/commands/publish.ts
21600
21614
  init_init();
21615
+ var toOrgSlug = (value) => value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-");
21601
21616
  async function listPackages2() {
21602
21617
  const { manifests, collections, source } = await findAndLoadManifests();
21603
21618
  console.log(`
@@ -21865,9 +21880,11 @@ ${"=".repeat(60)}`);
21865
21880
  }
21866
21881
  let selectedOrgId;
21867
21882
  let selectedOrgName;
21883
+ let selectedOrgSlug;
21868
21884
  if (manifest.organization && userInfo) {
21885
+ const manifestOrgSlug = toOrgSlug(manifest.organization);
21869
21886
  const orgFromManifest = (_a = userInfo.organizations) == null ? void 0 : _a.find(
21870
- (org) => org.name === manifest.organization || org.id === manifest.organization
21887
+ (org) => org.id === manifest.organization || org.name === manifest.organization || org.slug && typeof org.slug === "string" && org.slug.toLowerCase() === manifestOrgSlug || org.name && toOrgSlug(typeof org.name === "string" ? org.name : "") === manifestOrgSlug
21871
21888
  );
21872
21889
  if (!orgFromManifest) {
21873
21890
  throw new Error(
@@ -21881,6 +21898,7 @@ ${"=".repeat(60)}`);
21881
21898
  }
21882
21899
  selectedOrgId = orgFromManifest.id;
21883
21900
  selectedOrgName = orgFromManifest.name;
21901
+ selectedOrgSlug = (typeof orgFromManifest.slug === "string" ? orgFromManifest.slug : void 0) || (orgFromManifest.name ? toOrgSlug(String(orgFromManifest.name)) : void 0);
21884
21902
  }
21885
21903
  let publishAsAuthor;
21886
21904
  if ((userInfo == null ? void 0 : userInfo.is_admin) && manifest.author) {
@@ -21889,7 +21907,7 @@ ${"=".repeat(60)}`);
21889
21907
  const scopedPackageName = predictScopedPackageName(
21890
21908
  manifest.name,
21891
21909
  (userInfo == null ? void 0 : userInfo.username) || config.username || "unknown",
21892
- selectedOrgName || manifest.organization
21910
+ selectedOrgSlug || manifest.organization
21893
21911
  );
21894
21912
  console.log(` Source: ${source}`);
21895
21913
  console.log(` Package: ${scopedPackageName}@${manifest.version}`);
@@ -22744,6 +22762,7 @@ init_install();
22744
22762
  init_telemetry();
22745
22763
  init_errors();
22746
22764
  async function handleUpgrade(packageName, options = {}) {
22765
+ var _a;
22747
22766
  const startTime = Date.now();
22748
22767
  let success = false;
22749
22768
  let error;
@@ -22805,6 +22824,82 @@ ${emoji} Upgrading ${packageId}: ${currentVersion} \u2192 ${latestVersion} (${up
22805
22824
  );
22806
22825
  }
22807
22826
  }
22827
+ if (!packageName) {
22828
+ const lockfile = await readLockfile();
22829
+ if (lockfile) {
22830
+ const installedCollections = listCollectionsFromLockfile(lockfile);
22831
+ for (const collection of installedCollections) {
22832
+ try {
22833
+ const latestCollection = await client.getCollection(
22834
+ collection.name_slug
22835
+ );
22836
+ if (!latestCollection) continue;
22837
+ const currentVersion = collection.version;
22838
+ const latestVersion = latestCollection.version || "1.0.0";
22839
+ if (currentVersion !== latestVersion) {
22840
+ console.log(
22841
+ `
22842
+ \u{1F4E6} Collection ${collection.name_slug}: ${currentVersion} \u2192 ${latestVersion}`
22843
+ );
22844
+ const installedPackageIds = new Set(collection.packages);
22845
+ const newPackages = latestCollection.packages.filter(
22846
+ (pkg) => {
22847
+ var _a2;
22848
+ return !installedPackageIds.has(((_a2 = pkg.package) == null ? void 0 : _a2.name) || "");
22849
+ }
22850
+ );
22851
+ if (newPackages.length > 0) {
22852
+ console.log(
22853
+ ` \u{1F4E5} ${newPackages.length} new package(s) added to collection`
22854
+ );
22855
+ const existingCollectionPkg = installedPackages.find(
22856
+ (p) => {
22857
+ var _a2;
22858
+ return ((_a2 = p.fromCollection) == null ? void 0 : _a2.name_slug) === collection.name_slug;
22859
+ }
22860
+ );
22861
+ const collectionFormat = existingCollectionPkg == null ? void 0 : existingCollectionPkg.format;
22862
+ for (const pkg of newPackages) {
22863
+ const pkgName = (_a = pkg.package) == null ? void 0 : _a.name;
22864
+ if (!pkgName) continue;
22865
+ try {
22866
+ console.log(` \u{1F4E5} Installing new package: ${pkgName}`);
22867
+ await handleInstall(`${pkgName}@${pkg.version || "latest"}`, {
22868
+ as: collectionFormat,
22869
+ fromCollection: {
22870
+ name_slug: collection.name_slug,
22871
+ version: latestVersion
22872
+ }
22873
+ });
22874
+ upgradedCount++;
22875
+ } catch (err) {
22876
+ console.error(
22877
+ ` \u274C Failed to install ${pkgName}: ${err instanceof Error ? err.message : String(err)}`
22878
+ );
22879
+ }
22880
+ }
22881
+ }
22882
+ addCollectionToLockfile(lockfile, collection.name_slug, {
22883
+ name_slug: collection.name_slug,
22884
+ version: latestVersion,
22885
+ packages: [
22886
+ ...collection.packages,
22887
+ ...newPackages.map((p) => {
22888
+ var _a2;
22889
+ return (_a2 = p.package) == null ? void 0 : _a2.name;
22890
+ }).filter((n) => !!n)
22891
+ ]
22892
+ });
22893
+ await writeLockfile(lockfile);
22894
+ }
22895
+ } catch (err) {
22896
+ console.error(
22897
+ ` \u26A0\uFE0F Could not check collection ${collection.name_slug}: ${err instanceof Error ? err.message : String(err)}`
22898
+ );
22899
+ }
22900
+ }
22901
+ }
22902
+ }
22808
22903
  if (upgradedCount === 0) {
22809
22904
  console.log("\n\u2705 All packages are at the latest version!\n");
22810
22905
  } else {
@@ -147,10 +147,11 @@
147
147
  },
148
148
  "organization": {
149
149
  "type": "string",
150
- "description": "Organization name or ID to publish this package under. If not specified, publishes to personal account.",
150
+ "description": "Organization slug or ID to publish this package under (used for package scope). If not specified, publishes to personal account. Slugs should be lowercase, alphanumeric with hyphens (spaces removed).",
151
151
  "examples": [
152
152
  "my-team",
153
- "my-company"
153
+ "my-company",
154
+ "my-senior-dev"
154
155
  ]
155
156
  },
156
157
  "private": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prpm",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "Prompt Package Manager CLI - Install and manage prompt-based files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -45,9 +45,9 @@
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
47
  "@octokit/rest": "^22.0.0",
48
- "@pr-pm/converters": "^2.1.9",
49
- "@pr-pm/registry-client": "^2.3.8",
50
- "@pr-pm/types": "^2.1.9",
48
+ "@pr-pm/converters": "^2.1.10",
49
+ "@pr-pm/registry-client": "^2.3.9",
50
+ "@pr-pm/types": "^2.1.10",
51
51
  "ajv": "^8.17.1",
52
52
  "ajv-formats": "^3.0.1",
53
53
  "commander": "^11.1.0",
@@ -147,10 +147,11 @@
147
147
  },
148
148
  "organization": {
149
149
  "type": "string",
150
- "description": "Organization name or ID to publish this package under. If not specified, publishes to personal account.",
150
+ "description": "Organization slug or ID to publish this package under (used for package scope). If not specified, publishes to personal account. Slugs should be lowercase, alphanumeric with hyphens (spaces removed).",
151
151
  "examples": [
152
152
  "my-team",
153
- "my-company"
153
+ "my-company",
154
+ "my-senior-dev"
154
155
  ]
155
156
  },
156
157
  "private": {