@revturbine/cli 0.14.0 → 0.16.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/cli.js +142 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9554,10 +9554,106 @@ function renderHandlesModule(byType, opts) {
|
|
|
9554
9554
|
);
|
|
9555
9555
|
return lines.join("\n");
|
|
9556
9556
|
}
|
|
9557
|
+
function collectStrings(values) {
|
|
9558
|
+
const out = /* @__PURE__ */ new Set();
|
|
9559
|
+
for (const value of values) {
|
|
9560
|
+
const s = nonEmptyString(value);
|
|
9561
|
+
if (s) out.add(s);
|
|
9562
|
+
}
|
|
9563
|
+
return [...out].sort();
|
|
9564
|
+
}
|
|
9565
|
+
function extractPlanHandles(config) {
|
|
9566
|
+
if (!isRecord4(config) || !Array.isArray(config.plans)) return [];
|
|
9567
|
+
return collectStrings(
|
|
9568
|
+
config.plans.map(
|
|
9569
|
+
(p) => isRecord4(p) ? nonEmptyString(p.unique_handle) ?? nonEmptyString(p.handle) ?? p.id : null
|
|
9570
|
+
)
|
|
9571
|
+
);
|
|
9572
|
+
}
|
|
9573
|
+
function extractSegmentHandles(config) {
|
|
9574
|
+
if (!isRecord4(config) || !Array.isArray(config.segments)) return [];
|
|
9575
|
+
return collectStrings(
|
|
9576
|
+
config.segments.map((s) => isRecord4(s) ? nonEmptyString(s.handle) ?? s.id : null)
|
|
9577
|
+
);
|
|
9578
|
+
}
|
|
9579
|
+
function extractSurfaceTemplateIds(config) {
|
|
9580
|
+
if (!isRecord4(config)) return [];
|
|
9581
|
+
const ids = [];
|
|
9582
|
+
if (Array.isArray(config.surface_templates)) {
|
|
9583
|
+
for (const t of config.surface_templates) {
|
|
9584
|
+
if (isRecord4(t)) ids.push(t.id ?? t.template_id);
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9587
|
+
const surfacesOf = (payload) => {
|
|
9588
|
+
if (!isRecord4(payload) || !Array.isArray(payload.surfaces)) return;
|
|
9589
|
+
for (const surface of payload.surfaces) {
|
|
9590
|
+
if (isRecord4(surface)) ids.push(surface.template_id);
|
|
9591
|
+
}
|
|
9592
|
+
};
|
|
9593
|
+
if (Array.isArray(config.placements)) {
|
|
9594
|
+
for (const placement of config.placements) {
|
|
9595
|
+
if (!isRecord4(placement) || !Array.isArray(placement.payloads)) continue;
|
|
9596
|
+
for (const payload of placement.payloads) surfacesOf(payload);
|
|
9597
|
+
}
|
|
9598
|
+
}
|
|
9599
|
+
if (Array.isArray(config.placement_payloads)) {
|
|
9600
|
+
for (const payload of config.placement_payloads) surfacesOf(payload);
|
|
9601
|
+
}
|
|
9602
|
+
return collectStrings(ids);
|
|
9603
|
+
}
|
|
9604
|
+
function extractUiPathActionTypes(config) {
|
|
9605
|
+
if (!isRecord4(config) || !Array.isArray(config.content_ui_paths)) return [];
|
|
9606
|
+
return collectStrings(
|
|
9607
|
+
config.content_ui_paths.map((p) => isRecord4(p) ? p.action_type : null)
|
|
9608
|
+
);
|
|
9609
|
+
}
|
|
9610
|
+
function renderFlatFamily(lines, opts) {
|
|
9611
|
+
lines.push("", `/** ${opts.doc} */`);
|
|
9612
|
+
if (opts.values.length === 0) {
|
|
9613
|
+
lines.push(`export const ${opts.constName} = {} as const;`);
|
|
9614
|
+
lines.push(`export type ${opts.typeName} = never;`);
|
|
9615
|
+
return;
|
|
9616
|
+
}
|
|
9617
|
+
lines.push(`export const ${opts.constName} = {`);
|
|
9618
|
+
for (const value of opts.values) {
|
|
9619
|
+
lines.push(` ${key(value)}: ${quote(value)},`);
|
|
9620
|
+
}
|
|
9621
|
+
lines.push("} as const;");
|
|
9622
|
+
lines.push(`export type ${opts.typeName} =`);
|
|
9623
|
+
opts.values.forEach((value, i) => {
|
|
9624
|
+
lines.push(` | ${quote(value)}${i === opts.values.length - 1 ? ";" : ""}`);
|
|
9625
|
+
});
|
|
9626
|
+
}
|
|
9557
9627
|
function generateHandleTypes(config, opts) {
|
|
9558
9628
|
const byType = extractEntitlementHandles(config);
|
|
9559
9629
|
const handles = [...new Set(Object.values(byType).flat())].sort();
|
|
9560
|
-
|
|
9630
|
+
const lines = [renderHandlesModule(byType, opts).trimEnd()];
|
|
9631
|
+
renderFlatFamily(lines, {
|
|
9632
|
+
doc: "Plan handles \u2014 the values plan targeting and planHandle options take.",
|
|
9633
|
+
constName: "Plans",
|
|
9634
|
+
typeName: "PlanHandle",
|
|
9635
|
+
values: extractPlanHandles(config)
|
|
9636
|
+
});
|
|
9637
|
+
renderFlatFamily(lines, {
|
|
9638
|
+
doc: "Segment handles.",
|
|
9639
|
+
constName: "Segments",
|
|
9640
|
+
typeName: "SegmentHandle",
|
|
9641
|
+
values: extractSegmentHandles(config)
|
|
9642
|
+
});
|
|
9643
|
+
renderFlatFamily(lines, {
|
|
9644
|
+
doc: "Surface-template ids \u2014 catalog entries plus every template a payload references.",
|
|
9645
|
+
constName: "SurfaceTemplates",
|
|
9646
|
+
typeName: "SurfaceTemplateId",
|
|
9647
|
+
values: extractSurfaceTemplateIds(config)
|
|
9648
|
+
});
|
|
9649
|
+
renderFlatFamily(lines, {
|
|
9650
|
+
doc: "Authored ui-path action types \u2014 exactly the key set uiPathResolvers must cover.",
|
|
9651
|
+
constName: "UiPathActionTypes",
|
|
9652
|
+
typeName: "UiPathActionType",
|
|
9653
|
+
values: extractUiPathActionTypes(config)
|
|
9654
|
+
});
|
|
9655
|
+
lines.push("");
|
|
9656
|
+
return { byType, handles, ts: lines.join("\n") };
|
|
9561
9657
|
}
|
|
9562
9658
|
|
|
9563
9659
|
// src/lib/output.ts
|
|
@@ -9609,6 +9705,36 @@ function fail(cls, message) {
|
|
|
9609
9705
|
process.exit(cls);
|
|
9610
9706
|
}
|
|
9611
9707
|
|
|
9708
|
+
// src/lib/pin-drift.ts
|
|
9709
|
+
function isRecord5(value) {
|
|
9710
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9711
|
+
}
|
|
9712
|
+
function pinOf(pkg, name) {
|
|
9713
|
+
for (const field of ["devDependencies", "dependencies"]) {
|
|
9714
|
+
const deps = pkg[field];
|
|
9715
|
+
if (isRecord5(deps) && typeof deps[name] === "string") return deps[name];
|
|
9716
|
+
}
|
|
9717
|
+
return void 0;
|
|
9718
|
+
}
|
|
9719
|
+
var EXACT = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;
|
|
9720
|
+
function checkPinDrift(pkg) {
|
|
9721
|
+
if (!isRecord5(pkg)) return [];
|
|
9722
|
+
const warnings = [];
|
|
9723
|
+
const cliPin = pinOf(pkg, "@revturbine/cli");
|
|
9724
|
+
if (cliPin !== void 0 && !EXACT.test(cliPin)) {
|
|
9725
|
+
warnings.push(
|
|
9726
|
+
`@revturbine/cli is pinned "${cliPin}" \u2014 the repo-pinned CLI must be EXACT (e.g. "0.14.0"): delegation runs the repo's version, and a range makes the running CLI drift from the committed one.`
|
|
9727
|
+
);
|
|
9728
|
+
}
|
|
9729
|
+
const sdkPin = pinOf(pkg, "@revturbine/sdk");
|
|
9730
|
+
if (sdkPin !== void 0 && !sdkPin.startsWith("^")) {
|
|
9731
|
+
warnings.push(
|
|
9732
|
+
`@revturbine/sdk is pinned "${sdkPin}" \u2014 use a caret (e.g. "^${sdkPin.replace(/^[~>=\s]*/, "")}") so additive SDK releases flow in. (Note: on 0.x, ^ spans PATCH releases only.)`
|
|
9733
|
+
);
|
|
9734
|
+
}
|
|
9735
|
+
return warnings;
|
|
9736
|
+
}
|
|
9737
|
+
|
|
9612
9738
|
// src/lib/selectors.ts
|
|
9613
9739
|
var SelectorError = class extends Error {
|
|
9614
9740
|
code = "STATE_REQUIRED";
|
|
@@ -10531,7 +10657,7 @@ program.command("evaluate").description("Run placement/entitlement decisions for
|
|
|
10531
10657
|
);
|
|
10532
10658
|
var generateCmd = program.command("generate").description("Code generation from a config version (see: generate types).");
|
|
10533
10659
|
generateCmd.command("types").description(
|
|
10534
|
-
"Generate a TypeScript module of
|
|
10660
|
+
"Generate a TypeScript module of Playbook handles \u2014 entitlements (namespaced by type), plans, segments, surface-template ids, and ui-path action types \u2014 for type-safe call sites."
|
|
10535
10661
|
).argument("[file...]", "Path to a Config File").option("--draft", "The tenant's open draft").option("--live", "The current live Release").option("--release <id>", "A specific playbook version / Release").option("-o, --out <path>", "Write the generated module to this path (parent dirs created); default stdout").option("--json", "Emit the handle map as JSON instead of TypeScript").option("-u, --url <url>", "RevTurbine instance URL", DEFAULT_URL).option("-t, --tenant-id <id>", "x-tenant-id (defaults to the stored token tenant)").action(
|
|
10536
10662
|
async (files, opts) => {
|
|
10537
10663
|
const [sel] = requireSelectors(opts, files, {
|
|
@@ -10700,6 +10826,20 @@ function gitRootOf(from) {
|
|
|
10700
10826
|
process.exit(child.status ?? EXIT.UNEXPECTED);
|
|
10701
10827
|
}
|
|
10702
10828
|
}
|
|
10829
|
+
if (process.argv.includes("-V") || process.argv.includes("--version")) {
|
|
10830
|
+
process.stdout.write(`${pkgVersion} (schema ${SCHEMA_VERSION})
|
|
10831
|
+
`);
|
|
10832
|
+
try {
|
|
10833
|
+
const pkgPath = path2.resolve("package.json");
|
|
10834
|
+
if (existsSync2(pkgPath)) {
|
|
10835
|
+
for (const warning of checkPinDrift(JSON.parse(readFileSync2(pkgPath, "utf8")))) {
|
|
10836
|
+
diag(`\u26A0 pin drift: ${warning}`);
|
|
10837
|
+
}
|
|
10838
|
+
}
|
|
10839
|
+
} catch {
|
|
10840
|
+
}
|
|
10841
|
+
process.exit(EXIT.OK);
|
|
10842
|
+
}
|
|
10703
10843
|
program.exitOverride();
|
|
10704
10844
|
try {
|
|
10705
10845
|
await program.parseAsync(process.argv);
|
package/package.json
CHANGED