@flowrunner/cli 0.1.6-dev.1 → 0.1.6
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/cli.js +10 -62
- package/dist/cli.js.map +2 -2
- package/dist/index.js +7 -55
- package/dist/index.js.map +2 -2
- package/dist/types/packages/cli/src/operations/init/answers.d.ts +1 -12
- package/dist/types/packages/cli/src/templates/index.d.ts +2 -2
- package/dist/types/packages/cli/src/templates/manifest.d.ts +2 -20
- package/dist/types/packages/cli/src/templates/render.d.ts +0 -2
- package/package.json +1 -1
- package/templates/blank/template.json +9 -9
- package/templates/demo-todo-list/template.json +9 -9
- package/templates/qa-test/template.json +9 -9
package/dist/cli.js
CHANGED
|
@@ -4185,7 +4185,7 @@ var require_package = __commonJS({
|
|
|
4185
4185
|
"package.json"(exports2, module2) {
|
|
4186
4186
|
module2.exports = {
|
|
4187
4187
|
name: "@flowrunner/cli",
|
|
4188
|
-
version: "0.1.6
|
|
4188
|
+
version: "0.1.6",
|
|
4189
4189
|
publishConfig: {
|
|
4190
4190
|
access: "public"
|
|
4191
4191
|
},
|
|
@@ -4464,16 +4464,6 @@ function serviceDirectory(serviceId, projectRoot = process.cwd()) {
|
|
|
4464
4464
|
|
|
4465
4465
|
// src/templates/manifest.ts
|
|
4466
4466
|
var SERVICE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
4467
|
-
function toServiceId(value) {
|
|
4468
|
-
return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "");
|
|
4469
|
-
}
|
|
4470
|
-
function availableServiceId(id, projectRoot) {
|
|
4471
|
-
let candidate = id;
|
|
4472
|
-
for (let suffix = 2; import_fs.default.existsSync(serviceDirectory(candidate, projectRoot)); suffix++) {
|
|
4473
|
-
candidate = `${id}-${suffix}`;
|
|
4474
|
-
}
|
|
4475
|
-
return candidate;
|
|
4476
|
-
}
|
|
4477
4467
|
var VALIDATORS = {
|
|
4478
4468
|
// Both halves of "is this a usable id" live together, so the prompt can re-ask on either. Availability is
|
|
4479
4469
|
// checked here rather than at write time so the user finds out while they are still on that question.
|
|
@@ -4488,20 +4478,15 @@ var VALIDATORS = {
|
|
|
4488
4478
|
},
|
|
4489
4479
|
nonEmpty: (value) => value.trim().length > 0 ? null : "must not be empty"
|
|
4490
4480
|
};
|
|
4491
|
-
var NORMALIZERS = {
|
|
4492
|
-
serviceId: toServiceId
|
|
4493
|
-
};
|
|
4494
4481
|
var VALIDATOR_NAMES = Object.keys(VALIDATORS);
|
|
4495
4482
|
var StringPromptSchema = import_zod.z.object({
|
|
4496
4483
|
name: import_zod.z.string().min(1),
|
|
4497
4484
|
label: import_zod.z.string().min(1),
|
|
4498
4485
|
type: import_zod.z.literal("string"),
|
|
4499
4486
|
hint: import_zod.z.string().optional(),
|
|
4500
|
-
// May interpolate a value fixed by `values`,
|
|
4501
|
-
//
|
|
4502
|
-
|
|
4503
|
-
// follows an `--id` flag when there is one and falls back to the literal when there is not.
|
|
4504
|
-
default: import_zod.z.union([import_zod.z.string(), import_zod.z.array(import_zod.z.string()).min(1)]).default(""),
|
|
4487
|
+
// May interpolate a value fixed by `values`, or an answer collected *earlier* in the list:
|
|
4488
|
+
// "{{id}}", "{{id|titleCase}}".
|
|
4489
|
+
default: import_zod.z.string().default(""),
|
|
4505
4490
|
validate: import_zod.z.enum(VALIDATOR_NAMES).optional()
|
|
4506
4491
|
});
|
|
4507
4492
|
var BooleanPromptSchema = import_zod.z.object({
|
|
@@ -4657,8 +4642,7 @@ var IF_CLOSE = /^\s*(?:\/\/|#|<!--)\s*\{\{\/if\s*\}\}/;
|
|
|
4657
4642
|
var FILTERS = {
|
|
4658
4643
|
titleCase: (value) => value.split(/[-_\s]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" "),
|
|
4659
4644
|
upperCase: (value) => value.toUpperCase(),
|
|
4660
|
-
lowerCase: (value) => value.toLowerCase()
|
|
4661
|
-
serviceId: toServiceId
|
|
4645
|
+
lowerCase: (value) => value.toLowerCase()
|
|
4662
4646
|
};
|
|
4663
4647
|
function applyFilter(name, value) {
|
|
4664
4648
|
const filter = FILTERS[name];
|
|
@@ -4667,9 +4651,6 @@ function applyFilter(name, value) {
|
|
|
4667
4651
|
}
|
|
4668
4652
|
return filter(value);
|
|
4669
4653
|
}
|
|
4670
|
-
function canInterpolate(source, answers) {
|
|
4671
|
-
return [...source.matchAll(PLACEHOLDER)].every(([, name]) => name in answers);
|
|
4672
|
-
}
|
|
4673
4654
|
function interpolate(source, answers, origin) {
|
|
4674
4655
|
return source.replace(PLACEHOLDER, (_match, name, filter) => {
|
|
4675
4656
|
if (!(name in answers)) {
|
|
@@ -4767,15 +4748,7 @@ function resolveDefault(prompt, answers) {
|
|
|
4767
4748
|
if (prompt.type === "boolean" || prompt.type === "choice") {
|
|
4768
4749
|
return prompt.default;
|
|
4769
4750
|
}
|
|
4770
|
-
|
|
4771
|
-
const candidates = Array.isArray(prompt.default) ? prompt.default : [prompt.default];
|
|
4772
|
-
for (const candidate of candidates) {
|
|
4773
|
-
const value = canInterpolate(candidate, answers) ? interpolate(candidate, answers, origin) : "";
|
|
4774
|
-
if (value) {
|
|
4775
|
-
return value;
|
|
4776
|
-
}
|
|
4777
|
-
}
|
|
4778
|
-
return interpolate(candidates[candidates.length - 1], answers, origin);
|
|
4751
|
+
return interpolate(prompt.default, answers, `default of "${prompt.name}"`);
|
|
4779
4752
|
}
|
|
4780
4753
|
function coerceBoolean(label, value) {
|
|
4781
4754
|
if (typeof value === "boolean") {
|
|
@@ -4799,16 +4772,6 @@ function validator(prompt, context) {
|
|
|
4799
4772
|
return failure && `${prompt.label} ${failure}`;
|
|
4800
4773
|
};
|
|
4801
4774
|
}
|
|
4802
|
-
function normalizer(prompt) {
|
|
4803
|
-
const normalize = prompt.type === "string" && prompt.validate ? NORMALIZERS[prompt.validate] : void 0;
|
|
4804
|
-
return normalize ?? ((value) => value);
|
|
4805
|
-
}
|
|
4806
|
-
function offeredDefault(prompt, fallback, context) {
|
|
4807
|
-
if (prompt.type === "string" && prompt.validate === "serviceId" && typeof fallback === "string" && fallback) {
|
|
4808
|
-
return availableServiceId(fallback, context.projectRoot);
|
|
4809
|
-
}
|
|
4810
|
-
return fallback;
|
|
4811
|
-
}
|
|
4812
4775
|
async function resolveAnswers(prompts, {
|
|
4813
4776
|
prefilled = {},
|
|
4814
4777
|
constants = {},
|
|
@@ -4818,7 +4781,6 @@ async function resolveAnswers(prompts, {
|
|
|
4818
4781
|
} = {}) {
|
|
4819
4782
|
const context = { projectRoot };
|
|
4820
4783
|
const answers = { ...constants };
|
|
4821
|
-
const prefilledDefaults = {};
|
|
4822
4784
|
const known = [...prompts.map((prompt) => prompt.name), ...Object.keys(constants)];
|
|
4823
4785
|
const unknown = Object.keys(prefilled).filter((name) => !known.includes(name));
|
|
4824
4786
|
if (unknown.length > 0) {
|
|
@@ -4827,12 +4789,7 @@ async function resolveAnswers(prompts, {
|
|
|
4827
4789
|
);
|
|
4828
4790
|
}
|
|
4829
4791
|
for (const prompt of prompts) {
|
|
4830
|
-
|
|
4831
|
-
prefilledDefaults[prompt.name] = String(prefilled[prompt.name]);
|
|
4832
|
-
}
|
|
4833
|
-
}
|
|
4834
|
-
for (const prompt of prompts) {
|
|
4835
|
-
const fallback = resolveDefault(prompt, { ...prefilledDefaults, ...answers });
|
|
4792
|
+
const fallback = resolveDefault(prompt, answers);
|
|
4836
4793
|
const validate2 = validator(prompt, context);
|
|
4837
4794
|
if (prompt.name in prefilled) {
|
|
4838
4795
|
const supplied = prefilled[prompt.name];
|
|
@@ -4869,12 +4826,7 @@ async function resolveAnswers(prompts, {
|
|
|
4869
4826
|
`"${prompt.name}" has no answer and there is no way to ask for one. Supply it up front, or accept the defaults.`
|
|
4870
4827
|
);
|
|
4871
4828
|
}
|
|
4872
|
-
answers[prompt.name] = await ask({
|
|
4873
|
-
prompt,
|
|
4874
|
-
fallback: offeredDefault(prompt, fallback, context),
|
|
4875
|
-
validate: validate2,
|
|
4876
|
-
normalize: normalizer(prompt)
|
|
4877
|
-
});
|
|
4829
|
+
answers[prompt.name] = await ask({ prompt, fallback, validate: validate2 });
|
|
4878
4830
|
}
|
|
4879
4831
|
for (const [name, value] of Object.entries(prefilled)) {
|
|
4880
4832
|
if (prompts.some((prompt) => prompt.name === name)) {
|
|
@@ -10190,7 +10142,7 @@ function createPrompter() {
|
|
|
10190
10142
|
close: () => rl?.close()
|
|
10191
10143
|
};
|
|
10192
10144
|
}
|
|
10193
|
-
async function askOne({ prompt, fallback, validate: validate2
|
|
10145
|
+
async function askOne({ prompt, fallback, validate: validate2 }, readlineInterface) {
|
|
10194
10146
|
markDirty();
|
|
10195
10147
|
hint2(prompt.hint);
|
|
10196
10148
|
if (prompt.type === "choice") {
|
|
@@ -10203,11 +10155,7 @@ async function askOne({ prompt, fallback, validate: validate2, normalize }, read
|
|
|
10203
10155
|
}
|
|
10204
10156
|
while (true) {
|
|
10205
10157
|
const raw = (await readlineInterface().question(`${prompt.label} (${fallback}): `)).trim();
|
|
10206
|
-
const
|
|
10207
|
-
const value = normalize(typed);
|
|
10208
|
-
if (value && value !== typed) {
|
|
10209
|
-
say(`${DIM} \u2192 ${value}${RESET}`);
|
|
10210
|
-
}
|
|
10158
|
+
const value = raw === "" ? String(fallback) : raw;
|
|
10211
10159
|
const failure = validate2(value);
|
|
10212
10160
|
if (!failure) {
|
|
10213
10161
|
return value;
|