@andpipes/cli 0.1.7 → 0.1.9
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/bin.cjs +170 -110
- package/dist/bin.js +1 -1
- package/dist/{chunk-KICI3MTW.js → chunk-YOEZJUW3.js} +95 -33
- package/dist/index.cjs +171 -111
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/bin.cjs
CHANGED
|
@@ -19,7 +19,7 @@ function readVersion() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// src/cli.ts
|
|
22
|
-
var
|
|
22
|
+
var import_localization18 = require("@andpipes/localization");
|
|
23
23
|
var import_commander = require("commander");
|
|
24
24
|
|
|
25
25
|
// src/commands/audit-export.ts
|
|
@@ -59,7 +59,7 @@ var ADMIN_CLI_SCOPES = [
|
|
|
59
59
|
"admin.tool.read"
|
|
60
60
|
];
|
|
61
61
|
var ADMIN_CLI_DEFAULT_SCOPES = ADMIN_CLI_SCOPES.filter(
|
|
62
|
-
(scope) => !scope.startsWith("admin.audit_export.")
|
|
62
|
+
(scope) => !scope.startsWith("admin.audit_export.") && !scope.startsWith("admin.onboarding_template.")
|
|
63
63
|
);
|
|
64
64
|
var FILE_VERSION = 3;
|
|
65
65
|
var DEFAULT_PROFILE = "default";
|
|
@@ -6794,7 +6794,7 @@ function registerDomain(program, writer, locale = import_localization6.DEFAULT_L
|
|
|
6794
6794
|
var import_node_crypto11 = require("crypto");
|
|
6795
6795
|
var import_node_path11 = require("path");
|
|
6796
6796
|
var import_promises2 = require("readline/promises");
|
|
6797
|
-
var
|
|
6797
|
+
var import_localization10 = require("@andpipes/localization");
|
|
6798
6798
|
var import_tool_contract9 = require("@andpipes/tool-contract");
|
|
6799
6799
|
|
|
6800
6800
|
// src/lib/init-manifest.ts
|
|
@@ -7405,6 +7405,37 @@ function authModeMismatchGuidance(mismatch, text = import_localization7.CLI_OPEN
|
|
|
7405
7405
|
return lines.join("\n");
|
|
7406
7406
|
}
|
|
7407
7407
|
|
|
7408
|
+
// src/lib/scope-login-guidance.ts
|
|
7409
|
+
var import_localization8 = require("@andpipes/localization");
|
|
7410
|
+
var SCOPE_LOGIN_GUIDANCE = {
|
|
7411
|
+
ja: "\u5FC5\u8981\u306A\u6A29\u9650\u3067\u30ED\u30B0\u30A4\u30F3\u3057\u3001{profile} \u3092\u4ED8\u3051\u3066\u64CD\u4F5C\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
7412
|
+
en: "Sign in with the required permissions, then retry the operation with {profile}.",
|
|
7413
|
+
"zh-Hant": "\u8ACB\u4EE5\u6240\u9700\u6B0A\u9650\u767B\u5165\uFF0C\u7136\u5F8C\u52A0\u4E0A {profile} \u91CD\u8A66\u64CD\u4F5C\u3002",
|
|
7414
|
+
"zh-Hans": "\u8BF7\u4EE5\u6240\u9700\u6743\u9650\u767B\u5F55\uFF0C\u7136\u540E\u52A0\u4E0A {profile} \u91CD\u8BD5\u64CD\u4F5C\u3002",
|
|
7415
|
+
ko: "\uD544\uC694\uD55C \uAD8C\uD55C\uC73C\uB85C \uB85C\uADF8\uC778\uD55C \uD6C4 {profile} \uC635\uC158\uC744 \uBD99\uC5EC \uC791\uC5C5\uC744 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.",
|
|
7416
|
+
fr: "Connectez-vous avec les autorisations requises, puis r\xE9essayez avec {profile}.",
|
|
7417
|
+
es: "Inicia sesi\xF3n con los permisos necesarios y vuelve a intentar la operaci\xF3n con {profile}.",
|
|
7418
|
+
pt: "Entre com as permiss\xF5es necess\xE1rias e tente novamente com {profile}.",
|
|
7419
|
+
it: "Accedi con le autorizzazioni richieste e riprova con {profile}.",
|
|
7420
|
+
ru: "\u0412\u043E\u0439\u0434\u0438\u0442\u0435 \u0441 \u043D\u0443\u0436\u043D\u044B\u043C\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u0438\u044F\u043C\u0438 \u0438 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u044E \u0441 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u043C {profile}."
|
|
7421
|
+
};
|
|
7422
|
+
async function withScopeLoginGuidance(request, writer, locale, profile, scopes = []) {
|
|
7423
|
+
try {
|
|
7424
|
+
return await request;
|
|
7425
|
+
} catch (error) {
|
|
7426
|
+
if (error instanceof AdminApiClientError && error.status === 403 && error.code === "AP_INVALID_SCOPE") {
|
|
7427
|
+
const profileOption = `--profile ${profile}`;
|
|
7428
|
+
const scopeOption = scopes.length === 0 ? "" : ` --scope ${scopes.join(",")}`;
|
|
7429
|
+
interactive(
|
|
7430
|
+
writer,
|
|
7431
|
+
`${(0, import_localization8.formatCliOpenApiTemplateMessage)(SCOPE_LOGIN_GUIDANCE[locale], { profile: profileOption })}
|
|
7432
|
+
andpipe login ${profileOption}${scopeOption}`
|
|
7433
|
+
);
|
|
7434
|
+
}
|
|
7435
|
+
throw error;
|
|
7436
|
+
}
|
|
7437
|
+
}
|
|
7438
|
+
|
|
7408
7439
|
// src/lib/terminal-safe.ts
|
|
7409
7440
|
var import_tool_contract7 = require("@andpipes/tool-contract");
|
|
7410
7441
|
function terminalSafeText(value) {
|
|
@@ -7426,22 +7457,25 @@ function terminalSafeValue(value) {
|
|
|
7426
7457
|
// src/commands/template.ts
|
|
7427
7458
|
var import_node_crypto10 = require("crypto");
|
|
7428
7459
|
var import_node_path10 = require("path");
|
|
7429
|
-
var
|
|
7460
|
+
var import_localization9 = require("@andpipes/localization");
|
|
7430
7461
|
var import_tool_contract8 = require("@andpipes/tool-contract");
|
|
7431
7462
|
var BINDINGS_MAX_BYTES = 64 * 1024;
|
|
7432
7463
|
var EXPORT_MAX_BYTES = 1280 * 1024;
|
|
7433
7464
|
var TEMPLATE_ID_RE2 = /^[a-z][a-z0-9._-]{0,63}$/u;
|
|
7465
|
+
var TEMPLATE_PROFILE = "onboarding-template";
|
|
7466
|
+
var TEMPLATE_READ_SCOPES = ["admin.onboarding_template.read"];
|
|
7467
|
+
var TEMPLATE_WRITE_SCOPES = [...TEMPLATE_READ_SCOPES, "admin.onboarding_template.write"];
|
|
7434
7468
|
function createTemplateCommandRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
7435
7469
|
return { createClient, idempotencyKey: import_node_crypto10.randomUUID };
|
|
7436
7470
|
}
|
|
7437
7471
|
function jsonObject(text, label, messages) {
|
|
7438
7472
|
const parsed = (0, import_tool_contract8.parseToolContract)(text, { format: "json" });
|
|
7439
7473
|
if (!parsed.ok || !parsed.contract || typeof parsed.contract !== "object" || Array.isArray(parsed.contract)) {
|
|
7440
|
-
throw new UsageError((0,
|
|
7474
|
+
throw new UsageError((0, import_localization9.formatCliOpenApiTemplateMessage)(messages.jsonObjectInvalid, { label }));
|
|
7441
7475
|
}
|
|
7442
7476
|
return parsed.contract;
|
|
7443
7477
|
}
|
|
7444
|
-
function loadOnboardingTemplateArtifact(cwd, file, bindingsFile, messages =
|
|
7478
|
+
function loadOnboardingTemplateArtifact(cwd, file, bindingsFile, messages = import_localization9.CLI_OPENAPI_TEMPLATE_MESSAGES.ja) {
|
|
7445
7479
|
const anchor = captureLocalRootPath(cwd);
|
|
7446
7480
|
const readArtifact = (path, maxBytes, label) => {
|
|
7447
7481
|
const value = readBoundedLocalFileSnapshot((0, import_node_path10.resolve)(anchor.root, path), {
|
|
@@ -7587,14 +7621,20 @@ function assertApplyMatchesLocal(result, projectId, loaded, planCommitment, mess
|
|
|
7587
7621
|
throw new UsageError(messages.templateApplyMismatch);
|
|
7588
7622
|
}
|
|
7589
7623
|
}
|
|
7590
|
-
async function runTemplatePlanOrApply(options, writer, cwd, runtime = createTemplateCommandRuntime(), locale =
|
|
7591
|
-
const messages =
|
|
7624
|
+
async function runTemplatePlanOrApply(options, writer, cwd, runtime = createTemplateCommandRuntime(), locale = import_localization9.DEFAULT_LOCALE) {
|
|
7625
|
+
const messages = import_localization9.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
7592
7626
|
const proof = applyProof(options, messages);
|
|
7593
7627
|
const projectId = assertProjectId(options.project);
|
|
7594
7628
|
const loaded = loadOnboardingTemplateArtifact(cwd, options.file, options.bindings, messages);
|
|
7595
7629
|
const client = runtime.createClient(options.profile ?? DEFAULT_PROFILE_NAME);
|
|
7596
7630
|
if (!proof) {
|
|
7597
|
-
const plan = await
|
|
7631
|
+
const plan = await withScopeLoginGuidance(
|
|
7632
|
+
client.planOnboardingTemplate(projectId, loaded.manifest, loaded.bindings),
|
|
7633
|
+
writer,
|
|
7634
|
+
locale,
|
|
7635
|
+
TEMPLATE_PROFILE,
|
|
7636
|
+
TEMPLATE_READ_SCOPES
|
|
7637
|
+
);
|
|
7598
7638
|
assertPlanMatchesLocal(plan, projectId, loaded, messages);
|
|
7599
7639
|
json(writer, {
|
|
7600
7640
|
mode: "dry-run",
|
|
@@ -7612,30 +7652,42 @@ async function runTemplatePlanOrApply(options, writer, cwd, runtime = createTemp
|
|
|
7612
7652
|
if (loaded.exportProjectId !== void 0 && loaded.exportProjectId !== projectId) {
|
|
7613
7653
|
throw new UsageError(messages.exportProjectMismatch);
|
|
7614
7654
|
}
|
|
7615
|
-
const result = await
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7655
|
+
const result = await withScopeLoginGuidance(
|
|
7656
|
+
client.applyOnboardingTemplate(projectId, options.idempotencyKey, {
|
|
7657
|
+
scopeRiskReviewVersion: proof.scopeRiskReviewVersion,
|
|
7658
|
+
scopeRiskReview: proof.scopeRiskReview,
|
|
7659
|
+
manifest: loaded.manifest,
|
|
7660
|
+
bindings: loaded.bindings,
|
|
7661
|
+
expectedCurrentApplicationCommitment: proof.expectedCurrent,
|
|
7662
|
+
planCommitment: proof.planCommitment,
|
|
7663
|
+
confirmed: true
|
|
7664
|
+
}),
|
|
7665
|
+
writer,
|
|
7666
|
+
locale,
|
|
7667
|
+
TEMPLATE_PROFILE,
|
|
7668
|
+
TEMPLATE_WRITE_SCOPES
|
|
7669
|
+
);
|
|
7624
7670
|
assertApplyMatchesLocal(result, projectId, loaded, proof.planCommitment, messages);
|
|
7625
7671
|
if (JSON.stringify(result.scopeRiskReview) !== JSON.stringify(proof.scopeRiskReview)) {
|
|
7626
7672
|
throw new UsageError(messages.scopeMismatch);
|
|
7627
7673
|
}
|
|
7628
7674
|
json(writer, { mode: "applied", ...result });
|
|
7629
7675
|
}
|
|
7630
|
-
async function runTemplateRollback(options, writer, runtime = createTemplateCommandRuntime(), locale =
|
|
7631
|
-
const messages =
|
|
7676
|
+
async function runTemplateRollback(options, writer, runtime = createTemplateCommandRuntime(), locale = import_localization9.DEFAULT_LOCALE) {
|
|
7677
|
+
const messages = import_localization9.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
7632
7678
|
const proof = applyProof(options, messages);
|
|
7633
7679
|
const projectId = assertProjectId(options.project);
|
|
7634
7680
|
const templateId = canonicalTemplateId(options.template, messages);
|
|
7635
7681
|
const targetRevision = positiveRevision(options.targetRevision, messages);
|
|
7636
7682
|
const client = runtime.createClient(options.profile ?? DEFAULT_PROFILE_NAME);
|
|
7637
7683
|
if (!proof) {
|
|
7638
|
-
const plan = await
|
|
7684
|
+
const plan = await withScopeLoginGuidance(
|
|
7685
|
+
client.planOnboardingTemplateRollback(projectId, templateId, targetRevision),
|
|
7686
|
+
writer,
|
|
7687
|
+
locale,
|
|
7688
|
+
TEMPLATE_PROFILE,
|
|
7689
|
+
TEMPLATE_READ_SCOPES
|
|
7690
|
+
);
|
|
7639
7691
|
const parsed2 = (0, import_tool_contract8.parseOnboardingTemplateSafePlanDto)(plan);
|
|
7640
7692
|
if (parsed2.projectId !== projectId || parsed2.templateId !== templateId || parsed2.operation !== "rollback" || parsed2.rollbackFromRevision !== targetRevision || parsed2.currentApplicationCommitment === null) {
|
|
7641
7693
|
throw new UsageError(messages.rollbackPlanMismatch);
|
|
@@ -7657,18 +7709,19 @@ async function runTemplateRollback(options, writer, runtime = createTemplateComm
|
|
|
7657
7709
|
if (!options.idempotencyKey) {
|
|
7658
7710
|
throw new UsageError(messages.idemRequired);
|
|
7659
7711
|
}
|
|
7660
|
-
const result = await
|
|
7661
|
-
projectId,
|
|
7662
|
-
templateId,
|
|
7663
|
-
options.idempotencyKey,
|
|
7664
|
-
{
|
|
7712
|
+
const result = await withScopeLoginGuidance(
|
|
7713
|
+
client.rollbackOnboardingTemplate(projectId, templateId, options.idempotencyKey, {
|
|
7665
7714
|
targetRevision,
|
|
7666
7715
|
scopeRiskReviewVersion: proof.scopeRiskReviewVersion,
|
|
7667
7716
|
scopeRiskReview: proof.scopeRiskReview,
|
|
7668
7717
|
expectedCurrentApplicationCommitment: proof.expectedCurrent,
|
|
7669
7718
|
planCommitment: proof.planCommitment,
|
|
7670
7719
|
confirmed: true
|
|
7671
|
-
}
|
|
7720
|
+
}),
|
|
7721
|
+
writer,
|
|
7722
|
+
locale,
|
|
7723
|
+
TEMPLATE_PROFILE,
|
|
7724
|
+
TEMPLATE_WRITE_SCOPES
|
|
7672
7725
|
);
|
|
7673
7726
|
const parsed = (0, import_tool_contract8.parseOnboardingTemplateApplyDto)(result);
|
|
7674
7727
|
if (parsed.projectId !== projectId || parsed.templateId !== templateId || parsed.operation !== "rollback" || parsed.rollbackFromRevision !== targetRevision || parsed.planCommitment !== proof.planCommitment || parsed.applicationCommitment === proof.expectedCurrent || JSON.stringify(parsed.scopeRiskReview) !== JSON.stringify(proof.scopeRiskReview)) {
|
|
@@ -7676,9 +7729,9 @@ async function runTemplateRollback(options, writer, runtime = createTemplateComm
|
|
|
7676
7729
|
}
|
|
7677
7730
|
json(writer, { mode: "rolled_back", ...parsed });
|
|
7678
7731
|
}
|
|
7679
|
-
function registerTemplate(program, writer, cwd, runtime = createTemplateCommandRuntime(), locale =
|
|
7680
|
-
const messages =
|
|
7681
|
-
const common =
|
|
7732
|
+
function registerTemplate(program, writer, cwd, runtime = createTemplateCommandRuntime(), locale = import_localization9.DEFAULT_LOCALE) {
|
|
7733
|
+
const messages = import_localization9.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
7734
|
+
const common = import_localization9.CLI_MESSAGES[locale].common;
|
|
7682
7735
|
const template = program.command("template").description(messages.templateDescription);
|
|
7683
7736
|
template.command("validate").description(messages.validateDescription).requiredOption("--file <path>", messages.templateFileOption).option("--bindings <path>", messages.bindingsOption).action((options) => {
|
|
7684
7737
|
const loaded = loadOnboardingTemplateArtifact(
|
|
@@ -7707,7 +7760,13 @@ function registerTemplate(program, writer, cwd, runtime = createTemplateCommandR
|
|
|
7707
7760
|
const templateId = canonicalTemplateId(options.template, messages);
|
|
7708
7761
|
const anchor = captureLocalRootPath(cwd());
|
|
7709
7762
|
const result = (0, import_tool_contract8.parseOnboardingTemplateExportDto)(
|
|
7710
|
-
await
|
|
7763
|
+
await withScopeLoginGuidance(
|
|
7764
|
+
runtime.createClient(options.profile).exportOnboardingTemplate(projectId, templateId),
|
|
7765
|
+
writer,
|
|
7766
|
+
locale,
|
|
7767
|
+
TEMPLATE_PROFILE,
|
|
7768
|
+
TEMPLATE_READ_SCOPES
|
|
7769
|
+
)
|
|
7711
7770
|
);
|
|
7712
7771
|
if (result.projectId !== projectId || result.manifest.templateId !== templateId) {
|
|
7713
7772
|
throw new UsageError(messages.exportMismatch);
|
|
@@ -7757,10 +7816,10 @@ var MANIFEST_KEYS2 = [
|
|
|
7757
7816
|
"template_id",
|
|
7758
7817
|
"template_application_commitment"
|
|
7759
7818
|
];
|
|
7760
|
-
var DEFAULT_INIT_MESSAGES =
|
|
7761
|
-
var DEFAULT_SCOPE_REGISTRATION_MESSAGES =
|
|
7819
|
+
var DEFAULT_INIT_MESSAGES = import_localization10.CLI_MESSAGES.ja.init;
|
|
7820
|
+
var DEFAULT_SCOPE_REGISTRATION_MESSAGES = import_localization10.OAUTH_SCOPE_REGISTRATION_MESSAGES.ja.cli;
|
|
7762
7821
|
var CONNECTOR_PLACEHOLDER = "<connector-uuid>";
|
|
7763
|
-
function assertTemplateInitOptionShape(options, messages = DEFAULT_INIT_MESSAGES, copy =
|
|
7822
|
+
function assertTemplateInitOptionShape(options, messages = DEFAULT_INIT_MESSAGES, copy = import_localization10.CLI_OPENAPI_TEMPLATE_MESSAGES.ja) {
|
|
7764
7823
|
if (options.openapi !== void 0 && options.project === void 0) {
|
|
7765
7824
|
throw new UsageError(messages.optionRequires("--openapi", "--project <uuid>"));
|
|
7766
7825
|
}
|
|
@@ -7827,14 +7886,14 @@ async function materializeOpenApiInit(options, anchor, runtime, messages, copy)
|
|
|
7827
7886
|
}
|
|
7828
7887
|
} catch (error) {
|
|
7829
7888
|
if (error instanceof import_tool_contract9.OpenApiImportError) {
|
|
7830
|
-
throw new UsageError((0,
|
|
7889
|
+
throw new UsageError((0, import_localization10.formatCliOpenApiTemplateMessage)(copy.generateFailure, { detail: error.message }));
|
|
7831
7890
|
}
|
|
7832
7891
|
throw error;
|
|
7833
7892
|
}
|
|
7834
7893
|
const blocked = imported.operations.filter((operation) => !operation.publishGate.ok);
|
|
7835
7894
|
if (blocked.length > 0) {
|
|
7836
7895
|
throw new UsageError(
|
|
7837
|
-
(0,
|
|
7896
|
+
(0, import_localization10.formatCliOpenApiTemplateMessage)(copy.initGateFailed, {
|
|
7838
7897
|
tools: blocked.map((operation) => operation.toolName).join(", ")
|
|
7839
7898
|
})
|
|
7840
7899
|
);
|
|
@@ -8390,8 +8449,8 @@ function assertIdempotencyKey(value, messages) {
|
|
|
8390
8449
|
}
|
|
8391
8450
|
return canonical;
|
|
8392
8451
|
}
|
|
8393
|
-
async function runInitCommand(options, writer, cwd, runtime, messages = DEFAULT_INIT_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES, locale =
|
|
8394
|
-
const copy =
|
|
8452
|
+
async function runInitCommand(options, writer, cwd, runtime, messages = DEFAULT_INIT_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8453
|
+
const copy = import_localization10.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
8395
8454
|
assertTemplateInitOptionShape(options, messages, copy);
|
|
8396
8455
|
if (options.template !== void 0 && options.project === void 0) {
|
|
8397
8456
|
throw new UsageError(copy.initProjectRequired);
|
|
@@ -8527,8 +8586,8 @@ async function runInitCommand(options, writer, cwd, runtime, messages = DEFAULT_
|
|
|
8527
8586
|
);
|
|
8528
8587
|
}
|
|
8529
8588
|
}
|
|
8530
|
-
function registerInit(program, writer, cwd, createClient, description = "Project\u3092\u660E\u793A\u9078\u629E\u307E\u305F\u306F\u4F5C\u6210\u3057\u3001\u5B89\u5168\u306Alocal manifest\u3078bind\u3057\u307E\u3059", runtime = void 0, messages = DEFAULT_INIT_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES, locale =
|
|
8531
|
-
const copy =
|
|
8589
|
+
function registerInit(program, writer, cwd, createClient, description = "Project\u3092\u660E\u793A\u9078\u629E\u307E\u305F\u306F\u4F5C\u6210\u3057\u3001\u5B89\u5168\u306Alocal manifest\u3078bind\u3057\u307E\u3059", runtime = void 0, messages = DEFAULT_INIT_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8590
|
+
const copy = import_localization10.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
8532
8591
|
const commandRuntime = runtime ?? createInitCommandRuntime(createClient, messages);
|
|
8533
8592
|
program.command("init").description(description).option("--project <project-uuid>", messages.projectOption).option("--create", messages.createOption).option("--name <name>", messages.nameOption).option("--slug <slug>", messages.slugOption).option("--contract <root-file>", messages.contractOption).option("--template <export-file>", copy.initTemplateOption).option("--openapi <file>", messages.openApiOption).option("--base-url <https-url>", messages.openApiBaseUrlOption).option("--service-name <name>", messages.openApiServiceNameOption).option("--auth-mode <mode>", copy.authModeOption).option(
|
|
8534
8593
|
"--side-effect-free <toolName=level>",
|
|
@@ -8536,7 +8595,7 @@ function registerInit(program, writer, cwd, createClient, description = "Project
|
|
|
8536
8595
|
(value, previous) => [...previous, value],
|
|
8537
8596
|
[]
|
|
8538
8597
|
).option("--create-connector", copy.initCreateConnectorOption, false).option("--profile <name>", messages.profileOption, DEFAULT_PROFILE_NAME).option("--yes", messages.yesOption, false).action(async (options) => {
|
|
8539
|
-
|
|
8598
|
+
const result = runInitCommand(
|
|
8540
8599
|
options,
|
|
8541
8600
|
writer,
|
|
8542
8601
|
cwd(),
|
|
@@ -8545,14 +8604,15 @@ function registerInit(program, writer, cwd, createClient, description = "Project
|
|
|
8545
8604
|
scopeRegistrationMessages,
|
|
8546
8605
|
locale
|
|
8547
8606
|
);
|
|
8607
|
+
await (options.template === void 0 ? result : withScopeLoginGuidance(result, writer, locale, DEFAULT_PROFILE_NAME));
|
|
8548
8608
|
});
|
|
8549
8609
|
}
|
|
8550
8610
|
|
|
8551
8611
|
// src/commands/logs.ts
|
|
8552
|
-
var
|
|
8553
|
-
function registerLogs(program, writer, locale =
|
|
8554
|
-
const messages =
|
|
8555
|
-
const logMessages =
|
|
8612
|
+
var import_localization11 = require("@andpipes/localization");
|
|
8613
|
+
function registerLogs(program, writer, locale = import_localization11.DEFAULT_LOCALE) {
|
|
8614
|
+
const messages = import_localization11.CLI_MESSAGES[locale];
|
|
8615
|
+
const logMessages = import_localization11.CLI_LOG_MESSAGES[locale];
|
|
8556
8616
|
const logs = program.command("logs").description(messages.logs.commandDescription);
|
|
8557
8617
|
logs.command("tail").description(messages.logs.tailDescription).requiredOption("--project <project>", messages.logs.projectOption).option("--limit <count>", logMessages.limitOption, "20").option("--profile <name>", messages.common.targetProfileOption, DEFAULT_PROFILE_NAME).action(async (opts) => {
|
|
8558
8618
|
if (!/^(0|[1-9][0-9]*)$/.test(opts.limit)) {
|
|
@@ -8571,15 +8631,15 @@ function registerLogs(program, writer, locale = import_localization10.DEFAULT_LO
|
|
|
8571
8631
|
var import_node_crypto12 = require("crypto");
|
|
8572
8632
|
var import_node_fs12 = require("fs");
|
|
8573
8633
|
var import_node_path13 = require("path");
|
|
8574
|
-
var
|
|
8634
|
+
var import_localization13 = require("@andpipes/localization");
|
|
8575
8635
|
var import_tool_contract10 = require("@andpipes/tool-contract");
|
|
8576
8636
|
|
|
8577
8637
|
// src/commands/validate.ts
|
|
8578
8638
|
var import_node_fs11 = require("fs");
|
|
8579
8639
|
var import_node_path12 = require("path");
|
|
8580
|
-
var
|
|
8581
|
-
function resolveContractPath(file, cwd, locale =
|
|
8582
|
-
const messages =
|
|
8640
|
+
var import_localization12 = require("@andpipes/localization");
|
|
8641
|
+
function resolveContractPath(file, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
8642
|
+
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
8583
8643
|
if (file) {
|
|
8584
8644
|
const abs = (0, import_node_path12.resolve)(cwd, file);
|
|
8585
8645
|
if (!(0, import_node_fs11.existsSync)(abs)) {
|
|
@@ -8595,9 +8655,9 @@ function resolveContractPath(file, cwd, locale = import_localization11.DEFAULT_L
|
|
|
8595
8655
|
}
|
|
8596
8656
|
throw new UsageError(messages.defaultFileNotFound(import_tool_contract4.CONTRACT_FILENAMES));
|
|
8597
8657
|
}
|
|
8598
|
-
function registerValidate(program, writer, cwd, locale =
|
|
8599
|
-
const text =
|
|
8600
|
-
const messages =
|
|
8658
|
+
function registerValidate(program, writer, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
8659
|
+
const text = import_localization12.LOCALIZED_TEXT[locale].cli;
|
|
8660
|
+
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
8601
8661
|
program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
|
|
8602
8662
|
const path = resolveContractPath(opts.file, cwd(), locale);
|
|
8603
8663
|
const loaded = loadContractFile(path);
|
|
@@ -8647,13 +8707,13 @@ var REASON_KEYS = {
|
|
|
8647
8707
|
};
|
|
8648
8708
|
function parseToolNames(value, locale) {
|
|
8649
8709
|
const names = (value ?? "").split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
8650
|
-
if (names.length === 0) throw new UsageError(
|
|
8710
|
+
if (names.length === 0) throw new UsageError(import_localization13.MUSE_SETUP_MESSAGES[locale].cli.toolsRequired);
|
|
8651
8711
|
return names;
|
|
8652
8712
|
}
|
|
8653
8713
|
function parseOutputDir(value, locale) {
|
|
8654
8714
|
const output = value ?? DEFAULT_MUSE_OUTPUT_DIR;
|
|
8655
8715
|
if (!OUTPUT_DIR_RE.test(output) || output === "." || output === "..") {
|
|
8656
|
-
throw new UsageError(
|
|
8716
|
+
throw new UsageError(import_localization13.MUSE_SETUP_MESSAGES[locale].cli.outputInvalid);
|
|
8657
8717
|
}
|
|
8658
8718
|
return output;
|
|
8659
8719
|
}
|
|
@@ -8686,7 +8746,7 @@ function museWriteOrder(paths) {
|
|
|
8686
8746
|
);
|
|
8687
8747
|
}
|
|
8688
8748
|
function writeBundle(root, output, files, locale) {
|
|
8689
|
-
const messages =
|
|
8749
|
+
const messages = import_localization13.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8690
8750
|
const target = (0, import_node_path13.join)(root, output);
|
|
8691
8751
|
const ordered = museWriteOrder(Object.keys(files));
|
|
8692
8752
|
const directoryNames = /* @__PURE__ */ new Set();
|
|
@@ -8729,8 +8789,8 @@ function writeBundle(root, output, files, locale) {
|
|
|
8729
8789
|
throw new UsageError(`${messages.outputIncomplete(output)}${reason}`);
|
|
8730
8790
|
}
|
|
8731
8791
|
}
|
|
8732
|
-
function runMusePrepare(options, writer, cwd, locale =
|
|
8733
|
-
const messages =
|
|
8792
|
+
function runMusePrepare(options, writer, cwd, locale = import_localization13.DEFAULT_LOCALE) {
|
|
8793
|
+
const messages = import_localization13.MUSE_SETUP_MESSAGES[locale];
|
|
8734
8794
|
const toolNames = parseToolNames(options.tools, locale);
|
|
8735
8795
|
const output = parseOutputDir(options.output, locale);
|
|
8736
8796
|
const anchor = captureLocalRootPath(cwd);
|
|
@@ -8771,7 +8831,7 @@ function runMusePrepare(options, writer, cwd, locale = import_localization12.DEF
|
|
|
8771
8831
|
if (key) info(writer, ` ${output}/${path}: ${messages.files[key]}`);
|
|
8772
8832
|
}
|
|
8773
8833
|
info(writer, `${messages.cli.statesHeading}:`);
|
|
8774
|
-
for (const key of
|
|
8834
|
+
for (const key of import_localization13.MUSE_SETUP_STATE_KEYS) {
|
|
8775
8835
|
const state = messages.states[key];
|
|
8776
8836
|
info(
|
|
8777
8837
|
writer,
|
|
@@ -8780,8 +8840,8 @@ function runMusePrepare(options, writer, cwd, locale = import_localization12.DEF
|
|
|
8780
8840
|
}
|
|
8781
8841
|
info(writer, messages.cli.nextStep);
|
|
8782
8842
|
}
|
|
8783
|
-
function registerMuse(program, writer, cwd, locale =
|
|
8784
|
-
const messages =
|
|
8843
|
+
function registerMuse(program, writer, cwd, locale = import_localization13.DEFAULT_LOCALE) {
|
|
8844
|
+
const messages = import_localization13.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8785
8845
|
const muse = program.command("muse").description(messages.groupDescription);
|
|
8786
8846
|
muse.command("prepare").description(messages.prepareDescription).option(
|
|
8787
8847
|
"--tools <names>",
|
|
@@ -8793,20 +8853,20 @@ function registerMuse(program, writer, cwd, locale = import_localization12.DEFAU
|
|
|
8793
8853
|
// src/commands/oauth.ts
|
|
8794
8854
|
var import_node_crypto14 = require("crypto");
|
|
8795
8855
|
var import_node_fs13 = require("fs");
|
|
8796
|
-
var
|
|
8856
|
+
var import_localization15 = require("@andpipes/localization");
|
|
8797
8857
|
var import_tool_contract12 = require("@andpipes/tool-contract");
|
|
8798
8858
|
|
|
8799
8859
|
// src/commands/publish.ts
|
|
8800
8860
|
var import_node_crypto13 = require("crypto");
|
|
8801
|
-
var
|
|
8861
|
+
var import_localization14 = require("@andpipes/localization");
|
|
8802
8862
|
var import_tool_contract11 = require("@andpipes/tool-contract");
|
|
8803
8863
|
var UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
8804
8864
|
var SAFE_AP_CODE_RE2 = /^AP_[A-Z0-9_]{1,64}$/u;
|
|
8805
8865
|
var PUBLICATION_RESPONSE_MAX_BYTES = 96 * 1024;
|
|
8806
8866
|
var INITIAL_APPLY_MAX_ATTEMPTS = 3;
|
|
8807
|
-
var DEFAULT_PUBLISH_MESSAGES =
|
|
8808
|
-
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 =
|
|
8809
|
-
var DEFAULT_SCHEMA_REVIEW_MESSAGES =
|
|
8867
|
+
var DEFAULT_PUBLISH_MESSAGES = import_localization14.CLI_MESSAGES.ja.publish;
|
|
8868
|
+
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 = import_localization14.OAUTH_SCOPE_REGISTRATION_MESSAGES.ja.cli;
|
|
8869
|
+
var DEFAULT_SCHEMA_REVIEW_MESSAGES = import_localization14.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES.ja;
|
|
8810
8870
|
var REVIEW_PROFILE_REQUEST = Object.freeze({
|
|
8811
8871
|
reviewProfile: CLI_PUBLICATION_REVIEW_PROFILE
|
|
8812
8872
|
});
|
|
@@ -9304,7 +9364,7 @@ function writeSafeJson(writer, value) {
|
|
|
9304
9364
|
json(writer, terminalSafeValue(value));
|
|
9305
9365
|
}
|
|
9306
9366
|
function writePlan(writer, plan, messages) {
|
|
9307
|
-
const copy = messages.scopeRiskCopy ??
|
|
9367
|
+
const copy = messages.scopeRiskCopy ?? import_localization14.CLI_SCOPE_RISK_SUMMARY.ja;
|
|
9308
9368
|
writeSafeJson(writer, { phase: "plan", ...plan });
|
|
9309
9369
|
for (const item of plan.scopeRiskReview.items)
|
|
9310
9370
|
interactive(
|
|
@@ -9771,8 +9831,8 @@ function isUrl(value) {
|
|
|
9771
9831
|
function field(meta, snake, camel) {
|
|
9772
9832
|
return snake in meta ? meta[snake] : meta[camel];
|
|
9773
9833
|
}
|
|
9774
|
-
function validateOAuthMetadata(meta, locale =
|
|
9775
|
-
const messages =
|
|
9834
|
+
function validateOAuthMetadata(meta, locale = import_localization15.DEFAULT_LOCALE) {
|
|
9835
|
+
const messages = import_localization15.CLI_MESSAGES[locale].oauth;
|
|
9776
9836
|
const results = [];
|
|
9777
9837
|
if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
|
|
9778
9838
|
return {
|
|
@@ -9866,9 +9926,9 @@ function parseDraftOption(value, messages) {
|
|
|
9866
9926
|
}
|
|
9867
9927
|
return { toolId, versionId };
|
|
9868
9928
|
}
|
|
9869
|
-
function normalizeOAuthScopeRegisterOptions(options, locale =
|
|
9870
|
-
const messages =
|
|
9871
|
-
const cliMessages =
|
|
9929
|
+
function normalizeOAuthScopeRegisterOptions(options, locale = import_localization15.DEFAULT_LOCALE) {
|
|
9930
|
+
const messages = import_localization15.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9931
|
+
const cliMessages = import_localization15.CLI_MESSAGES[locale];
|
|
9872
9932
|
const apply = options.apply === true;
|
|
9873
9933
|
if (options.yes === true && !apply) throw new UsageError(messages.yesRequiresApply);
|
|
9874
9934
|
if (apply && options.yes !== true) {
|
|
@@ -10013,8 +10073,8 @@ async function projectAccessibility(client, projectId, error) {
|
|
|
10013
10073
|
}
|
|
10014
10074
|
}
|
|
10015
10075
|
function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
10016
|
-
const messages =
|
|
10017
|
-
const publishMessages =
|
|
10076
|
+
const messages = import_localization15.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
10077
|
+
const publishMessages = import_localization15.CLI_MESSAGES[locale].publish;
|
|
10018
10078
|
const project = loadPublicationProject(runtime.loadProject, cwd, publishMessages);
|
|
10019
10079
|
const projectId = assertManifestProject(project, normalized.projectId, publishMessages);
|
|
10020
10080
|
const connectorId = normalized.connectorId ?? project.manifest.connector_id;
|
|
@@ -10043,8 +10103,8 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
|
10043
10103
|
expectedToolNames: candidate.expectedToolNames
|
|
10044
10104
|
};
|
|
10045
10105
|
}
|
|
10046
|
-
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale =
|
|
10047
|
-
const messages =
|
|
10106
|
+
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale = import_localization15.DEFAULT_LOCALE) {
|
|
10107
|
+
const messages = import_localization15.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale];
|
|
10048
10108
|
const normalized = normalizeOAuthScopeRegisterOptions(options, locale);
|
|
10049
10109
|
const target = normalized.kind === "saved_drafts" ? {
|
|
10050
10110
|
projectId: normalized.projectId,
|
|
@@ -10092,7 +10152,7 @@ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, local
|
|
|
10092
10152
|
throw new OAuthScopeRegistrationCommandError(
|
|
10093
10153
|
"AP_NETWORK_ERROR",
|
|
10094
10154
|
"secure_random_invalid",
|
|
10095
|
-
|
|
10155
|
+
import_localization15.CLI_MESSAGES[locale].publish.failure("secure_random_invalid")
|
|
10096
10156
|
);
|
|
10097
10157
|
}
|
|
10098
10158
|
let applied;
|
|
@@ -10113,18 +10173,18 @@ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, local
|
|
|
10113
10173
|
writeRegistrationSummary(writer, applied, true, messages);
|
|
10114
10174
|
return { ok: true };
|
|
10115
10175
|
}
|
|
10116
|
-
function upstreamOAuthWizardUrl(profile, projectId, connectorId, locale =
|
|
10176
|
+
function upstreamOAuthWizardUrl(profile, projectId, connectorId, locale = import_localization15.DEFAULT_LOCALE) {
|
|
10117
10177
|
const record = getProfile(profile);
|
|
10118
10178
|
if (!record)
|
|
10119
10179
|
throw new UsageError(
|
|
10120
|
-
(0,
|
|
10180
|
+
(0, import_localization15.formatCliOpenApiTemplateMessage)(import_localization15.CLI_OAUTH_DOCTOR_MESSAGES[locale].oauth.profileMissing, { profile })
|
|
10121
10181
|
);
|
|
10122
10182
|
const url = new URL(`/projects/${projectId}/oauth`, new URL(record.verificationUriBase).origin);
|
|
10123
10183
|
url.searchParams.set("connector", connectorId);
|
|
10124
10184
|
return url.toString();
|
|
10125
10185
|
}
|
|
10126
10186
|
async function loadOAuthMetadata(opts, locale) {
|
|
10127
|
-
const messages =
|
|
10187
|
+
const messages = import_localization15.CLI_MESSAGES[locale];
|
|
10128
10188
|
if (opts.file && opts.issuer) {
|
|
10129
10189
|
throw new UsageError(messages.init.incompatibleOptions("--file / --issuer"));
|
|
10130
10190
|
}
|
|
@@ -10141,7 +10201,7 @@ async function loadOAuthMetadata(opts, locale) {
|
|
|
10141
10201
|
}
|
|
10142
10202
|
}
|
|
10143
10203
|
async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
10144
|
-
const messages =
|
|
10204
|
+
const messages = import_localization15.CLI_MESSAGES[locale];
|
|
10145
10205
|
const parsed = await loadOAuthMetadata(opts, locale);
|
|
10146
10206
|
const report = validateOAuthMetadata(parsed, locale);
|
|
10147
10207
|
json(writer, report.results);
|
|
@@ -10152,9 +10212,9 @@ async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
|
10152
10212
|
info(writer, messages.oauth.metadataOk);
|
|
10153
10213
|
}
|
|
10154
10214
|
}
|
|
10155
|
-
function registerOauth(program, writer, locale =
|
|
10156
|
-
const messages =
|
|
10157
|
-
const copy =
|
|
10215
|
+
function registerOauth(program, writer, locale = import_localization15.DEFAULT_LOCALE, dependencies = {}) {
|
|
10216
|
+
const messages = import_localization15.CLI_MESSAGES[locale];
|
|
10217
|
+
const copy = import_localization15.CLI_OAUTH_DOCTOR_MESSAGES[locale].oauth;
|
|
10158
10218
|
const oauth = program.command("oauth").description(messages.oauth.commandDescription);
|
|
10159
10219
|
oauth.command("init").description(messages.oauth.initDescription).requiredOption("--provider <name>", messages.oauth.providerOption).action((opts) => {
|
|
10160
10220
|
info(writer, messages.oauth.templateHeading(opts.provider));
|
|
@@ -10197,7 +10257,7 @@ function registerOauth(program, writer, locale = import_localization14.DEFAULT_L
|
|
|
10197
10257
|
});
|
|
10198
10258
|
json(writer, result);
|
|
10199
10259
|
});
|
|
10200
|
-
const registration =
|
|
10260
|
+
const registration = import_localization15.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
10201
10261
|
const scopeRegisterRuntime = dependencies.scopeRegisterRuntime ?? createOAuthScopeRegisterRuntime();
|
|
10202
10262
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
10203
10263
|
scopes.command("register").description(registration.commandDescription).option("--project <project-uuid>", registration.projectOption).option("--connector <connector-uuid>", registration.connectorOption).option(
|
|
@@ -10304,7 +10364,7 @@ function registerOauth(program, writer, locale = import_localization14.DEFAULT_L
|
|
|
10304
10364
|
}).getUpstreamOAuthConnectionState(projectId, opts.connector);
|
|
10305
10365
|
json(writer, state);
|
|
10306
10366
|
const url = upstreamOAuthWizardUrl(opts.profile, projectId, opts.connector, locale);
|
|
10307
|
-
info(writer, (0,
|
|
10367
|
+
info(writer, (0, import_localization15.formatCliOpenApiTemplateMessage)(copy.continueInAdmin, { url }));
|
|
10308
10368
|
if (opts.browser) {
|
|
10309
10369
|
try {
|
|
10310
10370
|
(dependencies.openBrowser ?? openBrowser)(url);
|
|
@@ -10327,7 +10387,7 @@ function registerOauth(program, writer, locale = import_localization14.DEFAULT_L
|
|
|
10327
10387
|
// src/commands/openapi.ts
|
|
10328
10388
|
var import_node_crypto15 = require("crypto");
|
|
10329
10389
|
var import_node_path14 = require("path");
|
|
10330
|
-
var
|
|
10390
|
+
var import_localization16 = require("@andpipes/localization");
|
|
10331
10391
|
var import_tool_contract13 = require("@andpipes/tool-contract");
|
|
10332
10392
|
function createOpenApiImportRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
10333
10393
|
return { createClient, idempotencyKey: import_node_crypto15.randomUUID };
|
|
@@ -10345,13 +10405,13 @@ function normalizedOptions(options, text) {
|
|
|
10345
10405
|
const apply = options.apply === true;
|
|
10346
10406
|
const yes = options.yes === true;
|
|
10347
10407
|
if (yes && !apply) {
|
|
10348
|
-
throw new UsageError((0,
|
|
10408
|
+
throw new UsageError((0, import_localization16.formatCliOpenApiTemplateMessage)(text.requiresApply, { flags: "--yes" }));
|
|
10349
10409
|
}
|
|
10350
10410
|
if (options.idempotencyKey !== void 0 && !apply) {
|
|
10351
|
-
throw new UsageError((0,
|
|
10411
|
+
throw new UsageError((0, import_localization16.formatCliOpenApiTemplateMessage)(text.requiresApply, { flags: "--idempotency-key" }));
|
|
10352
10412
|
}
|
|
10353
10413
|
if (!apply && options.planCommitment !== void 0) {
|
|
10354
|
-
throw new UsageError((0,
|
|
10414
|
+
throw new UsageError((0, import_localization16.formatCliOpenApiTemplateMessage)(text.requiresApply, { flags: "--plan-commitment" }));
|
|
10355
10415
|
}
|
|
10356
10416
|
return {
|
|
10357
10417
|
file: options.file,
|
|
@@ -10375,8 +10435,8 @@ function rethrowWithAuthModeGuidance(error, text) {
|
|
|
10375
10435
|
}
|
|
10376
10436
|
throw error;
|
|
10377
10437
|
}
|
|
10378
|
-
async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpenApiImportRuntime(), locale =
|
|
10379
|
-
const text =
|
|
10438
|
+
async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpenApiImportRuntime(), locale = import_localization16.DEFAULT_LOCALE) {
|
|
10439
|
+
const text = import_localization16.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
10380
10440
|
const normalized = normalizedOptions(options, text);
|
|
10381
10441
|
if (normalized.apply && !normalized.yes) {
|
|
10382
10442
|
throw new ConfirmationRequiredError("andpipe openapi import --apply", text.openapiConfirm);
|
|
@@ -10419,7 +10479,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
10419
10479
|
);
|
|
10420
10480
|
} catch (error) {
|
|
10421
10481
|
if (error instanceof import_tool_contract13.OpenApiImportError) {
|
|
10422
|
-
throw new UsageError((0,
|
|
10482
|
+
throw new UsageError((0, import_localization16.formatCliOpenApiTemplateMessage)(text.generateFailure, { detail: error.message }));
|
|
10423
10483
|
}
|
|
10424
10484
|
throw error;
|
|
10425
10485
|
}
|
|
@@ -10461,9 +10521,9 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
10461
10521
|
function collect(value, previous) {
|
|
10462
10522
|
return [...previous, value];
|
|
10463
10523
|
}
|
|
10464
|
-
function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRuntime(), locale =
|
|
10465
|
-
const text =
|
|
10466
|
-
const common =
|
|
10524
|
+
function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRuntime(), locale = import_localization16.DEFAULT_LOCALE) {
|
|
10525
|
+
const text = import_localization16.CLI_OPENAPI_TEMPLATE_MESSAGES[locale];
|
|
10526
|
+
const common = import_localization16.CLI_MESSAGES[locale].common;
|
|
10467
10527
|
const openapi = program.command("openapi").description(text.openapiDescription);
|
|
10468
10528
|
openapi.command("import").description(text.importDescription).requiredOption("--file <path>", text.sourceFileOption).requiredOption("--project <uuid>", common.projectOption).requiredOption("--connector <uuid>", text.connectorOption).option("--profile <name>", common.targetProfileOption, DEFAULT_PROFILE_NAME).option("--format <format>", text.formatOption).option("--base-url <url>", text.baseUrlOption).option("--service-name <name>", text.serviceNameOption).option("--apply", text.openapiApplyOption, false).option("--yes", text.openapiYesOption, false).option("--idempotency-key <key>", text.idempotencyOption).option("--plan-commitment <sha256>", text.openapiPlanOption).option("--auth-mode <mode>", text.authModeOption).option("--side-effect-free <toolName=level>", text.sideEffectOption, collect, []).action(
|
|
10469
10529
|
(options) => runOpenApiImportCommand(options, writer, cwd(), runtime, locale)
|
|
@@ -10471,16 +10531,16 @@ function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRunt
|
|
|
10471
10531
|
}
|
|
10472
10532
|
|
|
10473
10533
|
// src/commands/review-package.ts
|
|
10474
|
-
var
|
|
10534
|
+
var import_localization17 = require("@andpipes/localization");
|
|
10475
10535
|
var TARGETS = ["chatgpt", "claude", "generic_mcp"];
|
|
10476
|
-
function assertTarget(value, locale =
|
|
10536
|
+
function assertTarget(value, locale = import_localization17.DEFAULT_LOCALE) {
|
|
10477
10537
|
if (!TARGETS.includes(value)) {
|
|
10478
|
-
throw new UsageError(
|
|
10538
|
+
throw new UsageError(import_localization17.CLI_MESSAGES[locale].reviewPackage.invalidTarget(value, TARGETS));
|
|
10479
10539
|
}
|
|
10480
10540
|
}
|
|
10481
|
-
function registerReviewPackage(program, writer, locale =
|
|
10482
|
-
const messages =
|
|
10483
|
-
const guidance =
|
|
10541
|
+
function registerReviewPackage(program, writer, locale = import_localization17.DEFAULT_LOCALE, cwd = () => process.cwd()) {
|
|
10542
|
+
const messages = import_localization17.CLI_MESSAGES[locale];
|
|
10543
|
+
const guidance = import_localization17.REVIEW_PACKAGE_GUIDANCE[locale];
|
|
10484
10544
|
const reviewPackage = program.command("review-package").description(messages.reviewPackage.commandDescription);
|
|
10485
10545
|
reviewPackage.command("generate").description(messages.reviewPackage.generateDescription).requiredOption("--project <project>", messages.common.projectOption).requiredOption("--package-version <version>", messages.reviewPackage.packageVersionOption).option("--target <target>", messages.reviewPackage.targetOption).option("--from-template", guidance.fromTemplateOption, false).option("--profile <name>", messages.common.targetProfileOption, DEFAULT_PROFILE_NAME).option("--yes", messages.domain.yesOption, false).action(
|
|
10486
10546
|
async (opts) => {
|
|
@@ -10538,12 +10598,12 @@ function registerReviewPackage(program, writer, locale = import_localization16.D
|
|
|
10538
10598
|
}
|
|
10539
10599
|
|
|
10540
10600
|
// src/cli.ts
|
|
10541
|
-
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0,
|
|
10542
|
-
const text =
|
|
10543
|
-
const messages =
|
|
10544
|
-
const scopeRegistrationMessages =
|
|
10601
|
+
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0, import_localization18.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG)) {
|
|
10602
|
+
const text = import_localization18.LOCALIZED_TEXT[locale].cli;
|
|
10603
|
+
const messages = import_localization18.CLI_MESSAGES[locale];
|
|
10604
|
+
const scopeRegistrationMessages = import_localization18.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
10545
10605
|
const program = new import_commander.Command();
|
|
10546
|
-
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption,
|
|
10606
|
+
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption, import_localization18.DEFAULT_LOCALE).version(readVersion());
|
|
10547
10607
|
registerAuth(program, writer, locale);
|
|
10548
10608
|
registerAuditExport(program, writer, locale);
|
|
10549
10609
|
registerInit(
|
|
@@ -10577,20 +10637,20 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
|
|
|
10577
10637
|
void 0,
|
|
10578
10638
|
messages.publish,
|
|
10579
10639
|
scopeRegistrationMessages,
|
|
10580
|
-
|
|
10640
|
+
import_localization18.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES[locale]
|
|
10581
10641
|
);
|
|
10582
10642
|
return program;
|
|
10583
10643
|
}
|
|
10584
10644
|
function localeFromArgv(argv) {
|
|
10585
10645
|
const localeIndex = argv.indexOf("--locale");
|
|
10586
10646
|
if (localeIndex >= 0) {
|
|
10587
|
-
return (0,
|
|
10647
|
+
return (0, import_localization18.normalizeLocale)(argv[localeIndex + 1]);
|
|
10588
10648
|
}
|
|
10589
10649
|
const inlineLocale = argv.find((arg) => arg.startsWith("--locale="));
|
|
10590
10650
|
if (inlineLocale) {
|
|
10591
|
-
return (0,
|
|
10651
|
+
return (0, import_localization18.normalizeLocale)(inlineLocale.slice("--locale=".length));
|
|
10592
10652
|
}
|
|
10593
|
-
return (0,
|
|
10653
|
+
return (0, import_localization18.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG);
|
|
10594
10654
|
}
|
|
10595
10655
|
async function runCli(argv, writer = defaultWriter) {
|
|
10596
10656
|
await buildProgram(writer, () => process.cwd(), localeFromArgv(argv)).parseAsync(argv);
|