@eclipse-glsp/cli 1.1.0-next.4846de1.120

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 (79) hide show
  1. package/LICENSE +642 -0
  2. package/README.md +89 -0
  3. package/bin/glsp +2 -0
  4. package/lib/app.d.ts +3 -0
  5. package/lib/app.d.ts.map +1 -0
  6. package/lib/app.js +32 -0
  7. package/lib/app.js.map +1 -0
  8. package/lib/commands/check-header.d.ts +24 -0
  9. package/lib/commands/check-header.d.ts.map +1 -0
  10. package/lib/commands/check-header.js +234 -0
  11. package/lib/commands/check-header.js.map +1 -0
  12. package/lib/commands/coverage-report.d.ts +29 -0
  13. package/lib/commands/coverage-report.d.ts.map +1 -0
  14. package/lib/commands/coverage-report.js +100 -0
  15. package/lib/commands/coverage-report.js.map +1 -0
  16. package/lib/commands/release/common.d.ts +69 -0
  17. package/lib/commands/release/common.d.ts.map +1 -0
  18. package/lib/commands/release/common.js +273 -0
  19. package/lib/commands/release/common.js.map +1 -0
  20. package/lib/commands/release/release-client.d.ts +3 -0
  21. package/lib/commands/release/release-client.d.ts.map +1 -0
  22. package/lib/commands/release/release-client.js +53 -0
  23. package/lib/commands/release/release-client.js.map +1 -0
  24. package/lib/commands/release/release-eclipse-integration.d.ts +18 -0
  25. package/lib/commands/release/release-eclipse-integration.d.ts.map +1 -0
  26. package/lib/commands/release/release-eclipse-integration.js +90 -0
  27. package/lib/commands/release/release-eclipse-integration.js.map +1 -0
  28. package/lib/commands/release/release-java-server.d.ts +3 -0
  29. package/lib/commands/release/release-java-server.d.ts.map +1 -0
  30. package/lib/commands/release/release-java-server.js +68 -0
  31. package/lib/commands/release/release-java-server.js.map +1 -0
  32. package/lib/commands/release/release-server-node.d.ts +18 -0
  33. package/lib/commands/release/release-server-node.d.ts.map +1 -0
  34. package/lib/commands/release/release-server-node.js +51 -0
  35. package/lib/commands/release/release-server-node.js.map +1 -0
  36. package/lib/commands/release/release-theia-integration.d.ts +18 -0
  37. package/lib/commands/release/release-theia-integration.d.ts.map +1 -0
  38. package/lib/commands/release/release-theia-integration.js +62 -0
  39. package/lib/commands/release/release-theia-integration.js.map +1 -0
  40. package/lib/commands/release/release-vscode-integration.d.ts +18 -0
  41. package/lib/commands/release/release-vscode-integration.d.ts.map +1 -0
  42. package/lib/commands/release/release-vscode-integration.js +51 -0
  43. package/lib/commands/release/release-vscode-integration.js.map +1 -0
  44. package/lib/commands/release/release.d.ts +14 -0
  45. package/lib/commands/release/release.d.ts.map +1 -0
  46. package/lib/commands/release/release.js +165 -0
  47. package/lib/commands/release/release.js.map +1 -0
  48. package/lib/util/command-util.d.ts +26 -0
  49. package/lib/util/command-util.d.ts.map +1 -0
  50. package/lib/util/command-util.js +53 -0
  51. package/lib/util/command-util.js.map +1 -0
  52. package/lib/util/git-util.d.ts +60 -0
  53. package/lib/util/git-util.d.ts.map +1 -0
  54. package/lib/util/git-util.js +171 -0
  55. package/lib/util/git-util.js.map +1 -0
  56. package/lib/util/logger.d.ts +23 -0
  57. package/lib/util/logger.d.ts.map +1 -0
  58. package/lib/util/logger.js +50 -0
  59. package/lib/util/logger.js.map +1 -0
  60. package/lib/util/validation-util.d.ts +6 -0
  61. package/lib/util/validation-util.d.ts.map +1 -0
  62. package/lib/util/validation-util.js +64 -0
  63. package/lib/util/validation-util.js.map +1 -0
  64. package/package.json +64 -0
  65. package/src/app.ts +30 -0
  66. package/src/commands/check-header.ts +315 -0
  67. package/src/commands/coverage-report.ts +113 -0
  68. package/src/commands/release/common.ts +312 -0
  69. package/src/commands/release/release-client.ts +64 -0
  70. package/src/commands/release/release-eclipse-integration.ts +113 -0
  71. package/src/commands/release/release-java-server.ts +73 -0
  72. package/src/commands/release/release-server-node.ts +61 -0
  73. package/src/commands/release/release-theia-integration.ts +77 -0
  74. package/src/commands/release/release-vscode-integration.ts +65 -0
  75. package/src/commands/release/release.ts +215 -0
  76. package/src/util/command-util.ts +54 -0
  77. package/src/util/git-util.ts +172 -0
  78. package/src/util/logger.ts +57 -0
  79. package/src/util/validation-util.ts +63 -0
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Eclipse GLSP - CLI
2
+
3
+ The `@eclipse-glsp/cli` package provides helpful scripts and commands for extension and application development.
4
+ The contributed `glsp`, is a command line tool that offers all contributed commands.
5
+
6
+ ## Getting Started
7
+
8
+ Install `@eclipse-glsp/cli` as a dev dependency in your application.
9
+
10
+ ```bash
11
+ yarn add @eclipse-glsp/cli --dev
12
+ ```
13
+
14
+ ## checkHeaders
15
+
16
+ The `checkHeaders` command can be used to validate the copyright year (range) of license headers.
17
+ It checks for each file (matching the include pattern) whether the defined copyright range is in line with the first and last modification date in the git repository.
18
+ Found violations are printed to the console.
19
+ The validation check can be restricted to pending changes and/or the last commit e.g. to validate a commit before creating a PR.
20
+
21
+ ```console
22
+ $ glsp checkHeaders -h
23
+
24
+ Usage: glsp checkHeaders [options] <rootDir>
25
+
26
+ Validates the copyright year range of license header files
27
+
28
+ Arguments:
29
+ rootDir The starting directory for the check
30
+
31
+ 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",
33
+ default: "full")
34
+ -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
37
+ -p, --headerPattern <pattern> Regex pattern to extract the copyright year (range) from the header (default: "Copyright \\([cC]\\) \\d{4}(-d{4})?")
38
+ -j, --json Also persist validation results as json file (default: false)
39
+ -s, --severity <severity> The severity of validation results that should be printed. (choices: "error", "warn", "ok", default: "error" (only))
40
+ -h, --help display help for command
41
+ ```
42
+
43
+ ## coverageReport
44
+
45
+ The `coverageReport` command can be used to create a full nyc test coverage report for a lerna/yarn mono repository.
46
+ Individual coverage reports for each package are created and then combined to a full report.
47
+
48
+ ```console
49
+ $ glsp coverageReport -h
50
+ Usage: glsp coverageReport [options]
51
+
52
+ Generate a test coverage report for a glsp component
53
+
54
+ Options:
55
+ -p, --projectRoot <projectRoot> The root directory of the GLSP component (default: "<cwd>")
56
+ -c, --coverageScript <script> Script command of the package root for creating coverage reports (default: "test:coverage")
57
+ -h, --help display help for command
58
+ ```
59
+
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
+
86
+ ## More information
87
+
88
+ 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/).
89
+ 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/).
package/bin/glsp ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../lib/app.js');
package/lib/app.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export declare const COMMAND_VERSION = "1.1.0-next";
3
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";AAoBA,eAAO,MAAM,eAAe,eAAe,CAAC"}
package/lib/app.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.COMMAND_VERSION = void 0;
5
+ /********************************************************************************
6
+ * Copyright (c) 2022 EclipseSource and others.
7
+ *
8
+ * This program and the accompanying materials are made available under the
9
+ * terms of the Eclipse Public License v. 2.0 which is available at
10
+ * http://www.eclipse.org/legal/epl-2.0.
11
+ *
12
+ * This Source Code may also be made available under the following Secondary
13
+ * Licenses when the conditions for such availability set forth in the Eclipse
14
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
15
+ * with the GNU Classpath Exception which is available at
16
+ * https://www.gnu.org/software/classpath/license.html.
17
+ *
18
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
19
+ ********************************************************************************/
20
+ const check_header_1 = require("./commands/check-header");
21
+ const coverage_report_1 = require("./commands/coverage-report");
22
+ const release_1 = require("./commands/release/release");
23
+ const command_util_1 = require("./util/command-util");
24
+ exports.COMMAND_VERSION = '1.1.0-next';
25
+ const app = (0, command_util_1.baseCommand)() //
26
+ .version(exports.COMMAND_VERSION)
27
+ .name('glsp')
28
+ .addCommand(coverage_report_1.CoverageReportCommand)
29
+ .addCommand(release_1.ReleaseCommand)
30
+ .addCommand(check_header_1.CheckHeaderCommand);
31
+ app.parse(process.argv);
32
+ //# sourceMappingURL=app.js.map
package/lib/app.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AACA;;;;;;;;;;;;;;kFAckF;AAClF,0DAA6D;AAC7D,gEAAmE;AACnE,wDAA4D;AAC5D,sDAAkD;AACrC,QAAA,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAA,0BAAW,GAAE,CAAC,EAAE;KACvB,OAAO,CAAC,uBAAe,CAAC;KACxB,IAAI,CAAC,MAAM,CAAC;KACZ,UAAU,CAAC,uCAAqB,CAAC;KACjC,UAAU,CAAC,wBAAc,CAAC;KAC1B,UAAU,CAAC,iCAAkB,CAAC,CAAC;AAEpC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface HeaderCheckOptions {
2
+ type: CheckType;
3
+ exclude: string[];
4
+ fileExtensions: string[];
5
+ headerPattern: string;
6
+ json: boolean;
7
+ excludeDefaults: boolean;
8
+ severity: Severity;
9
+ }
10
+ declare const checkTypes: readonly ["full", "changes", "lastCommit"];
11
+ type CheckType = typeof checkTypes[number];
12
+ declare const severityTypes: readonly ["error", "warn", "ok"];
13
+ type Severity = typeof severityTypes[number];
14
+ export declare const CheckHeaderCommand: import("commander").Command;
15
+ export declare function checkHeaders(rootDir: string, options: HeaderCheckOptions): void;
16
+ export declare function displayValidationResult(rootDir: string, results: ValidationResult[], options: HeaderCheckOptions): void;
17
+ interface ValidationResult {
18
+ file: string;
19
+ severity: Severity;
20
+ violation: Violation;
21
+ }
22
+ type Violation = 'none' | 'noOrMissingHeader' | 'incorrectCopyrightPeriod' | 'invalidCopyrightYear';
23
+ export {};
24
+ //# sourceMappingURL=check-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-header.d.ts","sourceRoot":"","sources":["../../src/commands/check-header.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,4CAA6C,CAAC;AAC9D,KAAK,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAE3C,QAAA,MAAM,aAAa,kCAAmC,CAAC;AAEvD,KAAK,QAAQ,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAK7C,eAAO,MAAM,kBAAkB,6BAmCN,CAAC;AAE1B,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAgB/E;AA6ID,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAsBvH;AA4BD,UAAU,gBAAgB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;CACxB;AAaD,KAAK,SAAS,GAAG,MAAM,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.displayValidationResult = exports.checkHeaders = exports.CheckHeaderCommand = void 0;
4
+ /********************************************************************************
5
+ * Copyright (c) 2022 EclipseSource and others.
6
+ *
7
+ * This program and the accompanying materials are made available under the
8
+ * terms of the Eclipse Public License v. 2.0 which is available at
9
+ * http://www.eclipse.org/legal/epl-2.0.
10
+ *
11
+ * This Source Code may also be made available under the following Secondary
12
+ * Licenses when the conditions for such availability set forth in the Eclipse
13
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ * with the GNU Classpath Exception which is available at
15
+ * https://www.gnu.org/software/classpath/license.html.
16
+ *
17
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
18
+ ********************************************************************************/
19
+ /* eslint-disable max-len */
20
+ const commander_1 = require("commander");
21
+ const fs = require("fs");
22
+ const glob_1 = require("glob");
23
+ const minimatch = require("minimatch");
24
+ const sh = require("shelljs");
25
+ const command_util_1 = require("../util/command-util");
26
+ const git_util_1 = require("../util/git-util");
27
+ const logger_1 = require("../util/logger");
28
+ const validation_util_1 = require("../util/validation-util");
29
+ const path = require("path");
30
+ const checkTypes = ['full', 'changes', 'lastCommit'];
31
+ const severityTypes = ['error', 'warn', 'ok'];
32
+ const DEFAULT_EXCLUDES = ['**/@(node_modules|lib|dist|bundle)/**'];
33
+ const YEAR_RANGE_REGEX = /\d{4}(?:-d{4})?/g;
34
+ exports.CheckHeaderCommand = (0, command_util_1.baseCommand)() //
35
+ .name('checkHeaders')
36
+ .description('Validates the copyright year range of license header files')
37
+ .argument('<rootDir>', 'The starting directory for the check', validation_util_1.validateGitDirectory)
38
+ .addOption(new commander_1.Option('-t, --type <type>', 'The scope of the check. In addition to a full recursive check, is also possible to only' +
39
+ ' consider pending changes or the last commit')
40
+ .choices(checkTypes)
41
+ .default('full'))
42
+ .option('-f, --fileExtensions <extensions...>', 'File extensions that should be checked', ['ts', 'tsx'])
43
+ .addOption(new commander_1.Option('-e, --exclude <exclude...>', 'File patterns that should be excluded from the check. New exclude patterns are added to the default patterns').default([], `[${DEFAULT_EXCLUDES}]`))
44
+ .option('--no-exclude-defaults', 'Disables the default excludes patterns. Only explicitly passed exclude patterns (-e, --exclude) are considered')
45
+ .option('-p, --headerPattern <pattern>', 'Regex pattern to extract the copyright year (range) from the header', 'Copyright \\([cC]\\) \\d{4}(-d{4})?')
46
+ .option('-j, --json', 'Also persist validation results as json file', false)
47
+ .addOption(new commander_1.Option('-s, --severity <severity>', 'The severity of validation results that should be printed.')
48
+ .choices(severityTypes)
49
+ .default('error', '"error" (only)'))
50
+ .action(checkHeaders);
51
+ function checkHeaders(rootDir, options) {
52
+ (0, command_util_1.configureShell)({ silent: true, fatal: true });
53
+ if (options.excludeDefaults) {
54
+ options.exclude.push(...DEFAULT_EXCLUDES);
55
+ }
56
+ sh.cd(rootDir);
57
+ const files = getFiles(rootDir, options);
58
+ logger_1.LOGGER.info(`Check copy right headers of ${files.length} files`);
59
+ if (files.length === 0) {
60
+ logger_1.LOGGER.info('Check completed');
61
+ return;
62
+ }
63
+ const result = validate(rootDir, files, options);
64
+ displayValidationResult(rootDir, result, options);
65
+ }
66
+ exports.checkHeaders = checkHeaders;
67
+ function getFiles(rootDir, options) {
68
+ const includePattern = `**/*.@(${options.fileExtensions.join('|')})`;
69
+ const excludePattern = options.exclude;
70
+ if (options.type === 'full') {
71
+ return glob_1.glob.sync(includePattern, {
72
+ cwd: rootDir,
73
+ ignore: excludePattern
74
+ });
75
+ }
76
+ let changedFiles = options.type === 'changes' ? (0, git_util_1.getUncommittedChanges)(rootDir) : (0, git_util_1.getChangesOfLastCommit)(rootDir);
77
+ changedFiles = changedFiles.filter(minimatch.filter(includePattern));
78
+ excludePattern.forEach(pattern => {
79
+ changedFiles = changedFiles.filter(minimatch.filter(`!${pattern}`));
80
+ });
81
+ return changedFiles;
82
+ }
83
+ function validate(rootDir, files, options) {
84
+ var _a;
85
+ // Derives all files with valid headers, their copyright years and all files with no or invalid headers
86
+ const filesWithHeader = sh.grep('-l', options.headerPattern, files).stdout.trim().split('\n');
87
+ const copyrightYears = sh
88
+ .grep(options.headerPattern, files)
89
+ .stdout.trim()
90
+ .split('\n')
91
+ .map(line => line.match(YEAR_RANGE_REGEX).map(string => Number.parseInt(string, 10)));
92
+ const noHeaders = files.filter(file => !filesWithHeader.includes(file));
93
+ const results = [];
94
+ const allFilesLength = files.length;
95
+ // Create validation results for all files with no or invalid headers
96
+ const noHeadersLength = noHeaders.length;
97
+ if (noHeadersLength > 0) {
98
+ logger_1.LOGGER.info(`Found ${noHeadersLength} files with no (or an invalid) copyright header`);
99
+ }
100
+ noHeaders.forEach((file, i) => {
101
+ printValidationProgress(i + 1, allFilesLength, file);
102
+ results.push({ file: path.resolve(rootDir, file), violation: 'noOrMissingHeader', severity: 'error' });
103
+ });
104
+ // Performance optimization: avoid retrieving the dates for each individual file by precalculating the endYear if possible.
105
+ let defaultEndYear;
106
+ if (options.type === 'changes') {
107
+ defaultEndYear = new Date().getFullYear();
108
+ }
109
+ else if (options.type === 'lastCommit') {
110
+ defaultEndYear = (_a = (0, git_util_1.getLastModificationDate)(undefined, rootDir)) === null || _a === void 0 ? void 0 : _a.getFullYear();
111
+ }
112
+ // Create validation results for all files with valid headers
113
+ filesWithHeader.forEach((file, i) => {
114
+ printValidationProgress(i + 1 + noHeadersLength, allFilesLength, file);
115
+ const result = {
116
+ currentStartYear: copyrightYears[i].shift(),
117
+ expectedStartYear: (0, git_util_1.getFirstModificationDate)(file).getFullYear(),
118
+ currentEndYear: copyrightYears[i].shift(),
119
+ expectedEndYear: defaultEndYear !== null && defaultEndYear !== void 0 ? defaultEndYear : (0, git_util_1.getLastModificationDate)(file).getFullYear(),
120
+ file,
121
+ severity: 'ok',
122
+ violation: 'none'
123
+ };
124
+ if (result.expectedStartYear === result.expectedEndYear) {
125
+ validateSingleYear(result);
126
+ }
127
+ else {
128
+ validateTimePeriod(result);
129
+ }
130
+ results.push(result);
131
+ });
132
+ results.sort((a, b) => a.file.localeCompare(b.file));
133
+ process.stdout.clearLine(0);
134
+ return results;
135
+ }
136
+ function validateSingleYear(result) {
137
+ const { currentStartYear, expectedStartYear, currentEndYear } = result;
138
+ result.violation = 'invalidCopyrightYear';
139
+ result.severity = 'error';
140
+ if (!currentEndYear) {
141
+ if (currentStartYear === expectedStartYear) {
142
+ result.violation = 'none';
143
+ result.severity = 'ok';
144
+ }
145
+ return;
146
+ }
147
+ // Cornercase: For files of the initial contribution the copyright header predates the first git modification date.
148
+ // => declare as warning if not part of the initial contribution.
149
+ if (expectedStartYear === currentEndYear && currentStartYear < expectedStartYear) {
150
+ if ((0, git_util_1.getFirstCommit)(result.file) === (0, git_util_1.getInitialCommit)()) {
151
+ result.violation = 'none';
152
+ result.severity = 'ok';
153
+ }
154
+ else {
155
+ result.severity = 'warn';
156
+ }
157
+ }
158
+ }
159
+ function validateTimePeriod(result) {
160
+ const { currentStartYear, expectedStartYear, expectedEndYear, currentEndYear } = result;
161
+ result.violation = 'incorrectCopyrightPeriod';
162
+ result.severity = 'error';
163
+ if (!currentEndYear) {
164
+ result.severity = 'error';
165
+ return;
166
+ }
167
+ if (currentStartYear === expectedStartYear && currentEndYear === expectedEndYear) {
168
+ result.violation = 'none';
169
+ result.severity = 'ok';
170
+ return;
171
+ }
172
+ // Cornercase: For files of the initial contribution the copyright header predates the first git modification date.
173
+ // => declare as warning if not part of the initial contribution.
174
+ if (currentEndYear === expectedEndYear && currentStartYear < expectedEndYear) {
175
+ if ((0, git_util_1.getFirstCommit)(result.file) === (0, git_util_1.getInitialCommit)()) {
176
+ result.violation = 'none';
177
+ result.severity = 'ok';
178
+ }
179
+ else {
180
+ result.severity = 'warn';
181
+ }
182
+ }
183
+ }
184
+ function printValidationProgress(currentFileCount, maxFileCount, file) {
185
+ process.stdout.clearLine(0);
186
+ process.stdout.cursorTo(0);
187
+ process.stdout.write(`[${currentFileCount} of ${maxFileCount}] Validating ${file}`);
188
+ }
189
+ function displayValidationResult(rootDir, results, options) {
190
+ logger_1.LOGGER.newLine();
191
+ logger_1.LOGGER.info(`Header validation for ${results.length} files completed`);
192
+ const violations = results.filter(result => result.severity === 'error');
193
+ logger_1.LOGGER.info(`Found ${violations.length} copyright header violations:`);
194
+ logger_1.LOGGER.newLine();
195
+ // Adjust results to print based on configured severity level
196
+ let toPrint = results;
197
+ if (options.severity === 'error') {
198
+ toPrint = violations;
199
+ }
200
+ else if (options.severity === 'warn') {
201
+ toPrint = results.filter(result => result.severity !== 'ok');
202
+ }
203
+ toPrint.forEach((result, i) => logger_1.LOGGER.info(`${i + 1}. `, result.file, ':', toPrintMessage(result)));
204
+ logger_1.LOGGER.newLine();
205
+ if (options.json) {
206
+ fs.writeFileSync(path.join(rootDir, 'headerCheck.json'), JSON.stringify(results, undefined, 2));
207
+ }
208
+ logger_1.LOGGER.info('Check completed');
209
+ }
210
+ exports.displayValidationResult = displayValidationResult;
211
+ function toPrintMessage(result) {
212
+ const colors = {
213
+ error: '\x1b[31m',
214
+ warn: '\x1b[33m',
215
+ ok: '\x1b[32m'
216
+ };
217
+ if (isDateValidationResult(result) &&
218
+ (result.violation === 'incorrectCopyrightPeriod' || result.violation === 'invalidCopyrightYear')) {
219
+ const expected = result.expectedStartYear !== result.expectedEndYear
220
+ ? `${result.expectedStartYear}-${result.expectedEndYear}`
221
+ : result.expectedStartYear.toString();
222
+ const actual = result.currentEndYear ? `${result.currentStartYear}-${result.currentEndYear}` : result.currentStartYear.toString();
223
+ const message = result.violation === 'incorrectCopyrightPeriod' ? 'Invalid copyright period' : 'Invalid copyright year';
224
+ return `${colors[result.severity]} ${message}! Expected '${expected}' but is '${actual}'`;
225
+ }
226
+ else if (result.violation === 'noOrMissingHeader') {
227
+ return `${colors[result.severity]} No or invalid copyright header!`;
228
+ }
229
+ return `${colors[result.severity]} OK`;
230
+ }
231
+ function isDateValidationResult(object) {
232
+ return 'currentStartYear' in object && 'expectedStartYear' in object && 'expectedEndYear' in object;
233
+ }
234
+ //# sourceMappingURL=check-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-header.js","sourceRoot":"","sources":["../../src/commands/check-header.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,4BAA4B;AAC5B,yCAAmC;AACnC,yBAAyB;AACzB,+BAA4B;AAC5B,uCAAuC;AACvC,8BAA8B;AAC9B,uDAAmE;AACnE,+CAO0B;AAC1B,2CAAwC;AACxC,6DAA+D;AAC/D,6BAA8B;AAW9B,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAU,CAAC;AAG9D,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAIvD,MAAM,gBAAgB,GA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AAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAClI,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,KAAK,0BAA0B,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,wBAAwB,CAAC;QACxH,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO,eAAe,QAAQ,aAAa,MAAM,GAAG,CAAC;KAC7F;SAAM,IAAI,MAAM,CAAC,SAAS,KAAK,mBAAmB,EAAE;QACjD,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC;KACvE;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC3C,CAAC;AAgBD,SAAS,sBAAsB,CAAC,MAAwB;IACpD,OAAO,kBAAkB,IAAI,MAAM,IAAI,mBAAmB,IAAI,MAAM,IAAI,iBAAiB,IAAI,MAAM,CAAC;AACxG,CAAC"}
@@ -0,0 +1,29 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 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
+ export interface CoverageCmdOptions {
17
+ coverageScript: string;
18
+ projectRoot: string;
19
+ }
20
+ export declare const CoverageReportCommand: import("commander").Command;
21
+ /**
22
+ * Generates and aggregates an 'nyc' coverage report for lerna/yarn mono repositories.
23
+ * First, individual reports for each package are generated. Then, they are aggregated into one combined HTML report.
24
+ * @param options configuration options
25
+ */
26
+ export declare function generateCoverageReport(options: CoverageCmdOptions): void;
27
+ export declare function validateAndRetrievePackages(options: CoverageCmdOptions): string[];
28
+ export declare function collectPackageReportFiles(packages: string[], options: CoverageCmdOptions): string[];
29
+ //# sourceMappingURL=coverage-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage-report.d.ts","sourceRoot":"","sources":["../../src/commands/coverage-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AASlF,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,6BAKC,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAOxE;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAoBjF;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAWnG"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2022 EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the Eclipse Public License v. 2.0 which is available at
7
+ * http://www.eclipse.org/legal/epl-2.0.
8
+ *
9
+ * This Source Code may also be made available under the following Secondary
10
+ * Licenses when the conditions for such availability set forth in the Eclipse
11
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ * with the GNU Classpath Exception which is available at
13
+ * https://www.gnu.org/software/classpath/license.html.
14
+ *
15
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ ********************************************************************************/
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.collectPackageReportFiles = exports.validateAndRetrievePackages = exports.generateCoverageReport = exports.CoverageReportCommand = void 0;
19
+ const fs = require("fs");
20
+ const path = require("path");
21
+ const sh = require("shelljs");
22
+ const command_util_1 = require("../util/command-util");
23
+ const logger_1 = require("../util/logger");
24
+ const validation_util_1 = require("../util/validation-util");
25
+ exports.CoverageReportCommand = (0, command_util_1.baseCommand)() //
26
+ .name('coverageReport')
27
+ .description('Generate a test coverage report for a glsp component')
28
+ .option('-p, --projectRoot <projectRoot>', 'The root directory of the GLSP component', validation_util_1.validateDirectory, process.cwd())
29
+ .option('-c, --coverageScript <script>', 'Script command of the package root for creating coverage reports', 'test:coverage')
30
+ .action(generateCoverageReport);
31
+ /**
32
+ * Generates and aggregates an 'nyc' coverage report for lerna/yarn mono repositories.
33
+ * First, individual reports for each package are generated. Then, they are aggregated into one combined HTML report.
34
+ * @param options configuration options
35
+ */
36
+ function generateCoverageReport(options) {
37
+ sh.cd(options.projectRoot);
38
+ const packages = validateAndRetrievePackages(options);
39
+ logger_1.LOGGER.info('Create individual package coverage reports');
40
+ const jsonReports = collectPackageReportFiles(packages, options);
41
+ combineReports(jsonReports, options);
42
+ logger_1.LOGGER.info('Coverage reported generation successful');
43
+ }
44
+ exports.generateCoverageReport = generateCoverageReport;
45
+ function validateAndRetrievePackages(options) {
46
+ var _a;
47
+ const packagePath = path.join(options.projectRoot, 'package.json');
48
+ if (!fs.existsSync(packagePath)) {
49
+ exports.CoverageReportCommand.error(`Invalid root directory. '${options.projectRoot}' does not contain a package.json.`);
50
+ }
51
+ (0, command_util_1.fatalExec)('yarn nyc -h', 'Nyc is not installed!', (0, command_util_1.getShellConfig)({ silent: true }));
52
+ const packageJson = JSON.parse(fs.readFileSync(packagePath).toString());
53
+ if (!((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.scripts) === null || _a === void 0 ? void 0 : _a[options.coverageScript])) {
54
+ exports.CoverageReportCommand.error(`Invalid coverage script! The package.json does not have a script with name '${options.coverageScript}'!`);
55
+ }
56
+ if (!Array.isArray(packageJson.workspaces)) {
57
+ exports.CoverageReportCommand.error('Invalid package.json! No yarn workspaces are configured!');
58
+ }
59
+ return packageJson.workspaces.map(pkg => pkg.replace('/*', ''));
60
+ }
61
+ exports.validateAndRetrievePackages = validateAndRetrievePackages;
62
+ function collectPackageReportFiles(packages, options) {
63
+ logger_1.LOGGER.info('Create combined report');
64
+ sh.exec(`yarn ${options.coverageScript}`);
65
+ // collect reports
66
+ const reports = [];
67
+ packages.forEach(pkg => {
68
+ sh.find(pkg)
69
+ .filter(file => file.endsWith('coverage-final.json'))
70
+ .forEach(json => reports.push(path.resolve(options.projectRoot, json)));
71
+ });
72
+ return reports;
73
+ }
74
+ exports.collectPackageReportFiles = collectPackageReportFiles;
75
+ function combineReports(reportFiles, options) {
76
+ // Copy coverage into root/.nyc_output
77
+ const reportsDir = path.join(options.projectRoot, '.nyc_output');
78
+ if (fs.existsSync(reportsDir)) {
79
+ fs.rmSync(reportsDir, { force: true, recursive: true });
80
+ }
81
+ fs.mkdirSync(reportsDir);
82
+ for (let i = 0; i < reportFiles.length; i++) {
83
+ fs.copyFileSync(reportFiles[i], path.resolve('.nyc_output', `coverage-final-${i}.json`));
84
+ }
85
+ // Temporarily remove root nyc configs otherwise the report command might fail.
86
+ sh.cd(options.projectRoot);
87
+ const configFiles = ['.nycrc', '.nycrc.json', '.nyc-config.js'];
88
+ const tempFiles = [];
89
+ configFiles.forEach(config => {
90
+ if (fs.existsSync(path.join(options.projectRoot, config))) {
91
+ sh.mv(config, '_' + config);
92
+ tempFiles.push('_' + config);
93
+ }
94
+ });
95
+ // Generate report
96
+ sh.exec('yarn nyc report --reporter html', (0, command_util_1.getShellConfig)());
97
+ // Restore nyc configs (if any)
98
+ tempFiles.forEach(config => sh.mv(config, config.substring(1)));
99
+ }
100
+ //# sourceMappingURL=coverage-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage-report.js","sourceRoot":"","sources":["../../src/commands/coverage-report.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,yBAAyB;AACzB,6BAA6B;AAC7B,8BAA8B;AAC9B,uDAA8E;AAC9E,2CAAwC;AACxC,6DAA4D;AAO/C,QAAA,qBAAqB,GAAG,IAAA,0BAAW,GAAE,CAAC,EAAE;KAChD,IAAI,CAAC,gBAAgB,CAAC;KACtB,WAAW,CAAC,sDAAsD,CAAC;KACnE,MAAM,CAAC,iCAAiC,EAAE,0CAA0C,EAAE,mCAAiB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KACvH,MAAM,CAAC,+BAA+B,EAAE,kEAAkE,EAAE,eAAe,CAAC;KAC5H,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEpC;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,OAA2B;IAC9D,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACtD,eAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjE,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACrC,eAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;AAC3D,CAAC;AAPD,wDAOC;AAED,SAAgB,2BAA2B,CAAC,OAA2B;;IACnE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACnE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC7B,6BAAqB,CAAC,KAAK,CAAC,4BAA4B,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C,CAAC;SAChC;IACL,CAAC,CAAC,CAAC;IAEH,kBAAkB;IAClB,EAAE,CAAC,IAAI,CAAC,iCAAiC,EAAE,IAAA,6BAAc,GAAE,CAAC,CAAC;IAE7D,+BAA+B;IAC/B,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,69 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 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
+ export declare const VERDACCIO_REGISTRY = "http://localhost:4873/";
17
+ export interface ReleaseOptions {
18
+ component: Component;
19
+ releaseType: ReleaseType;
20
+ version: string;
21
+ checkoutDir: string;
22
+ branch: string;
23
+ verbose: boolean;
24
+ force: boolean;
25
+ publish: boolean;
26
+ npmDryRun: boolean;
27
+ draft: boolean;
28
+ }
29
+ export type ReleaseRepository = 'npm' | 'm2' | 'm2&p2' | 'p2';
30
+ export interface Component {
31
+ type: typeof Component.CLI_CHOICES[number];
32
+ releaseRepo: ReleaseRepository;
33
+ githubRepo: string;
34
+ directory: string;
35
+ }
36
+ export declare namespace Component {
37
+ const CLIENT: Component;
38
+ const THEIA_INTEGRATION: Component;
39
+ const VSCODE_INTEGRATION: Component;
40
+ const SERVER_NODE: Component;
41
+ const SERVER_JAVA: Component;
42
+ const ECLIPSE_INTEGRATION: Component;
43
+ const ALL: Component[];
44
+ const CLI_CHOICES: readonly ["client", "theia-integration", "vscode-integration", "eclipse-integration", "server-node", "server-java"];
45
+ function parse(cliChoice: string): Component;
46
+ function is(object: any): object is Component;
47
+ }
48
+ export declare namespace ReleaseType {
49
+ const CLI_CHOICES: readonly ["major", "minor", "patch", "rc", "custom"];
50
+ }
51
+ export type ReleaseType = typeof ReleaseType.CLI_CHOICES[number];
52
+ export declare function checkoutAndCd(options: ReleaseOptions): string;
53
+ export declare function commitAndTag(version: string, repositoryPath: string): string;
54
+ export declare function publish(repositoryPath: string, options: ReleaseOptions): void;
55
+ export declare function lernaSetVersion(repositoryPath: string, version: string): void;
56
+ export declare function yarnInstall(repositoryPath: string): void;
57
+ export declare function upgradeCommand(pckName: string, version: string): string;
58
+ export declare function updateVersion(...packages: {
59
+ name: string;
60
+ version: string;
61
+ }[]): void;
62
+ export declare function updateServerConfig(configFile: string, version: string, isSnapShot: boolean): void;
63
+ export declare function asMvnVersion(version: string): string;
64
+ export declare function checkIfNpmVersionExists(pckgName: string, newVersion: string): Promise<void>;
65
+ export declare function checkIfMavenVersionExists(groupId: string, artifactId: string, newVersion: string): void;
66
+ export declare function isExistingMavenVersion(groupId: string, artifactId: string, version: string): boolean;
67
+ export declare function checkJavaServerVersion(version: string, force?: boolean): void;
68
+ export declare function updateLernaForDryRun(): void;
69
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/commands/release/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAalF,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf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