Skip to content

Commit 42dece1

Browse files
authored
feat(jsii): Tag the jsii compiler version in the .jsii assemblies (#420)
By default, the fully qualified version number (including the commit SHA prefix) is written in the new `jsiiVersion` field of the assembly, however in order to make this friendlier to tests, there is an option to turn over to a *short* format by setting the new `jsii.versionFormat` key in `package.json` to `'short'`. Also, slightly altered the generation of the fully qualified version name to distinguish between cases where the commit SHA was provided by the CodeBuild environment variable, versus parsed using `git rev-parse`, denoting the later is indicative of an "unreleased" version. Fixes #412
1 parent 8ff9137 commit 42dece1

19 files changed

Lines changed: 87 additions & 48 deletions

File tree

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Edit your `package.json`:
6767
```js
6868
{
6969
// ...
70-
70+
7171
"main": "lib/index.js",
7272
"types": "lib/index.d.ts",
7373
"scripts": {
@@ -97,14 +97,14 @@ Edit your `package.json`:
9797

9898
So, what's going on here?
9999

100-
* The `jsii` section in your `package.json` is the [jsii configuration](#configuration) for your module.
100+
* The `jsii` section in your `package.json` is the [jsii configuration](#configuration) for your module.
101101
It tells jsii which target languages to package, and includes additional required information for the
102102
jsii packager.
103-
* `npm run build` uses `jsii` to compile your code. It invokes the TypeScript compiler (`tsc`) and will compile
103+
* `npm run build` uses `jsii` to compile your code. It invokes the TypeScript compiler (`tsc`) and will compile
104104
your .ts files into .js files.
105-
* `npm run watch` will invoke `tsc -w` which will monitor your filesystem for changes and recompile
105+
* `npm run watch` will invoke `tsc -w` which will monitor your filesystem for changes and recompile
106106
your .ts files to .js (note that jsii errors will not be reported in this mode)
107-
* `npm run package` invokes `jsii-pacmak`, which is the __jsii packager__. It will generate _and compile_ your
107+
* `npm run package` invokes `jsii-pacmak`, which is the __jsii packager__. It will generate _and compile_ your
108108
package to all target languages. The output packages will be emitted to `outdir` (in the above case `dist`).
109109
* Other required `package.json` fields: `license`, `main`, `types`.
110110

@@ -198,30 +198,30 @@ Now, if you check out the contents of `dist`, you'll find:
198198

199199
```
200200
├── dotnet
201-
   └── Acme.Hello.nupkg
201+
└── Acme.Hello.nupkg
202202
├── java
203-
   └── com
204-
   └── acme
205-
   └── hello
206-
   └── hello-jsii
207-
   ├── 1.0.0
208-
   │   ├── hello-jsii-1.0.0-javadoc.jar
209-
   │   ├── hello-jsii-1.0.0-javadoc.jar.md5
210-
   │   ├── hello-jsii-1.0.0-javadoc.jar.sha1
211-
   │   ├── hello-jsii-1.0.0-sources.jar
212-
   │   ├── hello-jsii-1.0.0-sources.jar.md5
213-
   │   ├── hello-jsii-1.0.0-sources.jar.sha1
214-
   │   ├── hello-jsii-1.0.0.jar
215-
   │   ├── hello-jsii-1.0.0.jar.md5
216-
   │   ├── hello-jsii-1.0.0.jar.sha1
217-
   │   ├── hello-jsii-1.0.0.pom
218-
   │   ├── hello-jsii-1.0.0.pom.md5
219-
   │   └── hello-jsii-1.0.0.pom.sha1
220-
   ├── maven-metadata.xml
221-
   ├── maven-metadata.xml.md5
222-
   └── maven-metadata.xml.sha1
203+
└── com
204+
└── acme
205+
└── hello
206+
└── hello-jsii
207+
├── 1.0.0
208+
├── hello-jsii-1.0.0-javadoc.jar
209+
├── hello-jsii-1.0.0-javadoc.jar.md5
210+
├── hello-jsii-1.0.0-javadoc.jar.sha1
211+
├── hello-jsii-1.0.0-sources.jar
212+
├── hello-jsii-1.0.0-sources.jar.md5
213+
├── hello-jsii-1.0.0-sources.jar.sha1
214+
├── hello-jsii-1.0.0.jar
215+
├── hello-jsii-1.0.0.jar.md5
216+
├── hello-jsii-1.0.0.jar.sha1
217+
├── hello-jsii-1.0.0.pom
218+
├── hello-jsii-1.0.0.pom.md5
219+
└── hello-jsii-1.0.0.pom.sha1
220+
├── maven-metadata.xml
221+
├── maven-metadata.xml.md5
222+
└── maven-metadata.xml.sha1
223223
├── js
224-
   └── hello-jsii@1.0.0.jsii.tgz
224+
└── hello-jsii@1.0.0.jsii.tgz
225225
└── sphinx
226226
└── hello-jsii.rst
227227
```

packages/jsii-calc-base-of-base/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"module": "scope.jsii_calc_base_of_base"
2525
},
2626
"sphinx": {}
27-
}
27+
},
28+
"versionFormat": "short"
2829
},
2930
"scripts": {
3031
"build": "jsii",

packages/jsii-calc-base-of-base/test/assembly.jsii

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"description": "An example transitive dependency for jsii-calc.",
1111
"homepage": "https://github.com/awslabs/jsii.git",
12+
"jsiiVersion": "0.8.2",
1213
"license": "Apache-2.0",
1314
"name": "@scope/jsii-calc-base-of-base",
1415
"repository": {
@@ -73,5 +74,5 @@
7374
}
7475
},
7576
"version": "0.8.2",
76-
"fingerprint": "oOrmdjK8cve8vAThWcnLUNaTPkvXx/XTFVMnVsR/dZc="
77+
"fingerprint": "II5j+yUrBn6dB/gWFSs9fbCeaOJTu2szjv0xtMpkn80="
7778
}

packages/jsii-calc-base/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"module": "scope.jsii_calc_base"
2525
},
2626
"sphinx": {}
27-
}
27+
},
28+
"versionFormat": "short"
2829
},
2930
"scripts": {
3031
"build": "jsii",
@@ -50,4 +51,4 @@
5051
"type": "git",
5152
"url": "https://github.com/awslabs/jsii.git"
5253
}
53-
}
54+
}

packages/jsii-calc-base/test/assembly.jsii

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"description": "An example direct dependency for jsii-calc.",
3737
"homepage": "https://github.com/awslabs/jsii.git",
38+
"jsiiVersion": "0.8.2",
3839
"license": "Apache-2.0",
3940
"name": "@scope/jsii-calc-base",
4041
"repository": {
@@ -111,5 +112,5 @@
111112
}
112113
},
113114
"version": "0.8.2",
114-
"fingerprint": "FrfcJZ64DB2APeRFjFb+EjYcfZxYEVji9GDpZ7KW1Ow="
115+
"fingerprint": "rxvvJXFGzGZKodg4kjh0+uD9J3GU64sbBwcOkTFU9l8="
115116
}

packages/jsii-calc-lib/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"module": "scope.jsii_calc_lib"
2525
},
2626
"sphinx": {}
27-
}
27+
},
28+
"versionFormat": "short"
2829
},
2930
"scripts": {
3031
"build": "jsii",
@@ -50,4 +51,4 @@
5051
"type": "git",
5152
"url": "https://github.com/awslabs/jsii.git"
5253
}
53-
}
54+
}

packages/jsii-calc-lib/test/assembly.jsii

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
},
6262
"description": "A simple calcuator library built on JSII.",
6363
"homepage": "https://github.com/awslabs/jsii.git",
64+
"jsiiVersion": "0.8.2",
6465
"license": "Apache-2.0",
6566
"name": "@scope/jsii-calc-lib",
6667
"repository": {
@@ -371,5 +372,5 @@
371372
}
372373
},
373374
"version": "0.8.2",
374-
"fingerprint": "8L8bV6COHcJBBT5CbQ4Bzwu5ZlT6VBMCXxB1S1TPczw="
375+
"fingerprint": "ydArnwt9qdOM1IiBaOFzS2A7t9/+na0q+OibmkwQrEg="
375376
}

packages/jsii-calc/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"module": "jsii_calc"
2525
},
2626
"sphinx": {}
27-
}
27+
},
28+
"versionFormat": "short"
2829
},
2930
"scripts": {
3031
"build": "jsii",
@@ -83,4 +84,4 @@
8384
"type": "git",
8485
"url": "https://github.com/awslabs/jsii.git"
8586
}
86-
}
87+
}

packages/jsii-calc/test/assembly.jsii

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
},
188188
"description": "A simple calcuator built on JSII.",
189189
"homepage": "https://github.com/awslabs/jsii.git",
190+
"jsiiVersion": "0.8.2",
190191
"license": "Apache-2.0",
191192
"name": "jsii-calc",
192193
"readme": {
@@ -4632,5 +4633,5 @@
46324633
}
46334634
},
46344635
"version": "0.8.2",
4635-
"fingerprint": "CSV1TF9zK+8oZfXWIov5XOKrTmFIpov07DaTV3k1IfA="
4636+
"fingerprint": "GihU8+thuZ1W9TNwDba1Ux44Rac3+kUHUCrGH73N0tw="
46364637
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"description": "An example direct dependency for jsii-calc.",
3737
"homepage": "https://github.com/awslabs/jsii.git",
38+
"jsiiVersion": "0.8.2",
3839
"license": "Apache-2.0",
3940
"name": "@scope/jsii-calc-base",
4041
"repository": {
@@ -111,5 +112,5 @@
111112
}
112113
},
113114
"version": "0.8.2",
114-
"fingerprint": "FrfcJZ64DB2APeRFjFb+EjYcfZxYEVji9GDpZ7KW1Ow="
115+
"fingerprint": "rxvvJXFGzGZKodg4kjh0+uD9J3GU64sbBwcOkTFU9l8="
115116
}

0 commit comments

Comments
 (0)