pax8-cta 0.1.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/LICENSE +200 -0
- package/README.md +659 -0
- package/demo-data/solutions/ProductQADemo_1_0_0_2_managed.zip +0 -0
- package/dist/commands/analyze.d.ts +28 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +571 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/auth.d.ts +18 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +171 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +34 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +299 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/demo.d.ts +33 -0
- package/dist/commands/demo.d.ts.map +1 -0
- package/dist/commands/demo.js +362 -0
- package/dist/commands/demo.js.map +1 -0
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +1186 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/deployments/helpers.d.ts +68 -0
- package/dist/commands/deployments/helpers.d.ts.map +1 -0
- package/dist/commands/deployments/helpers.js +414 -0
- package/dist/commands/deployments/helpers.js.map +1 -0
- package/dist/commands/deployments/index.d.ts +24 -0
- package/dist/commands/deployments/index.d.ts.map +1 -0
- package/dist/commands/deployments/index.js +47 -0
- package/dist/commands/deployments/index.js.map +1 -0
- package/dist/commands/deployments/list.d.ts +18 -0
- package/dist/commands/deployments/list.d.ts.map +1 -0
- package/dist/commands/deployments/list.js +97 -0
- package/dist/commands/deployments/list.js.map +1 -0
- package/dist/commands/deployments/show.d.ts +18 -0
- package/dist/commands/deployments/show.d.ts.map +1 -0
- package/dist/commands/deployments/show.js +81 -0
- package/dist/commands/deployments/show.js.map +1 -0
- package/dist/commands/deployments/undo.d.ts +18 -0
- package/dist/commands/deployments/undo.d.ts.map +1 -0
- package/dist/commands/deployments/undo.js +295 -0
- package/dist/commands/deployments/undo.js.map +1 -0
- package/dist/commands/export.d.ts +18 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +133 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +18 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +129 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init-config.d.ts +26 -0
- package/dist/commands/init-config.d.ts.map +1 -0
- package/dist/commands/init-config.js +123 -0
- package/dist/commands/init-config.js.map +1 -0
- package/dist/commands/init-validation.d.ts +47 -0
- package/dist/commands/init-validation.d.ts.map +1 -0
- package/dist/commands/init-validation.js +339 -0
- package/dist/commands/init-validation.js.map +1 -0
- package/dist/commands/init-wizard.d.ts +25 -0
- package/dist/commands/init-wizard.d.ts.map +1 -0
- package/dist/commands/init-wizard.js +433 -0
- package/dist/commands/init-wizard.js.map +1 -0
- package/dist/commands/init.d.ts +18 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +46 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/resolve-url.d.ts +18 -0
- package/dist/commands/resolve-url.d.ts.map +1 -0
- package/dist/commands/resolve-url.js +126 -0
- package/dist/commands/resolve-url.js.map +1 -0
- package/dist/commands/setup.d.ts +18 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +239 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/solutions/drift-analysis.d.ts +73 -0
- package/dist/commands/solutions/drift-analysis.d.ts.map +1 -0
- package/dist/commands/solutions/drift-analysis.js +416 -0
- package/dist/commands/solutions/drift-analysis.js.map +1 -0
- package/dist/commands/solutions/drift.d.ts +32 -0
- package/dist/commands/solutions/drift.d.ts.map +1 -0
- package/dist/commands/solutions/drift.js +641 -0
- package/dist/commands/solutions/drift.js.map +1 -0
- package/dist/commands/solutions/fix-planner.d.ts +48 -0
- package/dist/commands/solutions/fix-planner.d.ts.map +1 -0
- package/dist/commands/solutions/fix-planner.js +43 -0
- package/dist/commands/solutions/fix-planner.js.map +1 -0
- package/dist/commands/solutions/helpers.d.ts +35 -0
- package/dist/commands/solutions/helpers.d.ts.map +1 -0
- package/dist/commands/solutions/helpers.js +54 -0
- package/dist/commands/solutions/helpers.js.map +1 -0
- package/dist/commands/solutions/index.d.ts +18 -0
- package/dist/commands/solutions/index.d.ts.map +1 -0
- package/dist/commands/solutions/index.js +30 -0
- package/dist/commands/solutions/index.js.map +1 -0
- package/dist/commands/solutions/list.d.ts +18 -0
- package/dist/commands/solutions/list.d.ts.map +1 -0
- package/dist/commands/solutions/list.js +174 -0
- package/dist/commands/solutions/list.js.map +1 -0
- package/dist/commands/solutions/remove.d.ts +18 -0
- package/dist/commands/solutions/remove.d.ts.map +1 -0
- package/dist/commands/solutions/remove.js +137 -0
- package/dist/commands/solutions/remove.js.map +1 -0
- package/dist/commands/solutions/risk-calculator.d.ts +33 -0
- package/dist/commands/solutions/risk-calculator.d.ts.map +1 -0
- package/dist/commands/solutions/risk-calculator.js +79 -0
- package/dist/commands/solutions/risk-calculator.js.map +1 -0
- package/dist/commands/solutions/show.d.ts +18 -0
- package/dist/commands/solutions/show.d.ts.map +1 -0
- package/dist/commands/solutions/show.js +165 -0
- package/dist/commands/solutions/show.js.map +1 -0
- package/dist/commands/status.d.ts +18 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +573 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/telemetry.d.ts +18 -0
- package/dist/commands/telemetry.d.ts.map +1 -0
- package/dist/commands/telemetry.js +85 -0
- package/dist/commands/telemetry.js.map +1 -0
- package/dist/commands/tenants/health.d.ts +18 -0
- package/dist/commands/tenants/health.d.ts.map +1 -0
- package/dist/commands/tenants/health.js +172 -0
- package/dist/commands/tenants/health.js.map +1 -0
- package/dist/commands/tenants/helpers.d.ts +44 -0
- package/dist/commands/tenants/helpers.d.ts.map +1 -0
- package/dist/commands/tenants/helpers.js +72 -0
- package/dist/commands/tenants/helpers.js.map +1 -0
- package/dist/commands/tenants/index.d.ts +19 -0
- package/dist/commands/tenants/index.d.ts.map +1 -0
- package/dist/commands/tenants/index.js +39 -0
- package/dist/commands/tenants/index.js.map +1 -0
- package/dist/commands/tenants/inspect.d.ts +18 -0
- package/dist/commands/tenants/inspect.d.ts.map +1 -0
- package/dist/commands/tenants/inspect.js +176 -0
- package/dist/commands/tenants/inspect.js.map +1 -0
- package/dist/commands/tenants/list.d.ts +18 -0
- package/dist/commands/tenants/list.d.ts.map +1 -0
- package/dist/commands/tenants/list.js +144 -0
- package/dist/commands/tenants/list.js.map +1 -0
- package/dist/commands/tenants/manage.d.ts +20 -0
- package/dist/commands/tenants/manage.d.ts.map +1 -0
- package/dist/commands/tenants/manage.js +206 -0
- package/dist/commands/tenants/manage.js.map +1 -0
- package/dist/commands/tenants/show.d.ts +18 -0
- package/dist/commands/tenants/show.d.ts.map +1 -0
- package/dist/commands/tenants/show.js +191 -0
- package/dist/commands/tenants/show.js.map +1 -0
- package/dist/commands/validate.d.ts +18 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +536 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/auth.d.ts +51 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +153 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/banner.d.ts +19 -0
- package/dist/lib/banner.d.ts.map +1 -0
- package/dist/lib/banner.js +78 -0
- package/dist/lib/banner.js.map +1 -0
- package/dist/lib/command-wrapper.d.ts +56 -0
- package/dist/lib/command-wrapper.d.ts.map +1 -0
- package/dist/lib/command-wrapper.js +71 -0
- package/dist/lib/command-wrapper.js.map +1 -0
- package/dist/lib/credentials.d.ts +56 -0
- package/dist/lib/credentials.d.ts.map +1 -0
- package/dist/lib/credentials.js +146 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/demo-banner.d.ts +15 -0
- package/dist/lib/demo-banner.d.ts.map +1 -0
- package/dist/lib/demo-banner.js +33 -0
- package/dist/lib/demo-banner.js.map +1 -0
- package/dist/lib/error-handler.d.ts +51 -0
- package/dist/lib/error-handler.d.ts.map +1 -0
- package/dist/lib/error-handler.js +458 -0
- package/dist/lib/error-handler.js.map +1 -0
- package/dist/lib/errors.d.ts +61 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +168 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/formatters.d.ts +55 -0
- package/dist/lib/formatters.d.ts.map +1 -0
- package/dist/lib/formatters.js +163 -0
- package/dist/lib/formatters.js.map +1 -0
- package/dist/lib/graph-client.d.ts +74 -0
- package/dist/lib/graph-client.d.ts.map +1 -0
- package/dist/lib/graph-client.js +231 -0
- package/dist/lib/graph-client.js.map +1 -0
- package/dist/lib/input.d.ts +22 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/input.js +120 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/interactive-wizard.d.ts +26 -0
- package/dist/lib/interactive-wizard.d.ts.map +1 -0
- package/dist/lib/interactive-wizard.js +550 -0
- package/dist/lib/interactive-wizard.js.map +1 -0
- package/dist/lib/oss-surface.d.ts +21 -0
- package/dist/lib/oss-surface.d.ts.map +1 -0
- package/dist/lib/oss-surface.js +29 -0
- package/dist/lib/oss-surface.js.map +1 -0
- package/dist/lib/output.d.ts +74 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +156 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/picker.d.ts +75 -0
- package/dist/lib/picker.d.ts.map +1 -0
- package/dist/lib/picker.js +115 -0
- package/dist/lib/picker.js.map +1 -0
- package/dist/lib/repl.d.ts +19 -0
- package/dist/lib/repl.d.ts.map +1 -0
- package/dist/lib/repl.js +158 -0
- package/dist/lib/repl.js.map +1 -0
- package/dist/lib/spinner.d.ts +41 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/dist/lib/spinner.js +126 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/telemetry.d.ts +96 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +367 -0
- package/dist/lib/telemetry.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
import { resolve } from "node:path";
|
|
18
|
+
import chalk from "chalk";
|
|
19
|
+
import { createSpinner, isQuietMode } from "../../lib/spinner.js";
|
|
20
|
+
import { DEMO_TENANTS, loadConfig, TokenManager, DataverseClient, SolutionOperations, } from "@pax8-cta/core";
|
|
21
|
+
import { getClientSecretWithFallback } from "../../lib/credentials.js";
|
|
22
|
+
import { question } from "../../lib/input.js";
|
|
23
|
+
import { handleCommandError } from "../../lib/errors.js";
|
|
24
|
+
import { isDemo } from "../../lib/command-wrapper.js";
|
|
25
|
+
import { resolveFormat } from "../../lib/output.js";
|
|
26
|
+
import { showDemoBanner } from "../../lib/demo-banner.js";
|
|
27
|
+
import { findTenantMatches } from "../tenants/helpers.js";
|
|
28
|
+
export const removeCommand = new Command("remove")
|
|
29
|
+
.alias("uninstall")
|
|
30
|
+
.argument("<solution>", "Solution unique name to remove (e.g., TestDeploy)")
|
|
31
|
+
.description("Uninstall a managed solution from a target environment")
|
|
32
|
+
.requiredOption("-t, --tenant <name>", "Target tenant name or ID")
|
|
33
|
+
.option("-c, --config <path>", "Path to config file", "./config/tenants.yaml")
|
|
34
|
+
.option("-y, --yes", "Skip confirmation prompt")
|
|
35
|
+
.option("--json", "Output as JSON")
|
|
36
|
+
.option("--quiet", "Suppress all output (exit code only)")
|
|
37
|
+
.addHelpText("after", `
|
|
38
|
+
Examples:
|
|
39
|
+
solutions remove TestDeploy -t Pax8CTA-Test2 Uninstall with confirmation
|
|
40
|
+
solutions remove TestDeploy -t Pax8CTA-Test2 -y Uninstall without confirmation
|
|
41
|
+
`)
|
|
42
|
+
.action(async (solutionName, options, cmd) => {
|
|
43
|
+
// Merge global flags (--json, --quiet) registered on root program.
|
|
44
|
+
Object.assign(options, cmd.optsWithGlobals());
|
|
45
|
+
const spinner = createSpinner("Loading configuration...").start();
|
|
46
|
+
try {
|
|
47
|
+
// Issue #385: in demo mode, simulate the removal so the command works
|
|
48
|
+
// without ./config/tenants.yaml or real Dataverse credentials.
|
|
49
|
+
if (isDemo()) {
|
|
50
|
+
await runDemoRemove(spinner, solutionName, options);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const configPath = resolve(process.cwd(), options.config);
|
|
54
|
+
const config = await loadConfig(configPath);
|
|
55
|
+
const tenant = config.tenants.find((t) => t.name.toLowerCase() === options.tenant.toLowerCase() ||
|
|
56
|
+
t.tenantId.toLowerCase() === options.tenant.toLowerCase());
|
|
57
|
+
if (!tenant) {
|
|
58
|
+
spinner.fail(chalk.red(`Tenant '${options.tenant}' not found in config`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
spinner.succeed(`Target: ${tenant.name} (${tenant.environmentUrl})`);
|
|
62
|
+
// Confirm unless --yes
|
|
63
|
+
if (!options.yes) {
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk.yellow(` This will uninstall '${solutionName}' and remove all its components from ${tenant.name}.`));
|
|
66
|
+
const confirm = await question(chalk.red(" Are you sure? ") + chalk.gray("(yes/no) "));
|
|
67
|
+
if (confirm.toLowerCase() !== "yes" && confirm.toLowerCase() !== "y") {
|
|
68
|
+
console.log(chalk.gray(" Cancelled."));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
spinner.start("Authenticating...");
|
|
73
|
+
const clientSecret = await getClientSecretWithFallback();
|
|
74
|
+
const tokenManager = new TokenManager({
|
|
75
|
+
tenantId: config.partner.tenantId,
|
|
76
|
+
clientId: config.partner.clientId,
|
|
77
|
+
clientSecret,
|
|
78
|
+
});
|
|
79
|
+
const dataverseClient = new DataverseClient({
|
|
80
|
+
environmentUrl: tenant.environmentUrl,
|
|
81
|
+
tokenManager,
|
|
82
|
+
});
|
|
83
|
+
const solutionOps = new SolutionOperations(dataverseClient);
|
|
84
|
+
spinner.start(`Uninstalling '${solutionName}' from ${tenant.name}...`);
|
|
85
|
+
await solutionOps.deleteSolution(solutionName);
|
|
86
|
+
spinner.succeed(chalk.green(`Uninstalled '${solutionName}' from ${tenant.name}`));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
handleCommandError(error, spinner, "Failed to remove solution");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Demo-mode removal — looks up the requested tenant in DEMO_TENANTS and prints
|
|
94
|
+
* what *would* happen. Honors --json (machine-readable envelope) and --quiet
|
|
95
|
+
* (zero output, exit 0).
|
|
96
|
+
*/
|
|
97
|
+
async function runDemoRemove(spinner, solutionName, options) {
|
|
98
|
+
const fmt = resolveFormat({ json: options.json, quiet: options.quiet });
|
|
99
|
+
// Issue #402: reuse the same case-insensitive substring matching the rest of
|
|
100
|
+
// the CLI uses for `-t <name>`, but also report ambiguous partial matches so
|
|
101
|
+
// users don't get the wrong tenant silently chosen for them.
|
|
102
|
+
const matches = findTenantMatches(DEMO_TENANTS, options.tenant);
|
|
103
|
+
if (matches.length === 0) {
|
|
104
|
+
spinner.fail(chalk.red(`No tenant matches '${options.tenant}'; run 'pax8-cta tenants list' to see available tenants.`));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
if (matches.length > 1) {
|
|
108
|
+
spinner.fail(chalk.red(`Tenant '${options.tenant}' is ambiguous. Did you mean:`));
|
|
109
|
+
for (const candidate of matches) {
|
|
110
|
+
console.error(chalk.gray(` - ${candidate.name}`));
|
|
111
|
+
}
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
const tenant = matches[0];
|
|
115
|
+
spinner.succeed(`Target: ${tenant.name} (${tenant.environmentUrl})`);
|
|
116
|
+
// In demo mode we skip the interactive prompt entirely — simulating real I/O
|
|
117
|
+
// doesn't require destructive intent confirmation. Quiet/JSON callers (LLM
|
|
118
|
+
// agents, scripts) wouldn't be able to answer the prompt anyway.
|
|
119
|
+
if (fmt === "json") {
|
|
120
|
+
console.log(JSON.stringify({
|
|
121
|
+
demo: true,
|
|
122
|
+
action: "would-remove",
|
|
123
|
+
solution: solutionName,
|
|
124
|
+
tenant: { name: tenant.name, tenantId: tenant.tenantId },
|
|
125
|
+
message: `Would uninstall '${solutionName}' from ${tenant.name}`,
|
|
126
|
+
}, null, 2));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (fmt === "quiet") {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!isQuietMode()) {
|
|
133
|
+
showDemoBanner();
|
|
134
|
+
}
|
|
135
|
+
console.log(chalk.gray(` Would uninstall '${solutionName}' from ${tenant.name} (no real changes made).`));
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=remove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../src/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AI,CAAC,SAAS,CACZ;YACE,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,cAAc;YACtB,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;YACxD,OAAO,EAAE,oBAAoB,YAAY,UAAU,MAAM,CAAC,IAAI,EAAE;SACjE,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACnB,cAAc,EAAE,CAAC;IACnB,CAAC;IACD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CAAC,sBAAsB,YAAY,UAAU,MAAM,CAAC,IAAI,0BAA0B,CAAC,CAC9F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { DriftRecommendation, TenantVersionStatus } from "@pax8-cta/core";
|
|
17
|
+
/** Risk level for a tenant based on its drift state */
|
|
18
|
+
export type DriftRiskLevel = "low" | "medium" | "high";
|
|
19
|
+
/**
|
|
20
|
+
* Calculate the drift risk level for a tenant based on its version status.
|
|
21
|
+
*
|
|
22
|
+
* - low: 1 minor version behind on all solutions
|
|
23
|
+
* - medium: 2+ versions behind or multiple outdated solutions
|
|
24
|
+
* - high: not deployed solutions or 3+ versions behind
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateDriftRisk(status: TenantVersionStatus): DriftRiskLevel;
|
|
27
|
+
/**
|
|
28
|
+
* Parse the --max-risk option into a numeric threshold.
|
|
29
|
+
*/
|
|
30
|
+
export declare function riskLevelValue(level: DriftRiskLevel): number;
|
|
31
|
+
export declare function formatRiskLevel(level: string): string;
|
|
32
|
+
export declare function formatRecommendation(rec: DriftRecommendation): string;
|
|
33
|
+
//# sourceMappingURL=risk-calculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-calculator.d.ts","sourceRoot":"","sources":["../../../src/commands/solutions/risk-calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAa9E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAS5D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAerE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import chalk from "chalk";
|
|
17
|
+
/**
|
|
18
|
+
* Calculate the drift risk level for a tenant based on its version status.
|
|
19
|
+
*
|
|
20
|
+
* - low: 1 minor version behind on all solutions
|
|
21
|
+
* - medium: 2+ versions behind or multiple outdated solutions
|
|
22
|
+
* - high: not deployed solutions or 3+ versions behind
|
|
23
|
+
*/
|
|
24
|
+
export function calculateDriftRisk(status) {
|
|
25
|
+
const outdated = status.solutions.filter((s) => s.status === "outdated");
|
|
26
|
+
const notDeployed = status.solutions.filter((s) => s.status === "not_deployed");
|
|
27
|
+
if (notDeployed.length > 0)
|
|
28
|
+
return "high";
|
|
29
|
+
if (outdated.length === 0)
|
|
30
|
+
return "low";
|
|
31
|
+
const maxDrift = Math.max(...outdated.map((s) => Math.abs(s.versionDrift)));
|
|
32
|
+
if (maxDrift >= 3)
|
|
33
|
+
return "high";
|
|
34
|
+
if (maxDrift >= 2 || outdated.length >= 2)
|
|
35
|
+
return "medium";
|
|
36
|
+
return "low";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse the --max-risk option into a numeric threshold.
|
|
40
|
+
*/
|
|
41
|
+
export function riskLevelValue(level) {
|
|
42
|
+
switch (level) {
|
|
43
|
+
case "low":
|
|
44
|
+
return 1;
|
|
45
|
+
case "medium":
|
|
46
|
+
return 2;
|
|
47
|
+
case "high":
|
|
48
|
+
return 3;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function formatRiskLevel(level) {
|
|
52
|
+
switch (level) {
|
|
53
|
+
case "high":
|
|
54
|
+
return chalk.red("HIGH");
|
|
55
|
+
case "medium":
|
|
56
|
+
return chalk.yellow("MED");
|
|
57
|
+
case "low":
|
|
58
|
+
return chalk.green("LOW");
|
|
59
|
+
default:
|
|
60
|
+
return chalk.gray(level);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function formatRecommendation(rec) {
|
|
64
|
+
switch (rec) {
|
|
65
|
+
case "current":
|
|
66
|
+
return chalk.green("✓ current");
|
|
67
|
+
case "safe_to_update":
|
|
68
|
+
return chalk.green("safe to update");
|
|
69
|
+
case "review_recommended":
|
|
70
|
+
return chalk.yellow("review recommended");
|
|
71
|
+
case "update_risky":
|
|
72
|
+
return chalk.red("update risky");
|
|
73
|
+
case "do_not_update":
|
|
74
|
+
return chalk.red("⚠ do not update");
|
|
75
|
+
default:
|
|
76
|
+
return chalk.gray(rec);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=risk-calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-calculator.js","sourceRoot":"","sources":["../../../src/commands/solutions/risk-calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA2B;IAC5D,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC;IAEhF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IAE1C,IAAI,QAAQ,CAAC,MAAM,KAAK,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O,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAC5C,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACnC,KAAK,eAAe;YAClB,OAAO,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACtC;YACE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
export declare const showCommand: Command;
|
|
18
|
+
//# sourceMappingURL=show.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/solutions/show.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwDpC,eAAO,MAAM,WAAW,SAmJpB,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
import chalk from "chalk";
|
|
18
|
+
import { createSpinner } from "../../lib/spinner.js";
|
|
19
|
+
import { DEMO_SOLUTIONS } from "@pax8-cta/core";
|
|
20
|
+
import { withDemoMode } from "../../lib/command-wrapper.js";
|
|
21
|
+
import { formatTimeAgo } from "../../lib/formatters.js";
|
|
22
|
+
import { findSolution, getTenantDeploymentStatus } from "./helpers.js";
|
|
23
|
+
import { CliError, handleCommandError } from "../../lib/errors.js";
|
|
24
|
+
import { showDemoBanner } from "../../lib/demo-banner.js";
|
|
25
|
+
import { output, resolveFormat } from "../../lib/output.js";
|
|
26
|
+
const TENANT_COLUMNS = [
|
|
27
|
+
{ key: "tenantName", header: "Tenant" },
|
|
28
|
+
{
|
|
29
|
+
key: "version",
|
|
30
|
+
header: "Version",
|
|
31
|
+
format: (v) => (v == null || v === "" ? "-" : String(v)),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "status",
|
|
35
|
+
header: "Status",
|
|
36
|
+
format: (_v, row) => {
|
|
37
|
+
switch (row.status) {
|
|
38
|
+
case "current":
|
|
39
|
+
return chalk.green("✓ current");
|
|
40
|
+
case "outdated":
|
|
41
|
+
return chalk.yellow("↑ outdated");
|
|
42
|
+
case "not_deployed":
|
|
43
|
+
return chalk.gray("✗ not deployed");
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "deployedAt",
|
|
49
|
+
header: "Last Deployed",
|
|
50
|
+
format: (v) => (typeof v === "string" && v.length > 0 ? formatTimeAgo(v) : "-"),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
export const showCommand = new Command("show")
|
|
54
|
+
.argument("<name>", "Solution name or unique name")
|
|
55
|
+
.description("View solution details and where it's deployed")
|
|
56
|
+
.option("--tenants", "Show tenant deployment status")
|
|
57
|
+
.option("--json", "Output as JSON")
|
|
58
|
+
.option("--quiet", "Suppress all output (exit code only)")
|
|
59
|
+
.addHelpText("after", `
|
|
60
|
+
Examples:
|
|
61
|
+
solutions show TestDeploy View solution details
|
|
62
|
+
solutions show TestDeploy --tenants Show tenant deployment status
|
|
63
|
+
solutions show TestDeploy --json Output as JSON
|
|
64
|
+
`)
|
|
65
|
+
.action(async (name, options, cmd) => {
|
|
66
|
+
// Merge local opts with globals so root-level `--json` / `--quiet`
|
|
67
|
+
// (`pax8-cta --json solutions show ...`) reach this command. Resolve the
|
|
68
|
+
// effective output format up-front so every branch below can branch on a
|
|
69
|
+
// single `fmt` value (issue #406).
|
|
70
|
+
const opts = { ...options, ...cmd.optsWithGlobals() };
|
|
71
|
+
const fmt = resolveFormat({ json: !!opts.json, quiet: !!opts.quiet });
|
|
72
|
+
const spinner = createSpinner("Loading agent...").start();
|
|
73
|
+
try {
|
|
74
|
+
await withDemoMode(() => {
|
|
75
|
+
spinner.stop();
|
|
76
|
+
if (fmt === "table") {
|
|
77
|
+
showDemoBanner();
|
|
78
|
+
}
|
|
79
|
+
const solution = findSolution(DEMO_SOLUTIONS, name);
|
|
80
|
+
if (!solution) {
|
|
81
|
+
// Route through handleCommandError so --json/non-TTY callers get the
|
|
82
|
+
// structured error envelope instead of bare colored stdout.
|
|
83
|
+
throw new CliError(`Agent '${name}' not found. ` + `Run 'solutions list' to see all available agents.`);
|
|
84
|
+
}
|
|
85
|
+
const tenantStatus = getTenantDeploymentStatus(solution.uniqueName);
|
|
86
|
+
const rows = tenantStatus.map((t) => ({
|
|
87
|
+
tenantName: t.tenantName,
|
|
88
|
+
tenantId: t.tenantId,
|
|
89
|
+
version: t.version,
|
|
90
|
+
status: t.status,
|
|
91
|
+
deployedAt: t.deployedAt,
|
|
92
|
+
}));
|
|
93
|
+
const totalTenants = rows.length;
|
|
94
|
+
const deployed = rows.filter((r) => r.status !== "not_deployed").length;
|
|
95
|
+
const current = rows.filter((r) => r.status === "current").length;
|
|
96
|
+
const outdated = rows.filter((r) => r.status === "outdated").length;
|
|
97
|
+
const notDeployed = rows.filter((r) => r.status === "not_deployed").length;
|
|
98
|
+
// ──────────────────────────────────────────────────────────────────
|
|
99
|
+
// JSON envelope
|
|
100
|
+
// ──────────────────────────────────────────────────────────────────
|
|
101
|
+
if (fmt === "json") {
|
|
102
|
+
const envelope = {
|
|
103
|
+
name: solution.uniqueName,
|
|
104
|
+
displayName: solution.friendlyName,
|
|
105
|
+
latestVersion: solution.version,
|
|
106
|
+
summary: { totalTenants, deployed, current, outdated, notDeployed },
|
|
107
|
+
};
|
|
108
|
+
if (opts.tenants) {
|
|
109
|
+
envelope.tenants = rows;
|
|
110
|
+
}
|
|
111
|
+
console.log(JSON.stringify(envelope, null, 2));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// ──────────────────────────────────────────────────────────────────
|
|
115
|
+
// Quiet — produce no output
|
|
116
|
+
// ──────────────────────────────────────────────────────────────────
|
|
117
|
+
if (fmt === "quiet")
|
|
118
|
+
return;
|
|
119
|
+
// ──────────────────────────────────────────────────────────────────
|
|
120
|
+
// Table (TTY default) — existing human-readable rendering
|
|
121
|
+
// ──────────────────────────────────────────────────────────────────
|
|
122
|
+
console.log(chalk.bold(`${solution.friendlyName} (${solution.uniqueName})`));
|
|
123
|
+
console.log("━".repeat(60));
|
|
124
|
+
console.log(`Version: ${solution.version}`);
|
|
125
|
+
console.log(`Category: ${solution.category}`);
|
|
126
|
+
console.log(`Publisher: ${solution.publisherName}`);
|
|
127
|
+
console.log(`Tags: ${solution.tags.join(", ")}`);
|
|
128
|
+
console.log();
|
|
129
|
+
console.log(chalk.bold("Description:"));
|
|
130
|
+
console.log(` ${solution.description}`);
|
|
131
|
+
console.log();
|
|
132
|
+
console.log(chalk.bold("Capabilities:"));
|
|
133
|
+
solution.capabilities.forEach((cap) => {
|
|
134
|
+
console.log(` • ${cap}`);
|
|
135
|
+
});
|
|
136
|
+
console.log();
|
|
137
|
+
console.log(chalk.bold("Dependencies:"));
|
|
138
|
+
solution.dependencies.forEach((dep) => {
|
|
139
|
+
console.log(` • ${dep}`);
|
|
140
|
+
});
|
|
141
|
+
console.log();
|
|
142
|
+
console.log(`Last Published: ${formatTimeAgo(solution.lastPublished)}`);
|
|
143
|
+
// Tenant deployment status (when --tenants is passed)
|
|
144
|
+
if (opts.tenants) {
|
|
145
|
+
console.log();
|
|
146
|
+
console.log(chalk.bold(`${solution.uniqueName} - Tenant Deployment Status`));
|
|
147
|
+
console.log("━".repeat(60));
|
|
148
|
+
output(rows, { format: "table", columns: TENANT_COLUMNS });
|
|
149
|
+
console.log();
|
|
150
|
+
console.log(chalk.gray(`${deployed}/${totalTenants} tenants have this agent ` +
|
|
151
|
+
`(${current} current, ${outdated} outdated, ${notDeployed} not deployed)`));
|
|
152
|
+
}
|
|
153
|
+
}, () => {
|
|
154
|
+
// Production mode
|
|
155
|
+
spinner.fail(chalk.yellow("Production mode not yet implemented"));
|
|
156
|
+
if (fmt === "table") {
|
|
157
|
+
console.log(chalk.gray("\nEnable demo mode with 'demo on' to see sample data."));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
handleCommandError(error, spinner, "Failed to load agent");
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/commands/solutions/show.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OA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CACR,GAAG,QAAQ,IAAI,YAAY,2BAA2B;oBACpD,IAAI,OAAO,aAAa,QAAQ,cAAc,WAAW,gBAAgB,CAC5E,CACF,CAAC;YACJ,CAAC;QACH,CAAC,EACD,GAAG,EAAE;YACH,kBAAkB;YAClB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC;YAClE,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC,CAAC;YACnF,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Pax8, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
export declare const statusCommand: Command;
|
|
18
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkMpC,eAAO,MAAM,aAAa,SA8KtB,CAAC"}
|