Skip to content

Commit 10e2bfe

Browse files
authored
feat(jsii-spec): Add optional metadata field (#512)
This can be used to track free-form maintainer data, for use in systems that are not part of the standard JSII toolchain. For example, it can be used to encode configuration behavior for proprietary tools that process assemblies.
1 parent d1ef618 commit 10e2bfe

10 files changed

Lines changed: 41 additions & 29 deletions

File tree

packages/jsii-calc/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
},
2626
"sphinx": {}
2727
},
28+
"metadata": {
29+
"jsii:boolean": true,
30+
"jsii:number": 1337,
31+
"jsii:object": {
32+
"string": "yes!"
33+
}
34+
},
2835
"versionFormat": "short"
2936
},
3037
"scripts": {
@@ -84,4 +91,4 @@
8491
"type": "git",
8592
"url": "https://github.com/awslabs/jsii.git"
8693
}
87-
}
94+
}

packages/jsii-calc/test/assembly.jsii

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@
185185
"homepage": "https://github.com/awslabs/jsii.git",
186186
"jsiiVersion": "0.11.0",
187187
"license": "Apache-2.0",
188+
"metadata": {
189+
"jsii:boolean": true,
190+
"jsii:number": 1337,
191+
"jsii:object": {
192+
"string": "yes!"
193+
}
194+
},
188195
"name": "jsii-calc",
189196
"readme": {
190197
"markdown": "# jsii Calculator\n\nThis library is used to demonstrate and test the features of JSII\n\n## Sphinx\n\nThis file will be incorporated into the sphinx documentation.\n\nIf this file starts with an \"H1\" line (in our case `# jsii Calculator`), this\nheading will be used as the Sphinx topic name. Otherwise, the name of the module\n(`jsii-calc`) will be used instead.\n\n\n\n\n"
@@ -6803,5 +6810,5 @@
68036810
}
68046811
},
68056812
"version": "0.11.0",
6806-
"fingerprint": "bKi31JLqJ4B9MMHdwaDdxTQlL4VG06izio0DqYMQnt4="
6813+
"fingerprint": "i8GdLx7YlhttP5/pB0dKItig1wFkp/DwDdUtbYsIdfc="
68076814
}

packages/jsii-dotnet-generator/build.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ set -euo pipefail
33

44
npm run gen
55

6-
# TODO: Auto-rev NuGet package versions on each local build.
7-
# Because we we don't rev the versions, dotnet will pick
8-
# up an old build from the cache if it exists. So we
9-
# explicitly clear the cache as a temporary workaround.
10-
dotnet nuget locals all --clear
11-
dotnet build -c Release ./src/Amazon.JSII.Generator.sln
6+
dotnet build --force -c Release ./src/Amazon.JSII.Generator.sln
127
dotnet publish -c Release src/Amazon.JSII.Generator.CLI/
138

149
mkdir -p cli

packages/jsii-dotnet-jsonmodel/build.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ set -euo pipefail
33

44
npm run gen
55

6-
# TODO: Auto-rev NuGet package versions on each local build.
7-
# Because we we don't rev the versions, dotnet will pick
8-
# up an old build from the cache if it exists. So we
9-
# explicitly clear the cache as a temporary workaround.
10-
dotnet nuget locals all --clear
11-
dotnet build -c Release ./src/Amazon.JSII.JsonModel.sln
6+
dotnet build --force -c Release ./src/Amazon.JSII.JsonModel.sln
127

