Skip to content

Commit bed45f0

Browse files
committed
GLSP-1363 Refactor CLI application
Remove dependency to shelljs for CLI application, refactor release/releng commands and introduce bundling with esbuild ## Remove dependency to shelljs Shelljs has some issues in its core architecture which prevent it from proper bundling. We only use a very small subset of shelljs features. Therefore I opted for removing the dependency alltogether and introduce replacement functions in our utility library that directly use node builtins under the hood ## Refactor release/releng commands - Remove the existing release commands and introduce a new set of releng commands that can also be used in CI and enable (partly) automated releases - These commands have already been used for the 2.5.0 release (i.e. have been tested and work) - Introduce helpers for working with (reading, updating etc.) workspace package jsons ## Bundle application with es build - Introduce bundling with es build for the CLI package - Package is now dependency free and ships the CLI app in one bundle (+ source maps) - Update package scripts accordingly - Introduce proper watch mode for CLI package - Introduce vs code lauch config for debugin the CLI application. When starting the config the desired arguments/commands can be passed via input box ## Add workflows - Add dispatch workflow to trigger a new release preparation PR for a repository Fixes /issues/1363
1 parent 88834be commit bed45f0

37 files changed

+2445
-2017
lines changed

.eslintignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Compiled output
2+
**/dist/
3+
**/lib/
4+
**/node_modules/
5+
6+
# Build files
7+
**/.eslintrc.js
8+
**/esbuild.js
9+
10+
# Other generated files
11+
**/*.map

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
module.exports = {
33
root: true,
44
extends: '@eclipse-glsp',
5-
ignorePatterns: ['**/{node_modules,lib}', '**/.eslintrc.js'],
65

76
parserOptions: {
87
tsconfigRootDir: __dirname,
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type (major, minor, patch, next, or custom)'
8+
required: true
9+
type: choice
10+
options:
11+
- major
12+
- minor
13+
- patch
14+
- next
15+
- custom
16+
custom_version:
17+
description: 'Custom version (required if release_type is custom)'
18+
required: false
19+
type: string
20+
release_repo:
21+
description: 'GLSP repository to release'
22+
required: true
23+
type: choice
24+
options:
25+
- glsp
26+
- glsp-client
27+
- glsp-theia-integration
28+
- glsp-server
29+
- glsp-server-node
30+
- glsp-eclipse-integration
31+
- glsp-vscode-integration
32+
- glsp-playwright
33+
branch:
34+
description: 'Branch to use for the release repo (default: default branch)'
35+
required: false
36+
type: string
37+
draft:
38+
description: 'Create PR as draft'
39+
required: false
40+
type: boolean
41+
default: false
42+
43+
jobs:
44+
release:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout release helper repo (@eclipse-glsp/glsp)
48+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
with:
50+
repository: eclipse-glsp/glsp
51+
path: glsp-release-helper
52+
53+
- name: Checkout release repo (${{ github.event.inputs.release_repo }})
54+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
55+
with:
56+
repository: eclipse-glsp/${{ github.event.inputs.release_repo }}
57+
path: release-repo
58+
ref: ${{ github.event.inputs.branch }}
59+
60+
- name: Set up Node.js
61+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
62+
with:
63+
node-version: 20
64+
65+
- name: Install Yarn
66+
run: npm install -g yarn
67+
68+
- name: Install dependencies in glsp-release-helper
69+
working-directory: ./glsp-release-helper
70+
run: yarn install
71+
72+
- name: Configure Git
73+
run: |
74+
git config --global user.name "eclipse-glsp-bot"
75+
git config --global user.email "[email protected]"
76+
77+
- name: Prepare release
78+
id: prepare_release
79+
working-directory: ./glsp-release-helper
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
DRAFT_FLAG=""
84+
if [[ "${{ github.event.inputs.draft }}" == "true" ]]; then
85+
DRAFT_FLAG="-d"
86+
fi
87+
88+
if [[ "${{ github.event.inputs.release_type }}" == "custom" ]]; then
89+
yarn glsp releng prepare custom "${{ github.event.inputs.custom_version }}" -r ${{ github.workspace }}/release-repo $DRAFT_FLAG
90+
else
91+
yarn glsp releng prepare "${{ github.event.inputs.release_type }}" -r ${{ github.workspace }}/release-repo $DRAFT_FLAG
92+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22
*.log
33
lib
4+
dist
45
tsconfig.tsbuildinfo
56
eslint.xml

.vscode/launch.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug GLSP CLI",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/dev-packages/cli/dist/cli.js",
9+
"args": "${input:cliArgs}",
10+
"cwd": "${workspaceFolder}",
11+
"console": "integratedTerminal",
12+
"sourceMaps": true,
13+
"outFiles": ["${workspaceFolder}/dev-packages/cli/dist/*.js"]
14+
}
15+
],
16+
"inputs": [
17+
{
18+
"id": "cliArgs",
19+
"description": "CLI arguments (space-separated, e.g., 'checkHeaders ./')",
20+
"default": "",
21+
"type": "promptString"
22+
}
23+
]
24+
}

