@camunda8/cli 3.1.0 → 3.2.0-alpha.10
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/CONTEXT.md +7 -15
- package/EXAMPLES.md +253 -1
- package/PLUGIN-HELP.md +1 -1
- package/README.md +50 -180
- package/dist/command-dispatch.d.ts +1 -1
- package/dist/command-dispatch.d.ts.map +1 -1
- package/dist/command-dispatch.js +1 -1
- package/dist/command-dispatch.js.map +1 -1
- package/dist/commands/completion.d.ts +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +2 -3
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +328 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/forms.d.ts +1 -1
- package/dist/commands/forms.d.ts.map +1 -1
- package/dist/commands/forms.js +8 -8
- package/dist/commands/forms.js.map +1 -1
- package/dist/commands/helpers/deploy-helpers.d.ts +120 -0
- package/dist/commands/helpers/deploy-helpers.d.ts.map +1 -0
- package/dist/{deployments.js → commands/helpers/deploy-helpers.js} +307 -155
- package/dist/commands/helpers/deploy-helpers.js.map +1 -0
- package/dist/commands/identity-authorizations.d.ts +5 -18
- package/dist/commands/identity-authorizations.d.ts.map +1 -1
- package/dist/commands/identity-authorizations.js +8 -10
- package/dist/commands/identity-authorizations.js.map +1 -1
- package/dist/commands/identity-groups.d.ts +5 -5
- package/dist/commands/identity-groups.d.ts.map +1 -1
- package/dist/commands/identity-groups.js +7 -8
- package/dist/commands/identity-groups.js.map +1 -1
- package/dist/commands/identity-mapping-rules.d.ts +5 -5
- package/dist/commands/identity-mapping-rules.d.ts.map +1 -1
- package/dist/commands/identity-mapping-rules.js +7 -8
- package/dist/commands/identity-mapping-rules.js.map +1 -1
- package/dist/commands/identity-roles.d.ts +5 -5
- package/dist/commands/identity-roles.d.ts.map +1 -1
- package/dist/commands/identity-roles.js +7 -8
- package/dist/commands/identity-roles.js.map +1 -1
- package/dist/commands/identity-tenants.d.ts +5 -5
- package/dist/commands/identity-tenants.d.ts.map +1 -1
- package/dist/commands/identity-tenants.js +7 -8
- package/dist/commands/identity-tenants.js.map +1 -1
- package/dist/commands/identity-users.d.ts +5 -5
- package/dist/commands/identity-users.d.ts.map +1 -1
- package/dist/commands/identity-users.js +7 -8
- package/dist/commands/identity-users.js.map +1 -1
- package/dist/commands/identity.d.ts +11 -31
- package/dist/commands/identity.d.ts.map +1 -1
- package/dist/commands/identity.js +15 -15
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/incidents.d.ts +3 -3
- package/dist/commands/incidents.d.ts.map +1 -1
- package/dist/commands/incidents.js +6 -6
- package/dist/commands/incidents.js.map +1 -1
- package/dist/commands/jobs.d.ts +4 -4
- package/dist/commands/jobs.d.ts.map +1 -1
- package/dist/commands/jobs.js +7 -7
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/mcp-proxy.d.ts +1 -1
- package/dist/commands/mcp-proxy.d.ts.map +1 -1
- package/dist/commands/mcp-proxy.js +5 -9
- package/dist/commands/mcp-proxy.js.map +1 -1
- package/dist/commands/messages.d.ts +2 -2
- package/dist/commands/messages.d.ts.map +1 -1
- package/dist/commands/messages.js +4 -4
- package/dist/commands/messages.js.map +1 -1
- package/dist/commands/open.d.ts +4 -4
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +6 -6
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/plugins.d.ts +9 -9
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +2 -7
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/process-definitions.d.ts +2 -2
- package/dist/commands/process-definitions.d.ts.map +1 -1
- package/dist/commands/process-definitions.js +5 -5
- package/dist/commands/process-definitions.js.map +1 -1
- package/dist/commands/process-instances.d.ts +5 -5
- package/dist/commands/process-instances.d.ts.map +1 -1
- package/dist/commands/process-instances.js +8 -9
- package/dist/commands/process-instances.js.map +1 -1
- package/dist/commands/profiles.d.ts +4 -36
- package/dist/commands/profiles.d.ts.map +1 -1
- package/dist/commands/profiles.js +43 -41
- package/dist/commands/profiles.js.map +1 -1
- package/dist/commands/run.d.ts +2 -2
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +4 -4
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/search.d.ts +7 -7
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +9 -11
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/session.d.ts +4 -4
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +26 -5
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/topology.d.ts +1 -1
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +2 -2
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/user-tasks.d.ts +2 -2
- package/dist/commands/user-tasks.d.ts.map +1 -1
- package/dist/commands/user-tasks.js +5 -5
- package/dist/commands/user-tasks.js.map +1 -1
- package/dist/commands/variables.d.ts +1 -1
- package/dist/commands/variables.d.ts.map +1 -1
- package/dist/commands/variables.js +3 -3
- package/dist/commands/variables.js.map +1 -1
- package/dist/commands/watch.d.ts +2 -2
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +86 -19
- package/dist/commands/watch.js.map +1 -1
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js.map +1 -0
- package/dist/{config.d.ts → core/config.d.ts} +28 -2
- package/dist/core/config.d.ts.map +1 -0
- package/dist/{config.js → core/config.js} +61 -5
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/{runtime.js → core/runtime.js} +2 -2
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/update-check.d.ts.map +1 -0
- package/dist/core/update-check.js.map +1 -0
- package/dist/default-plugins/bpmn/README.md +12 -3
- package/dist/default-plugins/bpmn/c8ctl-plugin.js +7376 -108
- package/dist/default-plugins/bpmn/package.json +8 -1
- package/dist/default-plugins/cluster/c8ctl-plugin.js +66 -9
- package/dist/default-plugins/element-template/README.md +6 -3
- package/dist/default-plugins/element-template/c8ctl-plugin.js +10195 -229
- package/dist/default-plugins/element-template/docs/design.md +1 -1
- package/dist/default-plugins/element-template/package.json +11 -1
- package/dist/default-plugins/feel/c8ctl-plugin.js +14030 -584
- package/dist/default-plugins/feel/package.json +4 -1
- package/dist/{command-framework.d.ts → framework/command-framework.d.ts} +23 -9
- package/dist/framework/command-framework.d.ts.map +1 -0
- package/dist/{command-framework.js → framework/command-framework.js} +16 -29
- package/dist/framework/command-framework.js.map +1 -0
- package/dist/{command-registry.d.ts → framework/command-registry.d.ts} +35 -8
- package/dist/framework/command-registry.d.ts.map +1 -0
- package/dist/{command-registry.js → framework/command-registry.js} +74 -9
- package/dist/framework/command-registry.js.map +1 -0
- package/dist/{command-validation.d.ts → framework/command-validation.d.ts} +0 -14
- package/dist/framework/command-validation.d.ts.map +1 -0
- package/dist/{command-validation.js → framework/command-validation.js} +1 -34
- package/dist/framework/command-validation.js.map +1 -0
- package/dist/framework/index.d.ts +10 -0
- package/dist/framework/index.d.ts.map +1 -0
- package/dist/framework/index.js +16 -0
- package/dist/framework/index.js.map +1 -0
- package/dist/{plugin-loader.d.ts → framework/plugins/plugin-loader.d.ts} +30 -5
- package/dist/framework/plugins/plugin-loader.d.ts.map +1 -0
- package/dist/{plugin-loader.js → framework/plugins/plugin-loader.js} +26 -10
- package/dist/framework/plugins/plugin-loader.js.map +1 -0
- package/dist/framework/plugins/plugin-registry.d.ts.map +1 -0
- package/dist/{plugin-registry.js → framework/plugins/plugin-registry.js} +1 -1
- package/dist/framework/plugins/plugin-registry.js.map +1 -0
- package/dist/framework/plugins/plugin-version.d.ts.map +1 -0
- package/dist/framework/plugins/plugin-version.js.map +1 -0
- package/dist/{completion.d.ts → framework/ui/completion.d.ts} +2 -2
- package/dist/framework/ui/completion.d.ts.map +1 -0
- package/dist/{completion.js → framework/ui/completion.js} +7 -9
- package/dist/framework/ui/completion.js.map +1 -0
- package/dist/framework/ui/help.d.ts.map +1 -0
- package/dist/{help.js → framework/ui/help.js} +4 -4
- package/dist/framework/ui/help.js.map +1 -0
- package/dist/framework/ui/prompt.d.ts +132 -0
- package/dist/framework/ui/prompt.d.ts.map +1 -0
- package/dist/framework/ui/prompt.js +298 -0
- package/dist/framework/ui/prompt.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/dist/utils/command-local/deploy-version.d.ts +21 -0
- package/dist/utils/command-local/deploy-version.d.ts.map +1 -0
- package/dist/utils/command-local/deploy-version.js +31 -0
- package/dist/utils/command-local/deploy-version.js.map +1 -0
- package/dist/{mcp-proxy-helpers.d.ts → utils/command-local/mcp-proxy-helpers.d.ts} +1 -1
- package/dist/utils/command-local/mcp-proxy-helpers.d.ts.map +1 -0
- package/dist/{mcp-proxy-helpers.js → utils/command-local/mcp-proxy-helpers.js} +1 -1
- package/dist/utils/command-local/mcp-proxy-helpers.js.map +1 -0
- package/dist/utils/command-local/open-helpers.d.ts.map +1 -0
- package/dist/{open-helpers.js → utils/command-local/open-helpers.js} +2 -2
- package/dist/utils/command-local/open-helpers.js.map +1 -0
- package/dist/{search-helpers.d.ts → utils/command-local/search-helpers.d.ts} +1 -1
- package/dist/utils/command-local/search-helpers.d.ts.map +1 -0
- package/dist/utils/command-local/search-helpers.js.map +1 -0
- package/dist/utils/command-local/watch-constants.d.ts.map +1 -0
- package/dist/utils/command-local/watch-constants.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/shared/date-filter.d.ts.map +1 -0
- package/dist/utils/shared/date-filter.js.map +1 -0
- package/dist/{ignore.d.ts → utils/shared/ignore.d.ts} +19 -1
- package/dist/utils/shared/ignore.d.ts.map +1 -0
- package/dist/utils/shared/ignore.js +234 -0
- package/dist/utils/shared/ignore.js.map +1 -0
- package/dist/utils/shared/resource-extensions.d.ts.map +1 -0
- package/dist/utils/shared/resource-extensions.js.map +1 -0
- package/dist/utils/shared/validation.d.ts +23 -0
- package/dist/utils/shared/validation.d.ts.map +1 -0
- package/dist/utils/shared/validation.js +43 -0
- package/dist/utils/shared/validation.js.map +1 -0
- package/dist/vendor/bpmnlint.cjs +25907 -0
- package/package.json +12 -14
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/command-framework.d.ts.map +0 -1
- package/dist/command-framework.js.map +0 -1
- package/dist/command-registry.d.ts.map +0 -1
- package/dist/command-registry.js.map +0 -1
- package/dist/command-validation.d.ts.map +0 -1
- package/dist/command-validation.js.map +0 -1
- package/dist/commands/resource-extensions.d.ts.map +0 -1
- package/dist/commands/resource-extensions.js.map +0 -1
- package/dist/completion.d.ts.map +0 -1
- package/dist/completion.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/date-filter.d.ts.map +0 -1
- package/dist/date-filter.js.map +0 -1
- package/dist/default-plugins/bpmn/c8ctl-plugin.js.map +0 -1
- package/dist/default-plugins/bpmn/lint.js +0 -320
- package/dist/default-plugins/bpmn/lint.js.map +0 -1
- package/dist/default-plugins/element-template/c8ctl-plugin.js.map +0 -1
- package/dist/default-plugins/element-template/commands/apply.js +0 -336
- package/dist/default-plugins/element-template/commands/apply.js.map +0 -1
- package/dist/default-plugins/element-template/commands/get-properties.js +0 -344
- package/dist/default-plugins/element-template/commands/get-properties.js.map +0 -1
- package/dist/default-plugins/element-template/commands/get.js +0 -107
- package/dist/default-plugins/element-template/commands/get.js.map +0 -1
- package/dist/default-plugins/element-template/commands/info.js +0 -189
- package/dist/default-plugins/element-template/commands/info.js.map +0 -1
- package/dist/default-plugins/element-template/commands/search.js +0 -102
- package/dist/default-plugins/element-template/commands/search.js.map +0 -1
- package/dist/default-plugins/element-template/commands/sync.js +0 -36
- package/dist/default-plugins/element-template/commands/sync.js.map +0 -1
- package/dist/default-plugins/element-template/helpers.js +0 -429
- package/dist/default-plugins/element-template/helpers.js.map +0 -1
- package/dist/default-plugins/element-template/marketplace.js +0 -586
- package/dist/default-plugins/element-template/marketplace.js.map +0 -1
- package/dist/default-plugins/element-template/template-ref.js +0 -232
- package/dist/default-plugins/element-template/template-ref.js.map +0 -1
- package/dist/default-plugins/feel/c8ctl-plugin.js.map +0 -1
- package/dist/default-plugins/hello-world/README.md +0 -161
- package/dist/default-plugins/hello-world/c8ctl-plugin.js +0 -69
- package/dist/default-plugins/hello-world/package.json +0 -8
- package/dist/deployments.d.ts +0 -42
- package/dist/deployments.d.ts.map +0 -1
- package/dist/deployments.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/help.d.ts.map +0 -1
- package/dist/help.js.map +0 -1
- package/dist/ignore.d.ts.map +0 -1
- package/dist/ignore.js +0 -101
- package/dist/ignore.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/mcp-proxy-helpers.d.ts.map +0 -1
- package/dist/mcp-proxy-helpers.js.map +0 -1
- package/dist/open-helpers.d.ts.map +0 -1
- package/dist/open-helpers.js.map +0 -1
- package/dist/plugin-loader.d.ts.map +0 -1
- package/dist/plugin-loader.js.map +0 -1
- package/dist/plugin-registry.d.ts.map +0 -1
- package/dist/plugin-registry.js.map +0 -1
- package/dist/plugin-version.d.ts.map +0 -1
- package/dist/plugin-version.js.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/search-helpers.d.ts.map +0 -1
- package/dist/search-helpers.js.map +0 -1
- package/dist/update-check.d.ts.map +0 -1
- package/dist/update-check.js.map +0 -1
- package/dist/watch-constants.d.ts.map +0 -1
- package/dist/watch-constants.js.map +0 -1
- /package/dist/{client.d.ts → core/client.d.ts} +0 -0
- /package/dist/{client.js → core/client.js} +0 -0
- /package/dist/{errors.d.ts → core/errors.d.ts} +0 -0
- /package/dist/{errors.js → core/errors.js} +0 -0
- /package/dist/{logger.d.ts → core/logger.d.ts} +0 -0
- /package/dist/{logger.js → core/logger.js} +0 -0
- /package/dist/{runtime.d.ts → core/runtime.d.ts} +0 -0
- /package/dist/{update-check.d.ts → core/update-check.d.ts} +0 -0
- /package/dist/{update-check.js → core/update-check.js} +0 -0
- /package/dist/{plugin-registry.d.ts → framework/plugins/plugin-registry.d.ts} +0 -0
- /package/dist/{plugin-version.d.ts → framework/plugins/plugin-version.d.ts} +0 -0
- /package/dist/{plugin-version.js → framework/plugins/plugin-version.js} +0 -0
- /package/dist/{help.d.ts → framework/ui/help.d.ts} +0 -0
- /package/dist/{open-helpers.d.ts → utils/command-local/open-helpers.d.ts} +0 -0
- /package/dist/{search-helpers.js → utils/command-local/search-helpers.js} +0 -0
- /package/dist/{watch-constants.d.ts → utils/command-local/watch-constants.d.ts} +0 -0
- /package/dist/{watch-constants.js → utils/command-local/watch-constants.js} +0 -0
- /package/dist/{date-filter.d.ts → utils/shared/date-filter.d.ts} +0 -0
- /package/dist/{date-filter.js → utils/shared/date-filter.js} +0 -0
- /package/dist/{commands → utils/shared}/resource-extensions.d.ts +0 -0
- /package/dist/{commands → utils/shared}/resource-extensions.js +0 -0
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `c8ctl element-template get-properties` — list settable properties of a
|
|
3
|
-
* template. Default render is a condensed table of name + description
|
|
4
|
-
* rows grouped by section. `--detailed` swaps in per-property detail cards.
|
|
5
|
-
*/
|
|
6
|
-
import { styleText } from "node:util";
|
|
7
|
-
import { BINDING_TYPE_SHORTHANDS, globToRegex, } from "../helpers.js";
|
|
8
|
-
import { loadTemplate } from "../template-ref.js";
|
|
9
|
-
import { formatKeyedCard, parseInspectArgs } from "./info.js";
|
|
10
|
-
if (!globalThis.c8ctl)
|
|
11
|
-
throw new Error("c8ctl runtime not initialised");
|
|
12
|
-
const c8ctl = globalThis.c8ctl;
|
|
13
|
-
export async function getPropertiesSubcommand(args) {
|
|
14
|
-
const logger = c8ctl.getLogger();
|
|
15
|
-
const usage = "Usage: c8ctl element-template get-properties <template> [<name>...] [--group <id>...] [--detailed | -d]\n" +
|
|
16
|
-
" Default: condensed list (name + description). --detailed shows full cards.\n" +
|
|
17
|
-
" Names may include shell-style globs — quote to avoid shell expansion: 'auth*'";
|
|
18
|
-
const parsed = parseInspectArgs(args, usage, {
|
|
19
|
-
allowPropertyNames: true,
|
|
20
|
-
allowFilters: true,
|
|
21
|
-
});
|
|
22
|
-
const { template, allDetails, groupLabelMap, sourceByDetail, autoResolvedVersion, } = await loadTemplate(parsed.templateArg);
|
|
23
|
-
if (autoResolvedVersion) {
|
|
24
|
-
logger.warn(`Resolved latest version (${template.version}) of ${template.id}. ` +
|
|
25
|
-
`Use '${template.id}@${template.version}' to pin.`);
|
|
26
|
-
}
|
|
27
|
-
// Resolve positional names if any (literals or globs). Each arg must
|
|
28
|
-
// match at least one property — typos shouldn't silently produce no
|
|
29
|
-
// output. With no positionals, default to all properties.
|
|
30
|
-
let details = parsed.propertyArgs.length > 0
|
|
31
|
-
? parsed.propertyArgs.flatMap((arg) => filterByPropertyArg(allDetails, arg, parsed.templateArg))
|
|
32
|
-
: allDetails;
|
|
33
|
-
// --group intersects with positional matches. Validation of the
|
|
34
|
-
// requested group ids uses the full template (allDetails) so a
|
|
35
|
-
// valid group id on a property the name filter excluded still
|
|
36
|
-
// counts as known — the user should see "no match" for the
|
|
37
|
-
// combination, not "unknown group id".
|
|
38
|
-
details = applyGroupFilter(details, allDetails, parsed.groups, groupLabelMap);
|
|
39
|
-
// Dedupe by object reference — the same property detail object is
|
|
40
|
-
// returned when it matches multiple positionals (e.g. `url` and
|
|
41
|
-
// `u*` together). NOT by binding name+type: distinct properties
|
|
42
|
-
// sometimes share those (operation-conditional duplicates that
|
|
43
|
-
// bind to the same field with different `condition` clauses).
|
|
44
|
-
const seen = new Set();
|
|
45
|
-
details = details.filter((d) => {
|
|
46
|
-
if (seen.has(d)) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
seen.add(d);
|
|
50
|
-
return true;
|
|
51
|
-
});
|
|
52
|
-
// Each filter is individually validated (positional names via
|
|
53
|
-
// filterByPropertyArg, group ids via applyGroupFilter), but their
|
|
54
|
-
// intersection can still be empty when a property exists somewhere
|
|
55
|
-
// and a group exists, just not together. Surface that as an error
|
|
56
|
-
// to match the README contract that filters error on no-match.
|
|
57
|
-
if (details.length === 0 &&
|
|
58
|
-
(parsed.propertyArgs.length > 0 || parsed.groups.length > 0)) {
|
|
59
|
-
const nameClause = parsed.propertyArgs.length > 0
|
|
60
|
-
? `name${parsed.propertyArgs.length > 1 ? "s" : ""} ${parsed.propertyArgs.map((a) => `"${a}"`).join(", ")}`
|
|
61
|
-
: "";
|
|
62
|
-
const groupClause = parsed.groups.length > 0
|
|
63
|
-
? `group${parsed.groups.length > 1 ? "s" : ""} ${parsed.groups.map((g) => `"${g}"`).join(", ")}`
|
|
64
|
-
: "";
|
|
65
|
-
const what = [nameClause, groupClause].filter(Boolean).join(" and ");
|
|
66
|
-
throw new Error(`No properties match ${what}.`);
|
|
67
|
-
}
|
|
68
|
-
const total = allDetails.length;
|
|
69
|
-
if (c8ctl.outputMode === "json") {
|
|
70
|
-
const projector = parsed.detailed
|
|
71
|
-
? buildShowProperty
|
|
72
|
-
: buildCondensedProperty;
|
|
73
|
-
logger.json(buildJsonPayload(template, details, projector, total, sourceByDetail));
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
// Summary line at the top — gives an at-a-glance answer to "how
|
|
77
|
-
// many am I seeing, out of how many available". Especially useful
|
|
78
|
-
// after a filter to confirm scope.
|
|
79
|
-
logger.output(styleText("dim", `Showing ${details.length} of ${total} properties.`));
|
|
80
|
-
logger.output("");
|
|
81
|
-
if (parsed.detailed) {
|
|
82
|
-
// Detail-card view — full per-property fields.
|
|
83
|
-
for (let i = 0; i < details.length; i++) {
|
|
84
|
-
for (const line of formatPropertyCard(details[i])) {
|
|
85
|
-
logger.output(line);
|
|
86
|
-
}
|
|
87
|
-
if (i < details.length - 1) {
|
|
88
|
-
logger.output("");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Default: condensed list — group heading + name + description.
|
|
94
|
-
renderCondensedTable(details, groupLabelMap, logger);
|
|
95
|
-
// Trailing hint — point users at name filtering and --detailed.
|
|
96
|
-
logger.output("");
|
|
97
|
-
logger.output(styleText("dim", "Filter by name (supports globs):\n" +
|
|
98
|
-
` c8ctl element-template get-properties ${parsed.templateArg} 'auth*' url\n` +
|
|
99
|
-
"For full details on each property:\n" +
|
|
100
|
-
` c8ctl element-template get-properties ${parsed.templateArg} --detailed`));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Project a property into the JSON shape that mirrors the **condensed
|
|
104
|
-
* get-properties text output** — just identification (binding) and the
|
|
105
|
-
* descriptive text the row surfaces. Group is included so consumers
|
|
106
|
-
* can resolve the section heading via the top-level `groups` table.
|
|
107
|
-
*/
|
|
108
|
-
function buildCondensedProperty(prop) {
|
|
109
|
-
return {
|
|
110
|
-
id: prop.id,
|
|
111
|
-
binding: prop.binding,
|
|
112
|
-
label: prop.label,
|
|
113
|
-
description: prop.description,
|
|
114
|
-
group: prop.group,
|
|
115
|
-
choices: prop.choices,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Project a property into the JSON shape that mirrors the
|
|
120
|
-
* **--detailed get-properties card** — every field the card surfaces.
|
|
121
|
-
* Schema field names verbatim.
|
|
122
|
-
*/
|
|
123
|
-
function buildShowProperty(prop) {
|
|
124
|
-
return {
|
|
125
|
-
id: prop.id,
|
|
126
|
-
binding: prop.binding,
|
|
127
|
-
type: prop.type,
|
|
128
|
-
optional: prop.optional,
|
|
129
|
-
value: prop.value,
|
|
130
|
-
feel: prop.feel,
|
|
131
|
-
group: prop.group,
|
|
132
|
-
condition: prop.condition,
|
|
133
|
-
label: prop.label,
|
|
134
|
-
description: prop.description,
|
|
135
|
-
constraints: prop.constraints,
|
|
136
|
-
choices: prop.choices,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* JSON payload for `get-properties`. `projectProp` decides which
|
|
141
|
-
* per-property shape to use (condensed vs detailed) so JSON mirrors
|
|
142
|
-
* text density per mode.
|
|
143
|
-
*/
|
|
144
|
-
function buildJsonPayload(template, details, projectProp, totalCount, sourceByDetail) {
|
|
145
|
-
const properties = details
|
|
146
|
-
.map((d) => sourceByDetail.get(d))
|
|
147
|
-
.filter((p) => Boolean(p))
|
|
148
|
-
.map(projectProp);
|
|
149
|
-
return {
|
|
150
|
-
count: properties.length,
|
|
151
|
-
total: totalCount,
|
|
152
|
-
groups: template.groups ?? [],
|
|
153
|
-
properties,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Filter `details` to those whose `groupId` is in the requested list.
|
|
158
|
-
* Empty list means no filter. Unknown group ids throw with the list of
|
|
159
|
-
* valid ids — group ids are short and bounded so we always show them.
|
|
160
|
-
*
|
|
161
|
-
* `allDetails` is the unfiltered property set from the template; we
|
|
162
|
-
* use it to compute the valid-group set so that a group id which only
|
|
163
|
-
* appears on a property excluded by an earlier name filter still counts
|
|
164
|
-
* as known. Without this, combining a valid name filter and a valid
|
|
165
|
-
* group id from a template with no `groups` table would surface
|
|
166
|
-
* "Unknown group id" rather than the intended empty-intersection error.
|
|
167
|
-
*/
|
|
168
|
-
function applyGroupFilter(details, allDetails, groups, groupLabelMap) {
|
|
169
|
-
if (groups.length === 0) {
|
|
170
|
-
return details;
|
|
171
|
-
}
|
|
172
|
-
// Valid group IDs: the template's declared groups table PLUS any group id
|
|
173
|
-
// referenced directly on any property in the template (templates that use
|
|
174
|
-
// property.group without a matching groups entry still render a heading —
|
|
175
|
-
// so the filter must accept those ids too).
|
|
176
|
-
const validFromTemplate = new Set(groupLabelMap.keys());
|
|
177
|
-
const validFromDetails = new Set(allDetails
|
|
178
|
-
.map((d) => d.groupId)
|
|
179
|
-
.filter((id) => id !== undefined));
|
|
180
|
-
const valid = new Set([...validFromTemplate, ...validFromDetails]);
|
|
181
|
-
for (const g of groups) {
|
|
182
|
-
if (!valid.has(g)) {
|
|
183
|
-
const known = [...valid].join(", ") || "(none defined on this template)";
|
|
184
|
-
throw new Error(`Unknown group id "${g}". Use the template's group id (not its label).\n` +
|
|
185
|
-
`Available group ids: ${known}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const set = new Set(groups);
|
|
189
|
-
return details.filter((d) => d.groupId !== undefined && set.has(d.groupId));
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Render the condensed one-line-per-property listing grouped by
|
|
193
|
-
* section.
|
|
194
|
-
*/
|
|
195
|
-
function renderCondensedTable(details, groupLabelMap, logger) {
|
|
196
|
-
const grouped = new Map();
|
|
197
|
-
const ungrouped = [];
|
|
198
|
-
for (const detail of details) {
|
|
199
|
-
if (detail.groupId) {
|
|
200
|
-
const list = grouped.get(detail.groupId) ?? [];
|
|
201
|
-
list.push(detail);
|
|
202
|
-
grouped.set(detail.groupId, list);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
ungrouped.push(detail);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
// Global name-column width so the description column anchors at the
|
|
209
|
-
// same x-position across all groups.
|
|
210
|
-
const nameWidth = Math.max(0, ...details.map((d) => (d.name ?? "?").length));
|
|
211
|
-
const groupEntries = [...grouped.entries()].map(([groupId, group]) => ({ groupId, group }));
|
|
212
|
-
if (ungrouped.length > 0) {
|
|
213
|
-
groupEntries.push({ groupId: null, group: ungrouped });
|
|
214
|
-
}
|
|
215
|
-
for (let i = 0; i < groupEntries.length; i++) {
|
|
216
|
-
const { groupId, group } = groupEntries[i];
|
|
217
|
-
const label = groupId ? (groupLabelMap.get(groupId) ?? groupId) : "Other";
|
|
218
|
-
// Show "Label (id)" so the --group filter token is self-documenting.
|
|
219
|
-
// Skip the parenthetical when label and id are identical.
|
|
220
|
-
const heading = groupId && label !== groupId
|
|
221
|
-
? `${styleText("bold", label)} ${styleText("dim", `(${groupId})`)}`
|
|
222
|
-
: styleText("bold", label);
|
|
223
|
-
logger.output(heading);
|
|
224
|
-
for (const detail of group) {
|
|
225
|
-
logger.output(formatCondensedRow(detail, { nameWidth }));
|
|
226
|
-
}
|
|
227
|
-
if (i < groupEntries.length - 1) {
|
|
228
|
-
logger.output("");
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Build one condensed row: indent · padded name · description-or-label.
|
|
234
|
-
*/
|
|
235
|
-
function formatCondensedRow(detail, { nameWidth }) {
|
|
236
|
-
const NAME_INDENT = " ";
|
|
237
|
-
const COLUMN_GAP = " ";
|
|
238
|
-
const CONT_INDENT = " ".repeat(NAME_INDENT.length + 4);
|
|
239
|
-
const name = (detail.name ?? "?").padEnd(nameWidth);
|
|
240
|
-
const text = detail.description ?? detail.label ?? "";
|
|
241
|
-
const trailing = text ? `${COLUMN_GAP}${styleText("dim", text)}` : "";
|
|
242
|
-
const lines = [`${NAME_INDENT}${styleText("bold", name)}${trailing}`];
|
|
243
|
-
// Surface `id` only when it adds information — i.e. it exists and
|
|
244
|
-
// differs from the binding name. For most properties (id == name or
|
|
245
|
-
// id missing) this stays a single-line row.
|
|
246
|
-
if (detail.id && detail.id !== detail.name) {
|
|
247
|
-
lines.push(styleText("dim", `${CONT_INDENT}[id: ${detail.id}]`));
|
|
248
|
-
}
|
|
249
|
-
if (detail.choices?.length) {
|
|
250
|
-
const values = detail.choices.map((c) => c.value).join(", ");
|
|
251
|
-
lines.push(styleText("dim", `${CONT_INDENT}[choices: ${values}]`));
|
|
252
|
-
}
|
|
253
|
-
return lines.join("\n");
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Detail card for a single property — keyed two-column layout.
|
|
257
|
-
*/
|
|
258
|
-
function formatPropertyCard(detail) {
|
|
259
|
-
const fields = [];
|
|
260
|
-
if (detail.id) {
|
|
261
|
-
fields.push(["Id", detail.id]);
|
|
262
|
-
}
|
|
263
|
-
fields.push(["Type", detail.type ?? "String"]);
|
|
264
|
-
fields.push(["Required", detail.required ? "yes" : "no"]);
|
|
265
|
-
if (detail.feel) {
|
|
266
|
-
fields.push(["FEEL", detail.feel]);
|
|
267
|
-
}
|
|
268
|
-
if (detail.default !== undefined && detail.default !== "") {
|
|
269
|
-
fields.push(["Default", formatBadgeValue(detail.default)]);
|
|
270
|
-
}
|
|
271
|
-
if (detail.bindingType) {
|
|
272
|
-
fields.push(["Binding", detail.bindingType]);
|
|
273
|
-
}
|
|
274
|
-
if (detail.label || detail.description) {
|
|
275
|
-
const text = [detail.label, detail.description].filter(Boolean).join(" — ");
|
|
276
|
-
fields.push(["Description", text]);
|
|
277
|
-
}
|
|
278
|
-
if (detail.conditionText) {
|
|
279
|
-
fields.push(["Active when", detail.conditionText]);
|
|
280
|
-
}
|
|
281
|
-
else if (detail.condition) {
|
|
282
|
-
fields.push(["Conditional", "(see template definition)"]);
|
|
283
|
-
}
|
|
284
|
-
if (detail.pattern) {
|
|
285
|
-
fields.push(["Pattern", detail.pattern.value]);
|
|
286
|
-
if (detail.pattern.message) {
|
|
287
|
-
fields.push(["", detail.pattern.message]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (detail.choices?.length) {
|
|
291
|
-
fields.push(["Choices", detail.choices.map((c) => c.value).join(", ")]);
|
|
292
|
-
}
|
|
293
|
-
return formatKeyedCard({
|
|
294
|
-
title: detail.name ?? "?",
|
|
295
|
-
subtitle: detail.group ? `(${detail.group})` : undefined,
|
|
296
|
-
fields,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Filter properties by a `<name>` or `<binding-type>:<name>` argument.
|
|
301
|
-
*/
|
|
302
|
-
function filterByPropertyArg(details, propertyArg, templateArg) {
|
|
303
|
-
const colon = propertyArg.indexOf(":");
|
|
304
|
-
let nameFilter = propertyArg;
|
|
305
|
-
let typeFilter;
|
|
306
|
-
if (colon !== -1) {
|
|
307
|
-
const prefix = propertyArg.slice(0, colon);
|
|
308
|
-
typeFilter = BINDING_TYPE_SHORTHANDS[prefix];
|
|
309
|
-
if (!typeFilter) {
|
|
310
|
-
const valid = Object.keys(BINDING_TYPE_SHORTHANDS).join(", ");
|
|
311
|
-
throw new Error(`Unknown binding type prefix "${prefix}". Valid prefixes: ${valid}`);
|
|
312
|
-
}
|
|
313
|
-
nameFilter = propertyArg.slice(colon + 1);
|
|
314
|
-
}
|
|
315
|
-
const isGlob = nameFilter.includes("*");
|
|
316
|
-
const matcher = isGlob ? globToRegex(nameFilter) : null;
|
|
317
|
-
const matches = details.filter((d) => {
|
|
318
|
-
if (typeFilter && d.bindingType !== typeFilter) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
if (!d.name) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
return matcher ? matcher.test(d.name) : d.name === nameFilter;
|
|
325
|
-
});
|
|
326
|
-
if (matches.length === 0) {
|
|
327
|
-
const hint = templateArg
|
|
328
|
-
? `\nRun 'c8ctl element-template get-properties ${templateArg}' to list all available properties.`
|
|
329
|
-
: "";
|
|
330
|
-
throw new Error(`Property "${propertyArg}" not found.${hint}`);
|
|
331
|
-
}
|
|
332
|
-
return matches;
|
|
333
|
-
}
|
|
334
|
-
function formatBadgeValue(value) {
|
|
335
|
-
if (typeof value === "string") {
|
|
336
|
-
// Multi-line defaults (FEEL expression bodies, JSON snippets) would
|
|
337
|
-
// otherwise wrap and break the badge layout — collapse to a single
|
|
338
|
-
// line and truncate.
|
|
339
|
-
const oneLine = value.replace(/\s+/g, " ").trim();
|
|
340
|
-
return oneLine.length > 60 ? `${oneLine.slice(0, 57)}...` : oneLine;
|
|
341
|
-
}
|
|
342
|
-
return JSON.stringify(value);
|
|
343
|
-
}
|
|
344
|
-
//# sourceMappingURL=get-properties.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-properties.js","sourceRoot":"","sources":["../../../../default-plugins/element-template/commands/get-properties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EACN,uBAAuB,EACvB,WAAW,GAKX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE9D,IAAI,CAAC,UAAU,CAAC,KAAK;IAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACxE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAAc;IAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,KAAK,GACV,2GAA2G;QAC3G,gFAAgF;QAChF,iFAAiF,CAAC;IAEnF,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE;QAC5C,kBAAkB,EAAE,IAAI;QACxB,YAAY,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,EACd,mBAAmB,GACnB,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE3C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,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `c8ctl element-template get` — print the raw template JSON to stdout
|
|
3
|
-
* (pipe-friendly).
|
|
4
|
-
*
|
|
5
|
-
* For local paths and URLs we pass the source bytes through unchanged (no
|
|
6
|
-
* parse/stringify round-trip — preserves whitespace, key order, trailing
|
|
7
|
-
* newline). For OOTB ids we don't have the upstream bytes, so we
|
|
8
|
-
* serialize the cached object with a 2-space indent. Designed for shell
|
|
9
|
-
* redirection:
|
|
10
|
-
*
|
|
11
|
-
* c8ctl element-template get <id> > template.json
|
|
12
|
-
*
|
|
13
|
-
* No trailing hints or colored output — they would corrupt the piped
|
|
14
|
-
* payload.
|
|
15
|
-
*/
|
|
16
|
-
import { installStdoutEpipeHandler, parseTemplateJson, readFileOrUrl, } from "../helpers.js";
|
|
17
|
-
import { parseTemplateRef, resolveOotbTemplate } from "../template-ref.js";
|
|
18
|
-
export async function getSubcommand(args) {
|
|
19
|
-
// `get` writes raw template JSON straight to stdout; consumers that
|
|
20
|
-
// take only a prefix (e.g. `get <id> | head -c N`) close the pipe
|
|
21
|
-
// early and would otherwise crash the process with an unhandled
|
|
22
|
-
// EPIPE event.
|
|
23
|
-
installStdoutEpipeHandler();
|
|
24
|
-
const usage = "Usage: c8ctl element-template get <template> [--no-icon]";
|
|
25
|
-
let templateArg;
|
|
26
|
-
let noIcon = false;
|
|
27
|
-
for (let i = 0; i < args.length; i++) {
|
|
28
|
-
const arg = args[i];
|
|
29
|
-
if (arg === "--") {
|
|
30
|
-
// All tokens after `--` are literal positionals — not flags.
|
|
31
|
-
for (const rest of args.slice(i + 1)) {
|
|
32
|
-
if (templateArg === undefined) {
|
|
33
|
-
templateArg = rest;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
throw new Error(`Unexpected argument: ${rest}. ${usage}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if (arg === "--no-icon") {
|
|
42
|
-
noIcon = true;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (arg.startsWith("-")) {
|
|
46
|
-
throw new Error(`Unknown flag: ${arg}. ${usage}`);
|
|
47
|
-
}
|
|
48
|
-
if (templateArg === undefined) {
|
|
49
|
-
templateArg = arg;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
throw new Error(`Unexpected argument: ${arg}. ${usage}`);
|
|
53
|
-
}
|
|
54
|
-
if (!templateArg) {
|
|
55
|
-
throw new Error(`Missing template argument. ${usage}`);
|
|
56
|
-
}
|
|
57
|
-
const ref = parseTemplateRef(templateArg);
|
|
58
|
-
if (!ref) {
|
|
59
|
-
throw new Error(`Missing template argument. ${usage}`);
|
|
60
|
-
}
|
|
61
|
-
if (ref.kind === "path" || ref.kind === "url") {
|
|
62
|
-
const content = await readFileOrUrl(ref.value);
|
|
63
|
-
// Pass-through preserves whitespace + key order — but --no-icon
|
|
64
|
-
// requires a parse/strip/re-stringify round-trip, which loses
|
|
65
|
-
// that. The user is opting in to the rewrite by asking for it.
|
|
66
|
-
if (noIcon) {
|
|
67
|
-
const template = parseTemplateJson(content);
|
|
68
|
-
const stripped = stripIcon(template);
|
|
69
|
-
process.stdout.write(`${JSON.stringify(stripped, null, 2)}\n`);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
process.stdout.write(content);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// OOTB id: no upstream bytes available — stringify the cached object.
|
|
76
|
-
// `resolveOotbTemplate` calls `requireCachePresent` under the hood, so
|
|
77
|
-
// a missing cache surfaces with the same "run sync first" message every
|
|
78
|
-
// other subcommand uses.
|
|
79
|
-
const template = await resolveOotbTemplate(ref);
|
|
80
|
-
// The cache injects `metadata.upstreamRef` (our internal pointer for
|
|
81
|
-
// incremental sync); strip it so the output matches what you'd get
|
|
82
|
-
// from the marketplace, not c8ctl's cache shape.
|
|
83
|
-
let cleaned = stripInternalMetadata(template);
|
|
84
|
-
if (noIcon) {
|
|
85
|
-
cleaned = stripIcon(cleaned);
|
|
86
|
-
}
|
|
87
|
-
process.stdout.write(`${JSON.stringify(cleaned, null, 2)}\n`);
|
|
88
|
-
}
|
|
89
|
-
function stripInternalMetadata(template) {
|
|
90
|
-
if (!template.metadata?.upstreamRef) {
|
|
91
|
-
return template;
|
|
92
|
-
}
|
|
93
|
-
const { metadata, ...rest } = template;
|
|
94
|
-
const { upstreamRef: _ignored, ...metaRest } = metadata;
|
|
95
|
-
if (Object.keys(metaRest).length === 0) {
|
|
96
|
-
return { ...rest, properties: template.properties };
|
|
97
|
-
}
|
|
98
|
-
return { ...rest, properties: template.properties, metadata: metaRest };
|
|
99
|
-
}
|
|
100
|
-
function stripIcon(template) {
|
|
101
|
-
if (!template.icon) {
|
|
102
|
-
return template;
|
|
103
|
-
}
|
|
104
|
-
const { icon: _icon, ...rest } = template;
|
|
105
|
-
return { ...rest, properties: template.properties };
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=get.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../default-plugins/element-template/commands/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACN,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,GAEb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IACjD,oEAAoE;IACpE,kEAAkE;IAClE,gEAAgE;IAChE,eAAe;IACf,yBAAyB,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,0DAA0D,CAA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IACD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC;IACxD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,SAAS,CAAC,QAAkB;IACpC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `c8ctl element-template info` — show a keyed card of template-level
|
|
3
|
-
* metadata.
|
|
4
|
-
*
|
|
5
|
-
* Also hosts the shared inspect-arg parser (used by `info` and
|
|
6
|
-
* `get-properties`), the template-header renderer (used by `info` and
|
|
7
|
-
* `search`), and the generic keyed-card layout used by both header and
|
|
8
|
-
* property-detail cards.
|
|
9
|
-
*/
|
|
10
|
-
import { styleText } from "node:util";
|
|
11
|
-
import { loadTemplate } from "../template-ref.js";
|
|
12
|
-
if (!globalThis.c8ctl)
|
|
13
|
-
throw new Error("c8ctl runtime not initialised");
|
|
14
|
-
const c8ctl = globalThis.c8ctl;
|
|
15
|
-
/**
|
|
16
|
-
* Parse the shared inspect args: `<template> [<name>...] [--group <id>...]`.
|
|
17
|
-
* `--group` is repeatable. Comma-separated values are NOT split — pass
|
|
18
|
-
* `--group a --group b` for multiple ids.
|
|
19
|
-
*/
|
|
20
|
-
export function parseInspectArgs(args, usage, { allowPropertyNames, allowFilters, }) {
|
|
21
|
-
let templateArg;
|
|
22
|
-
const propertyArgs = [];
|
|
23
|
-
const groups = [];
|
|
24
|
-
let detailed = false;
|
|
25
|
-
let afterDoubleDash = false;
|
|
26
|
-
for (let i = 0; i < args.length; i++) {
|
|
27
|
-
const arg = args[i];
|
|
28
|
-
if (!afterDoubleDash && arg === "--") {
|
|
29
|
-
afterDoubleDash = true;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (!afterDoubleDash && (arg === "--group" || arg.startsWith("--group="))) {
|
|
33
|
-
if (!allowFilters) {
|
|
34
|
-
throw new Error(`Unknown flag: --group. ${usage}`);
|
|
35
|
-
}
|
|
36
|
-
const value = arg === "--group" ? args[++i] : arg.slice("--group=".length);
|
|
37
|
-
if (value === undefined || value === "") {
|
|
38
|
-
throw new Error(`--group requires a value (group id). ${usage}`);
|
|
39
|
-
}
|
|
40
|
-
groups.push(value);
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (!afterDoubleDash && (arg === "--detailed" || arg === "-d")) {
|
|
44
|
-
if (!allowFilters) {
|
|
45
|
-
throw new Error(`Unknown flag: ${arg}. ${usage}`);
|
|
46
|
-
}
|
|
47
|
-
detailed = true;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (!afterDoubleDash && arg.startsWith("-")) {
|
|
51
|
-
throw new Error(`Unknown flag: ${arg}. ${usage}`);
|
|
52
|
-
}
|
|
53
|
-
if (templateArg === undefined) {
|
|
54
|
-
templateArg = arg;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (!allowPropertyNames) {
|
|
58
|
-
throw new Error(`Unexpected argument: ${arg}. ${usage}`);
|
|
59
|
-
}
|
|
60
|
-
propertyArgs.push(arg);
|
|
61
|
-
}
|
|
62
|
-
if (!templateArg) {
|
|
63
|
-
throw new Error(`Missing template argument. ${usage}`);
|
|
64
|
-
}
|
|
65
|
-
return { templateArg, propertyArgs, groups, detailed };
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Project a template into the JSON summary shape — only the fields
|
|
69
|
-
* the text output surfaces (name/id/version, description, applies-to,
|
|
70
|
-
* engines, docs link), but using the element-templates JSON schema's
|
|
71
|
-
* own field names. No invented derivations; no full-template dump.
|
|
72
|
-
*/
|
|
73
|
-
export function buildTemplateSummary(template) {
|
|
74
|
-
return {
|
|
75
|
-
name: template.name,
|
|
76
|
-
id: template.id,
|
|
77
|
-
version: template.version,
|
|
78
|
-
description: template.description,
|
|
79
|
-
documentationRef: template.documentationRef,
|
|
80
|
-
appliesTo: template.appliesTo,
|
|
81
|
-
elementType: template.elementType,
|
|
82
|
-
engines: template.engines,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Render template-level metadata as a keyed card.
|
|
87
|
-
*/
|
|
88
|
-
export function formatTemplateHeaderLines(template, fallbackName, { autoResolvedVersion = false } = {}) {
|
|
89
|
-
const fields = [];
|
|
90
|
-
if (template.id) {
|
|
91
|
-
fields.push(["ID", template.id]);
|
|
92
|
-
}
|
|
93
|
-
if (template.version !== undefined) {
|
|
94
|
-
const versionCell = autoResolvedVersion
|
|
95
|
-
? `${template.version} ${styleText("dim", "(latest; @<n> to pin)")}`
|
|
96
|
-
: String(template.version);
|
|
97
|
-
fields.push(["Version", versionCell]);
|
|
98
|
-
}
|
|
99
|
-
const appliesValue = formatAppliesToValue(template);
|
|
100
|
-
if (appliesValue) {
|
|
101
|
-
fields.push(["Applies to", appliesValue]);
|
|
102
|
-
}
|
|
103
|
-
if (template.engines?.camunda) {
|
|
104
|
-
fields.push(["Engines", template.engines.camunda]);
|
|
105
|
-
}
|
|
106
|
-
if (template.description) {
|
|
107
|
-
fields.push(["Description", template.description]);
|
|
108
|
-
}
|
|
109
|
-
if (template.documentationRef) {
|
|
110
|
-
fields.push(["Docs", styleText("dim", template.documentationRef)]);
|
|
111
|
-
}
|
|
112
|
-
return formatKeyedCard({
|
|
113
|
-
title: template.name ?? fallbackName ?? "Template",
|
|
114
|
-
fields,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Resolve `appliesTo` and `elementType.value` into a single value cell.
|
|
119
|
-
*/
|
|
120
|
-
export function formatAppliesToValue(template) {
|
|
121
|
-
const applies = Array.isArray(template.appliesTo)
|
|
122
|
-
? template.appliesTo.filter((v) => Boolean(v))
|
|
123
|
-
: [];
|
|
124
|
-
const elementType = template.elementType?.value;
|
|
125
|
-
if (applies.length === 0 && !elementType) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
const left = applies.length === 0
|
|
129
|
-
? null
|
|
130
|
-
: applies.length === 1
|
|
131
|
-
? applies[0]
|
|
132
|
-
: applies.length === 2
|
|
133
|
-
? applies.join(" or ")
|
|
134
|
-
: `${applies.slice(0, -1).join(", ")}, or ${applies[applies.length - 1]}`;
|
|
135
|
-
if (left && elementType && !applies.includes(elementType)) {
|
|
136
|
-
return `${left} → ${elementType}`;
|
|
137
|
-
}
|
|
138
|
-
if (left) {
|
|
139
|
-
return left;
|
|
140
|
-
}
|
|
141
|
-
return elementType ?? null;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Generic keyed-card renderer used by both the template header and the
|
|
145
|
-
* property detail card.
|
|
146
|
-
*/
|
|
147
|
-
export function formatKeyedCard({ title, subtitle, fields, }) {
|
|
148
|
-
const lines = [];
|
|
149
|
-
const titleParts = [styleText("bold", title)];
|
|
150
|
-
if (subtitle) {
|
|
151
|
-
titleParts.push(styleText("dim", subtitle));
|
|
152
|
-
}
|
|
153
|
-
lines.push(titleParts.join(" "));
|
|
154
|
-
if (fields.length === 0) {
|
|
155
|
-
return lines;
|
|
156
|
-
}
|
|
157
|
-
const keyWidth = Math.max(0, ...fields.map(([k]) => k.length));
|
|
158
|
-
for (const [key, value] of fields) {
|
|
159
|
-
const paddedKey = key.padEnd(keyWidth);
|
|
160
|
-
const styledKey = key ? styleText("dim", paddedKey) : paddedKey;
|
|
161
|
-
lines.push(` ${styledKey} ${value}`);
|
|
162
|
-
}
|
|
163
|
-
return lines;
|
|
164
|
-
}
|
|
165
|
-
export async function infoSubcommand(args) {
|
|
166
|
-
const logger = c8ctl.getLogger();
|
|
167
|
-
const usage = "Usage: c8ctl element-template info <template>";
|
|
168
|
-
const parsed = parseInspectArgs(args, usage, {
|
|
169
|
-
allowPropertyNames: false,
|
|
170
|
-
allowFilters: false,
|
|
171
|
-
});
|
|
172
|
-
const { template, autoResolvedVersion } = await loadTemplate(parsed.templateArg);
|
|
173
|
-
if (c8ctl.outputMode === "json") {
|
|
174
|
-
logger.json(buildTemplateSummary(template));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
// Template metadata card. The version row carries a dim parenthetical
|
|
178
|
-
// when the version was auto-resolved from an OOTB id.
|
|
179
|
-
for (const line of formatTemplateHeaderLines(template, parsed.templateArg, {
|
|
180
|
-
autoResolvedVersion,
|
|
181
|
-
})) {
|
|
182
|
-
logger.output(line);
|
|
183
|
-
}
|
|
184
|
-
logger.output("");
|
|
185
|
-
// Trailing hint — point at get-properties for the property listing.
|
|
186
|
-
logger.output(styleText("dim", "For settable properties, run:\n" +
|
|
187
|
-
` c8ctl element-template get-properties ${parsed.templateArg}`));
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=info.js.map
|