@eclipse-glsp/cli 2.3.0-next.164 → 2.3.0-next.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +143 -38
  2. package/dist/cli.js +21959 -0
  3. package/dist/cli.js.map +6 -0
  4. package/package.json +22 -29
  5. package/bin/glsp +0 -2
  6. package/lib/app.d.ts +0 -2
  7. package/lib/app.d.ts.map +0 -1
  8. package/lib/app.js +0 -35
  9. package/lib/app.js.map +0 -1
  10. package/lib/commands/check-header.d.ts +0 -21
  11. package/lib/commands/check-header.d.ts.map +0 -1
  12. package/lib/commands/check-header.js +0 -240
  13. package/lib/commands/check-header.js.map +0 -1
  14. package/lib/commands/coverage-report.d.ts +0 -29
  15. package/lib/commands/coverage-report.d.ts.map +0 -1
  16. package/lib/commands/coverage-report.js +0 -126
  17. package/lib/commands/coverage-report.js.map +0 -1
  18. package/lib/commands/generate-index.d.ts +0 -46
  19. package/lib/commands/generate-index.d.ts.map +0 -1
  20. package/lib/commands/generate-index.js +0 -172
  21. package/lib/commands/generate-index.js.map +0 -1
  22. package/lib/commands/release/common.d.ts +0 -68
  23. package/lib/commands/release/common.d.ts.map +0 -1
  24. package/lib/commands/release/common.js +0 -293
  25. package/lib/commands/release/common.js.map +0 -1
  26. package/lib/commands/release/release-client.d.ts +0 -3
  27. package/lib/commands/release/release-client.d.ts.map +0 -1
  28. package/lib/commands/release/release-client.js +0 -58
  29. package/lib/commands/release/release-client.js.map +0 -1
  30. package/lib/commands/release/release-eclipse-integration.d.ts +0 -18
  31. package/lib/commands/release/release-eclipse-integration.d.ts.map +0 -1
  32. package/lib/commands/release/release-eclipse-integration.js +0 -93
  33. package/lib/commands/release/release-eclipse-integration.js.map +0 -1
  34. package/lib/commands/release/release-java-server.d.ts +0 -3
  35. package/lib/commands/release/release-java-server.d.ts.map +0 -1
  36. package/lib/commands/release/release-java-server.js +0 -71
  37. package/lib/commands/release/release-java-server.js.map +0 -1
  38. package/lib/commands/release/release-server-node.d.ts +0 -18
  39. package/lib/commands/release/release-server-node.d.ts.map +0 -1
  40. package/lib/commands/release/release-server-node.js +0 -54
  41. package/lib/commands/release/release-server-node.js.map +0 -1
  42. package/lib/commands/release/release-theia-integration.d.ts +0 -18
  43. package/lib/commands/release/release-theia-integration.d.ts.map +0 -1
  44. package/lib/commands/release/release-theia-integration.js +0 -54
  45. package/lib/commands/release/release-theia-integration.js.map +0 -1
  46. package/lib/commands/release/release-vscode-integration.d.ts +0 -18
  47. package/lib/commands/release/release-vscode-integration.d.ts.map +0 -1
  48. package/lib/commands/release/release-vscode-integration.js +0 -54
  49. package/lib/commands/release/release-vscode-integration.js.map +0 -1
  50. package/lib/commands/release/release.d.ts +0 -14
  51. package/lib/commands/release/release.d.ts.map +0 -1
  52. package/lib/commands/release/release.js +0 -191
  53. package/lib/commands/release/release.js.map +0 -1
  54. package/lib/commands/update-next.d.ts +0 -20
  55. package/lib/commands/update-next.d.ts.map +0 -1
  56. package/lib/commands/update-next.js +0 -146
  57. package/lib/commands/update-next.js.map +0 -1
  58. package/lib/util/command-util.d.ts +0 -26
  59. package/lib/util/command-util.d.ts.map +0 -1
  60. package/lib/util/command-util.js +0 -56
  61. package/lib/util/command-util.js.map +0 -1
  62. package/lib/util/git-util.d.ts +0 -42
  63. package/lib/util/git-util.d.ts.map +0 -1
  64. package/lib/util/git-util.js +0 -125
  65. package/lib/util/git-util.js.map +0 -1
  66. package/lib/util/logger.d.ts +0 -23
  67. package/lib/util/logger.d.ts.map +0 -1
  68. package/lib/util/logger.js +0 -50
  69. package/lib/util/logger.js.map +0 -1
  70. package/lib/util/validation-util.d.ts +0 -5
  71. package/lib/util/validation-util.d.ts.map +0 -1
  72. package/lib/util/validation-util.js +0 -86
  73. package/lib/util/validation-util.js.map +0 -1
  74. package/src/app.ts +0 -34
  75. package/src/commands/check-header.ts +0 -280
  76. package/src/commands/coverage-report.ts +0 -113
  77. package/src/commands/generate-index.ts +0 -169
  78. package/src/commands/release/common.ts +0 -306
  79. package/src/commands/release/release-client.ts +0 -55
  80. package/src/commands/release/release-eclipse-integration.ts +0 -113
  81. package/src/commands/release/release-java-server.ts +0 -73
  82. package/src/commands/release/release-server-node.ts +0 -61
  83. package/src/commands/release/release-theia-integration.ts +0 -65
  84. package/src/commands/release/release-vscode-integration.ts +0 -67
  85. package/src/commands/release/release.ts +0 -215
  86. package/src/commands/update-next.ts +0 -129
  87. package/src/util/command-util.ts +0 -54
  88. package/src/util/git-util.ts +0 -123
  89. package/src/util/logger.ts +0 -57
  90. package/src/util/validation-util.ts +0 -62