dev-packages/cli/README.md

Lines changed: 143 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ Install `@eclipse-glsp/cli` as a dev dependency in your application.
1111
yarn add @eclipse-glsp/cli --dev
1212
```
1313

14+
## Usage
15+
16+
```console
17+
Usage: glsp [options] [command]
18+
19+
Options:
20+
-V, --version output the version number
21+
-h, --help display help for command
22+
23+
Commands:
24+
coverageReport [options] Generate a test coverage report for a glsp component
25+
checkHeaders [options] <rootDir> Validates the copyright year range (end year) of license header files
26+
updateNext|u [options] [rootDir] Updates all `next` dependencies in GLSP project to the latest version
27+
generateIndex [options] <rootDir...> Generate index files in a given source directory.
28+
releng Commands for GLSP release engineering (Linux only, intended for CI/Maintainer use).
29+
help [command] display help for command
30+
```
31+
1432
## checkHeaders
1533

1634
The `checkHeaders` command can be used to validate the copyright year (range) of license headers.
@@ -23,19 +41,21 @@ $ glsp checkHeaders -h
2341

2442
Usage: glsp checkHeaders [options] <rootDir>
2543

26-
Validates the copyright year range of license header files
44+
Validates the copyright year range (end year) of license header files
2745

2846
Arguments:
2947
rootDir The starting directory for the check
3048

3149
Options:
32-
-t, --type <type> The scope of the check. In addition to a full recursive check, is also possible to only consider pending changes or the last commit (choices: "full", "changes", "lastCommit", default:
33-
"full")
50+
-t, --type <type> The scope of the check. In addition to a full recursive check, is also possible to only
51+
consider pending changes or the last commit (choices: "full", "changes", "lastCommit",
52+
default: "full")
3453
-f, --fileExtensions <extensions...> File extensions that should be checked (default: ["ts","tsx"])
35-
-e, --exclude <exclude...> File patterns that should be excluded from the check. New exclude patterns are added to the default patterns (default: [**/@(node_modules|lib|dist|bundle)/**])
36-
--no-exclude-defaults Disables the default excludes patterns. Only explicitly passed exclude patterns (-e, --exclude) are considered
54+
-e, --exclude <exclude...> File patterns that should be excluded from the check. New exclude patterns are added to
55+
the default patterns (default: [**/@(node_modules|lib|dist|bundle)/**])
56+
--no-exclude-defaults Disables the default excludes patterns. Only explicitly passed exclude patterns (-e,
57+
--exclude) are considered
3758
-j, --json Also persist validation results as json file (default: false)
38-
-s, --severity <severity> The severity of validation results that should be printed. (choices: "error", "warn", "ok", default: "error" (only))
3959
-a, --autoFix Auto apply & commit fixes without prompting the user (default: false)
4060
-h, --help display help for command
4161
```
@@ -52,37 +72,12 @@ Usage: glsp coverageReport [options]
5272
Generate a test coverage report for a glsp component
5373

