Skip to content

Commit

Permalink
feat(node,jsii): npmDistTag
Browse files Browse the repository at this point in the history
Support releasing to an npm dist tag
  • Loading branch information
Elad Ben-Israel committed Jul 5, 2020
1 parent d9f6a9a commit 142e591
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ jobs:
run: npx -p jsii-release jsii-release-npm
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_DIST_TAG: latest
8 changes: 8 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ new JsiiProject(options: JsiiProjectOptions)
* **keywords** (<code>Array<string></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **maxNodeVersion** (<code>string</code>) Minimum node.js version to require via `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no max
* **minNodeVersion** (<code>string</code>) Node.js version to require via package.json `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no "engines" specified
* **npmDistTag** (<code>string</code>) The dist-tag to use when releasing to npm. <span style="text-decoration: underline">*Default*</span>: "latest"
* **peerDependencies** (<code>Map<string, [Semver](#projen-semver)></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **peerDependencyOptions** (<code>[PeerDependencyOptions](#projen-peerdependencyoptions)</code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **projenDevDependency** (<code>boolean</code>) Indicates of "projen" should be installed as a devDependency. <span style="text-decoration: underline">*Default*</span>: true
Expand Down Expand Up @@ -632,6 +633,7 @@ new NodeProject(options: NodeProjectOptions)
* **keywords** (<code>Array<string></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **maxNodeVersion** (<code>string</code>) Minimum node.js version to require via `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no max
* **minNodeVersion** (<code>string</code>) Node.js version to require via package.json `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no "engines" specified
* **npmDistTag** (<code>string</code>) The dist-tag to use when releasing to npm. <span style="text-decoration: underline">*Default*</span>: "latest"
* **peerDependencies** (<code>Map<string, [Semver](#projen-semver)></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **peerDependencyOptions** (<code>[PeerDependencyOptions](#projen-peerdependencyoptions)</code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **projenDevDependency** (<code>boolean</code>) Indicates of "projen" should be installed as a devDependency. <span style="text-decoration: underline">*Default*</span>: true
Expand Down Expand Up @@ -661,6 +663,7 @@ new NodeProject(options: NodeProjectOptions)

Name | Type | Description
-----|------|-------------
**npmDistTag**🔹 | <code>string</code> | <span></span>
**npmignore**🔹 | <code>[IgnoreFile](#projen-ignorefile)</code> | <span></span>
**version**🔹 | <code>any</code> | Returns the current version of the project.
**buildWorkflow**?🔹 | <code>[NodeBuildWorkflow](#projen-nodebuildworkflow)</code> | The PR build GitHub workflow.<br/><span style="text-decoration: underline">*Optional*</span>
Expand Down Expand Up @@ -961,6 +964,7 @@ new TypeScriptLibraryProject(options: TypeScriptLibraryProjectOptions)
* **keywords** (<code>Array<string></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **maxNodeVersion** (<code>string</code>) Minimum node.js version to require via `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no max
* **minNodeVersion** (<code>string</code>) Node.js version to require via package.json `engines` (inclusive). <span style="text-decoration: underline">*Default*</span>: no "engines" specified
* **npmDistTag** (<code>string</code>) The dist-tag to use when releasing to npm. <span style="text-decoration: underline">*Default*</span>: "latest"
* **peerDependencies** (<code>Map<string, [Semver](#projen-semver)></code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **peerDependencyOptions** (<code>[PeerDependencyOptions](#projen-peerdependencyoptions)</code>) *No description* <span style="text-decoration: underline">*Optional*</span>
* **projenDevDependency** (<code>boolean</code>) Indicates of "projen" should be installed as a devDependency. <span style="text-decoration: underline">*Default*</span>: true
Expand Down Expand Up @@ -1083,6 +1087,7 @@ Name | Type | Description
**keywords**?🔹 | <code>Array<string></code> | <span style="text-decoration: underline">*Optional*</span>
**maxNodeVersion**?🔹 | <code>string</code> | Minimum node.js version to require via `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no max
**minNodeVersion**?🔹 | <code>string</code> | Node.js version to require via package.json `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no "engines" specified
**npmDistTag**?🔹 | <code>string</code> | The dist-tag to use when releasing to npm.<br/><span style="text-decoration: underline">*Default*</span>: "latest"
**peerDependencies**?🔹 | <code>Map<string, [Semver](#projen-semver)></code> | <span style="text-decoration: underline">*Optional*</span>
**peerDependencyOptions**?🔹 | <code>[PeerDependencyOptions](#projen-peerdependencyoptions)</code> | <span style="text-decoration: underline">*Optional*</span>
**projenDevDependency**?🔹 | <code>boolean</code> | Indicates of "projen" should be installed as a devDependency.<br/><span style="text-decoration: underline">*Default*</span>: true
Expand Down Expand Up @@ -1206,6 +1211,7 @@ Name | Type | Description
**maxNodeVersion**?🔹 | <code>string</code> | Minimum node.js version to require via `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no max
**mergify**?🔹 | <code>boolean</code> | Add mergify configuration.<br/><span style="text-decoration: underline">*Default*</span>: true
**minNodeVersion**?🔹 | <code>string</code> | Node.js version to require via package.json `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no "engines" specified
**npmDistTag**?🔹 | <code>string</code> | The dist-tag to use when releasing to npm.<br/><span style="text-decoration: underline">*Default*</span>: "latest"
**outdir**?🔹 | <code>string</code> | Compiler artifacts output directory.<br/><span style="text-decoration: underline">*Default*</span>: "lib"
**peerDependencies**?🔹 | <code>Map<string, [Semver](#projen-semver)></code> | <span style="text-decoration: underline">*Optional*</span>
**peerDependencyOptions**?🔹 | <code>[PeerDependencyOptions](#projen-peerdependencyoptions)</code> | <span style="text-decoration: underline">*Optional*</span>
Expand Down Expand Up @@ -1326,6 +1332,7 @@ Name | Type | Description
**license**?🔹 | <code>string</code> | <span style="text-decoration: underline">*Optional*</span>
**maxNodeVersion**?🔹 | <code>string</code> | Minimum node.js version to require via `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no max
**minNodeVersion**?🔹 | <code>string</code> | Node.js version to require via package.json `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no "engines" specified
**npmDistTag**?🔹 | <code>string</code> | The dist-tag to use when releasing to npm.<br/><span style="text-decoration: underline">*Default*</span>: "latest"
**npmignore**?🔹 | <code>Array<string></code> | <span style="text-decoration: underline">*Optional*</span>
**outdir**?🔹 | <code>string</code> | <span style="text-decoration: underline">*Default*</span>: . current directory
**peerDependencies**?🔹 | <code>Map<string, [Semver](#projen-semver)></code> | <span style="text-decoration: underline">*Optional*</span>
Expand Down Expand Up @@ -1401,6 +1408,7 @@ Name | Type | Description
**mergify**?🔹 | <code>boolean</code> | Adds mergify configuration.<br/><span style="text-decoration: underline">*Default*</span>: true
**mergifyOptions**?🔹 | <code>[MergifyOptions](#projen-mergifyoptions)</code> | Options for mergify.<br/><span style="text-decoration: underline">*Default*</span>: default options
**minNodeVersion**?🔹 | <code>string</code> | Node.js version to require via package.json `engines` (inclusive).<br/><span style="text-decoration: underline">*Default*</span>: no "engines" specified
**npmDistTag**?🔹 | <code>string</code> | The dist-tag to use when releasing to npm.<br/><span style="text-decoration: underline">*Default*</span>: "latest"
**npmignore**?🔹 | <code>Array<string></code> | <span style="text-decoration: underline">*Optional*</span>
**outdir**?🔹 | <code>string</code> | <span style="text-decoration: underline">*Default*</span>: . current directory
**peerDependencies**?🔹 | <code>Map<string, [Semver](#projen-semver)></code> | <span style="text-decoration: underline">*Optional*</span>
Expand Down
1 change: 1 addition & 0 deletions src/jsii-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export class JsiiProject extends NodeProject {
run: 'npx -p jsii-release jsii-release-npm',
env: {
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}',
NPM_DIST_TAG: this.npmDistTag,
},
},
],
Expand Down
12 changes: 12 additions & 0 deletions src/node-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ export interface CommonOptions {
* @default - same as `minNodeVersion`
*/
readonly workflowNodeVersion?: string;

/**
* The dist-tag to use when releasing to npm.
*
* @default "latest"
*/
readonly npmDistTag?: string;
}

export interface NodeProjectOptions extends ProjectOptions, CommonOptions {
Expand Down Expand Up @@ -156,6 +163,8 @@ export class NodeProject extends Project {
public readonly minNodeVersion?: string;
public readonly maxNodeVersion?: string;

protected readonly npmDistTag: string;

constructor(options: NodeProjectOptions) {
super(options);

Expand All @@ -172,6 +181,8 @@ export class NodeProject extends Project {
nodeVersion += ` <= ${this.maxNodeVersion}`;
}

this.npmDistTag = options.npmDistTag ?? 'latest';

this.manifest = {
'//': GENERATION_DISCLAIMER,
'name': options.name,
Expand Down Expand Up @@ -278,6 +289,7 @@ export class NodeProject extends Project {
run: 'npx -p jsii-release jsii-release-npm',
env: {
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}',
NPM_DIST_TAG: this.npmDistTag,
},
},
],
Expand Down

0 comments on commit 142e591

Please sign in to comment.