@eclipse-glsp/cli 2.2.0-next.b5aff4f.157 → 2.2.0
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.
- package/README.md +24 -0
- package/bin/glsp +1 -1
- package/lib/app.d.ts +0 -1
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +4 -3
- package/lib/app.js.map +1 -1
- package/lib/commands/check-header.d.ts +2 -1
- package/lib/commands/check-header.d.ts.map +1 -1
- package/lib/commands/check-header.js +34 -21
- package/lib/commands/check-header.js.map +1 -1
- package/lib/commands/coverage-report.d.ts +1 -1
- package/lib/commands/coverage-report.js +12 -9
- package/lib/commands/coverage-report.js.map +1 -1
- package/lib/commands/generate-index.d.ts +46 -0
- package/lib/commands/generate-index.d.ts.map +1 -0
- package/lib/commands/generate-index.js +172 -0
- package/lib/commands/generate-index.js.map +1 -0
- package/lib/commands/release/common.d.ts +1 -1
- package/lib/commands/release/common.js +24 -24
- package/lib/commands/release/common.js.map +1 -1
- package/lib/commands/release/release-client.js +7 -27
- package/lib/commands/release/release-client.js.map +1 -1
- package/lib/commands/release/release-eclipse-integration.d.ts +2 -2
- package/lib/commands/release/release-eclipse-integration.d.ts.map +1 -1
- package/lib/commands/release/release-eclipse-integration.js +20 -40
- package/lib/commands/release/release-eclipse-integration.js.map +1 -1
- package/lib/commands/release/release-java-server.d.ts.map +1 -1
- package/lib/commands/release/release-java-server.js +9 -29
- package/lib/commands/release/release-java-server.js.map +1 -1
- package/lib/commands/release/release-server-node.d.ts +2 -2
- package/lib/commands/release/release-server-node.d.ts.map +1 -1
- package/lib/commands/release/release-server-node.js +13 -33
- package/lib/commands/release/release-server-node.js.map +1 -1
- package/lib/commands/release/release-theia-integration.d.ts +2 -2
- package/lib/commands/release/release-theia-integration.d.ts.map +1 -1
- package/lib/commands/release/release-theia-integration.js +13 -33
- package/lib/commands/release/release-theia-integration.js.map +1 -1
- package/lib/commands/release/release-vscode-integration.d.ts +2 -2
- package/lib/commands/release/release-vscode-integration.d.ts.map +1 -1
- package/lib/commands/release/release-vscode-integration.js +13 -33
- package/lib/commands/release/release-vscode-integration.js.map +1 -1
- package/lib/commands/release/release.d.ts +1 -1
- package/lib/commands/release/release.d.ts.map +1 -1
- package/lib/commands/release/release.js +19 -16
- package/lib/commands/release/release.js.map +1 -1
- package/lib/commands/update-next.d.ts.map +1 -1
- package/lib/commands/update-next.js +9 -6
- package/lib/commands/update-next.js.map +1 -1
- package/lib/util/command-util.d.ts +2 -2
- package/lib/util/command-util.d.ts.map +1 -1
- package/lib/util/command-util.js +6 -26
- package/lib/util/command-util.js.map +1 -1
- package/lib/util/git-util.d.ts +1 -1
- package/lib/util/git-util.js +15 -35
- package/lib/util/git-util.js.map +1 -1
- package/lib/util/logger.d.ts +1 -1
- package/lib/util/logger.js +4 -4
- package/lib/util/logger.js.map +1 -1
- package/lib/util/validation-util.d.ts +0 -1
- package/lib/util/validation-util.d.ts.map +1 -1
- package/lib/util/validation-util.js +2 -3
- package/lib/util/validation-util.js.map +1 -1
- package/package.json +4 -4
- package/src/app.ts +4 -3
- package/src/commands/check-header.ts +28 -18
- package/src/commands/coverage-report.ts +2 -2
- package/src/commands/generate-index.ts +169 -0
- package/src/commands/release/common.ts +2 -2
- package/src/commands/release/release-client.ts +2 -2
- package/src/commands/release/release-eclipse-integration.ts +5 -5
- package/src/commands/release/release-java-server.ts +3 -3
- package/src/commands/release/release-server-node.ts +3 -3
- package/src/commands/release/release-theia-integration.ts +3 -3
- package/src/commands/release/release-vscode-integration.ts +3 -3
- package/src/commands/release/release.ts +3 -3
- package/src/commands/update-next.ts +3 -2
- package/src/util/command-util.ts +2 -2
- package/src/util/git-util.ts +2 -2
- package/src/util/logger.ts +1 -1
- package/src/util/validation-util.ts +1 -2
package/lib/util/git-util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2022-
|
|
3
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
4
4
|
*
|
|
5
5
|
* This program and the accompanying materials are made available under the
|
|
6
6
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,37 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
19
|
};
|
|
40
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
21
|
exports.getRemoteUrl = exports.hasBranch = exports.getLatestTag = exports.getLatestGithubRelease = exports.getFilesOfCommit = exports.getLastModificationDate = exports.getChangesOfLastCommit = exports.getUncommittedChanges = exports.hasGitChanges = exports.getGitRoot = exports.isGitRepository = void 0;
|
|
42
22
|
const path_1 = require("path");
|
|
43
|
-
const
|
|
23
|
+
const shelljs_1 = __importDefault(require("shelljs"));
|
|
44
24
|
const command_util_1 = require("./command-util");
|
|
45
25
|
function isGitRepository(path) {
|
|
46
26
|
cdIfPresent(path);
|
|
47
|
-
const isGitRepo =
|
|
27
|
+
const isGitRepo = shelljs_1.default
|
|
48
28
|
.exec('git rev-parse --is-inside-work-tree', (0, command_util_1.getShellConfig)({ silent: true }))
|
|
49
29
|
.stdout.trim()
|
|
50
30
|
.toLocaleLowerCase() === 'true';
|
|
@@ -53,7 +33,7 @@ function isGitRepository(path) {
|
|
|
53
33
|
exports.isGitRepository = isGitRepository;
|
|
54
34
|
function getGitRoot(path) {
|
|
55
35
|
cdIfPresent(path);
|
|
56
|
-
const fileString =
|
|
36
|
+
const fileString = shelljs_1.default.exec('git rev-parse --show-toplevel', (0, command_util_1.getShellConfig)()).stdout.trim();
|
|
57
37
|
return (0, path_1.resolve)(fileString);
|
|
58
38
|
}
|
|
59
39
|
exports.getGitRoot = getGitRoot;
|
|
@@ -67,7 +47,7 @@ exports.hasGitChanges = hasGitChanges;
|
|
|
67
47
|
*/
|
|
68
48
|
function getUncommittedChanges(path) {
|
|
69
49
|
cdIfPresent(path);
|
|
70
|
-
return
|
|
50
|
+
return shelljs_1.default
|
|
71
51
|
.exec('git status --porcelain', (0, command_util_1.getShellConfig)())
|
|
72
52
|
.stdout.trim()
|
|
73
53
|
.split('\n')
|
|
@@ -83,7 +63,7 @@ exports.getUncommittedChanges = getUncommittedChanges;
|
|
|
83
63
|
*/
|
|
84
64
|
function getChangesOfLastCommit(path) {
|
|
85
65
|
cdIfPresent(path);
|
|
86
|
-
return
|
|
66
|
+
return shelljs_1.default
|
|
87
67
|
.exec('git diff --name-only HEAD^', (0, command_util_1.getShellConfig)())
|
|
88
68
|
.stdout.trim()
|
|
89
69
|
.split('\n')
|
|
@@ -100,7 +80,7 @@ exports.getChangesOfLastCommit = getChangesOfLastCommit;
|
|
|
100
80
|
function getLastModificationDate(filePath, repoRoot, excludeMessage) {
|
|
101
81
|
cdIfPresent(repoRoot);
|
|
102
82
|
const additionalArgs = excludeMessage ? `--grep="${excludeMessage}" --invert-grep` : '';
|
|
103
|
-
const result =
|
|
83
|
+
const result = shelljs_1.default.exec(`git log -1 ${additionalArgs} --pretty="format:%ci" ${filePath !== null && filePath !== void 0 ? filePath : ''}`, (0, command_util_1.getShellConfig)());
|
|
104
84
|
if (result.code !== 0) {
|
|
105
85
|
return undefined;
|
|
106
86
|
}
|
|
@@ -109,7 +89,7 @@ function getLastModificationDate(filePath, repoRoot, excludeMessage) {
|
|
|
109
89
|
exports.getLastModificationDate = getLastModificationDate;
|
|
110
90
|
function getFilesOfCommit(commitHash, repoRoot) {
|
|
111
91
|
cdIfPresent(repoRoot);
|
|
112
|
-
const result =
|
|
92
|
+
const result = shelljs_1.default.exec(`git show --pretty="" --name-only ${commitHash}`, (0, command_util_1.getShellConfig)());
|
|
113
93
|
if (result.code !== 0) {
|
|
114
94
|
return [];
|
|
115
95
|
}
|
|
@@ -118,28 +98,28 @@ function getFilesOfCommit(commitHash, repoRoot) {
|
|
|
118
98
|
exports.getFilesOfCommit = getFilesOfCommit;
|
|
119
99
|
function getLatestGithubRelease(path) {
|
|
120
100
|
cdIfPresent(path);
|
|
121
|
-
const release =
|
|
101
|
+
const release = shelljs_1.default.exec('gh release list --exclude-drafts -L 1', (0, command_util_1.getShellConfig)()).stdout.trim().split('\t');
|
|
122
102
|
return release[release.length - 2];
|
|
123
103
|
}
|
|
124
104
|
exports.getLatestGithubRelease = getLatestGithubRelease;
|
|
125
105
|
function getLatestTag(path) {
|
|
126
106
|
cdIfPresent(path);
|
|
127
|
-
return
|
|
107
|
+
return shelljs_1.default.exec('git describe --abbrev=0 --tags', (0, command_util_1.getShellConfig)()).stdout.trim();
|
|
128
108
|
}
|
|
129
109
|
exports.getLatestTag = getLatestTag;
|
|
130
110
|
function hasBranch(branch, path) {
|
|
131
111
|
cdIfPresent(path);
|
|
132
|
-
return
|
|
112
|
+
return shelljs_1.default.exec(`git branch --list ${branch}`, (0, command_util_1.getShellConfig)()).stdout.trim().length !== 0;
|
|
133
113
|
}
|
|
134
114
|
exports.hasBranch = hasBranch;
|
|
135
115
|
function getRemoteUrl(path) {
|
|
136
116
|
cdIfPresent(path);
|
|
137
|
-
return
|
|
117
|
+
return shelljs_1.default.exec('git config --get remote.origin.url', (0, command_util_1.getShellConfig)()).stdout.trim();
|
|
138
118
|
}
|
|
139
119
|
exports.getRemoteUrl = getRemoteUrl;
|
|
140
120
|
function cdIfPresent(path) {
|
|
141
121
|
if (path) {
|
|
142
|
-
|
|
122
|
+
shelljs_1.default.cd(path);
|
|
143
123
|
}
|
|
144
124
|
}
|
|
145
125
|
//# sourceMappingURL=git-util.js.map
|
package/lib/util/git-util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-util.js","sourceRoot":"","sources":["../../src/util/git-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF
|
|
1
|
+
{"version":3,"file":"git-util.js","sourceRoot":"","sources":["../../src/util/git-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;AAElF,+BAA+B;AAC/B,sDAAyB;AACzB,iDAAgD;AAEhD,SAAgB,eAAe,CAAC,IAAa;IACzC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClB,MAAM,SAAS,GACX,iBAAE;SACG,IAAI,CAAC,qCAAqC,EAAE,IAAA,6BAAc,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SAC7E,MAAM,CAAC,IAAI,EAAE;SACb,iBAAiB,EAAE,KAAK,MAAM,CAAC;IACxC,OAAO,SAAS,CAAC;AACrB,CAAC;AARD,0CAQC;AAED,SAAgB,UAAU,CAAC,IAAa;IACpC,WAAW,CAAC,IAAI,CAAC,CAAC;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IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7G,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAJD,wDAIC;AAED,SAAgB,YAAY,CAAC,IAAa;IACtC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,iBAAE,CAAC,IAAI,CAAC,gCAAgC,EAAE,IAAA,6BAAc,GAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACrF,CAAC;AAHD,oCAGC;AAED,SAAgB,SAAS,CAAC,MAAc,EAAE,IAAa;IACnD,WAAW,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,iBAAE,CAAC,IAAI,CAAC,qBAAqB,MAAM,EAAE,EAAE,IAAA,6BAAc,GAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;AAC/F,CAAC;AAHD,8BAGC;AAED,SAAgB,YAAY,CAAC,IAAa;IACtC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,iBAAE,CAAC,IAAI,CAAC,oCAAoC,EAAE,IAAA,6BAAc,GAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACzF,CAAC;AAHD,oCAGC;AAED,SAAS,WAAW,CAAC,IAAa;IAC9B,IAAI,IAAI,EAAE,CAAC;QACP,iBAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;AACL,CAAC"}
|
package/lib/util/logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2023 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
package/lib/util/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
3
|
+
* Copyright (c) 2022-2023 EclipseSource and others.
|
|
4
4
|
*
|
|
5
5
|
* This program and the accompanying materials are made available under the
|
|
6
6
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.configureLogger = exports.LOGGER = void 0;
|
|
19
19
|
const levels = {
|
|
20
|
-
error: { threshold: 0, color: '\x1b[31m' },
|
|
21
|
-
warn: { threshold: 1, color: '\x1b[33m' },
|
|
22
|
-
info: { threshold: 2, color: '\x1b[0m' },
|
|
20
|
+
error: { threshold: 0, color: '\x1b[31m' }, // red
|
|
21
|
+
warn: { threshold: 1, color: '\x1b[33m' }, // yellow
|
|
22
|
+
info: { threshold: 2, color: '\x1b[0m' }, // default terminal color
|
|
23
23
|
debug: { threshold: 3, color: '\x1b[32m' } // green
|
|
24
24
|
};
|
|
25
25
|
let levelThreshold = levels.info.threshold;
|
package/lib/util/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAQlF,MAAM,MAAM,GAA2D;IACnE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAQlF,MAAM,MAAM,GAA2D;IACnE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM;IAClD,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,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K,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;SAAM,CAAC;QACJ,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;AACL,CAAC;AAPD,0CAOC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const COMMAND_VERSION = "1.1.0-next";
|
|
2
1
|
export declare function validateDirectory(rootDir: string): string;
|
|
3
2
|
export declare function validateFile(filePath: string, hasToExist?: boolean): string;
|
|
4
3
|
export declare function validateVersion(version: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-util.d.ts","sourceRoot":"","sources":["../../src/util/validation-util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation-util.d.ts","sourceRoot":"","sources":["../../src/util/validation-util.ts"],"names":[],"mappings":"AAsBA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,MAAM,CAUzE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAO/D"}
|
|
@@ -23,9 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.validateGitDirectory = exports.validateVersion = exports.validateFile = exports.validateDirectory =
|
|
26
|
+
exports.validateGitDirectory = exports.validateVersion = exports.validateFile = exports.validateDirectory = void 0;
|
|
27
27
|
/********************************************************************************
|
|
28
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
28
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
29
29
|
*
|
|
30
30
|
* This program and the accompanying materials are made available under the
|
|
31
31
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -45,7 +45,6 @@ const path_1 = require("path");
|
|
|
45
45
|
const semver = __importStar(require("semver"));
|
|
46
46
|
const git_util_1 = require("./git-util");
|
|
47
47
|
const logger_1 = require("./logger");
|
|
48
|
-
exports.COMMAND_VERSION = '1.1.0-next';
|
|
49
48
|
function validateDirectory(rootDir) {
|
|
50
49
|
const path = (0, path_1.resolve)(rootDir);
|
|
51
50
|
if (!fs.existsSync(path)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-util.js","sourceRoot":"","sources":["../../src/util/validation-util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAAiD;AACjD,uCAAyB;AACzB,+BAA+B;AAC/B,+CAAiC;AACjC,yCAAyD;AACzD,qCAAkC;
|
|
1
|
+
{"version":3,"file":"validation-util.js","sourceRoot":"","sources":["../../src/util/validation-util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAAiD;AACjD,uCAAyB;AACzB,+BAA+B;AAC/B,+CAAiC;AACjC,yCAAyD;AACzD,qCAAkC;AAElC,SAAgB,iBAAiB,CAAC,OAAe;IAC7C,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,gCAAoB,CAAC,wBAAwB,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,gCAAoB,CAAC,kBAAkB,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAVD,8CAUC;AAED,SAAgB,YAAY,CAAC,QAAgB,EAAE,UAAU,GAAG,KAAK;IAC7D,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;IAE/B,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,gCAAoB,CAAC,wBAAwB,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9B,MAAM,IAAI,gCAAoB,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAVD,oCAUC;AAED,SAAgB,eAAe,CAAC,OAAe;IAC3C,eAAM,CAAC,KAAK,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,gCAAoB,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAND,0CAMC;AAED,SAAgB,oBAAoB,CAAC,UAAkB;IACnD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,IAAA,0BAAe,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,gCAAoB,CAAC,4BAA4B,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAPD,oDAOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/cli",
|
|
3
|
-
"version": "2.2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "CLI Tooling & scripts for GLSP components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"clean": "rimraf lib tsconfig.tsbuildinfo",
|
|
37
37
|
"lint": "eslint --ext .ts,.tsx ./src",
|
|
38
38
|
"lint:ci": "yarn lint -o eslint.xml -f checkstyle",
|
|
39
|
-
"prepare": "yarn clean && yarn build ",
|
|
40
39
|
"start": "node --enable-source-maps lib/app.js",
|
|
41
40
|
"watch": "tsc -w"
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"commander": "^10.0.1",
|
|
45
44
|
"glob": "^10.3.10",
|
|
45
|
+
"globby": "13.2.2",
|
|
46
46
|
"node-fetch": "^2.6.11",
|
|
47
47
|
"node-jq": "^4.3.1",
|
|
48
48
|
"readline-sync": "^1.4.10",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"shelljs": "^0.8.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@eclipse-glsp/config": "2.2.0
|
|
53
|
+
"@eclipse-glsp/config": "2.2.0",
|
|
54
54
|
"@types/glob": "^8.1.0",
|
|
55
55
|
"@types/node-fetch": "^2.6.6",
|
|
56
56
|
"@types/readline-sync": "^1.4.5",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "36e4b3dc808061dffe381947f842204f769ea21a"
|
|
64
64
|
}
|
package/src/app.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
4
3
|
*
|
|
5
4
|
* This program and the accompanying materials are made available under the
|
|
6
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -16,6 +15,7 @@
|
|
|
16
15
|
********************************************************************************/
|
|
17
16
|
import { CheckHeaderCommand } from './commands/check-header';
|
|
18
17
|
import { CoverageReportCommand } from './commands/coverage-report';
|
|
18
|
+
import { GenerateIndex } from './commands/generate-index';
|
|
19
19
|
import { ReleaseCommand } from './commands/release/release';
|
|
20
20
|
import { UpdateNextCommand } from './commands/update-next';
|
|
21
21
|
import { baseCommand } from './util/command-util';
|
|
@@ -28,6 +28,7 @@ const app = baseCommand() //
|
|
|
28
28
|
.addCommand(CoverageReportCommand)
|
|
29
29
|
.addCommand(ReleaseCommand)
|
|
30
30
|
.addCommand(CheckHeaderCommand)
|
|
31
|
-
.addCommand(UpdateNextCommand)
|
|
31
|
+
.addCommand(UpdateNextCommand)
|
|
32
|
+
.addCommand(GenerateIndex);
|
|
32
33
|
|
|
33
34
|
app.parse(process.argv);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -19,13 +19,14 @@ import * as fs from 'fs';
|
|
|
19
19
|
import { glob } from 'glob';
|
|
20
20
|
import * as minimatch from 'minimatch';
|
|
21
21
|
import * as readline from 'readline-sync';
|
|
22
|
-
import
|
|
22
|
+
import sh from 'shelljs';
|
|
23
23
|
import { baseCommand, configureShell, getShellConfig } from '../util/command-util';
|
|
24
24
|
import { getChangesOfLastCommit, getLastModificationDate, getUncommittedChanges } from '../util/git-util';
|
|
25
25
|
|
|
26
|
+
import * as path from 'path';
|
|
26
27
|
import { LOGGER } from '../util/logger';
|
|
27
28
|
import { validateGitDirectory } from '../util/validation-util';
|
|
28
|
-
|
|
29
|
+
|
|
29
30
|
export interface HeaderCheckOptions {
|
|
30
31
|
type: CheckType;
|
|
31
32
|
exclude: string[];
|
|
@@ -140,19 +141,22 @@ function validate(rootDir: string, files: string[], options: HeaderCheckOptions)
|
|
|
140
141
|
printFileProgress(i + 1 + noHeadersLength, allFilesLength, `Validating ${file}`);
|
|
141
142
|
const copyrightLine = sh.head({ '-n': 2 }, file).stdout.trim().split('\n')[1];
|
|
142
143
|
const copyRightYears = copyrightLine.match(YEAR_RANGE_REGEX)!;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
if (!copyRightYears) {
|
|
145
|
+
const result: ValidationResult = { file, violation: 'noYear', line: copyrightLine };
|
|
146
|
+
results.push(result);
|
|
147
|
+
} else {
|
|
148
|
+
const currentStartYear = Number.parseInt(copyRightYears[0], 10);
|
|
149
|
+
const currentEndYear = copyRightYears[1] ? Number.parseInt(copyRightYears[1], 10) : undefined;
|
|
150
|
+
const result: DateValidationResult = {
|
|
151
|
+
currentStartYear,
|
|
152
|
+
currentEndYear,
|
|
153
|
+
expectedEndYear: defaultEndYear ?? getLastModificationDate(file, rootDir, AUTO_FIX_MESSAGE)!.getFullYear(),
|
|
154
|
+
file,
|
|
155
|
+
violation: 'none'
|
|
156
|
+
};
|
|
157
|
+
validateEndYear(result);
|
|
158
|
+
results.push(result);
|
|
159
|
+
}
|
|
156
160
|
});
|
|
157
161
|
|
|
158
162
|
results.sort((a, b) => a.file.localeCompare(b.file));
|
|
@@ -202,7 +206,10 @@ export function handleValidationResults(rootDir: string, results: ValidationResu
|
|
|
202
206
|
fs.writeFileSync(path.join(rootDir, 'headerCheck.json'), JSON.stringify(results, undefined, 2));
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
if (
|
|
209
|
+
if (
|
|
210
|
+
violations.length > 0 &&
|
|
211
|
+
(options.autoFix || readline.keyInYN('Do you want to automatically fix copyright year range violations?'))
|
|
212
|
+
) {
|
|
206
213
|
const toFix = violations.filter(violation => isDateValidationResult(violation)) as DateValidationResult[];
|
|
207
214
|
fixViolations(rootDir, toFix, options);
|
|
208
215
|
}
|
|
@@ -223,6 +230,8 @@ function toPrintMessage(result: ValidationResult): string {
|
|
|
223
230
|
return `${error} ${message}! Expected end year '${expected}' but is '${actual}'`;
|
|
224
231
|
} else if (result.violation === 'noOrMissingHeader') {
|
|
225
232
|
return `${error} No or invalid copyright header!`;
|
|
233
|
+
} else if (result.violation === 'noYear') {
|
|
234
|
+
return `${error} No year found!${result.line ? ' (line: ' + result.line + ')' : ''}`;
|
|
226
235
|
}
|
|
227
236
|
|
|
228
237
|
return `${info} OK`;
|
|
@@ -255,6 +264,7 @@ function fixViolations(rootDir: string, violations: DateValidationResult[], opti
|
|
|
255
264
|
interface ValidationResult {
|
|
256
265
|
file: string;
|
|
257
266
|
violation: Violation;
|
|
267
|
+
line?: string;
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
interface DateValidationResult extends ValidationResult {
|
|
@@ -267,4 +277,4 @@ function isDateValidationResult(object: ValidationResult): object is DateValidat
|
|
|
267
277
|
return 'currentStartYear' in object && 'expectedEndYear' in object;
|
|
268
278
|
}
|
|
269
279
|
|
|
270
|
-
type Violation = 'none' | 'noOrMissingHeader' | 'invalidEndYear';
|
|
280
|
+
type Violation = 'none' | 'noOrMissingHeader' | 'invalidEndYear' | 'noYear';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import * as fs from 'fs';
|
|
18
18
|
import * as path from 'path';
|
|
19
|
-
import
|
|
19
|
+
import sh from 'shelljs';
|
|
20
20
|
import { baseCommand, fatalExec, getShellConfig } from '../util/command-util';
|
|
21
21
|
import { LOGGER } from '../util/logger';
|
|
22
22
|
import { validateDirectory } from '../util/validation-util';
|
|
@@ -0,0 +1,169 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -19,7 +19,7 @@ import fetch from 'node-fetch';
|
|
|
19
19
|
import { resolve } from 'path';
|
|
20
20
|
import * as readline from 'readline-sync';
|
|
21
21
|
import * as semver from 'semver';
|
|
22
|
-
import
|
|
22
|
+
import sh from 'shelljs';
|
|
23
23
|
import { fatalExec, getShellConfig } from '../../util/command-util';
|
|
24
24
|
import { getLatestGithubRelease, getLatestTag, hasGitChanges, isGitRepository } from '../../util/git-util';
|
|
25
25
|
import { LOGGER } from '../../util/logger';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import
|
|
16
|
+
import sh from 'shelljs';
|
|
17
17
|
import { getShellConfig } from '../../util/command-util';
|
|
18
18
|
import { LOGGER } from '../../util/logger';
|
|
19
19
|
import { checkoutAndCd, commitAndTag, lernaSetVersion, publish, ReleaseOptions, updateLernaForDryRun, yarnInstall } from './common';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import sh from 'shelljs';
|
|
18
18
|
import { fatalExec, getShellConfig } from '../../util/command-util';
|
|
19
19
|
import { LOGGER } from '../../util/logger';
|
|
20
20
|
import {
|
|
21
|
+
ReleaseOptions,
|
|
22
|
+
ReleaseType,
|
|
21
23
|
asMvnVersion,
|
|
22
24
|
checkJavaServerVersion,
|
|
23
25
|
checkoutAndCd,
|
|
24
26
|
commitAndTag,
|
|
25
27
|
lernaSetVersion,
|
|
26
28
|
publish,
|
|
27
|
-
ReleaseOptions,
|
|
28
|
-
ReleaseType,
|
|
29
29
|
updateLernaForDryRun,
|
|
30
30
|
updateVersion,
|
|
31
31
|
yarnInstall
|
|
32
|
-
} from './common';
|
|
32
|
+
} from './common.js';
|
|
33
33
|
|
|
34
34
|
let REPO_ROOT: string;
|
|
35
35
|
|