@penvhq/cli 0.16.0 → 0.16.2

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
@@ -51195,9 +51195,12 @@ function planInstall(root, version2 = engineVersion()) {
51195
51195
  name: TYPES_PACKAGE,
51196
51196
  version: version2,
51197
51197
  ...types === void 0 ? {} : { declared: types.version },
51198
- // Any declared version counts, for zod's reason: the augmentation binds on
51199
- // the module resolving, not on which release of it a project pinned.
51200
- satisfied: types !== void 0
51198
+ // Held to the pin, exactly as a workspace member's copy is. The augmentation
51199
+ // binds on the module resolving, but what it binds to is whatever release
51200
+ // resolved: a core behind the pin checks `penv.config.ts` against a shape the
51201
+ // engine no longer has, and the committed declarations augment interfaces
51202
+ // that moved under them.
51203
+ satisfied: types?.version === version2
51201
51204
  };
51202
51205
  const pending = packages.filter((entry) => !entry.satisfied);
51203
51206
  const steps = [
@@ -53467,8 +53470,21 @@ init_cjs_shims();
53467
53470
  // src/input.ts
53468
53471
  init_cjs_shims();
53469
53472
  var import_node_readline = require("readline");
53473
+ var import_node_stream = require("stream");
53474
+ function isTerminal(output) {
53475
+ return output.isTTY === true;
53476
+ }
53470
53477
  function lineReader(input = process.stdin, output = process.stdout) {
53471
- const rl = (0, import_node_readline.createInterface)({ input, output });
53478
+ let muted = false;
53479
+ const sink = new import_node_stream.Writable({
53480
+ write(chunk, _encoding, callback) {
53481
+ if (!muted) {
53482
+ output.write(chunk);
53483
+ }
53484
+ callback();
53485
+ }
53486
+ });
53487
+ const rl = (0, import_node_readline.createInterface)({ input, output: sink, terminal: isTerminal(output) });
53472
53488
  const buffered = [];
53473
53489
  const waiting = [];
53474
53490
  let closed = false;
@@ -53487,7 +53503,7 @@ function lineReader(input = process.stdin, output = process.stdout) {
53487
53503
  }
53488
53504
  });