@@ -1,169 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2023-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { createOption } from 'commander';
18
- import * as fs from 'fs';
19
- import * as os from 'os';
20
- import * as path from 'path';
21
- import sh from 'shelljs';
22
- import { baseCommand } from '../util/command-util';
23
- import { LOGGER, configureLogger } from '../util/logger';
24
- import { validateDirectory } from '../util/validation-util';
25
-
26
- export interface GenerateIndexCmdOptions {
27
- singleIndex: boolean;
28
- forceOverwrite: boolean;
29
- match: string[] | boolean;
30
- ignore: string[] | boolean;
31
- ignoreFile: string;
32
- style: 'commonjs' | 'esm';
33
- verbose: boolean;
34
- }
35
-
36
- // Partial type of the globby imports since we can not use the esm type directly
37
- interface GlobbyOptions {
38
- ignore: string[];
39
- cwd: string;
40
- onlyFiles: boolean;
41
- markDirectories: true;
42
- ignoreFiles: string;
43
- }
44
-
45
- export const GenerateIndex = baseCommand() //
46
- .name('generateIndex')
47
- .description('Generate index files in a given source directory.')
48
- .argument('<rootDir...>', 'The source directory for index generation.')
49
- .option('-s, --singleIndex', 'Generate a single index file in the source directory instead of indices in each sub-directory', false)
50
- .option('-f, --forceOverwrite', 'Overwrite existing index files and remove them if there are no entries', false)
51
- .option('-m, --match [match patterns...]', 'File patterns to consider during indexing', ['**/*.ts', '**/*.tsx'])
52
- .option('-i, --ignore [ignore patterns...]', 'File patterns to ignore during indexing', ['**/*.spec.ts', '**/*.spec.tsx', '**/*.d.ts'])
53
- .addOption(createOption('-s, --style <importStyle>', 'Import Style').choices(['commonjs', 'esm']).default('commonjs'))
54
- .option('--ignoreFile <ignoreFile>', 'The file that is used to specify patterns that should be ignored during indexing', '.indexignore')
55
- .option('-v, --verbose', 'Generate verbose output during generation', false)
56
- .action(generateIndices);
57
-
58
- export async function generateIndices(rootDirs: string[], options: GenerateIndexCmdOptions): Promise<void> {
59
- const dirs = rootDirs.map(rootDir => validateDirectory(path.resolve(rootDir)));
60
- const globby = await import('globby');
61
- const ignoreFilter: (pattern: string[], options: GlobbyOptions) => string[] = (pattern, globbyOptions) =>
62
- globby.globbySync(pattern, globbyOptions);
63
- dirs.forEach(dir => generateIndex(dir, ignoreFilter, options));
64
- }
65
-
66
- export async function generateIndex(
67
- rootDir: string,
68
- ignoreFilter: (pattern: string[], options: GlobbyOptions) => string[],
69
- options: GenerateIndexCmdOptions
70
- ): Promise<void> {
71
- configureLogger(options.verbose);
72
- LOGGER.debug('Run generateIndex for', rootDir, 'with the following options:', options);
73
- sh.cd(rootDir);
74
- const cwd = process.cwd();
75
-
76
- // we want to match all given patterns and subdirectories and ignore all given patterns and (generated) index files
77
- const pattern = typeof options.match === 'boolean' ? ['**/'] : [...options.match, '**/'];
78
- const ignore = typeof options.ignore === 'boolean' ? ['**/index.ts'] : [...options.ignore, '**/index.ts'];
79
- const globbyOptions: GlobbyOptions = {
80
- ignore,
81
- cwd,
82
- onlyFiles: options.singleIndex,
83
- markDirectories: true, // directories have '/' at the end
84
- ignoreFiles: '**/' + options.ignoreFile // users can add this file in their directories to ignore files for indexing
85
- };
86
- LOGGER.debug('Search for children using the following globby options', globbyOptions);
87
- const files = ignoreFilter(pattern, globbyOptions);
88
- LOGGER.debug('All children considered in the input directory', files);
89
-
90
- const relativeRootDirectory = '';
91
- if (options.singleIndex) {
92
- writeIndex(relativeRootDirectory, files.filter(isFile), options);
93
- } else {
94
- // sort by length so we deal with sub-directories before we deal with their parents to determine whether they are empty
95
- const directories = [...files.filter(isDirectory), relativeRootDirectory].sort((left, right) => right.length - left.length);
96
- const directoryChildren = new Map<string, string[]>();
97
- for (const directory of directories) {
98
- const children = files.filter(file => isDirectChild(directory, file, () => !!directoryChildren.get(file)?.length));
99
- directoryChildren.set(directory, children);
100
- writeIndex(directory, children, options);
101
- }
102
- }
103
- }
104
-
105
- export function isDirectChild(parent: string, child: string, childHasChildren: () => boolean): boolean {
106
- return isChildFile(parent, child) || (isChildDirectory(parent, child) && childHasChildren());
107
- }
108
-
109
- export function isDirectory(file: string): boolean {
110
- return file.endsWith('/');
111
- }
112
-
113
- export function isFile(file: string): boolean {
114
- return !isDirectory(file);
115
- }
116
-
117
- export function getLevel(file: string): number {
118
- return file.split('/').length;
119
- }
120
-
121
- export function isChild(parent: string, child: string): boolean {
122
- return child.startsWith(parent);
123
- }
124
-
125
- export function isChildDirectory(parent: string, child: string): boolean {
126
- return isDirectory(child) && isChild(parent, child) && getLevel(child) === getLevel(parent) + 1;
127
- }
128
-
129
- export function isChildFile(parent: string, child: string): boolean {
130
- return isFile(child) && isChild(parent, child) && getLevel(child) === getLevel(parent);
131
- }
132
-
133
- export function writeIndex(directory: string, exports: string[], options: GenerateIndexCmdOptions): void {
134
- const indexFile = path.join(process.cwd(), directory, 'index.ts');
135
- if (exports.length === 0) {
136
- if (options.forceOverwrite && fs.existsSync(indexFile)) {
137
- LOGGER.info('Remove index file', indexFile);
138
- fs.rmSync(indexFile);
139
- }
140
- return;
141
- }
142
- const exists = fs.existsSync(indexFile);
143
- if (exists && !options.forceOverwrite) {
144
- LOGGER.info("Do not overwrite existing index file. Use '-f' to force an overwrite.", indexFile);
145
- return;
146
- }
147
-
148
- const headerContent = exists ? extractReusableContent(fs.readFileSync(indexFile, { encoding: 'utf-8' })) : '';
149
- const exportContent = exports.map(exported => createExport(directory, exported, options)).sort();
150
- const content = headerContent + exportContent.join(os.EOL) + os.EOL; // end with an empty line
151
- LOGGER.info((exists ? 'Overwrite' : 'Write') + ' index file', indexFile);
152
- LOGGER.debug(' ' + content.split(os.EOL).join(os.EOL + ' '));
153
- fs.writeFileSync(indexFile, content, { flag: 'w' });
154
- }
155
-
156
- export function createExport(directory: string, relativePath: string, options: GenerateIndexCmdOptions): string {
157
- // remove directory prefix, file extension and directory ending '/'
158
- const parentPrefix = directory.length;
159
- const suffix = isFile(relativePath) ? path.extname(relativePath).length : 1;
160
- const relativeName = relativePath.substring(parentPrefix, relativePath.length - suffix);
161
- const exportName = options.style === 'esm' && isFile(relativePath) ? relativeName + '.js' : relativeName;
162
- const exportLine = `export * from './${exportName}';`;
163
- return exportLine;
164
- }
165
-
166
- export function extractReusableContent(fileContent: string): string {
167
- // all code before any actual export lines are considered re-usable
168
- return fileContent.match(/^(.*?)(?=^export)/ms)?.[0] ?? '';
169
- }
@@ -1,306 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import * as fs from 'fs';
18
- import fetch from 'node-fetch';
19
- import { resolve } from 'path';
20
- import * as readline from 'readline-sync';
21
- import * as semver from 'semver';
22
- import sh from 'shelljs';
23
- import { fatalExec, getShellConfig } from '../../util/command-util';
24
- import { getLatestGithubRelease, getLatestTag, hasGitChanges, isGitRepository } from '../../util/git-util';
25
- import { LOGGER } from '../../util/logger';
26
- import { validateVersion } from '../../util/validation-util';
27
-
28
- export const VERDACCIO_REGISTRY = 'http://localhost:4873/';
29
-
30
- export interface ReleaseOptions {
31
- component: Component;
32
- releaseType: ReleaseType;
33
- version: string;
34
- checkoutDir: string;
35
- branch: string;
36
- verbose: boolean;
37
- force: boolean;
38
- publish: boolean;
39
- npmDryRun: boolean;
40
- draft: boolean;
41
- }
42
-
43
- export type ReleaseRepository = 'npm' | 'm2' | 'm2&p2' | 'p2';
44
-
45
- export interface Component {
46
- type: (typeof Component.CLI_CHOICES)[number];
47
- releaseRepo: ReleaseRepository;
48
- githubRepo: string;
49
- directory: string;
50
- }
51
- export namespace Component {
52
- export const CLIENT: Component = {
53
- type: 'client',
54
- githubRepo: 'eclipse-glsp/glsp-client',
55
- releaseRepo: 'npm',
56
- directory: 'glsp-client'
57
- };
58
- export const THEIA_INTEGRATION: Component = {
59
- type: 'theia-integration',
60
- githubRepo: 'eclipse-glsp/glsp-theia-integration',
61
- releaseRepo: 'npm',
62
- directory: 'glsp-theia-integration'
63
- };
64
- export const VSCODE_INTEGRATION: Component = {
65
- type: 'vscode-integration',
66
- githubRepo: 'eclipse-glsp/glsp-vscode-integration',
67
- releaseRepo: 'npm',
68
- directory: 'glsp-vscode-integration'
69
- };
70
- export const SERVER_NODE: Component = {
71
- type: 'server-node',
72
- githubRepo: 'eclipse-glsp/glsp-server-node',
73
- releaseRepo: 'npm',
74
- directory: 'serer-node'
75
- };
76
- export const SERVER_JAVA: Component = {
77
- type: 'server-java',
78
- githubRepo: 'eclipse-glsp/glsp-server',
79
- releaseRepo: 'm2&p2',
80
- directory: 'glsp-server'
81
- };
82
- export const ECLIPSE_INTEGRATION: Component = {
83
- type: 'eclipse-integration',
84
- githubRepo: 'eclipse-glsp/glsp-eclipse-integration',
85
- releaseRepo: 'm2',
86
- directory: 'glsp-eclipse-integration'
87
- };
88
-
89
- export const ALL: Component[] = [CLIENT, THEIA_INTEGRATION, VSCODE_INTEGRATION, ECLIPSE_INTEGRATION, SERVER_JAVA, SERVER_NODE];
90
- export const CLI_CHOICES = [
91
- 'client',
92
- 'theia-integration',
93
- 'vscode-integration',
94
- 'eclipse-integration',
95
- 'server-node',
96
- 'server-java'
97
- ] as const;
98
-
99
- export function parse(cliChoice: string): Component {
100
- const key = cliChoice.toUpperCase().replace('-', '_');
101
- const component: Component = (Component as any)[key];
102
- if (!component) {
103
- throw new Error(`Could not parse component for type: ${cliChoice}`);
104
- }
105
- return component;
106
- }
107
-
108
- export function is(object: any): object is Component {
109
- return typeof object === 'object' && typeof object.type === 'string';
110
- }
111
- }
112
-
113
- export namespace ReleaseType {
114
- export const CLI_CHOICES = ['major', 'minor', 'patch', 'rc', 'custom'] as const;
115
- }
116
-
117
- export type ReleaseType = (typeof ReleaseType.CLI_CHOICES)[number];
118
-
119
- export function checkoutAndCd(options: ReleaseOptions): string {
120
- const ghUrl = options.component.githubRepo;
121
- LOGGER.info(`Clone repository '${ghUrl}' to directory: ${options.checkoutDir}`);
122
- sh.cd(options.checkoutDir);
123
- const directory = ghUrl.substring(ghUrl.lastIndexOf('/') + 1);
124
- const repoPath = resolve(options.checkoutDir, directory);
125
- if (fs.existsSync(resolve(options.checkoutDir, directory))) {
126
- if (options.force) {
127
- LOGGER.debug('A directory with the checkout name already exists.');
128
- LOGGER.debug('Force mode is enabled. The directory will be removed');
129
- fatalExec(`rm -rf ${repoPath}`, `Could not remove directory: ${repoPath}`);
130
- } else {
131
- throw new Error('Directory with the checkout name already exists.');
132
- }
133
- }
134
- sh.exec(`gh repo clone ${ghUrl}`, getShellConfig());
135
- LOGGER.debug(`Successfully cloned to ${directory}`);
136
- sh.cd(directory);
137
- if (options.branch !== 'master' && options.branch !== 'main') {
138
- sh.exec(`git checkout ${options.branch} `);
139
- }
140
- return sh.pwd();
141
- }
142
-
143
- export function commitAndTag(version: string, repositoryPath: string): string {
144
- LOGGER.info('Commit changes and create new tag');
145
- sh.cd(repositoryPath);
146
-
147
- LOGGER.debug('Check wether the given url is a git repository');
148
- if (!isGitRepository(sh.pwd())) {
149
- throw new Error(`The given path is not a git repository: ${repositoryPath}`);
150
- }
151
- const tag = `v${version}`;
152
- LOGGER.debug(`Create tag with label: ${tag}}`);
153
- sh.exec(`git checkout -b ${tag}`, getShellConfig());
154
- sh.exec('git add .', getShellConfig());
155
- sh.exec(`git commit -m "${tag}"`, getShellConfig());
156
- sh.exec(`git tag ${tag}`, getShellConfig());
157
- return tag;
158
- }
159
-
160
- export function publish(repositoryPath: string, options: ReleaseOptions): void {
161
- if (!options.publish || options.npmDryRun) {
162
- LOGGER.info('Skip publishing to Github');
163
- if (options.npmDryRun && options.component.releaseRepo === 'npm') {
164
- fatalExec(
165
- 'lerna publish from-git --no-git-reset --no-git-tag-version --no-verify-access --no-push --dist-tag rc --yes',
166
- 'Dry-run publish failed',
167
- { silent: false }
168
- );
169
- }
170
- return;
171
- }
172
- LOGGER.info(`Publish new GH release ${options.draft ? '[DRAFT]' : ''}`);
173
- sh.cd(repositoryPath);
174
- if (!options.force && hasGitChanges()) {
175
- throw new Error('Publish failed. The repository has pending changes');
176
- }
177
-
178
- const latestReleaseTag = getLatestGithubRelease();
179
- const localTag = getLatestTag();
180
- validateTag(latestReleaseTag, localTag);
181
- const preRelease = options.releaseType === 'rc' || localTag.includes('-');
182
- doPublish(localTag, preRelease, latestReleaseTag, options.draft);
183
- }
184
-
185
- function doPublish(tag: string, preRelease: boolean, latestRelease: string, draft: boolean): void {
186
- fatalExec(`git push origin HEAD:${tag}`, 'Could not push release branch to Github', getShellConfig({ silent: false }));
187
- fatalExec(`git push origin tag ${tag}`, 'Could not push tag to Github', getShellConfig({ silent: false }));
188
- const version = tagToVersion(tag);
189
- const titleSuffix = preRelease ? ` Candidate ${version.substring(version.lastIndexOf('-RC') + 3)}` : '';
190
- const title = `${version.replace(/-.*/, '')} Release${titleSuffix} `;
191
- sh.exec(
192
- `gh release create ${tag} -t "${title}" --notes-start-tag ${latestRelease} --generate-notes ${draft ? '-d' : ''} ${
193
- preRelease ? '-p' : ''
194
- }`,
195
- getShellConfig()
196
- );
197
- }
198
-
199
- function validateTag(currentReleaseTag: string, newTag: string): void {
200
- const releaseVersion = tagToVersion(currentReleaseTag);
201
- const newVersion = tagToVersion(newTag);
202
- if (!semver.satisfies(newVersion, `>${releaseVersion}`, { includePrerelease: true })) {
203
- throw new Error(`Tag version is lower than the current release: ${newTag} `);
204
- }
205
- }
206
-
207
- function tagToVersion(tag: string): string {
208
- if (!tag.startsWith('v')) {
209
- throw new Error(`Invalid format. The release tag should start with 'v': ${tag}`);
210
- }
211
- const version = tag.substring(1).replace('.RC', '-RC');
212
- return validateVersion(version);
213
- }
214
-
215
- export function lernaSetVersion(repositoryPath: string, version: string): void {
216
- LOGGER.info(`Bump version in ${repositoryPath} to: ${version}`);
217
- sh.cd(repositoryPath);
218
- fatalExec(`lerna version --exact ${version} --ignore-scripts --yes --no-push --no-git-tag-version`, 'Lerna version bump failed!', {
219
- silent: false
220
- });
221
- LOGGER.debug('Update root package.json version');
222
- sh.exec(`jq '.version="${version}"' package.json > temp.json`, getShellConfig());
223
- sh.exec('mv temp.json package.json ', getShellConfig());
224
- }
225
-
226
- export function yarnInstall(repositoryPath: string): void {
227
- LOGGER.debug(`Build ${repositoryPath}`);
228
- sh.cd(repositoryPath);
229
- fatalExec('yarn', 'Yarn build failed', getShellConfig({ silent: false }));
230
- }
231
-
232
- export function upgradeCommand(pckName: string, version: string): string {
233
- LOGGER.debug(`Upgrade '${pckName}' to version ${version}`);
234
- return `lernaupdate --non-interactive --dependency ${pckName}@${version}`;
235
- }
236
-
237
- export function updateVersion(...packages: { name: string; version: string }[]): void {
238
- packages.forEach(pckg => {
239
- const result = sh.exec(upgradeCommand(pckg.name, pckg.version), getShellConfig({ silent: false })).stdout.trim();
240
- if (result.includes('An error occurred:')) {
241
- const errorMsg = result.substring(result.lastIndexOf('An error occurred:')).trim();
242
- throw new Error(errorMsg);
243
- }
244
- });
245
- }
246
-
247
- export function asMvnVersion(version: string): string {
248
- LOGGER.debug(`Convert to maven conform version: ${version}`);
249
- const mavenVersion = version.replace('-', '.');
250
- LOGGER.debug(`Maven version :${mavenVersion}`);
251
- return mavenVersion;
252
- }
253
-
254
- export async function checkIfNpmVersionIsNew(pckgName: string, newVersion: string): Promise<void> {
255
- LOGGER.debug(`Check that the release version is new i.e. does not exist on npm: ${newVersion}`);
256
-
257
- const response = await fetch(`https://registry.npmjs.org/${pckgName}/${newVersion}`);
258
- const data = await response.json();
259
- if (typeof data === 'string' && data.includes('version not found:')) {
260
- LOGGER.debug(`Version '${newVersion}' does not exist on NPM. Continue with release`);
261
- return;
262
- }
263
- throw new Error(`Version '${newVersion} is already present on NPM!}`);
264
- }
265
-
266
- export function checkIfMavenVersionExists(groupId: string, artifactId: string, newVersion: string): void {
267
- LOGGER.debug('Check if maven version exists');
268
- if (isExistingMavenVersion(groupId, artifactId, newVersion)) {
269
- throw new Error(`Version '${newVersion} is already present on maven central!}`);
270
- }
271
- LOGGER.debug(`Version '${newVersion}' does not exist on maven central. Continue with release`);
272
- }
273
-
274
- export function isExistingMavenVersion(groupId: string, artifactId: string, version: string): boolean {
275
- const versions = sh
276
- .exec(
277
- `wget -q -O - https://repo1.maven.org/maven2/${groupId.replace(/\./g, '/')}/${artifactId}/maven-metadata.xml`,
278
- getShellConfig()
279
- )
280
- .exec("grep -P '<version>\\K[^<]*'", getShellConfig())
281
- .stdout.replace(/<\/?version>/g, '')
282
- .split('\n')
283
- .map(versionString => versionString.trim());
284
- LOGGER.debug(`${versions.length} released versions found:`, versions);
285
- return versions.includes(version);
286
- }
287
-
288
- export function checkJavaServerVersion(version: string, force = false): void {
289
- const mvnVersion = asMvnVersion(version);
290
- if (!isExistingMavenVersion('org.eclipse.glsp', 'org.eclipse.glsp.server', mvnVersion)) {
291
- // eslint-disable-next-line max-len
292
- const errorMsg = `No Java GLSP server with version ${mvnVersion} found on maven central!. Please release a new Java GLSP Server version before publishing this release!`;
293
- LOGGER.warn(errorMsg);
294
- if (force || readline.keyInYN('No Java GLSP server with corresponding version found. Do you want to continue anyways?')) {
295
- return;
296
- }
297
- throw new Error(errorMsg);
298
- }
299
- }
300
-
301
- export function updateLernaForDryRun(): void {
302
- LOGGER.debug('Update lerna.json to use local publish registry');
303
- sh.exec(`jq '.command.publish.registry="${VERDACCIO_REGISTRY}"' lerna.json > temp.json`, getShellConfig());
304
- sh.exec('mv temp.json lerna.json', getShellConfig());
305
- sh.exec(`npm set registry ${VERDACCIO_REGISTRY}`);
306
- }
@@ -1,55 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import sh from 'shelljs';
17
- import { getShellConfig } from '../../util/command-util';
18
- import { LOGGER } from '../../util/logger';
19
- import { checkoutAndCd, commitAndTag, lernaSetVersion, publish, ReleaseOptions, updateLernaForDryRun, yarnInstall } from './common';
20
-
21
- let REPO_ROOT: string;
22
-
23
- export async function releaseClient(options: ReleaseOptions): Promise<void> {
24
- LOGGER.info('Prepare glsp-client release');
25
- LOGGER.debug('Release options: ', options.version);
26
- REPO_ROOT = checkoutAndCd(options);
27
- updateDownloadServerScript(options.version);
28
- generateChangeLog();
29
- lernaSetVersion(REPO_ROOT, options.version);
30
- build();
31
- if (options.npmDryRun) {
32
- updateLernaForDryRun();
33
- }
34
- commitAndTag(options.version, REPO_ROOT);
35
- publish(REPO_ROOT, options);
36
- }
37
-
38
- async function updateDownloadServerScript(version: string): Promise<void> {
39
- LOGGER.info('Update example server download config');
40
- sh.cd(`${REPO_ROOT}/examples/workflow-standalone/scripts`);
41
- const configFile = 'config.json';
42
- LOGGER.info('Update example server download config');
43
- sh.exec(`jq '.version="${version}"' ${configFile} > temp.json`, getShellConfig());
44
- sh.exec(`mv temp.json ${configFile}`, getShellConfig());
45
- }
46
-
47
- function generateChangeLog(): void {
48
- // do nothing for now
49
- }
50
-
51
- function build(): void {
52
- LOGGER.info('Install & Build with yarn');
53
- yarnInstall(REPO_ROOT);
54
- LOGGER.debug('Build successful');
55
- }
@@ -1,113 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import sh from 'shelljs';
18
- import { fatalExec, getShellConfig } from '../../util/command-util';
19
- import { LOGGER } from '../../util/logger';
20
- import {
21
- ReleaseOptions,
22
- ReleaseType,
23
- asMvnVersion,
24
- checkJavaServerVersion,
25
- checkoutAndCd,
26
- commitAndTag,
27
- lernaSetVersion,
28
- publish,
29
- updateLernaForDryRun,
30
- updateVersion,
31
- yarnInstall
32
- } from './common.js';
33
-
34
- let REPO_ROOT: string;
35
-
36
- export async function releaseEclipseIntegration(options: ReleaseOptions): Promise<void> {
37
- LOGGER.info('Prepare glsp-eclipse-integration release');
38
- LOGGER.debug('Release options: ', options);
39
- checkJavaServerVersion(options.version);
40
-
41
- REPO_ROOT = checkoutAndCd(options);
42
- prepareClient(options);
43
- prepareServer(options);
44
- generateChangeLog();
45
- commitAndTag(asMvnVersion(options.version), REPO_ROOT);
46
- publish(REPO_ROOT, options);
47
- LOGGER.info('glsp-eclipse-integration release successful!');
48
- }
49
-
50
- function prepareClient(options: ReleaseOptions): void {
51
- LOGGER.info('Prepare client');
52
- updateExternalGLSPDependencies(options.version);
53
- lernaSetVersion(`${REPO_ROOT}/client`, options.version);
54
- buildClient();
55
- if (options.npmDryRun) {
56
- updateLernaForDryRun();
57
- }
58
- }
59
-
60
- function updateExternalGLSPDependencies(version: string): void {
61
- LOGGER.info('Update external GLSP dependencies (Client and workflow example)');
62
- sh.cd(`${REPO_ROOT}/client`);
63
- updateVersion({ name: '@eclipse-glsp/client', version }, { name: '@eclipse-glsp-examples/workflow-glsp', version });
64
- }
65
-
66
- function buildClient(): void {
67
- LOGGER.info('[Client] Install & Build with yarn');
68
- yarnInstall(`${REPO_ROOT}/client`);
69
- LOGGER.debug('Build successful');
70
- }
71
-
72
- function generateChangeLog(): void {
73
- // do nothing for now
74
- }
75
-
76
- function prepareServer(options: ReleaseOptions): void {
77
- const mvnVersion = asMvnVersion(options.version);
78
- setServerVersion(mvnVersion);
79
- updateTarget(mvnVersion, options.releaseType);
80
- buildServer();
81
- }
82
-
83
- function setServerVersion(version: string): void {
84
- LOGGER.info(`Set pom version to ${version}`);
85
- sh.cd(`${REPO_ROOT}/server`);
86
- // Execute tycho-versions plugin
87
- fatalExec(`mvn tycho-versions:set-version -DnewVersion=${version}`, 'Mvn set-versions failed', getShellConfig({ silent: false }));
88
- LOGGER.debug('Version update complete!');
89
- }
90
-
91
- function buildServer(): void {
92
- sh.cd(`${REPO_ROOT}/server`);
93
- LOGGER.info('Build Server(P2)');
94
- fatalExec('mvn clean install', 'P2 build failed', getShellConfig({ silent: false }));
95
- }
96
- function updateTarget(mvnVersion: string, releaseType: ReleaseType): void {
97
- const p2SubLocation = releaseType === 'rc' ? 'staging' : 'releases';
98
- const p2Location = `https://download.eclipse.org/glsp/server/p2/${p2SubLocation}/${mvnVersion}/`;
99
- LOGGER.info(`Update glsp server p2 repository to ${p2Location}`);
100
- sh.cd(`${REPO_ROOT}/server/releng/org.eclipse.glsp.ide.releng.target`);
101
- LOGGER.debug('Update r2021-03.tpd file');
102
- sh.exec(
103
- `sed -i 's_location "https://download.eclipse.org/glsp/server/p2/.*"_location "${p2Location}"_' r2021-03.tpd`,
104
- getShellConfig()
105
- );
106
- LOGGER.debug('Update r2021-03.target file');
107
- sh.exec(
108
- // eslint-disable-next-line max-len
109
- `sed -i 's_ <repository location="https://download.eclipse.org/glsp/server/p2/.*"_ <repository location="${p2Location}"_g' r2021-03.target`,
110
- getShellConfig()
111
- );
112
- LOGGER.debug('Target update successful');
113
- }