5474
Options:
55-
-p, --projectRoot <projectRoot> The root directory of the GLSP component (default: "<cwd>")
75+
-p, --projectRoot <projectRoot> The root directory of the GLSP component (default:
76+
"<cwd>")
5677
-c, --coverageScript <script> Script command of the package root for creating coverage reports (default: "test:coverage")
5778
-h, --help display help for command
5879
```
5980

60-
## release
61-
62-
Eclipse GLSP committers can use the `release` command to prepare & publish a new Github release for a specific GLSP component.
63-
64-
```console
65-
$ glsp release -h
66-
Usage: glsp release [options] <component> <releaseType> [customVersion]
67-
68-
Prepare & publish a new release for a glsp component
69-
70-
Arguments:
71-
component The glsp component to be released (choices: "client", "theia-integration", "vscode-integration", "eclipse-integration", "server-node", "server-java")
72-
releaseType The release type (choices: "major", "minor", "patch", "rc", "custom")
73-
customVersion Custom version number. Will be ignored if the release type is not "custom"
74-
75-
Options:
76-
-f, --force Enable force mode (default: false)
77-
-d, --checkoutDir <checkoutDir> The git checkout directory (default: "<cwd>")
78-
-b, --branch <branch> The git branch to checkout (default: "master")
79-
-v, --verbose Enable verbose (debug) log output (default: false)
80-
--no-publish Only prepare release but do not publish to github
81-
--draft Publish github releases as drafts (default: false)
82-
--npm-dryRun Execute a npm dry-run for inspection. Publishes to the local npm registry and does not publish to github (default: false)
83-
-h, --help display help for command
84-
```
85-
8681
## updateNext
8782

8883
```console
@@ -105,25 +100,135 @@ Use this command to create an index file of all sources for a given directory an
105100

106101
```console
107102
$ glsp generateIndex -h
108-
Usage: glsp generateIndex [options] <rootDir>
103+
Usage: glsp generateIndex [options] <rootDir...>
109104

110105
Generate index files in a given source directory.
111106

112107
Arguments:
113108
rootDir The source directory for index generation.
114109

115110
Options:
116-
-s, --singleIndex Generate a single index file in the source directory instead of indices in each sub-directory (default: false)
111+
-s, --singleIndex Generate a single index file in the source directory instead of indices in each
112+
sub-directory (default: false)
117113
-f, --forceOverwrite Overwrite existing index files and remove them if there are no entries (default: false)
118114
-m, --match [match patterns...] File patterns to consider during indexing (default: ["**/*.ts","**/*.tsx"])
119-
-i, --ignore [ignore patterns...] File patterns to ignore during indexing (default: ["**/*.spec.ts","**/*.spec.tsx","**/*.d.ts"])
120-
-s, --style <importStyle> Import Style (choices: "commonjs", "esm", default: "commonjs")
121-
--ignoreFile <ignoreFile> The file that is used to specify patterns that should be ignored during indexing (default: ".indexignore")
115+
-i, --ignore [ignore patterns...] File patterns to ignore during indexing (default:
116+
["**/*.spec.ts","**/*.spec.tsx","**/*.d.ts"])
117+
--style <importStyle> Import Style (choices: "commonjs", "esm", default: "commonjs")
118+
--ignoreFile <ignoreFile> The file that is used to specify patterns that should be ignored during indexing (default:
119+
".indexignore")
122120
-v, --verbose Generate verbose output during generation (default: false)
123121
-h, --help display help for command
124122
```
125123

