@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/index.js
CHANGED
|
@@ -9086,16 +9086,6 @@ function serviceDirectory(serviceId, projectRoot = process.cwd()) {
|
|
|
9086
9086
|
|
|
9087
9087
|
// src/templates/manifest.ts
|
|
9088
9088
|
var SERVICE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
9089
|
-
function toServiceId(value) {
|
|
9090
|
-
return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "");
|
|
9091
|
-
}
|
|
9092
|
-
function availableServiceId(id, projectRoot) {
|
|
9093
|
-
let candidate = id;
|
|
9094
|
-
for (let suffix = 2; import_fs9.default.existsSync(serviceDirectory(candidate, projectRoot)); suffix++) {
|
|
9095
|
-
candidate = `${id}-${suffix}`;
|
|
9096
|
-
}
|
|
9097
|
-
return candidate;
|
|
9098
|
-
}
|
|
9099
9089
|
var VALIDATORS = {
|
|
9100
9090
|
// Both halves of "is this a usable id" live together, so the prompt can re-ask on either. Availability is
|
|
9101
9091
|
// checked here rather than at write time so the user finds out while they are still on that question.
|
|
@@ -9110,20 +9100,15 @@ var VALIDATORS = {
|
|
|
9110
9100
|
},
|
|
9111
9101
|
nonEmpty: (value) => value.trim().length > 0 ? null : "must not be empty"
|
|
9112
9102
|
};
|
|
9113
|
-
var NORMALIZERS = {
|
|
9114
|
-
serviceId: toServiceId
|
|
9115
|
-
};
|
|
9116
9103
|
var VALIDATOR_NAMES = Object.keys(VALIDATORS);
|
|
9117
9104
|
var StringPromptSchema = import_zod5.z.object({
|
|
9118
9105
|
name: import_zod5.z.string().min(1),
|
|
9119
9106
|
label: import_zod5.z.string().min(1),
|
|
9120
9107
|
type: import_zod5.z.literal("string"),
|
|
9121
9108
|
hint: import_zod5.z.string().optional(),
|
|
9122
|
-
// May interpolate a value fixed by `values`,
|
|
9123
|
-
//
|
|
9124
|
-
|
|
9125
|
-
// follows an `--id` flag when there is one and falls back to the literal when there is not.
|
|
9126
|
-
default: import_zod5.z.union([import_zod5.z.string(), import_zod5.z.array(import_zod5.z.string()).min(1)]).default(""),
|
|
9109
|
+
// May interpolate a value fixed by `values`, or an answer collected *earlier* in the list:
|
|
9110
|
+
// "{{id}}", "{{id|titleCase}}".
|
|
9111
|
+
default: import_zod5.z.string().default(""),
|
|
9127
9112
|
validate: import_zod5.z.enum(VALIDATOR_NAMES).optional()
|
|
9128
9113
|
});
|
|
9129
9114
|
var BooleanPromptSchema = import_zod5.z.object({
|
|
@@ -9250,8 +9235,7 @@ var IF_CLOSE = /^\s*(?:\/\/|#|<!--)\s*\{\{\/if\s*\}\}/;
|
|
|
9250
9235
|
var FILTERS = {
|
|
9251
9236
|
titleCase: (value) => value.split(/[-_\s]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" "),
|
|
9252
9237
|
upperCase: (value) => value.toUpperCase(),
|
|
9253
|
-
lowerCase: (value) => value.toLowerCase()
|
|
9254
|
-
serviceId: toServiceId
|
|
9238
|
+
lowerCase: (value) => value.toLowerCase()
|
|
9255
9239
|
};
|
|
9256
9240
|
function applyFilter(name, value) {
|
|
9257
9241
|
const filter = FILTERS[name];
|
|
@@ -9260,9 +9244,6 @@ function applyFilter(name, value) {
|
|
|
9260
9244
|
}
|
|
9261
9245
|
return filter(value);
|
|
9262
9246
|
}
|
|
9263
|
-
function canInterpolate(source, answers) {
|
|
9264
|
-
return [...source.matchAll(PLACEHOLDER)].every(([, name]) => name in answers);
|
|
9265
|
-
}
|
|
9266
9247
|
function interpolate(source, answers, origin) {
|
|
9267
9248
|
return source.replace(PLACEHOLDER, (_match, name, filter) => {
|
|
9268
9249
|
if (!(name in answers)) {
|
|
@@ -9355,15 +9336,7 @@ function resolveDefault(prompt, answers) {
|
|
|
9355
9336
|
if (prompt.type === "boolean" || prompt.type === "choice") {
|
|
9356
9337
|
return prompt.default;
|
|
9357
9338
|
}
|
|
9358
|
-
|
|
9359
|
-
const candidates = Array.isArray(prompt.default) ? prompt.default : [prompt.default];
|
|
9360
|
-
for (const candidate of candidates) {
|
|
9361
|
-
const value = canInterpolate(candidate, answers) ? interpolate(candidate, answers, origin) : "";
|
|
9362
|
-
if (value) {
|
|
9363
|
-
return value;
|
|
9364
|
-
}
|
|
9365
|
-
}
|
|
9366
|
-
return interpolate(candidates[candidates.length - 1], answers, origin);
|
|
9339
|
+
return interpolate(prompt.default, answers, `default of "${prompt.name}"`);
|
|
9367
9340
|
}
|
|
9368
9341
|
function coerceBoolean(label, value) {
|
|
9369
9342
|
if (typeof value === "boolean") {
|
|
@@ -9387,16 +9360,6 @@ function validator(prompt, context) {
|
|
|
9387
9360
|
return failure && `${prompt.label} ${failure}`;
|
|
9388
9361
|
};
|
|
9389
9362
|
}
|
|
9390
|
-
function normalizer(prompt) {
|
|
9391
|
-
const normalize = prompt.type === "string" && prompt.validate ? NORMALIZERS[prompt.validate] : void 0;
|
|
9392
|
-
return normalize ?? ((value) => value);
|
|
9393
|
-
}
|
|
9394
|
-
function offeredDefault(prompt, fallback, context) {
|
|
9395
|
-
if (prompt.type === "string" && prompt.validate === "serviceId" && typeof fallback === "string" && fallback) {
|
|
9396
|
-
return availableServiceId(fallback, context.projectRoot);
|
|
9397
|
-
}
|
|
9398
|
-
return fallback;
|
|
9399
|
-
}
|
|
9400
9363
|
async function resolveAnswers(prompts, {
|
|
9401
9364
|
prefilled = {},
|
|
9402
9365
|
constants = {},
|
|
@@ -9406,7 +9369,6 @@ async function resolveAnswers(prompts, {
|
|
|
9406
9369
|
} = {}) {
|
|
9407
9370
|
const context = { projectRoot };
|
|
9408
9371
|
const answers = { ...constants };
|
|
9409
|
-
const prefilledDefaults = {};
|
|
9410
9372
|
const known = [...prompts.map((prompt) => prompt.name), ...Object.keys(constants)];
|
|
9411
9373
|
const unknown = Object.keys(prefilled).filter((name) => !known.includes(name));
|
|
9412
9374
|
if (unknown.length > 0) {
|
|
@@ -9415,12 +9377,7 @@ async function resolveAnswers(prompts, {
|
|
|
9415
9377
|
);
|
|
9416
9378
|
}
|
|
9417
9379
|
for (const prompt of prompts) {
|
|
9418
|
-
|
|
9419
|
-
prefilledDefaults[prompt.name] = String(prefilled[prompt.name]);
|
|
9420
|
-
}
|
|
9421
|
-
}
|
|
9422
|
-
for (const prompt of prompts) {
|
|
9423
|
-
const fallback = resolveDefault(prompt, { ...prefilledDefaults, ...answers });
|
|
9380
|
+
const fallback = resolveDefault(prompt, answers);
|
|
9424
9381
|
const validate2 = validator(prompt, context);
|
|
9425
9382
|
if (prompt.name in prefilled) {
|
|
9426
9383
|
const supplied = prefilled[prompt.name];
|
|
@@ -9457,12 +9414,7 @@ async function resolveAnswers(prompts, {
|
|
|
9457
9414
|
`"${prompt.name}" has no answer and there is no way to ask for one. Supply it up front, or accept the defaults.`
|
|
9458
9415
|
);
|
|
9459
9416
|
}
|
|
9460
|
-
answers[prompt.name] = await ask({
|
|
9461
|
-
prompt,
|
|
9462
|
-
fallback: offeredDefault(prompt, fallback, context),
|
|
9463
|
-
validate: validate2,
|
|
9464
|
-
normalize: normalizer(prompt)
|
|
9465
|
-
});
|
|
9417
|
+
answers[prompt.name] = await ask({ prompt, fallback, validate: validate2 });
|
|
9466
9418
|
}
|
|
9467
9419
|
for (const [name, value] of Object.entries(prefilled)) {
|
|
9468
9420
|
if (prompts.some((prompt) => prompt.name === name)) {
|