53489
53505
  return {
53490
- ask(question) {
53506
+ ask(question, options) {
53491
53507
  const early = buffered.shift();
53492
53508
  if (early !== void 0) {
53493
53509
  return Promise.resolve(early);
@@ -53495,6 +53511,19 @@ function lineReader(input = process.stdin, output = process.stdout) {
53495
53511
  if (closed) {
53496
53512
  return Promise.resolve(void 0);
53497
53513
  }
53514
+ if (options?.secret === true) {
53515
+ output.write(question);
53516
+ muted = true;
53517
+ rl.setPrompt("");
53518
+ rl.prompt();
53519
+ return new Promise((resolve13) => {
53520
+ waiting.push((line) => {
53521
+ muted = false;
53522
+ output.write("\n");
53523
+ resolve13(line);
53524
+ });
53525
+ });
53526
+ }
53498
53527
  rl.setPrompt(question);
53499
53528
  rl.prompt();
53500
53529
  return new Promise((resolve13) => {
@@ -54813,16 +54842,30 @@ async function runSet(options) {
54813
54842
  const ref = refFromKey(options.key, project.config);
54814
54843
  const scope = targetScope(project, options, options.key);
54815
54844
  const environment = policyEnvironment(project, options);
54845
+ const value2 = options.value ?? await askForValue(project, ref, environment, options);
54816
54846
  const { encrypted, location } = await sealAwareWrite({
54817
54847
  project,
54818
54848
  provider: project.provider,
54819
54849
  ref,
54820
54850
  scope,
54821
- value: options.value,
54851
+ value: value2,
54822
54852
  environment
54823
54853
  });
54824
54854
  return { parameter: options.key, location, encrypted };
54825
54855
  }
54856
+ async function askForValue(project, ref, environment, options) {
54857
+ const parameter = parameterId(ref);
54858
+ const remedy = `Pass it on the command line \u2014 \`penv set ${options.key} <value>\` \u2014 pipe it in, or answer the prompt.`;
54859
+ if (options.ask === void 0) {
54860
+ throw new PenvError("VALUE_MISSING", `No value was given for parameter ${parameter}`, remedy);
54861
+ }
54862
+ const secret = isSecret(await project.provider.readMeta(ref), environment);
54863
+ const answer = await options.ask({ parameter, secret });
54864
+ if (answer === void 0 || answer.length === 0) {
54865
+ throw new PenvError("VALUE_MISSING", `No value was entered for parameter ${parameter}`, remedy);
54866
+ }
54867
+ return answer;
54868
+ }
54826
54869
  function renderSet(result2) {
54827
54870
  return formatRows([
54828
54871
  {
@@ -54860,18 +54903,29 @@ var setCommand = defineCommand({
54860
54903
  },
54861
54904
  run({ args }) {
54862
54905
  return guard(async () => {
54863
- const value2 = args.value ?? await readStdin();
54864
- write(
54865
- renderSet(
54866
- await runSet({
54867
- cwd: process.cwd(),
54868
- key: args.key,
54869
- value: value2,
54870
- ...args.env === void 0 ? {} : { environment: args.env },
54871
- ...args.local === void 0 ? {} : { local: args.local }
54872
- })
54873
- )
54874
- );
54906
+ const base = {
54907
+ cwd: process.cwd(),
54908
+ key: args.key,
54909
+ ...args.env === void 0 ? {} : { environment: args.env },
54910
+ ...args.local === void 0 ? {} : { local: args.local }
54911
+ };
54912
+ if (args.value !== void 0) {
54913
+ write(renderSet(await runSet({ ...base, value: args.value })));
54914
+ return;
54915
+ }
54916
+ if (process.stdin.isTTY !== true) {
54917
+ write(renderSet(await runSet({ ...base, value: await readStdin() })));
54918
+ return;
54919
+ }
54920
+ const reader = lineReader();
54921
+ try {
54922
+ const ask = ({ parameter, secret }) => reader.ask(prompt(parameter, secret ? "secret, typing is hidden" : void 0), {
54923
+ secret
54924
+ });
54925
+ write(renderSet(await runSet({ ...base, ask })));
54926
+ } finally {
54927
+ reader.close();
54928
+ }
54875
54929
  });
54876
54930
  }
54877
54931
  });
@@ -55034,6 +55088,8 @@ ${detail}`,
55034
55088
  `Fix these \u2014 \`penv validate\` reports them \u2014 then run \`penv fill\`. If you have not written a schema yet, declare the required parameters in ${SCHEMA_SHAPE_FILE}.`
55035
55089
  );
55036
55090
  }
55091
+ const project = openProject(options.cwd);
55092
+ const secretFor = async (ref) => isSecret(await project.provider.readMeta(ref), environment);
55037
55093
  const written = [];
55038
55094
  const skipped2 = [];
55039
55095
  const kept = [];
@@ -55048,7 +55104,7 @@ ${detail}`,
55048
55104
  const value2 = await options.ask({
55049
55105
  parameter: key,
55050
55106
  environment,
55051
- secret: false,
55107
+ secret: await secretFor(ref),
55052
55108
  optional: false
55053
55109
  });
55054
55110
  if (value2 === void 0 || value2 === "") {
@@ -55072,7 +55128,7 @@ ${detail}`,
55072
55128
  const value2 = await options.ask({
55073
55129
  parameter: key,
55074
55130
  environment,
55075
- secret: false,
55131
+ secret: await secretFor(ref),
55076
55132
  optional: true,
55077
55133
  ...item.defaultValue === void 0 ? {} : { defaultValue: item.defaultValue }
55078
55134
  });
@@ -55142,7 +55198,7 @@ var fillCommand = defineCommand({
55142
55198
  run({ args }) {
55143
55199
  return guard(async () => {
55144
55200
  const reader = lineReader();
55145
- const ask = (prompt2) => reader.ask(prompt(prompt2.parameter, contextFor(prompt2)));
55201
+ const ask = (prompt2) => reader.ask(prompt(prompt2.parameter, contextFor(prompt2)), { secret: prompt2.secret });
55146
55202
  try {
55147
55203
  write(
55148
55204
  renderFill(