@eclipse-glsp/cli 2.6.0-next.183 → 2.6.0-next.4

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 +22240 -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 -3
  7. package/lib/app.d.ts.map +0 -1
  8. package/lib/app.js +0 -36
  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 -250
  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 -136
  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 -182
  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 -303
  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 -57
  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 -92
  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 -70
  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 -53
  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 -53
  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 -53
  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 -201
  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 -156
  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 -59
  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 -124
  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 -95
  73. package/lib/util/validation-util.js.map +0 -1
  74. package/src/app.ts +0 -35
  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,129 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 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 { glob } from 'glob';
19
- import * as jq from 'node-jq';
20
- import * as path from 'path';
21
- import sh from 'shelljs';
22
- import { baseCommand, configureShell } from '../util/command-util';
23
- import { getUncommittedChanges } from '../util/git-util';
24
- import { LOGGER, configureLogger } from '../util/logger';
25
- import { validateGitDirectory } from '../util/validation-util';
26
-
27
- export const UpdateNextCommand = baseCommand()
28
- .name('updateNext')
29
- .alias('u')
30
- .description('Updates all `next` dependencies in GLSP project to the latest version')
31
- .argument('[rootDir]', 'The repository root', validateGitDirectory, process.cwd())
32
- .option('-v, --verbose', 'Enable verbose (debug) log output', false)
33
- .action(updateNext);
34
-
35
- export async function updateNext(rootDir: string, options: { verbose: boolean }): Promise<void> {
36
- configureLogger(options.verbose);
37
- configureShell({ silent: true, fatal: true });
38
-
39
- const rootPackage = path.join(rootDir, 'package.json');
40
- if (getUncommittedChanges(rootDir).includes(rootPackage)) {
41
- LOGGER.warn('Uncommitted changes in root `package.json`. Please commit or stash them before running this command.');
42
- return;
43
- }
44
-
45
- configureShell({ silent: false, fatal: true });
46
-
47
- LOGGER.info('Updating next dependencies ...');
48
- rootDir = path.resolve(rootDir);
49
- const packages = await getWorkspacePackages(rootDir);
50
- LOGGER.debug(`Scanning ${packages.length} packages to derive resolutions`, packages);
51
- const resolutions = await getResolutions(packages);
52
- if (Object.keys(resolutions).length === 0) {
53
- LOGGER.info('No next dependencies found');
54
- return;
55
- }
56
- LOGGER.info('Upgrade and rebuild packages ...');
57
- const packageJson = fs.readFileSync(path.join(rootDir, 'package.json'), 'utf-8');
58
- LOGGER.debug('Updating package.json with resolutions', resolutions);
59
- fs.writeFileSync(path.join(rootDir, 'package.json'), JSON.stringify({ ...JSON.parse(packageJson), resolutions }, undefined, 2));
60
- LOGGER.debug('Running yarn install');
61
- sh.exec('yarn install --ignore-scripts');
62
- LOGGER.debug('Reverting package.json');
63
- sh.exec('git checkout HEAD -- package.json');
64
- LOGGER.debug('Rebuild to update yarn.lock');
65
- sh.exec('yarn');
66
- LOGGER.info('Upgrade successfully completed');
67
- }
68
-
69
- async function getWorkspacePackages(rootDir: string): Promise<string[]> {
70
- const rootPackage = path.join(rootDir, 'package.json');
71
- const packages = [rootPackage];
72
- if (!fs.existsSync(rootPackage)) {
73
- LOGGER.error('No package.json found in root directory');
74
- process.exit(1);
75
- }
76
- const workspaces = await getWorkspaceConfig(rootPackage);
77
- if (workspaces) {
78
- workspaces
79
- .map(workspace => `${workspace}/**/package.json`)
80
- .forEach(pattern => {
81
- glob.sync(pattern, {
82
- cwd: rootDir,
83
- ignore: ['**/node_modules/**']
84
- }).forEach(packageJson => packages.push(path.join(rootDir, packageJson)));
85
- });
86
- }
87
-
88
- return [...new Set(packages)];
89
- }
90
-
91
- async function getResolutions(packages: string[]): Promise<Record<string, string>> {
92
- let dependencies: string[] = [];
93
- for (const pkg of packages) {
94
- const deps = await jq.run(
95
- '.dependencies //{} + .devDependencies + .peerDependencies | with_entries(select(.value == "next")) | keys',
96
- pkg,
97
- {
98
- output: 'json'
99
- }
100
- );
101
- if (Array.isArray(deps)) {
102
- dependencies.push(...deps);
103
- }
104
- }
105
- dependencies = [...new Set(dependencies)];
106
- LOGGER.debug(`Found ${dependencies.length} 'next' dependencies`, dependencies);
107
- LOGGER.info('Retrieve next versions ... ');
108
- const resolutions: Record<string, string> = {};
109
- [...new Set(dependencies)].forEach(dep => {
110
- LOGGER.info(`Retrieving next version for ${dep}`);
111
- const version = sh.exec(`npm view ${dep}@next version`, { silent: true }).stdout.trim();
112
- resolutions[`**/${dep}`] = version;
113
- });
114
- return resolutions;
115
- }
116
- async function getWorkspaceConfig(rootPackage: string): Promise<string[] | undefined> {
117
- const result = await jq.run('.workspaces', rootPackage, { output: 'json' });
118
- if (!result) {
119
- return undefined;
120
- }
121
- if (Array.isArray(result)) {
122
- return result;
123
- }
124
- if (typeof result === 'object' && 'packages' in result && Array.isArray(result.packages)) {
125
- return result.packages;
126
- }
127
-
128
- return undefined;
129
- }
@@ -1,54 +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 { Command } from 'commander';
17
- import sh from 'shelljs';
18
-
19
- // Commander.js utils
20
- export function baseCommand(cmd = new Command()): Command {
21
- return cmd //
22
- .showSuggestionAfterError(true)
23
- .showHelpAfterError(true)
24
- .allowUnknownOption(false);
25
- }
26
-
27
- export type ShellConfig = sh.ExecOptions & { async: false };
28
- export const SH_CONFIG: ShellConfig = {
29
- async: false,
30
- fatal: true,
31
- silent: false
32
- };
33
-
34
- export function getShellConfig(options: Partial<Omit<ShellConfig, 'async'>> = {}): ShellConfig {
35
- return {
36
- ...SH_CONFIG,
37
- ...options
38
- };
39
- }
40
-
41
- export function configureShell(config: Partial<sh.ShellConfig>): void {
42
- sh.config.reset();
43
- getShellConfig({});
44
- SH_CONFIG.silent = config.silent;
45
- SH_CONFIG.fatal = config.fatal;
46
- }
47
-
48
- export function fatalExec(command: string, fatalErrorMessage: string, options: Partial<Omit<ShellConfig, 'async'>> = {}): sh.ShellString {
49
- const result = sh.exec(command, getShellConfig(options));
50
- if (result.code !== 0) {
51
- throw new Error(fatalErrorMessage);
52
- }
53
- return result;
54
- }
@@ -1,123 +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 { resolve } from 'path';
18
- import sh from 'shelljs';
19
- import { getShellConfig } from './command-util';
20
-
21
- export function isGitRepository(path?: string): boolean {
22
- cdIfPresent(path);
23
- const isGitRepo =
24
- sh
25
- .exec('git rev-parse --is-inside-work-tree', getShellConfig({ silent: true }))
26
- .stdout.trim()
27
- .toLocaleLowerCase() === 'true';
28
- return isGitRepo;
29
- }
30
-
31
- export function getGitRoot(path?: string): string {
32
- cdIfPresent(path);
33
- const fileString = sh.exec('git rev-parse --show-toplevel', getShellConfig()).stdout.trim();
34
- return resolve(fileString);
35
- }
36
-
37
- export function hasGitChanges(path?: string): boolean {
38
- return getUncommittedChanges(path).length > 0;
39
- }
40
-
41
- /**
42
- * Returns the files that have uncommitted changes (staged, not staged and untracked) of a git repository.
43
- * Filepaths are absolute.
44
- */
45
- export function getUncommittedChanges(path?: string): string[] {
46
- cdIfPresent(path);
47
- return sh
48
- .exec('git status --porcelain', getShellConfig())
49
- .stdout.trim()
50
- .split('\n')
51
- .filter(value => value.trim().length !== 0)
52
- .map(fileInfo =>
53
- // Extract relative file path from the info string and convert to absolute path
54
- resolve(path ?? process.cwd(), fileInfo.trim().split(' ').pop() ?? '')
55
- );
56
- }
57
-
58
- /**
59
- * Returns the files tha have been changed with the last commit (also includes currently staged but uncommitted changes)
60
- * Filepaths are absolute.
61
- */
62
- export function getChangesOfLastCommit(path?: string): string[] {
63
- cdIfPresent(path);
64
- return sh
65
- .exec('git diff --name-only HEAD^', getShellConfig())
66
- .stdout.trim()
67
- .split('\n')
68
- .map(file => resolve(path ?? process.cwd(), file));
69
- }
70
-
71
- /**
72
- * Returns the last modification date of a file (or the last commit) in a git repo.
73
- * @param filePath The file. If undefined the modification date of the last commit will be returned
74
- * @param repoRoot The path to the repo root. If undefined the current working directory is used.
75
- * @param excludeMessage Only consider commits that don`t match the excludeMessage
76
- * @returns The date or undefined if the file is outside of the git repo.
77
- */
78
- export function getLastModificationDate(filePath?: string, repoRoot?: string, excludeMessage?: string): Date | undefined {
79
- cdIfPresent(repoRoot);
80
- const additionalArgs = excludeMessage ? `--grep="${excludeMessage}" --invert-grep` : '';
81
- const result = sh.exec(`git log -1 ${additionalArgs} --pretty="format:%ci" ${filePath ?? ''}`, getShellConfig());
82
- if (result.code !== 0) {
83
- return undefined;
84
- }
85
- return new Date(result.stdout.trim());
86
- }
87
-
88
- export function getFilesOfCommit(commitHash: string, repoRoot?: string): string[] {
89
- cdIfPresent(repoRoot);
90
- const result = sh.exec(`git show --pretty="" --name-only ${commitHash}`, getShellConfig());
91
- if (result.code !== 0) {
92
- return [];
93
- }
94
-
95
- return result.stdout.trim().split('\n');
96
- }
97
-
98
- export function getLatestGithubRelease(path?: string): string {
99
- cdIfPresent(path);
100
- const release = sh.exec('gh release list --exclude-drafts -L 1', getShellConfig()).stdout.trim().split('\t');
101
- return release[release.length - 2];
102
- }
103
-
104
- export function getLatestTag(path?: string): string {
105
- cdIfPresent(path);
106
- return sh.exec('git describe --abbrev=0 --tags', getShellConfig()).stdout.trim();
107
- }
108
-
109
- export function hasBranch(branch: string, path?: string): boolean {
110
- cdIfPresent(path);
111
- return sh.exec(`git branch --list ${branch}`, getShellConfig()).stdout.trim().length !== 0;
112
- }
113
-
114
- export function getRemoteUrl(path?: string): string {
115
- cdIfPresent(path);
116
- return sh.exec('git config --get remote.origin.url', getShellConfig()).stdout.trim();
117
- }
118
-
119
- function cdIfPresent(path?: string): void {
120
- if (path) {
121
- sh.cd(path);
122
- }
123
- }
@@ -1,57 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2023 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
- export interface Logger extends Pick<Console, LogLevel> {
18
- newLine(): void;
19
- }
20
-
21
- export type LogLevel = 'info' | 'debug' | 'error' | 'warn';
22
-
23
- const levels: Record<LogLevel, { threshold: number; color: string }> = {
24
- error: { threshold: 0, color: '\x1b[31m' }, // red
25
- warn: { threshold: 1, color: '\x1b[33m' }, // yellow
26
- info: { threshold: 2, color: '\x1b[0m' }, // default terminal color
27
- debug: { threshold: 3, color: '\x1b[32m' } // green
28
- };
29
-
30
- let levelThreshold: number = levels.info.threshold;
31
-
32
- export const LOGGER: Logger = {
33
- info: (...args) => log('info', ...args),
34
- error: (...args) => log('error', ...args),
35
- warn: (...args) => log('warn', ...args),
36
- debug: (...args) => log('debug', ...args),
37
- newLine: () => console.log('')
38
- } as const;
39
-
40
- function log(level: LogLevel, ...args: any[]): void {
41
- const levelData = levels[level];
42
- if (levelThreshold < levelData.threshold) {
43
- return;
44
- }
45
- console[level](levelData.color, ...args, '\x1b[0m');
46
- }
47
-
48
- export function configureLogger(level: LogLevel): void;
49
- export function configureLogger(verbose: boolean): void;
50
- export function configureLogger(levelOrVerbose: LogLevel | boolean): void {
51
- if (typeof levelOrVerbose === 'boolean') {
52
- const level: LogLevel = levelOrVerbose ? 'debug' : 'info';
53
- levelThreshold = levels[level].threshold;
54
- } else {
55
- levelThreshold = levels[levelOrVerbose].threshold;
56
- }
57
- }
@@ -1,62 +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 { InvalidArgumentError } from 'commander';
17
- import * as fs from 'fs';
18
- import { resolve } from 'path';
19
- import * as semver from 'semver';
20
- import { getGitRoot, isGitRepository } from './git-util';
21
- import { LOGGER } from './logger';
22
-
23
- export function validateDirectory(rootDir: string): string {
24
- const path = resolve(rootDir);
25
- if (!fs.existsSync(path)) {
26
- throw new InvalidArgumentError('Not a valid file path!');
27
- }
28
-
29
- if (!fs.statSync(path).isDirectory()) {
30
- throw new InvalidArgumentError('Not a directory!');
31
- }
32
- return path;
33
- }
34
-
35
- export function validateFile(filePath: string, hasToExist = false): string {
36
- const path = resolve(filePath);
37
-
38
- if (hasToExist && !fs.existsSync(path)) {
39
- throw new InvalidArgumentError('Not a valid file path!');
40
- }
41
- if (!fs.statSync(path).isFile()) {
42
- throw new InvalidArgumentError('Not a file!');
43
- }
44
- return path;
45
- }
46
-
47
- export function validateVersion(version: string): string {
48
- LOGGER.debug(`Validate version format of: ${version}`);
49
- if (!semver.valid(version)) {
50
- throw new InvalidArgumentError(`Not a valid version: ${version}`);
51
- }
52
- return version;
53
- }
54
-
55
- export function validateGitDirectory(repository: string): string {
56
- const repoPath = validateDirectory(repository);
57
- if (!isGitRepository(repoPath)) {
58
- throw new InvalidArgumentError('Not a valid git repository');
59
- }
60
-
61
- return getGitRoot(repository);
62
- }