Skip to content

Commit 64e2d44

Browse files
authored
Merge branch 'master' into huijbers/apigw-task-token
2 parents 6a09f3c + 2465b51 commit 64e2d44

7 files changed

Lines changed: 84 additions & 18 deletions

File tree

packages/@aws-cdk/assert-internal/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
---
55

6-
![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
6+
![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)
77

8-
> The APIs of higher level constructs in this module are experimental and under active development.
9-
> They are subject to non-backward compatible changes or removal in any future version. These are
10-
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
11-
> announced in the release notes. This means that while you may use them, you may need to update
12-
> your source code when upgrading to a newer version of this package.
8+
> This API may emit warnings. Backward compatibility is not guaranteed.
139
14-
If using monocdk, use [@monocdk-experiment/assert](https://www.npmjs.com/package/@monocdk-experiment/assert) instead.
10+
## Replacement recommended
11+
12+
This library has been deprecated. We recommend you use the
13+
[@aws-cdk/assertions](https://docs.aws.amazon.com/cdk/api/v1/docs/assertions-readme.html) module instead.
1514

1615
---
1716

packages/@aws-cdk/assert-internal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"engines": {
5656
"node": ">= 10.13.0 <13 || >=13.7.0"
5757
},
58-
"stability": "experimental",
59-
"maturity": "experimental",
58+
"stability": "deprecated",
59+
"maturity": "deprecated",
6060
"publishConfig": {
6161
"tag": "latest"
6262
},

packages/@aws-cdk/assert/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
"exclude": true
7272
},
7373
"nozem": false,
74-
"stability": "experimental",
75-
"maturity": "developer-preview",
74+
"stability": "deprecated",
75+
"maturity": "deprecated",
7676
"publishConfig": {
7777
"tag": "latest-1"
7878
}

packages/@monocdk-experiment/assert/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
"engines": {
6565
"node": ">= 10.13.0 <13 || >=13.7.0"
6666
},
67-
"stability": "experimental",
68-
"maturity": "developer-preview",
67+
"stability": "deprecated",
68+
"maturity": "deprecated",
6969
"publishConfig": {
7070
"tag": "latest"
7171
}

tools/@aws-cdk/cdk-integ-tools/bin/cdk-integ-assert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
// Verify that all integration tests still match their expected output
3-
import { canonicalizeTemplate } from '@aws-cdk/assert-internal';
43
import { diffTemplate, formatDifferences } from '@aws-cdk/cloudformation-diff';
4+
import { canonicalizeTemplate } from '../lib/canonicalize-assets';
55
import { DEFAULT_SYNTH_OPTIONS, IntegrationTests } from '../lib/integ-helpers';
66

77
/* eslint-disable no-console */
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Reduce template to a normal form where asset references have been normalized
3+
*
4+
* This makes it possible to compare templates if all that's different between
5+
* them is the hashes of the asset values.
6+
*
7+
* Currently only handles parameterized assets, but can (and should)
8+
* be adapted to handle convention-mode assets as well when we start using
9+
* more of those.
10+
*/
11+
export function canonicalizeTemplate(template: any): any {
12+
// For the weird case where we have an array of templates...
13+
if (Array.isArray(template)) {
14+
return template.map(canonicalizeTemplate);
15+
}
16+
17+
// Find assets via parameters
18+
const stringSubstitutions = new Array<[RegExp, string]>();
19+
const paramRe = /^AssetParameters([a-zA-Z0-9]{64})(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})$/;
20+
21+
const assetsSeen = new Set<string>();
22+
for (const paramName of Object.keys(template?.Parameters || {})) {
23+
const m = paramRe.exec(paramName);
24+
if (!m) { continue; }
25+
if (assetsSeen.has(m[1])) { continue; }
26+
27+
assetsSeen.add(m[1]);
28+
const ix = assetsSeen.size;
29+
30+
// Full parameter reference
31+
stringSubstitutions.push([
32+
new RegExp(`AssetParameters${m[1]}(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})`),
33+
`Asset${ix}$1`,
34+
]);
35+
// Substring asset hash reference
36+
stringSubstitutions.push([
37+
new RegExp(`${m[1]}`),
38+
`Asset${ix}Hash`,
39+
]);
40+
}
41+
42+
// Substitute them out
43+
return substitute(template);
44+
45+
function substitute(what: any): any {
46+
if (Array.isArray(what)) {
47+
return what.map(substitute);
48+
}
49+
50+
if (typeof what === 'object' && what !== null) {
51+
const ret: any = {};
52+
for (const [k, v] of Object.entries(what)) {
53+
ret[stringSub(k)] = substitute(v);
54+
}
55+
return ret;
56+
}
57+
58+
if (typeof what === 'string') {
59+
return stringSub(what);
60+
}
61+
62+
return what;
63+
}
64+
65+
function stringSub(x: string) {
66+
for (const [re, replacement] of stringSubstitutions) {
67+
x = x.replace(re, replacement);
68+
}
69+
return x;
70+
}
71+
}

tools/@aws-cdk/cdk-integ-tools/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"dependencies": {
4040
"@aws-cdk/cloudformation-diff": "0.0.0",
4141
"@aws-cdk/cx-api": "0.0.0",
42-
"@aws-cdk/assert-internal": "0.0.0",
4342
"aws-cdk": "0.0.0",
4443
"fs-extra": "^9.1.0",
4544
"yargs": "^16.2.0"
@@ -52,9 +51,6 @@
5251
"engines": {
5352
"node": ">= 10.13.0 <13 || >=13.7.0"
5453
},
55-
"peerDependencies": {
56-
"@aws-cdk/assert-internal": "0.0.0"
57-
},
5854
"ubergen": {
5955
"exclude": true
6056
}

0 commit comments

Comments
 (0)