cdk-real-drift 0.4.16 → 0.4.18

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
@@ -836,14 +836,26 @@ function applyIgnores(findings, scope, config) {
836
836
 
837
837
  //#endregion
838
838
  //#region src/synth/resolve-app.ts
839
+ function decodeCdkJson(buf) {
840
+ const encoding = buf[0] === 255 && buf[1] === 254 ? "utf-16le" : buf[0] === 254 && buf[1] === 255 ? "utf-16be" : "utf-8";
841
+ return new TextDecoder(encoding).decode(buf);
842
+ }
839
843
  function resolveApp(explicit) {
840
844
  if (explicit) return explicit;
845
+ if (!existsSync("cdk.json")) return void 0;
846
+ let text;
841
847
  try {
842
- if (existsSync("cdk.json")) {
843
- const json = JSON.parse(readFileSync("cdk.json", "utf8"));
844
- if (typeof json.app === "string" && json.app.length > 0) return json.app;
845
- }
846
- } catch {}
848
+ text = decodeCdkJson(readFileSync("cdk.json"));
849
+ } catch (e) {
850
+ throw new Error(`cdk.json exists but could not be read: ${e.message}`);
851
+ }
852
+ let json;
853
+ try {
854
+ json = JSON.parse(text);
855
+ } catch (e) {
856
+ throw new Error(`cdk.json exists but is not valid JSON (an unsupported encoding or a syntax error?): ${e.message}`);
857
+ }
858
+ return typeof json.app === "string" && json.app.length > 0 ? json.app : void 0;
847
859
  }
848
860
 
849
861
  //#endregion
@@ -14992,7 +15004,10 @@ async function runCheck(args) {
14992
15004
  const { json, code } = buildStackJson(preDeployReconciled, preDeployHeader);
14993
15005
  jsonReports.push(json);
14994
15006
  preDeployCode = code;
14995
- } else preDeployCode = report(preDeployReconciled, preDeployHeader, { verbose: a.verbose });
15007
+ } else preDeployCode = report(preDeployReconciled, preDeployHeader, {
15008
+ verbose: a.verbose,
15009
+ preDeploy: true
15010
+ });
14996
15011
  if (preDeployCode === 1) anyDrift = true;
14997
15012
  worst = Math.max(worst, finalCheckExit(preDeployCode, a.fail));
14998
15013
  worst = Math.max(worst, strictCoverageExit(a.strict, gathered.findings, desired.resources, true));