Skip to content

Commit 91edfec

Browse files
committed
Change serialization method within tree-metadata.ts
1 parent eea12ea commit 91edfec

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@
167167
"aws-cdk-lib/table",
168168
"aws-cdk-lib/table/**",
169169
"aws-cdk-lib/yaml",
170-
"aws-cdk-lib/yaml/**"
170+
"aws-cdk-lib/yaml/**",
171+
"aws-cdk-lib/json-stream-stringify",
172+
"aws-cdk-lib/json-stream-stringify/**"
171173
]
172174
},
173175
"dependencies": {

packages/aws-cdk-lib/NOTICE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,4 +750,32 @@ THIS SOFTWARE IS PROVIDED BY GARY COURT "AS IS" AND ANY EXPRESS OR IMPLIED WARRA
750750
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Gary Court.
751751

752752

753+
----------------
754+
755+
** json-stream-stringify - https://www.npmjs.com/package/json-stream-stringify/v/3.0.0 | MIT
756+
The MIT License
757+
758+
Copyright (c) 2016 Faleij <[email protected]>
759+
760+
Permission is hereby granted, free of charge,
761+
to any person obtaining a copy of this software and
762+
associated documentation files (the "Software"), to
763+
deal in the Software without restriction, including
764+
without limitation the rights to use, copy, modify,
765+
merge, publish, distribute, sublicense, and/or sell
766+
copies of the Software, and to permit persons to whom
767+
the Software is furnished to do so,
768+
subject to the following conditions:
769+
770+
The above copyright notice and this permission notice
771+
shall be included in all copies or substantial portions of the Software.
772+
773+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
774+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
775+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
776+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
777+
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
778+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
779+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
780+
753781
----------------

packages/aws-cdk-lib/core/lib/private/tree-metadata.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from 'fs';
22
import * as path from 'path';
33

44
import { Construct, IConstruct } from 'constructs';
5+
import { JsonStreamStringify } from 'json-stream-stringify';
56
import { ConstructInfo, constructInfoFromConstruct } from './runtime-info';
67
import { ArtifactType } from '../../../cloud-assembly-schema';
78
import { Annotations } from '../annotations';
@@ -71,14 +72,16 @@ export class TreeMetadata extends Construct {
7172
this._tree = lookup;
7273

7374
const builder = session.assembly;
74-
fs.writeFileSync(path.join(builder.outdir, FILE_PATH), JSON.stringify(tree, (key: string, value: any) => {
75+
const jsonStream = new JsonStreamStringify(tree, (key: string, value: any) => {
7576
// we are adding in the `parent` attribute for internal use
7677
// and it doesn't make much sense to include it in the
7778
// tree.json
7879
if (key === 'parent') return undefined;
7980
return value;
80-
}, 2), { encoding: 'utf-8' });
81+
}, 2);
8182

83+
const out = fs.createWriteStream(path.join(builder.outdir, FILE_PATH), { encoding: 'utf-8' });
84+
jsonStream.pipe(out);
8285
builder.addArtifact('Tree', {
8386
type: ArtifactType.CDK_TREE,
8487
properties: {

packages/aws-cdk-lib/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
],
6565
"attribution": [
6666
"kubectl",
67-
"helm"
67+
"helm",
68+
"json-stream-stringify"
6869
]
6970
},
7071
"jsii": {
@@ -115,6 +116,7 @@
115116
"case",
116117
"fs-extra",
117118
"ignore",
119+
"json-stream-stringify",
118120
"jsonschema",
119121
"minimatch",
120122
"punycode",
@@ -130,6 +132,7 @@
130132
"case": "1.6.3",
131133
"fs-extra": "^11.1.1",
132134
"ignore": "^5.2.4",
135+
"json-stream-stringify": "^3.0.0",
133136
"jsonschema": "^1.4.1",
134137
"minimatch": "^3.1.2",
135138
"punycode": "^2.3.0",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9044,6 +9044,11 @@ json-stable-stringify-without-jsonify@^1.0.1:
90449044
resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
90459045
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
90469046

9047+
json-stream-stringify@^3.0.0:
9048+
version "3.1.0"
9049+
resolved "https://registry.npmjs.org/json-stream-stringify/-/json-stream-stringify-3.1.0.tgz#821df0993f630b7bba8198b1c966e5aaf9ec7657"
9050+
integrity sha512-ilynhoPlWa29XqgWJTD8V3bOF8k4Ybm3U9Oc7o/CG8qvFMGUzPlh9P4mOj9Ss3VtisA6N2OYevCWa14VRpJtQQ==
9051+
90479052
json-stringify-nice@^1.1.4:
90489053
version "1.1.4"
90499054
resolved "https://registry.npmjs.org/json-stringify-nice/-/json-stringify-nice-1.1.4.tgz#2c937962b80181d3f317dd39aa323e14f5a60a67"

0 commit comments

Comments
 (0)