138
cp -f ./bin/Release/NuGet/*.nupkg .
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
# TODO: Auto-rev NuGet package versions on each local build.
5-
# Because we we don't rev the versions, dotnet will pick
6-
# up an old build from the cache if it exists. So we
7-
# explicitly clear the cache as a temporary workaround.
8-
dotnet nuget locals all --clear
9-
dotnet build -c Release ./test/Amazon.JSII.Runtime.IntegrationTests
4+
dotnet build --force -c Release ./test/Amazon.JSII.Runtime.IntegrationTests

packages/jsii-dotnet-runtime/build.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@ bundle_dir="src/Amazon.JSII.Runtime/jsii-runtime"
66
mkdir -p ${bundle_dir}
77
rsync -av node_modules/jsii-runtime/webpack/ ${bundle_dir}
88

9-
# TODO: Auto-rev NuGet package versions on each local build.
10-
# Because we we don't rev the versions, dotnet will pick
11-
# up an old build from the cache if it exists. So we
12-
# explicitly clear the cache as a temporary workaround.
13-
dotnet nuget locals all --clear
14-
159
# Build just Runtime and it's dependencies instead of the
1610
# solution to avoid integration tests from trying to be
1711
# built before the calc packages are generated.
18-
dotnet build -c Release ./src/Amazon.JSII.Runtime
12+
dotnet build --force -c Release ./src/Amazon.JSII.Runtime
1913

2014
cp -f ./bin/Release/NuGet/*.nupkg .

packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@
185185
"homepage": "https://github.com/awslabs/jsii.git",
186186
"jsiiVersion": "0.11.0",
187187
"license": "Apache-2.0",
188+
"metadata": {
189+
"jsii:boolean": true,
190+
"jsii:number": 1337,
191+
"jsii:object": {
192+
"string": "yes!"
193+
}
194+
},
188195
"name": "jsii-calc",
189196
"readme": {
190197
"markdown": "# jsii Calculator\n\nThis library is used to demonstrate and test the features of JSII\n\n## Sphinx\n\nThis file will be incorporated into the sphinx documentation.\n\nIf this file starts with an \"H1\" line (in our case `# jsii Calculator`), this\nheading will be used as the Sphinx topic name. Otherwise, the name of the module\n(`jsii-calc`) will be used instead.\n\n\n\n\n"
@@ -6803,5 +6810,5 @@
68036810
}
68046811
},
68056812
"version": "0.11.0",
6806-
"fingerprint": "bKi31JLqJ4B9MMHdwaDdxTQlL4VG06izio0DqYMQnt4="
6813+
"fingerprint": "i8GdLx7YlhttP5/pB0dKItig1wFkp/DwDdUtbYsIdfc="
68076814
}

packages/jsii-spec/lib/spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ export interface Assembly extends Documentable {
9696
*/
9797
targets?: AssemblyTargets;
9898

99+
/**
100+
* Arbitrary key-value pairs of metadata, which the maintainer chose to
101+
* document with the assembly. These entries do not carry normative
102+
* semantics and their interpretation is up to the assembly maintainer.
103+
*
104+
* @default none
105+
*/
106+
metadata?: { [key: string]: any };
107+
99108
/**
100109
* Direct dependencies on other assemblies (with semver), the key is the JSII
101110
* assembly name.

packages/jsii/lib/assembler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export class Assembler implements Emitter {
114114
bundled: this.projectInfo.bundleDependencies,
115115
types: this._types,
116116
targets: this.projectInfo.targets,
117+
metadata: this.projectInfo.metadata,
117118
readme,
118119
jsiiVersion,
119120
fingerprint: '<TBD>',
@@ -1627,4 +1628,4 @@ const PROHIBITED_MEMBER_NAMES = ['equals', 'hashcode'];
16271628
*/
16281629
function isProhibitedMemberName(name: string) {
16291630
return PROHIBITED_MEMBER_NAMES.includes(name.toLowerCase());
1630-
}
1631+
}

packages/jsii/lib/project-info.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface ProjectInfo {
3232
readonly transitiveDependencies: ReadonlyArray<spec.Assembly>;
3333
readonly bundleDependencies?: { readonly [name: string]: string };
3434
readonly targets: spec.AssemblyTargets;
35+
readonly metadata?: { [key: string]: any };
3536
readonly jsiiVersionFormat: 'short' | 'full';
3637
readonly description?: string;
3738
readonly homepage?: string;
@@ -123,6 +124,7 @@ export async function loadProjectInfo(projectRoot: string, { fixPeerDependencies
123124
..._required(pkg.jsii, 'The "package.json" file must specify the "jsii" attribute').targets,
124125
js: { npm: pkg.name }
125126
},
127+
metadata: pkg.jsii && pkg.jsii.metadata,
126128
jsiiVersionFormat: _validateVersionFormat(pkg.jsii.versionFormat || 'full'),
127129

128130
description: pkg.description,

0 commit comments

Comments
 (0)