124+
## releng
125+
126+
Commands for GLSP release engineering.
127+
These commands are intended for CI usage and direct usage by Eclipse GLSP committers.
128+
They are not general-purpose commands. Subcommands might rely on tools and CLI commands that are only available in
129+
Linux environments.
130+
131+
```console
132+
$ glsp releng -h
133+
Usage: glsp releng [options] [command]
134+
135+
Commands for GLSP release engineering (Linux only, intended for CI/Maintainer use).
136+
137+
Options:
138+
-h, --help display help for command
139+
140+
Commands:
141+
version [options] <versionType> [customVersion] Set the version of all packages in a GLSP repository
142+
prepare [options] <versionType> [customVersion] Prepare a new release for a GLSP component (version bump, changelog, PR
143+
creation ...)
144+
publish [options] Publish a new release for a GLSP component (npm, maven, github ...)
145+
help [command] display help for command
146+
```
147+
148+
### version
149+
150+
Command to bump the version of all packages in a GLSP repository.
151+
Similar to "lerna version" this bumps the version of all workspace packages.
152+
In addition, external GLSP dependencies are considered and bumped as well.
153+
The glsp repository type ("glsp-client", "glsp-server-node" etc.) is auto detected from the given repository path.
154+
If the command is invoked in a non-GLSP repository it will fail.
155+
156+
```console
157+
$ glsp releng version -h
158+
Usage: glsp releng version [options] <versionType> [customVersion]
159+
160+
Set the version of all packages in a GLSP repository
161+
162+
Arguments:
163+
versionType The version type (choices: "major", "minor", "patch", "custom", "next")
164+
customVersion Custom version number. Will be ignored if the release type is not "custom"
165+
166+
Options:
167+
-v, --verbose Enable verbose (debug) log output (default: false)
168+
-r, --repoDir <repoDir> Path to the component repository (default:
169+
"<cwd>")
170+
-h, --help display help for command
171+
```
172+
173+
### prepare
174+
175+
Prepares a new release for a GLSP repository.
176+
This includes bumping the version, updating the changelog, commit & push the changes
177+
and opening a PR for the release.
178+
179+
The glsp repository type ("glsp-client", "glsp-server-node" etc.) is auto detected from the given repository path.
180+
If the command is invoked in a non-GLSP repository it will fail.
181+
182+
```console
183+
$ glsp releng prepare -h
184+
Usage: glsp releng prepare [options] <versionType> [customVersion]
185+
186+
Prepare a new release for a GLSP component (version bump, changelog, PR creation ...)
187+
188+
Arguments:
189+
versionType The version type (choices: "major", "minor", "patch", "custom", "next")
190+
customVersion Custom version number. Will be ignored if the release type is not "custom"
191+
192+
Options:
193+
-v, --verbose Enable verbose (debug) log output (default: false)
194+
-r, --repoDir <repoDir> Path to the component repository (default:
195+
"<cwd>")
196+
--no-push Do not push changes to remote git repository
197+
-d, --draft Create a draft pull request (only if push is enabled) (default: false)
198+
--no-check Skip initial checks for existing dependency versions
199+
-h, --help display help for command
200+
```
201+
202+
### publish
203+
204+
Helper command for publishing a new GLSP release.
205+
This command should be used on the main branch of GLSP repo after a (previously prepared) Release PR has been merged.
206+
Creates & publishes an new tag and Github release.
207+
In addition, for all non-Java repositories the release version will be published to npm.
208+
209+
The glsp repository type ("glsp-client", "glsp-server-node" etc.) is auto detected from the given repository path.
210+
If the command is invoked in a non-GLSP repository it will fail.
211+
212+
```console
213+
$ glsp releng publish -h\
214+
Usage: glsp releng publish [options]
215+
216+
Publish a new release for a GLSP component (npm, maven, github ...)
217+
218+
Options:
219+
-v, --verbose Enable verbose (debug) log output (default: false)
220+
-r, --repoDir <repoDir> Path to the component repository (default:
221+
"<cwd>")
222+
--no-npm Skip npm publishing
223+
-d, --draft Create a draft GitHub release (default: false)
224+
-h, --help display help for command
225+
```
226+
126227
## More information
127228

128229
For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/).
129230
If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/).
231+
232+
```
233+
234+
```

0 commit comments

Comments
 (0)