Skip to content

Commit 847298e

Browse files
committed
Introduce rush-published-versions-json-plugin.
1 parent cc3fb1f commit 847298e

14 files changed

Lines changed: 347 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/rush-published-versions-json-plugin",
5+
"comment": "Initial release.",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@rushstack/rush-published-versions-json-plugin"
10+
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.
2+
3+
# Ignore all files by default, to avoid accidentally publishing unintended files.
4+
*
5+
6+
# Use negative patterns to bring back the specific things we want to publish.
7+
!/bin/**
8+
!/lib/**
9+
!/lib-*/**
10+
!/dist/**
11+
!/includes/**
12+
13+
!CHANGELOG.md
14+
!CHANGELOG.json
15+
!heft-plugin.json
16+
!rush-plugin-manifest.json
17+
!ThirdPartyNotice.txt
18+
19+
# Ignore certain patterns that should not get published.
20+
/dist/*.stats.*
21+
/lib/**/test/
22+
/lib-*/**/test/
23+
*.test.js
24+
*.test.[cm]js
25+
*.test.d.ts
26+
*.test.d.[cm]ts
27+
28+
# NOTE: These don't need to be specified, because NPM includes them automatically.
29+
#
30+
# package.json
31+
# README.md
32+
# LICENSE
33+
34+
# ---------------------------------------------------------------------------
35+
# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below.
36+
# ---------------------------------------------------------------------------
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@rushstack/rush-published-versions-json-plugin
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
MIT License
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
"Software"), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# @rushstack/rush-published-versions-json-plugin
2+
3+
A Rush plugin that generates a JSON file recording the version numbers of all published packages in a Rush monorepo.
4+
5+
## Installation
6+
7+
1. Add the plugin package to an autoinstaller (e.g. `common/autoinstallers/rush-plugins/package.json`):
8+
9+
```
10+
rush init-autoinstaller --name rush-plugins
11+
```
12+
13+
```bash
14+
cd common/autoinstallers/rush-plugins
15+
pnpm add @rushstack/rush-published-versions-json-plugin
16+
rush update-autoinstaller --name rush-plugins
17+
```
18+
19+
2. Register the plugin in `common/config/rush/rush-plugins.json`:
20+
21+
```json
22+
{
23+
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugins.schema.json",
24+
"plugins": [
25+
{
26+
"packageName": "@rushstack/rush-published-versions-json-plugin",
27+
"pluginName": "rush-published-versions-json-plugin",
28+
"autoinstallerName": "rush-plugins"
29+
}
30+
]
31+
}
32+
```
33+
34+
3. Run `rush update` to install the plugin.
35+
36+
## Usage
37+
38+
```bash
39+
rush record-published-versions --output-path <FILE_PATH>
40+
```
41+
42+
### Parameters
43+
44+
| Parameter | Short | Required | Description |
45+
| --- | --- | --- | --- |
46+
| `--output-path` | `-o` | Yes | The path to the output JSON file. Relative paths are resolved from the repo root. |
47+
48+
### Example
49+
50+
```bash
51+
rush record-published-versions --output-path common/config/published-versions.json
52+
```
53+
54+
### Output format
55+
56+
The output is a JSON object mapping published package names to their current versions:
57+
58+
```json
59+
{
60+
"@my-scope/my-library": "1.2.3",
61+
"@my-scope/my-app": "0.5.0"
62+
}
63+
```
64+
65+
A package is included if it has `shouldPublish` set to `true` or has a `versionPolicy` assigned in
66+
**rush.json**.
67+
68+
## Links
69+
70+
- [CHANGELOG.md](./CHANGELOG.md)
71+
- [Rush: Using rush plugins](https://rushjs.io/pages/maintainer/using_rush_plugins/)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json",
3+
"commands": [
4+
{
5+
"commandKind": "global",
6+
"name": "record-published-versions",
7+
"summary": "Generates a JSON file recording the version numbers of all published packages.",
8+
"safeForSimultaneousRushProcesses": true,
9+
// The command is handled by the plugin, so we don't want Rush to attempt to execute anything.
10+
"shellCommand": ""
11+
}
12+
],
13+
"parameters": [
14+
{
15+
"parameterKind": "string",
16+
"longName": "--output-path",
17+
"shortName": "-o",
18+
"argumentName": "FILE_PATH",
19+
"description": "The path to the output JSON file. Relative paths are resolved from the repo root.",
20+
"associatedCommands": ["record-published-versions"],
21+
"required": true
22+
}
23+
]
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// The "rig.json" file directs tools to look for their config files in an external package.
3+
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4+
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5+
6+
"rigPackageName": "local-node-rig"
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
const nodeProfile = require('local-node-rig/profiles/default/includes/eslint/flat/profile/node');
5+
const friendlyLocalsMixin = require('local-node-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals');
6+
const tsdocMixin = require('local-node-rig/profiles/default/includes/eslint/flat/mixins/tsdoc');
7+
8+
module.exports = [
9+
...nodeProfile,
10+
...friendlyLocalsMixin,
11+
...tsdocMixin,
12+
{
13+
files: ['**/*.ts', '**/*.tsx'],
14+
languageOptions: {
15+
parserOptions: {
16+
tsconfigRootDir: __dirname
17+
}
18+
}
19+
}
20+
];
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "@rushstack/rush-published-versions-json-plugin",
3+
"version": "0.0.0",
4+
"description": "A Rush plugin for generating a JSON file containing the versions of all published packages in the monorepo.",
5+
"license": "MIT",
6+
"repository": {
7+
"url": "https://github.com/microsoft/rushstack.git",
8+
"type": "git",
9+
"directory": "rush-plugins/rush-published-versions-json-plugin"
10+
},
11+
"scripts": {
12+
"build": "heft test --clean",
13+
"_phase:build": "heft run --only build -- --clean"
14+
},
15+
"dependencies": {
16+
"@rushstack/node-core-library": "workspace:*",
17+
"@rushstack/rush-sdk": "workspace:*",
18+
"@rushstack/terminal": "workspace:*"
19+
},
20+
"devDependencies": {
21+
"@rushstack/heft": "workspace:*",
22+
"@rushstack/ts-command-line": "workspace:*",
23+
"eslint": "~9.37.0",
24+
"local-node-rig": "workspace:*"
25+
},
26+
"main": "./lib-commonjs/index.js",
27+
"module": "./lib-esm/index.js",
28+
"types": "./lib-dts/index.d.ts",
29+
"exports": {
30+
".": {
31+
"types": "./lib-dts/index.d.ts",
32+
"import": "./lib-esm/index.js",
33+
"require": "./lib-commonjs/index.js"
34+
},
35+
"./lib/*": {
36+
"types": "./lib-dts/*.d.ts",
37+
"import": "./lib-esm/*.js",
38+
"require": "./lib-commonjs/*.js"
39+
},
40+
"./package.json": "./package.json"
41+
},
42+
"typesVersions": {
43+
"*": {
44+
"lib/*": [
45+
"lib-dts/*"
46+
]
47+
}
48+
}
49+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json",
3+
"plugins": [
4+
{
5+
"pluginName": "rush-published-versions-json-plugin",
6+
"description": "A Rush plugin for generating a JSON file containing the versions of all published packages in the monorepo.",
7+
"entryPoint": "./lib-commonjs/index.js",
8+
"associatedCommands": ["record-published-versions"],
9+
"commandLineJsonFilePath": "./command-line.json"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)