@anthusai/papyrus 1.19.0 → 1.19.1

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.
@@ -134,20 +134,24 @@ if (command === "deploy") {
134
134
  const outputDirectory = path.resolve(opt("out", process.env.CDK_OUTDIR ?? "cdk.out"));
135
135
  const explicitAccount = opt("account");
136
136
  const explicitRegion = opt("region");
137
- const synthCommand = [
137
+ const synthesis = spawnSync(
138
138
  process.execPath,
139
- path.resolve(process.argv[1]),
140
- "synth",
141
- "--site",
142
- path.resolve(opt("site", "infra/site.json")),
143
- "--out",
144
- outputDirectory,
145
- ...(explicitAccount ? ["--account", explicitAccount] : []),
146
- ...(explicitRegion ? ["--region", explicitRegion] : []),
147
- ].map((part) => JSON.stringify(part)).join(" ");
139
+ [
140
+ path.resolve(process.argv[1]),
141
+ "synth",
142
+ "--site",
143
+ path.resolve(opt("site", "infra/site.json")),
144
+ "--out",
145
+ outputDirectory,
146
+ ...(explicitAccount ? ["--account", explicitAccount] : []),
147
+ ...(explicitRegion ? ["--region", explicitRegion] : []),
148
+ ],
149
+ { stdio: "inherit" },
150
+ );
151
+ if (synthesis.status !== 0) process.exit(synthesis.status ?? 1);
148
152
  const deployment = spawnSync(
149
153
  "npx",
150
- ["--yes", "aws-cdk@2", "deploy", "--app", synthCommand, "--require-approval", "never", "--output", outputDirectory, `AmplifyAppShell-${config.siteId}`],
154
+ ["--yes", "aws-cdk@2", "deploy", "--app", outputDirectory, "--require-approval", "never", `AmplifyAppShell-${config.siteId}`],
151
155
  { stdio: "inherit" },
152
156
  );
153
157
  process.exit(deployment.status ?? 1);
package/package.json CHANGED
@@ -379,7 +379,7 @@
379
379
  "optional": true
380
380
  }
381
381
  },
382
- "version": "1.19.0",
382
+ "version": "1.19.1",
383
383
  "dependencies": {
384
384
  "@aws-amplify/adapter-nextjs": "^1.7.3",
385
385
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.19.1",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -25,15 +25,22 @@ function logicalIdsInStack(stackName, region) {
25
25
  return new Set(JSON.parse(completed.stdout).StackResourceSummaries.map((summary) => summary.LogicalResourceId));
26
26
  }
27
27
 
28
- function templateParameterFlags(parameterValues, templateFile) {
28
+ function parameterNamesInStack(stackName, region) {
29
+ const completed = runAws(["cloudformation", "describe-stacks", "--stack-name", stackName, "--region", region, "--output", "json"], { allowFailure: true });
30
+ if (completed.status !== 0) return new Set();
31
+ const stack = JSON.parse(completed.stdout).Stacks?.[0];
32
+ return new Set((stack?.Parameters ?? []).map((parameter) => parameter.ParameterKey));
33
+ }
34
+
35
+ function templateParameterFlags(parameterValues, templateFile, parameterNamesInStackNow) {
29
36
  const templateText = fs.readFileSync(templateFile, "utf8");
30
37
  const parametersSection = templateText.split("\nResources:")[0].split("\nParameters:\n")[1] ?? "";
31
38
  const parameterNames = [...parametersSection.matchAll(/^ ([A-Za-z0-9]+):\s*$/gm)].map((match) => match[1]);
32
- return parameterNames.map((name) =>
33
- name in parameterValues
34
- ? `ParameterKey=${name},ParameterValue=${parameterValues[name]}`
35
- : `ParameterKey=${name},UsePreviousValue=true`,
36
- );
39
+ return parameterNames.flatMap((name) => {
40
+ if (name in parameterValues) return [`ParameterKey=${name},ParameterValue=${parameterValues[name]}`];
41
+ if (parameterNamesInStackNow.has(name)) return [`ParameterKey=${name},UsePreviousValue=true`];
42
+ return [];
43
+ });
37
44
  }
38
45
 
39
46
  export function applyChangeSet({ stackName, region, templateFile, parameterValues, adoptions }) {
@@ -47,7 +54,7 @@ export function applyChangeSet({ stackName, region, templateFile, parameterValue
47
54
  "--template-body", `file://${path.resolve(templateFile)}`,
48
55
  "--capabilities", "CAPABILITY_IAM",
49
56
  "--region", region,
50
- "--parameters", ...templateParameterFlags(parameterValues, templateFile),
57
+ "--parameters", ...templateParameterFlags(parameterValues, templateFile, parameterNamesInStack(stackName, region)),
51
58
  ];
52
59
  if (adoptions) createArguments.push("--resources-to-import", JSON.stringify(adoptions));
53
60
  runAws(createArguments);