Skip to content

Commit

Permalink
feat(jsii-spec): Add optional metadata field (#512)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RomainMuller committed Jun 3, 2019
1 parent d1ef618 commit 10e2bfe
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 29 deletions.
9 changes: 8 additions & 1 deletion packages/jsii-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
},
"sphinx": {}
},
"metadata": {
"jsii:boolean": true,
"jsii:number": 1337,
"jsii:object": {
"string": "yes!"
}
},
"versionFormat": "short"
},
"scripts": {
Expand Down Expand Up @@ -84,4 +91,4 @@
"type": "git",
"url": "https://github.com/awslabs/jsii.git"
}
}
}
9 changes: 8 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@
"homepage": "https://github.com/awslabs/jsii.git",
"jsiiVersion": "0.11.0",
"license": "Apache-2.0",
"metadata": {
"jsii:boolean": true,
"jsii:number": 1337,
"jsii:object": {
"string": "yes!"
}
},
"name": "jsii-calc",
"readme": {
"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"
Expand Down Expand Up @@ -6803,5 +6810,5 @@
}
},
"version": "0.11.0",
"fingerprint": "bKi31JLqJ4B9MMHdwaDdxTQlL4VG06izio0DqYMQnt4="
"fingerprint": "i8GdLx7YlhttP5/pB0dKItig1wFkp/DwDdUtbYsIdfc="
}
7 changes: 1 addition & 6 deletions packages/jsii-dotnet-generator/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ set -euo pipefail

npm run gen

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

mkdir -p cli
Expand Down
7 changes: 1 addition & 6 deletions packages/jsii-dotnet-jsonmodel/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ set -euo pipefail

npm run gen

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

cp -f ./bin/Release/NuGet/*.nupkg .
7 changes: 1 addition & 6 deletions packages/jsii-dotnet-runtime-test/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/bin/bash
set -euo pipefail

# TODO: Auto-rev NuGet package versions on each local build.
# Because we we don't rev the versions, dotnet will pick
# up an old build from the cache if it exists. So we
# explicitly clear the cache as a temporary workaround.
dotnet nuget locals all --clear
dotnet build -c Release ./test/Amazon.JSII.Runtime.IntegrationTests
dotnet build --force -c Release ./test/Amazon.JSII.Runtime.IntegrationTests
8 changes: 1 addition & 7 deletions packages/jsii-dotnet-runtime/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ bundle_dir="src/Amazon.JSII.Runtime/jsii-runtime"
mkdir -p ${bundle_dir}
rsync -av node_modules/jsii-runtime/webpack/ ${bundle_dir}

# TODO: Auto-rev NuGet package versions on each local build.
# Because we we don't rev the versions, dotnet will pick
# up an old build from the cache if it exists. So we
# explicitly clear the cache as a temporary workaround.
dotnet nuget locals all --clear

# Build just Runtime and it's dependencies instead of the
# solution to avoid integration tests from trying to be
# built before the calc packages are generated.
dotnet build -c Release ./src/Amazon.JSII.Runtime
dotnet build --force -c Release ./src/Amazon.JSII.Runtime

cp -f ./bin/Release/NuGet/*.nupkg .
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@
"homepage": "https://github.com/awslabs/jsii.git",
"jsiiVersion": "0.11.0",
"license": "Apache-2.0",
"metadata": {
"jsii:boolean": true,
"jsii:number": 1337,
"jsii:object": {
"string": "yes!"
}
},
"name": "jsii-calc",
"readme": {
"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"
Expand Down Expand Up @@ -6803,5 +6810,5 @@
}
},
"version": "0.11.0",
"fingerprint": "bKi31JLqJ4B9MMHdwaDdxTQlL4VG06izio0DqYMQnt4="
"fingerprint": "i8GdLx7YlhttP5/pB0dKItig1wFkp/DwDdUtbYsIdfc="
}
9 changes: 9 additions & 0 deletions packages/jsii-spec/lib/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ export interface Assembly extends Documentable {
*/
targets?: AssemblyTargets;

/**
* Arbitrary key-value pairs of metadata, which the maintainer chose to
* document with the assembly. These entries do not carry normative
* semantics and their interpretation is up to the assembly maintainer.
*
* @default none
*/
metadata?: { [key: string]: any };

/**
* Direct dependencies on other assemblies (with semver), the key is the JSII
* assembly name.
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii/lib/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class Assembler implements Emitter {
bundled: this.projectInfo.bundleDependencies,
types: this._types,
targets: this.projectInfo.targets,
metadata: this.projectInfo.metadata,
readme,
jsiiVersion,
fingerprint: '<TBD>',
Expand Down Expand Up @@ -1627,4 +1628,4 @@ const PROHIBITED_MEMBER_NAMES = ['equals', 'hashcode'];
*/
function isProhibitedMemberName(name: string) {
return PROHIBITED_MEMBER_NAMES.includes(name.toLowerCase());
}
}
2 changes: 2 additions & 0 deletions packages/jsii/lib/project-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ProjectInfo {
readonly transitiveDependencies: ReadonlyArray<spec.Assembly>;
readonly bundleDependencies?: { readonly [name: string]: string };
readonly targets: spec.AssemblyTargets;
readonly metadata?: { [key: string]: any };
readonly jsiiVersionFormat: 'short' | 'full';
readonly description?: string;
readonly homepage?: string;
Expand Down Expand Up @@ -123,6 +124,7 @@ export async function loadProjectInfo(projectRoot: string, { fixPeerDependencies
..._required(pkg.jsii, 'The "package.json" file must specify the "jsii" attribute').targets,
js: { npm: pkg.name }
},
metadata: pkg.jsii && pkg.jsii.metadata,
jsiiVersionFormat: _validateVersionFormat(pkg.jsii.versionFormat || 'full'),

description: pkg.description,
Expand Down

0 comments on commit 10e2bfe

Please sign in to comment.