cdk-real-drift 0.3.7 → 0.3.8

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/README.md CHANGED
@@ -300,7 +300,7 @@ Full design and rationale: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
300
300
  | --------------------- | ------------------------------------------------------------- |
301
301
  | `cdkrd check` | every stack the CDK app defines, each in its own `env.region` |
302
302
  | `cdkrd check 'Dev*'` | glob, matched against the app's stack names |
303
- | `cdkrd check MyStack` | one stack, selected by name from the app |
303
+ | `cdkrd check MyStack` | every same-named stack (a name can repeat across regions) |
304
304
 
305
305
  cdkrd resolves your CDK app to discover which stacks exist and to label findings by
306
306
  construct path. The app comes from `cdk.json` (when run in the project directory) or
package/dist/cli.js CHANGED
@@ -873,6 +873,20 @@ function missingContextWarning(keys, opts = {}) {
873
873
  //#endregion
874
874
  //#region src/synth/synth.ts
875
875
  const CONCRETE_REGION = /^[a-z]{2}(-[a-z]+)+-\d+$/;
876
+ /**
877
+ * Build the stderr message body (no `warning:` prefix — the caller adds it) for the case where
878
+ * `--app` points at a pre-synthesized cloud-assembly DIRECTORY (`cdk.out`) yet the user also
879
+ * passed `-c/--context`. There is no CDK app subprocess to feed context to — the assembly's
880
+ * templates were frozen at synth time — so the `-c` values are silently dropped. Returns `null`
881
+ * when it does NOT apply (a real CDK app command, or no context given), so the caller warns only
882
+ * on the ignored case (#956). Advisory only (a warning, not a refusal): the frozen assembly is
883
+ * still a valid drift source, the user is just misled into thinking their `-c` mattered.
884
+ */
885
+ function contextIgnoredWarning(isDir, context) {
886
+ const keys = Object.keys(context);
887
+ if (!isDir || keys.length === 0) return null;
888
+ return `ignoring -c/--context (${keys.join(", ")}): --app points at a pre-synthesized cloud-assembly directory, whose context was baked in at synth time — there is no CDK app to re-run with new context. To apply new context, point --app at the CDK app itself (not its cdk.out).`;
889
+ }
876
890
  async function synthApp(app, opts = {}) {
877
891
  const { region, profile, context = {} } = opts;
878
892
  const toolkit = new Toolkit({
@@ -885,8 +899,11 @@ async function synthApp(app, opts = {}) {
885
899
  const p = resolve(app);
886
900
  const isDir = existsSync(p) && statSync(p).isDirectory();
887
901
  let source;
888
- if (isDir) source = await toolkit.fromAssemblyDirectory(p, { failOnMissingContext: false });
889
- else {
902
+ if (isDir) {
903
+ const ignored = contextIgnoredWarning(isDir, context);
904
+ if (ignored) console.error(`warning: ${ignored}`);
905
+ source = await toolkit.fromAssemblyDirectory(p, { failOnMissingContext: false });
906
+ } else {
890
907
  const hasOverrides = Object.keys(context).length > 0;
891
908
  const env = {};
892
909
  if (region) {
@@ -13068,7 +13085,7 @@ async function runRecord(args) {
13068
13085
  emitJsonArray(jsonReports);
13069
13086
  return worst;
13070
13087
  }
13071
- if (worst === 0 && wroteAny) console.log("commit the baseline file(s) so drift is detected against them going forward.");
13088
+ if (wroteAny) console.log("commit the baseline file(s) so drift is detected against them going forward.");
13072
13089
  return worst;
13073
13090
  }
13074
13091
 
@@ -13182,7 +13199,7 @@ async function runIgnore(args) {
13182
13199
  emitJsonArray(jsonReports);
13183
13200
  return worst;
13184
13201
  }
13185
- if (worst === 0 && wroteAny) console.log("commit .cdkrd/ignore.yaml so the ignore rules apply for everyone going forward.");
13202
+ if (wroteAny) console.log("commit .cdkrd/ignore.yaml so the ignore rules apply for everyone going forward.");
13186
13203
  return worst;
13187
13204
  }
13188
13205