@penvhq/cli 0.16.1 → 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 +71 -18
- package/dist/bin.cjs.map +1 -1
- package/dist/index.cjs +71 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +72 -19
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2637,8 +2637,21 @@ var import_citty6 = require("citty");
|
|
|
2637
2637
|
|
|
2638
2638
|
// src/input.ts
|
|
2639
2639
|
var import_node_readline = require("readline");
|
|
2640
|
+
var import_node_stream = require("stream");
|
|
2641
|
+
function isTerminal(output) {
|
|
2642
|
+
return output.isTTY === true;
|
|
2643
|
+
}
|
|
2640
2644
|
function lineReader(input = process.stdin, output = process.stdout) {
|
|
2641
|
-
|
|
2645
|
+
let muted = false;
|
|
2646
|
+
const sink = new import_node_stream.Writable({
|
|
2647
|
+
write(chunk, _encoding, callback) {
|
|
2648
|
+
if (!muted) {
|
|
2649
|
+
output.write(chunk);
|
|
2650
|
+
}
|
|
2651
|
+
callback();
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
const rl = (0, import_node_readline.createInterface)({ input, output: sink, terminal: isTerminal(output) });
|
|
2642
2655
|
const buffered = [];
|
|
2643
2656
|
const waiting = [];
|
|
2644
2657
|
let closed = false;
|
|
@@ -2657,7 +2670,7 @@ function lineReader(input = process.stdin, output = process.stdout) {
|
|
|
2657
2670
|
}
|
|
2658
2671
|
});
|
|
2659
2672
|
return {
|
|
2660
|
-
ask(question) {
|
|
2673
|
+
ask(question, options) {
|
|
2661
2674
|
const early = buffered.shift();
|
|
2662
2675
|
if (early !== void 0) {
|
|
2663
2676
|
return Promise.resolve(early);
|
|
@@ -2665,6 +2678,19 @@ function lineReader(input = process.stdin, output = process.stdout) {
|
|
|
2665
2678
|
if (closed) {
|
|
2666
2679
|
return Promise.resolve(void 0);
|
|
2667
2680
|
}
|
|
2681
|
+
if (options?.secret === true) {
|
|
2682
|
+
output.write(question);
|
|
2683
|
+
muted = true;
|
|
2684
|
+
rl.setPrompt("");
|
|
2685
|
+
rl.prompt();
|
|
2686
|
+
return new Promise((resolve9) => {
|
|
2687
|
+
waiting.push((line) => {
|
|
2688
|
+
muted = false;
|
|
2689
|
+
output.write("\n");
|
|
2690
|
+
resolve9(line);
|
|
2691
|
+
});
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2668
2694
|
rl.setPrompt(question);
|
|
2669
2695
|
rl.prompt();
|
|
2670
2696
|
return new Promise((resolve9) => {
|
|
@@ -3985,16 +4011,30 @@ async function runSet(options) {
|
|
|
3985
4011
|
const ref = refFromKey(options.key, project.config);
|
|
3986
4012
|
const scope = targetScope(project, options, options.key);
|
|
3987
4013
|
const environment = policyEnvironment(project, options);
|
|
4014
|
+
const value = options.value ?? await askForValue(project, ref, environment, options);
|
|
3988
4015
|
const { encrypted, location } = await sealAwareWrite({
|
|
3989
4016
|
project,
|
|
3990
4017
|
provider: project.provider,
|
|
3991
4018
|
ref,
|
|
3992
4019
|
scope,
|
|
3993
|
-
value
|
|
4020
|
+
value,
|
|
3994
4021
|
environment
|
|
3995
4022
|
});
|
|
3996
4023
|
return { parameter: options.key, location, encrypted };
|
|
3997
4024
|
}
|
|
4025
|
+
async function askForValue(project, ref, environment, options) {
|
|
4026
|
+
const parameter = (0, import_core17.parameterId)(ref);
|
|
4027
|
+
const remedy = `Pass it on the command line \u2014 \`penv set ${options.key} <value>\` \u2014 pipe it in, or answer the prompt.`;
|
|
4028
|
+
if (options.ask === void 0) {
|
|
4029
|
+
throw new import_core17.PenvError("VALUE_MISSING", `No value was given for parameter ${parameter}`, remedy);
|
|
4030
|
+
}
|
|
4031
|
+
const secret = (0, import_core17.isSecret)(await project.provider.readMeta(ref), environment);
|
|
4032
|
+
const answer = await options.ask({ parameter, secret });
|
|
4033
|
+
if (answer === void 0 || answer.length === 0) {
|
|
4034
|
+
throw new import_core17.PenvError("VALUE_MISSING", `No value was entered for parameter ${parameter}`, remedy);
|
|
4035
|
+
}
|
|
4036
|
+
return answer;
|
|
4037
|
+
}
|
|
3998
4038
|
function renderSet(result2) {
|
|
3999
4039
|
return formatRows([
|
|
4000
4040
|
{
|
|
@@ -4032,18 +4072,29 @@ var setCommand = (0, import_citty8.defineCommand)({
|
|
|
4032
4072
|
},
|
|
4033
4073
|
run({ args }) {
|
|
4034
4074
|
return guard(async () => {
|
|
4035
|
-
const
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4075
|
+
const base = {
|
|
4076
|
+
cwd: process.cwd(),
|
|
4077
|
+
key: args.key,
|
|
4078
|
+
...args.env === void 0 ? {} : { environment: args.env },
|
|
4079
|
+
...args.local === void 0 ? {} : { local: args.local }
|
|
4080
|
+
};
|
|
4081
|
+
if (args.value !== void 0) {
|
|
4082
|
+
write(renderSet(await runSet({ ...base, value: args.value })));
|
|
4083
|
+
return;
|
|
4084
|
+
}
|
|
4085
|
+
if (process.stdin.isTTY !== true) {
|
|
4086
|
+
write(renderSet(await runSet({ ...base, value: await readStdin() })));
|
|
4087
|
+
return;
|
|
4088
|
+
}
|
|
4089
|
+
const reader = lineReader();
|
|
4090
|
+
try {
|
|
4091
|
+
const ask = ({ parameter, secret }) => reader.ask(prompt(parameter, secret ? "secret, typing is hidden" : void 0), {
|
|
4092
|
+
secret
|
|
4093
|
+
});
|
|
4094
|
+
write(renderSet(await runSet({ ...base, ask })));
|
|
4095
|
+
} finally {
|
|
4096
|
+
reader.close();
|
|
4097
|
+
}
|
|
4047
4098
|
});
|
|
4048
4099
|
}
|
|
4049
4100
|
});
|
|
@@ -4207,6 +4258,8 @@ ${detail}`,
|
|
|
4207
4258
|
`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 ${import_core19.SCHEMA_SHAPE_FILE}.`
|
|
4208
4259
|
);
|
|
4209
4260
|
}
|
|
4261
|
+
const project = openProject(options.cwd);
|
|
4262
|
+
const secretFor = async (ref) => (0, import_core19.isSecret)(await project.provider.readMeta(ref), environment);
|
|
4210
4263
|
const written = [];
|
|
4211
4264
|
const skipped2 = [];
|
|
4212
4265
|
const kept = [];
|
|
@@ -4221,7 +4274,7 @@ ${detail}`,
|
|
|
4221
4274
|
const value = await options.ask({
|
|
4222
4275
|
parameter: key,
|
|
4223
4276
|
environment,
|
|
4224
|
-
secret:
|
|
4277
|
+
secret: await secretFor(ref),
|
|
4225
4278
|
optional: false
|
|
4226
4279
|
});
|
|
4227
4280
|
if (value === void 0 || value === "") {
|
|
@@ -4245,7 +4298,7 @@ ${detail}`,
|
|
|
4245
4298
|
const value = await options.ask({
|
|
4246
4299
|
parameter: key,
|
|
4247
4300
|
environment,
|
|
4248
|
-
secret:
|
|
4301
|
+
secret: await secretFor(ref),
|
|
4249
4302
|
optional: true,
|
|
4250
4303
|
...item.defaultValue === void 0 ? {} : { defaultValue: item.defaultValue }
|
|
4251
4304
|
});
|
|
@@ -4315,7 +4368,7 @@ var fillCommand = (0, import_citty10.defineCommand)({
|
|
|
4315
4368
|
run({ args }) {
|
|
4316
4369
|
return guard(async () => {
|
|
4317
4370
|
const reader = lineReader();
|
|
4318
|
-
const ask = (prompt2) => reader.ask(prompt(prompt2.parameter, contextFor(prompt2)));
|
|
4371
|
+
const ask = (prompt2) => reader.ask(prompt(prompt2.parameter, contextFor(prompt2)), { secret: prompt2.secret });
|
|
4319
4372
|
try {
|
|
4320
4373
|
write(
|
|
4321
4374
|
renderFill(
|