@continuous-excellence/ze-great-dashboard-aws 0.14.4 → 0.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // packages/aws/src/cli.ts
4
+ import { execFile as execFile3 } from "node:child_process";
4
5
  import { readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
5
6
  import { fileURLToPath as fileURLToPath3 } from "node:url";
7
+ import { promisify as promisify3 } from "node:util";
6
8
  import { parse as parse3 } from "yaml";
7
9
 
8
10
  // packages/aws/src/doctor.ts
@@ -1538,7 +1540,7 @@ function changeSetCommands(input) {
1538
1540
  }
1539
1541
  var githubOidcProvider = {
1540
1542
  name: "github-oidc",
1541
- async prerequisite(config, runner) {
1543
+ async prerequisite(config, runner2) {
1542
1544
  const repository = config.githubOidc?.repository;
1543
1545
  if (!repository)
1544
1546
  return {
@@ -1546,7 +1548,7 @@ var githubOidcProvider = {
1546
1548
  blocking: false,
1547
1549
  detail: "GitHub repository is absent from the manifest."
1548
1550
  };
1549
- if (!runner)
1551
+ if (!runner2)
1550
1552
  return {
1551
1553
  status: "unverified",
1552
1554
  blocking: false,
@@ -1554,7 +1556,7 @@ var githubOidcProvider = {
1554
1556
  };
1555
1557
  try {
1556
1558
  const response = JSON.parse(
1557
- await runner.execute("gh", ["api", `repos/${repository}/actions/oidc/customization/sub`])
1559
+ await runner2.execute("gh", ["api", `repos/${repository}/actions/oidc/customization/sub`])
1558
1560
  );
1559
1561
  const keys = response.include_claim_keys;
1560
1562
  if (response.use_default === false && Array.isArray(keys) && githubSubjectKeys.every((key) => keys.includes(key)))
@@ -1850,10 +1852,10 @@ function repositoryParts(repository) {
1850
1852
  function accountFromArn(arn) {
1851
1853
  return arn.match(/^arn:[^:]+:iam::(\d+):oidc-provider\//)?.[1];
1852
1854
  }
1853
- async function optional(runner, command, args2) {
1854
- if (!runner) return void 0;
1855
+ async function optional(runner2, command, args2) {
1856
+ if (!runner2) return void 0;
1855
1857
  try {
1856
- return await runner.execute(command, args2);
1858
+ return await runner2.execute(command, args2);
1857
1859
  } catch {
1858
1860
  return void 0;
1859
1861
  }
@@ -1961,8 +1963,8 @@ async function bootstrapPreflight(input) {
1961
1963
  nextOperation: "Complete the missing manifest fields, then rerun bootstrap preflight."
1962
1964
  })
1963
1965
  };
1964
- const runner = input.runner;
1965
- const identityRaw = await optional(runner, "aws", [
1966
+ const runner2 = input.runner;
1967
+ const identityRaw = await optional(runner2, "aws", [
1966
1968
  "sts",
1967
1969
  "get-caller-identity",
1968
1970
  "--output",
@@ -1988,7 +1990,7 @@ async function bootstrapPreflight(input) {
1988
1990
  detail: `AWS account ${identity.Account} does not match provider account ${providerAccount}.`
1989
1991
  }
1990
1992
  );
1991
- const regionRaw = await optional(runner, "aws", ["configure", "get", "region"]);
1993
+ const regionRaw = await optional(runner2, "aws", ["configure", "get", "region"]);
1992
1994
  if (!regionRaw?.trim())
1993
1995
  checks.push({
1994
1996
  name: "aws-region",
@@ -2003,7 +2005,7 @@ async function bootstrapPreflight(input) {
2003
2005
  detail: `AWS Region ${regionRaw.trim()} does not match manifest ${input.config.region}.`
2004
2006
  }
2005
2007
  );
2006
- const providerRaw = await optional(runner, "aws", [
2008
+ const providerRaw = await optional(runner2, "aws", [
2007
2009
  "iam",
2008
2010
  "get-open-id-connect-provider",
2009
2011
  "--open-id-connect-provider-arn",
@@ -2017,7 +2019,7 @@ async function bootstrapPreflight(input) {
2017
2019
  } : absent(providerRaw) ? { name: "oidc-provider", status: "missing", detail: "OIDC provider does not exist." } : { name: "oidc-provider", status: "ready", detail: "OIDC provider exists." }
2018
2020
  );
2019
2021
  const repository = input.config.githubOidc?.repository ?? "";
2020
- const repoRaw = await optional(runner, "gh", ["api", `repos/${repository}`]);
2022
+ const repoRaw = await optional(runner2, "gh", ["api", `repos/${repository}`]);
2021
2023
  const repo = parseOrUnavailable(repoRaw);
2022
2024
  if (!repoRaw)
2023
2025
  checks.push({
@@ -2043,7 +2045,7 @@ async function bootstrapPreflight(input) {
2043
2045
  status: "ready",
2044
2046
  detail: "GitHub repository identity matches the manifest."
2045
2047
  });
2046
- const environmentRaw = await optional(runner, "gh", [
2048
+ const environmentRaw = await optional(runner2, "gh", [
2047
2049
  "api",
2048
2050
  `repos/${repository}/environments/${input.config.githubOidc?.environment}`
2049
2051
  ]);
@@ -2062,7 +2064,7 @@ async function bootstrapPreflight(input) {
2062
2064
  detail: "GitHub Environment exists; its policy is administrator-owned context."
2063
2065
  }
2064
2066
  );
2065
- const subject = await (input.provider ?? githubOidcProvider).prerequisite(input.config, runner);
2067
+ const subject = await (input.provider ?? githubOidcProvider).prerequisite(input.config, runner2);
2066
2068
  checks.push({
2067
2069
  name: "immutable-subject",
2068
2070
  status: subject.status === "immutable-subject-required" ? "mismatch" : subject.status,
@@ -2082,9 +2084,8 @@ async function bootstrapPreflight(input) {
2082
2084
  function quote(args2) {
2083
2085
  return args2.map((arg) => `'${arg.replaceAll("'", `'\\"'\\"'`)}'`).join(" ");
2084
2086
  }
2085
- async function bootstrapGuide(input) {
2086
- const handoff = await bootstrapHandoff(input);
2087
- const plan = await bootstrapPlan(input.config);
2087
+ async function bootstrapGuideReport(input) {
2088
+ const [handoff, plan] = await Promise.all([bootstrapHandoff(input), bootstrapPlan(input.config)]);
2088
2089
  const lines = [
2089
2090
  `Phase: ${handoff.phase}`,
2090
2091
  `Package version: ${plan.packageVersion}`,
@@ -2122,8 +2123,8 @@ async function bootstrapGuide(input) {
2122
2123
  for (const command of verified.githubEnvironmentInstructions) lines.push(quote(command));
2123
2124
  }
2124
2125
  lines.push("", ...formatBootstrapRemediationText(plan.remediation));
2125
- return `${lines.join("\n")}
2126
- `;
2126
+ return { handoff, plan, guide: `${lines.join("\n")}
2127
+ ` };
2127
2128
  }
2128
2129
 
2129
2130
  // packages/aws/src/index.ts
@@ -2468,6 +2469,7 @@ async function runDoctor(options, dependencies = actualDependencies) {
2468
2469
 
2469
2470
  // packages/aws/src/cli.ts
2470
2471
  var args = process.argv.slice(2);
2472
+ var runCommand = promisify3(execFile3);
2471
2473
  var option = (name, fallback) => {
2472
2474
  const i2 = args.indexOf(name);
2473
2475
  return i2 >= 0 ? args[i2 + 1] : fallback;
@@ -2571,6 +2573,24 @@ function printBootstrap(value2, text, shell, defaultFormat = "json") {
2571
2573
  } else if (format === "text") console.log(text);
2572
2574
  else console.log(JSON.stringify(value2));
2573
2575
  }
2576
+ var runner = {
2577
+ async execute(command, commandArgs) {
2578
+ return (await runCommand(command, commandArgs)).stdout.trim();
2579
+ }
2580
+ };
2581
+ var preflightRunner = {
2582
+ async execute(command, commandArgs) {
2583
+ try {
2584
+ return await runner.execute(command, commandArgs);
2585
+ } catch (error) {
2586
+ if (error && typeof error === "object" && "stderr" in error) {
2587
+ const stderr = error.stderr;
2588
+ if (typeof stderr === "string" && /not found|404|nosuchentity/i.test(stderr)) return stderr;
2589
+ }
2590
+ throw error;
2591
+ }
2592
+ }
2593
+ };
2574
2594
  async function templateParameters(mode = "lambda") {
2575
2595
  const template = await cloudFormationTemplate(mode);
2576
2596
  const block = template.match(/^Parameters:\n[\s\S]*?(?=^[A-Za-z][A-Za-z0-9]*:\s*$)/m)?.[0];
@@ -2694,11 +2714,7 @@ try {
2694
2714
  githubOidcStackPath: option("--github-oidc-stack-json")
2695
2715
  },
2696
2716
  {
2697
- async execute(command, commandArgs) {
2698
- const { execFile: execFile3 } = await import("node:child_process");
2699
- const { promisify: promisify3 } = await import("node:util");
2700
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2701
- },
2717
+ execute: runner.execute,
2702
2718
  async fetch(url) {
2703
2719
  return fetch(url);
2704
2720
  },
@@ -2772,13 +2788,6 @@ try {
2772
2788
  if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT"))
2773
2789
  throw error;
2774
2790
  }
2775
- const runner = {
2776
- async execute(command, commandArgs) {
2777
- const { execFile: execFile3 } = await import("node:child_process");
2778
- const { promisify: promisify3 } = await import("node:util");
2779
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2780
- }
2781
- };
2782
2791
  const manifest = await scaffoldBootstrapManifest({
2783
2792
  slug: requiredOption("--slug"),
2784
2793
  repository: requiredOption("--repository"),
@@ -2802,23 +2811,7 @@ try {
2802
2811
  const config = await bootstrapConfig();
2803
2812
  if (action === "preflight") {
2804
2813
  requiredOption("--config");
2805
- const runner = {
2806
- async execute(command, commandArgs) {
2807
- const { execFile: execFile3 } = await import("node:child_process");
2808
- const { promisify: promisify3 } = await import("node:util");
2809
- try {
2810
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2811
- } catch (error) {
2812
- if (error && typeof error === "object" && "stderr" in error) {
2813
- const stderr = error.stderr;
2814
- if (typeof stderr === "string" && /not found|404|nosuchentity/i.test(stderr))
2815
- return stderr;
2816
- }
2817
- throw error;
2818
- }
2819
- }
2820
- };
2821
- const result = await bootstrapPreflight({ config, runner });
2814
+ const result = await bootstrapPreflight({ config, runner: preflightRunner });
2822
2815
  printBootstrap(
2823
2816
  result,
2824
2817
  [
@@ -2834,24 +2827,7 @@ try {
2834
2827
  const configPath = requiredOption("--config");
2835
2828
  const coreStackPath = option("--core-stack-json");
2836
2829
  const githubStackPath = option("--github-oidc-stack-json");
2837
- const runner = {
2838
- async execute(command, commandArgs) {
2839
- const { execFile: execFile3 } = await import("node:child_process");
2840
- const { promisify: promisify3 } = await import("node:util");
2841
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2842
- }
2843
- };
2844
- const handoff = await bootstrapHandoff({
2845
- config,
2846
- configPath,
2847
- workDir: option("--work-dir"),
2848
- coreStack: coreStackPath ? JSON.parse(await readFile5(coreStackPath, "utf8")) : void 0,
2849
- coreStackPath,
2850
- githubOidcStack: githubStackPath ? JSON.parse(await readFile5(githubStackPath, "utf8")) : void 0,
2851
- githubOidcStackPath: githubStackPath,
2852
- runner
2853
- });
2854
- const guide = await bootstrapGuide({
2830
+ const report = await bootstrapGuideReport({
2855
2831
  config,
2856
2832
  configPath,
2857
2833
  workDir: option("--work-dir"),
@@ -2862,8 +2838,12 @@ try {
2862
2838
  runner
2863
2839
  });
2864
2840
  printBootstrap(
2865
- { handoff, guide, remediation: handoff.remediation },
2866
- guide,
2841
+ {
2842
+ handoff: report.handoff,
2843
+ guide: report.guide,
2844
+ remediation: report.handoff.remediation
2845
+ },
2846
+ report.guide,
2867
2847
  void 0,
2868
2848
  "text"
2869
2849
  );
@@ -2871,13 +2851,6 @@ try {
2871
2851
  const configPath = requiredOption("--config");
2872
2852
  const coreStackPath = option("--core-stack-json");
2873
2853
  const githubStackPath = option("--github-oidc-stack-json");
2874
- const runner = {
2875
- async execute(command, commandArgs) {
2876
- const { execFile: execFile3 } = await import("node:child_process");
2877
- const { promisify: promisify3 } = await import("node:util");
2878
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2879
- }
2880
- };
2881
2854
  const handoff = await bootstrapHandoff({
2882
2855
  config,
2883
2856
  configPath,
@@ -2948,15 +2921,11 @@ ${plan.notes.join("\n")}`);
2948
2921
  } else console.log(JSON.stringify(plan));
2949
2922
  } else if (action === "check") {
2950
2923
  requiredOption("--config");
2951
- const { execFile: execFile3 } = await import("node:child_process");
2952
- const { promisify: promisify3 } = await import("node:util");
2953
2924
  const result = await checkBootstrap(
2954
2925
  config,
2955
2926
  { resourceDrift: args.includes("--resource-drift") },
2956
2927
  {
2957
- async execute(command, commandArgs) {
2958
- return (await promisify3(execFile3)(command, commandArgs)).stdout.trim();
2959
- }
2928
+ execute: runner.execute
2960
2929
  }
2961
2930
  );
2962
2931
  if (outputFormat() === "text") process.stdout.write(formatBootstrapCheckText(result));
@@ -2997,15 +2966,16 @@ ${plan.notes.join("\n")}`);
2997
2966
  }
2998
2967
  await writeFile3(output, `${JSON.stringify(parameters, null, 2)}
2999
2968
  `);
2969
+ const remediation = (await bootstrapPlan(config)).remediation;
3000
2970
  printBootstrap(
3001
2971
  {
3002
2972
  output,
3003
2973
  kind,
3004
2974
  preservedDeployedValues: Boolean(deployedStackPath),
3005
- remediation: (await bootstrapPlan(config)).remediation
2975
+ remediation
3006
2976
  },
3007
2977
  `Wrote ${output}. Next: review and execute the generated ${kind} change set.
3008
- ${formatBootstrapRemediationText((await bootstrapPlan(config)).remediation).join("\n")}`
2978
+ ${formatBootstrapRemediationText(remediation).join("\n")}`
3009
2979
  );
3010
2980
  } else if (action === "change-set") {
3011
2981
  const kind = bootstrapKind();
@@ -3044,7 +3014,7 @@ ${formatBootstrapRemediationText((await bootstrapPlan(config)).remediation).join
3044
3014
  reviewRequired: true,
3045
3015
  awsCommand,
3046
3016
  shellCommand: args.includes("--format-shell") ? shellCommand(awsCommand) : void 0,
3047
- remediation: (await bootstrapPlan(config)).remediation
3017
+ remediation: plan.remediation
3048
3018
  };
3049
3019
  printBootstrap(
3050
3020
  handoff,
package/dist/guided.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type BootstrapConfig, type ComputeMode } from './bootstrap.js';
1
+ import { type BootstrapConfig, bootstrapPlan, type ComputeMode } from './bootstrap.js';
2
2
  import { type BootstrapProvider, bootstrapHandoff, type CommandRunner } from './handoff.js';
3
3
  import { type BootstrapRemediation } from './remediation.js';
4
4
  export type BootstrapCheckStatus = 'ready' | 'missing' | 'mismatch' | 'unverified';
@@ -12,6 +12,11 @@ export type BootstrapPreflight = {
12
12
  checks: BootstrapPreflightCheck[];
13
13
  remediation: BootstrapRemediation;
14
14
  };
15
+ export type BootstrapGuideReport = {
16
+ handoff: Awaited<ReturnType<typeof bootstrapHandoff>>;
17
+ plan: Awaited<ReturnType<typeof bootstrapPlan>>;
18
+ guide: string;
19
+ };
15
20
  export type BootstrapInitInput = {
16
21
  mode?: ComputeMode;
17
22
  slug: string;
@@ -33,4 +38,5 @@ export declare function bootstrapPreflight(input: {
33
38
  runner?: CommandRunner;
34
39
  provider?: BootstrapProvider;
35
40
  }): Promise<BootstrapPreflight>;
41
+ export declare function bootstrapGuideReport(input: Parameters<typeof bootstrapHandoff>[0]): Promise<BootstrapGuideReport>;
36
42
  export declare function bootstrapGuide(input: Parameters<typeof bootstrapHandoff>[0]): Promise<string>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ComputeMode } from './bootstrap.js';
2
2
  export { type BootstrapConfig, type BootstrapConsistency, type BootstrapKind, type BootstrapPlan, type BootstrapTemplateInspection, bootstrapConsistency, bootstrapContractVersion, bootstrapPlan, bootstrapTemplate, bootstrapTemplatePath, bootstrapTemplateRevision, type CloudFormationParameterValue, type ComputeMode, computeMode, coreBootstrapOutputs, type DeployedBootstrapStack, deployedBootstrapStack, mergeBootstrapParameters, requireComputeMode, requiredBootstrapParameters, resolveComputeMode, } from './bootstrap.js';
3
3
  export { type BootstrapCheck, type BootstrapCheckDependencies, type BootstrapResourceDifference, type BootstrapResourceDrift, type BootstrapResourceDriftResult, type BootstrapStackCheck, checkBootstrap, formatBootstrapCheckText, } from './bootstrap-check.js';
4
- export { type BootstrapCheckStatus, type BootstrapInitInput, type BootstrapPreflight, type BootstrapPreflightCheck, bootstrapGuide, bootstrapPreflight, scaffoldBootstrapManifest, } from './guided.js';
4
+ export { type BootstrapCheckStatus, type BootstrapGuideReport, type BootstrapInitInput, type BootstrapPreflight, type BootstrapPreflightCheck, bootstrapGuide, bootstrapGuideReport, bootstrapPreflight, scaffoldBootstrapManifest, } from './guided.js';
5
5
  export { type BootstrapHandoff, type BootstrapPhase, type BootstrapProvider, type BootstrapVerification, bootstrapHandoff, type CommandRunner, githubOidcProvider, verifyBootstrap, } from './handoff.js';
6
6
  export { type BootstrapAffectedStack, type BootstrapRemediation, type BootstrapRemediationInput, bootstrapRemediation, formatBootstrapRemediationText, } from './remediation.js';
7
7
  export type ReleaseMetadata = {
package/dist/index.js CHANGED
@@ -2069,9 +2069,8 @@ async function bootstrapPreflight(input) {
2069
2069
  function quote(args) {
2070
2070
  return args.map((arg) => `'${arg.replaceAll("'", `'\\"'\\"'`)}'`).join(" ");
2071
2071
  }
2072
- async function bootstrapGuide(input) {
2073
- const handoff = await bootstrapHandoff(input);
2074
- const plan = await bootstrapPlan(input.config);
2072
+ async function bootstrapGuideReport(input) {
2073
+ const [handoff, plan] = await Promise.all([bootstrapHandoff(input), bootstrapPlan(input.config)]);
2075
2074
  const lines = [
2076
2075
  `Phase: ${handoff.phase}`,
2077
2076
  `Package version: ${plan.packageVersion}`,
@@ -2109,8 +2108,11 @@ async function bootstrapGuide(input) {
2109
2108
  for (const command of verified.githubEnvironmentInstructions) lines.push(quote(command));
2110
2109
  }
2111
2110
  lines.push("", ...formatBootstrapRemediationText(plan.remediation));
2112
- return `${lines.join("\n")}
2113
- `;
2111
+ return { handoff, plan, guide: `${lines.join("\n")}
2112
+ ` };
2113
+ }
2114
+ async function bootstrapGuide(input) {
2115
+ return (await bootstrapGuideReport(input)).guide;
2114
2116
  }
2115
2117
 
2116
2118
  // packages/aws/src/index.ts
@@ -2288,6 +2290,7 @@ export {
2288
2290
  bootstrapConsistency,
2289
2291
  bootstrapContractVersion,
2290
2292
  bootstrapGuide,
2293
+ bootstrapGuideReport,
2291
2294
  bootstrapHandoff,
2292
2295
  bootstrapPlan,
2293
2296
  bootstrapPreflight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@continuous-excellence/ze-great-dashboard-aws",
3
- "version": "0.14.4",
3
+ "version": "0.14.5",
4
4
  "type": "module",
5
5
  "description": "AWS Lambda and CloudFormation adapter for Ze Great Dashboard.",
6
6
  "keywords": [