@penvhq/cli 0.12.0 → 0.14.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/bin.cjs CHANGED
@@ -50926,6 +50926,7 @@ function escapeArgument(argument, doubleEscape) {
50926
50926
  // src/install.ts
50927
50927
  var RUNTIME_PACKAGE = "@penvhq/penv";
50928
50928
  var SCHEMA_PACKAGE = "zod";
50929
+ var TYPES_PACKAGE = "@penvhq/core";
50929
50930
  var LOCKFILES = [
50930
50931
  ["pnpm", "pnpm-lock.yaml"],
50931
50932
  ["yarn", "yarn.lock"],
@@ -51028,6 +51029,10 @@ function declaredIn(dir, name) {
51028
51029
  }
51029
51030
  return void 0;
51030
51031
  }
51032
+ function blockPresentIn(dir, dev) {
51033
+ const block = manifestOf(dir)?.[dev ? "devDependencies" : "dependencies"];
51034
+ return block !== null && typeof block === "object" && !Array.isArray(block);
51035
+ }
51031
51036
  function isPnpmWorkspaceRoot(root) {
51032
51037
  return (0, import_node_fs2.existsSync)((0, import_node_path2.join)(root, PNPM_WORKSPACE)) && (0, import_node_fs2.existsSync)((0, import_node_path2.join)(root, "package.json"));
51033
51038
  }
@@ -51151,6 +51156,8 @@ function stepFor(manager, manifest, packages, options) {
51151
51156
  manifest,
51152
51157
  packages,
51153
51158
  command: addCommand(manager, options, specs),
51159
+ dev: options.dev,
51160
+ blockPresent: blockPresentIn(options.dir, options.dev),
51154
51161
  satisfied: pending.length === 0
51155
51162
  };
51156
51163
  }
@@ -51162,6 +51169,7 @@ function planInstall(root, version2 = engineVersion()) {
51162
51169
  const workspaceRoot = manager === "pnpm" && isPnpmWorkspaceRoot(root);
51163
51170
  const runtime = declaredIn(root, RUNTIME_PACKAGE);
51164
51171
  const zod = declaredIn(root, SCHEMA_PACKAGE);
51172
+ const types = declaredIn(root, TYPES_PACKAGE);
51165
51173
  const packages = [
51166
51174
  {
51167
51175
  name: RUNTIME_PACKAGE,
@@ -51178,34 +51186,47 @@ function planInstall(root, version2 = engineVersion()) {
51178
51186
  satisfied: zod !== void 0
51179
51187
  }
51180
51188
  ];
51189
+ const typesPackage = {
51190
+ name: TYPES_PACKAGE,
51191
+ version: version2,
51192
+ ...types === void 0 ? {} : { declared: types.version },
51193
+ // Any declared version counts, for zod's reason: the augmentation binds on
51194
+ // the module resolving, not on which release of it a project pinned.
51195
+ satisfied: types !== void 0
51196
+ };
51181
51197
  const pending = packages.filter((entry) => !entry.satisfied);
51182
51198
  const steps = [
51183
51199
  stepFor(manager, "package.json", packages, {
51184
51200
  workspaceRoot,
51201
+ dir: root,
51185
51202
  dev: runtime?.dev === true && pending.every((entry) => entry.name === RUNTIME_PACKAGE) && pending.length > 0
51186
- })
51203
+ }),
51204
+ stepFor(manager, "package.json", [typesPackage], { workspaceRoot, dir: root, dev: true })
51187
51205
  ];
51188
- for (const dir of workspaceMembers(root, RUNTIME_PACKAGE)) {
51189
- const declared = declaredIn(dir, RUNTIME_PACKAGE);
51190
- steps.push(
51191
- stepFor(
51192
- manager,
51193
- manifestPathOf(root, dir),
51194
- [
51206
+ for (const name of [RUNTIME_PACKAGE, TYPES_PACKAGE]) {
51207
+ for (const dir of workspaceMembers(root, name)) {
51208
+ const declared = declaredIn(dir, name);
51209
+ steps.push(
51210
+ stepFor(
51211
+ manager,
51212
+ manifestPathOf(root, dir),
51213
+ [
51214
+ {
51215
+ name,
51216
+ version: version2,
51217
+ declared: declared.version,
51218
+ satisfied: declared.version === version2
51219
+ }
51220
+ ],
51195
51221
  {
51196
- name: RUNTIME_PACKAGE,
51197
- version: version2,
51198
- declared: declared.version,
51199
- satisfied: declared.version === version2
51222
+ filter: `./${(0, import_node_path2.relative)(root, dir).split(import_node_path2.sep).join("/")}`,
51223
+ workspaceRoot: false,
51224
+ dir,
51225
+ dev: declared.dev
51200
51226
  }
51201
- ],
51202
- {
51203
- filter: `./${(0, import_node_path2.relative)(root, dir).split(import_node_path2.sep).join("/")}`,
51204
- workspaceRoot: false,
51205
- dev: declared.dev
51206
- }
51207
- )
51208
- );
51227
+ )
51228
+ );
51229
+ }
51209
51230
  }
51210
51231
  return {
51211
51232
  root,
@@ -51222,16 +51243,25 @@ function installedPackages(plan2) {
51222
51243
  const pending = plan2.steps.flatMap((step) => step.packages).filter((entry) => !entry.satisfied);
51223
51244
  return [...new Map(pending.map((entry) => [entry.name, entry])).values()];
51224
51245
  }
51246
+ function plannedPackages(plan2) {
51247
+ const all = plan2.steps.flatMap((step) => step.packages);
51248
+ return [...new Map(all.map((entry) => [entry.name, entry])).values()];
51249
+ }
51250
+ function series(values) {
51251
+ return values.length < 2 ? values[0] ?? "" : `${values.slice(0, -1).join(", ")} and ${values.at(-1)}`;
51252
+ }
51225
51253
  function renderStep(step) {
51226
51254
  const pending = step.packages.filter((entry) => !entry.satisfied);
51227
51255
  const added = pending.filter((entry) => entry.declared === void 0);
51228
51256
  const replaced = pending.filter((entry) => entry.declared !== void 0);
51257
+ const block = step.dev ? "devDependencies" : "dependencies";
51258
+ const edge = step.blockPresent ? " " : " +";
51229
51259
  return [
51230
51260
  step.manifest,
51231
51261
  ...added.length === 0 ? [] : [
51232
- ' + "dependencies": {',
51262
+ `${edge} "${block}": {`,
51233
51263
  ...added.map((entry) => ` + "${entry.name}": "${entry.version}"`),
51234
- " + }"
51264
+ `${edge} }`
51235
51265
  ],
51236
51266
  ...replaced.flatMap((entry) => [
51237
51267
  ` - "${entry.name}": "${entry.declared}"`,
@@ -51241,9 +51271,8 @@ function renderStep(step) {
51241
51271
  }
51242
51272
  function renderInstallPlan(plan2) {
51243
51273
  if (plan2.satisfied) {
51244
- const packages = plan2.steps[0]?.packages ?? [];
51245
51274
  return [
51246
- `package.json already has ${packages.map(describe4).join(" and ")} \u2014 nothing to install.`
51275
+ `package.json already has ${series(plannedPackages(plan2).map(describe4))} \u2014 nothing to install.`
51247
51276
  ];
51248
51277
  }
51249
51278
  const pending = plan2.steps.filter((step) => !step.satisfied);