@eclipse-glsp/cli 2.3.0-next.164 → 2.3.0-next.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -38
- package/dist/cli.js +21959 -0
- package/dist/cli.js.map +6 -0
- package/package.json +22 -29
- package/bin/glsp +0 -2
- package/lib/app.d.ts +0 -2
- package/lib/app.d.ts.map +0 -1
- package/lib/app.js +0 -35
- package/lib/app.js.map +0 -1
- package/lib/commands/check-header.d.ts +0 -21
- package/lib/commands/check-header.d.ts.map +0 -1
- package/lib/commands/check-header.js +0 -240
- package/lib/commands/check-header.js.map +0 -1
- package/lib/commands/coverage-report.d.ts +0 -29
- package/lib/commands/coverage-report.d.ts.map +0 -1
- package/lib/commands/coverage-report.js +0 -126
- package/lib/commands/coverage-report.js.map +0 -1
- package/lib/commands/generate-index.d.ts +0 -46
- package/lib/commands/generate-index.d.ts.map +0 -1
- package/lib/commands/generate-index.js +0 -172
- package/lib/commands/generate-index.js.map +0 -1
- package/lib/commands/release/common.d.ts +0 -68
- package/lib/commands/release/common.d.ts.map +0 -1
- package/lib/commands/release/common.js +0 -293
- package/lib/commands/release/common.js.map +0 -1
- package/lib/commands/release/release-client.d.ts +0 -3
- package/lib/commands/release/release-client.d.ts.map +0 -1
- package/lib/commands/release/release-client.js +0 -58
- package/lib/commands/release/release-client.js.map +0 -1
- package/lib/commands/release/release-eclipse-integration.d.ts +0 -18
- package/lib/commands/release/release-eclipse-integration.d.ts.map +0 -1
- package/lib/commands/release/release-eclipse-integration.js +0 -93
- package/lib/commands/release/release-eclipse-integration.js.map +0 -1
- package/lib/commands/release/release-java-server.d.ts +0 -3
- package/lib/commands/release/release-java-server.d.ts.map +0 -1
- package/lib/commands/release/release-java-server.js +0 -71
- package/lib/commands/release/release-java-server.js.map +0 -1
- package/lib/commands/release/release-server-node.d.ts +0 -18
- package/lib/commands/release/release-server-node.d.ts.map +0 -1
- package/lib/commands/release/release-server-node.js +0 -54
- package/lib/commands/release/release-server-node.js.map +0 -1
- package/lib/commands/release/release-theia-integration.d.ts +0 -18
- package/lib/commands/release/release-theia-integration.d.ts.map +0 -1
- package/lib/commands/release/release-theia-integration.js +0 -54
- package/lib/commands/release/release-theia-integration.js.map +0 -1
- package/lib/commands/release/release-vscode-integration.d.ts +0 -18
- package/lib/commands/release/release-vscode-integration.d.ts.map +0 -1
- package/lib/commands/release/release-vscode-integration.js +0 -54
- package/lib/commands/release/release-vscode-integration.js.map +0 -1
- package/lib/commands/release/release.d.ts +0 -14
- package/lib/commands/release/release.d.ts.map +0 -1
- package/lib/commands/release/release.js +0 -191
- package/lib/commands/release/release.js.map +0 -1
- package/lib/commands/update-next.d.ts +0 -20
- package/lib/commands/update-next.d.ts.map +0 -1
- package/lib/commands/update-next.js +0 -146
- package/lib/commands/update-next.js.map +0 -1
- package/lib/util/command-util.d.ts +0 -26
- package/lib/util/command-util.d.ts.map +0 -1
- package/lib/util/command-util.js +0 -56
- package/lib/util/command-util.js.map +0 -1
- package/lib/util/git-util.d.ts +0 -42
- package/lib/util/git-util.d.ts.map +0 -1
- package/lib/util/git-util.js +0 -125
- package/lib/util/git-util.js.map +0 -1
- package/lib/util/logger.d.ts +0 -23
- package/lib/util/logger.d.ts.map +0 -1
- package/lib/util/logger.js +0 -50
- package/lib/util/logger.js.map +0 -1
- package/lib/util/validation-util.d.ts +0 -5
- package/lib/util/validation-util.d.ts.map +0 -1
- package/lib/util/validation-util.js +0 -86
- package/lib/util/validation-util.js.map +0 -1
- package/src/app.ts +0 -34
- package/src/commands/check-header.ts +0 -280
- package/src/commands/coverage-report.ts +0 -113
- package/src/commands/generate-index.ts +0 -169
- package/src/commands/release/common.ts +0 -306
- package/src/commands/release/release-client.ts +0 -55
- package/src/commands/release/release-eclipse-integration.ts +0 -113
- package/src/commands/release/release-java-server.ts +0 -73
- package/src/commands/release/release-server-node.ts +0 -61
- package/src/commands/release/release-theia-integration.ts +0 -65
- package/src/commands/release/release-vscode-integration.ts +0 -67
- package/src/commands/release/release.ts +0 -215
- package/src/commands/update-next.ts +0 -129
- package/src/util/command-util.ts +0 -54
- package/src/util/git-util.ts +0 -123
- package/src/util/logger.ts +0 -57
- package/src/util/validation-util.ts +0 -62
package/lib/util/git-util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;IAClB,MAAM,UAAU,GAAG,iBAAE,CAAC,IAAI,CAAC,+BAA+B,EAAE,IAAA,6BAAc,GAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5F,OAAO,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAJD,gCAIC;AAED,SAAgB,aAAa,CAAC,IAAa;IACvC,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC;AAFD,sCAEC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,IAAa;IAC/C,WAAW,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,iBAAE;SACJ,IAAI,CAAC,wBAAwB,EAAE,IAAA,6BAAc,GAAE,CAAC;SAChD,MAAM,CAAC,IA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,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
DELETED
|
@@ -1,23 +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
|
-
export interface Logger extends Pick<Console, LogLevel> {
|
|
17
|
-
newLine(): void;
|
|
18
|
-
}
|
|
19
|
-
export type LogLevel = 'info' | 'debug' | 'error' | 'warn';
|
|
20
|
-
export declare const LOGGER: Logger;
|
|
21
|
-
export declare function configureLogger(level: LogLevel): void;
|
|
22
|
-
export declare function configureLogger(verbose: boolean): void;
|
|
23
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/lib/util/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,MAAM,WAAW,MAAO,SAAQ,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;IACnD,OAAO,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAW3D,eAAO,MAAM,MAAM,EAAE,MAMX,CAAC;AAUX,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;AACvD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC"}
|
package/lib/util/logger.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2022-2023 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.configureLogger = exports.LOGGER = void 0;
|
|
19
|
-
const levels = {
|
|
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
|
-
debug: { threshold: 3, color: '\x1b[32m' } // green
|
|
24
|
-
};
|
|
25
|
-
let levelThreshold = levels.info.threshold;
|
|
26
|
-
exports.LOGGER = {
|
|
27
|
-
info: (...args) => log('info', ...args),
|
|
28
|
-
error: (...args) => log('error', ...args),
|
|
29
|
-
warn: (...args) => log('warn', ...args),
|
|
30
|
-
debug: (...args) => log('debug', ...args),
|
|
31
|
-
newLine: () => console.log('')
|
|
32
|
-
};
|
|
33
|
-
function log(level, ...args) {
|
|
34
|
-
const levelData = levels[level];
|
|
35
|
-
if (levelThreshold < levelData.threshold) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
console[level](levelData.color, ...args, '\x1b[0m');
|
|
39
|
-
}
|
|
40
|
-
function configureLogger(levelOrVerbose) {
|
|
41
|
-
if (typeof levelOrVerbose === 'boolean') {
|
|
42
|
-
const level = levelOrVerbose ? 'debug' : 'info';
|
|
43
|
-
levelThreshold = levels[level].threshold;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
levelThreshold = levels[levelOrVerbose].threshold;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.configureLogger = configureLogger;
|
|
50
|
-
//# sourceMappingURL=logger.js.map
|
package/lib/util/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,SA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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,5 +0,0 @@
|
|
|
1
|
-
export declare function validateDirectory(rootDir: string): string;
|
|
2
|
-
export declare function validateFile(filePath: string, hasToExist?: boolean): string;
|
|
3
|
-
export declare function validateVersion(version: string): string;
|
|
4
|
-
export declare function validateGitDirectory(repository: string): string;
|
|
5
|
-
//# sourceMappingURL=validation-util.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.validateGitDirectory = exports.validateVersion = exports.validateFile = exports.validateDirectory = void 0;
|
|
27
|
-
/********************************************************************************
|
|
28
|
-
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
29
|
-
*
|
|
30
|
-
* This program and the accompanying materials are made available under the
|
|
31
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
32
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
33
|
-
*
|
|
34
|
-
* This Source Code may also be made available under the following Secondary
|
|
35
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
36
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
37
|
-
* with the GNU Classpath Exception which is available at
|
|
38
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
39
|
-
*
|
|
40
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
41
|
-
********************************************************************************/
|
|
42
|
-
const commander_1 = require("commander");
|
|
43
|
-
const fs = __importStar(require("fs"));
|
|
44
|
-
const path_1 = require("path");
|
|
45
|
-
const semver = __importStar(require("semver"));
|
|
46
|
-
const git_util_1 = require("./git-util");
|
|
47
|
-
const logger_1 = require("./logger");
|
|
48
|
-
function validateDirectory(rootDir) {
|
|
49
|
-
const path = (0, path_1.resolve)(rootDir);
|
|
50
|
-
if (!fs.existsSync(path)) {
|
|
51
|
-
throw new commander_1.InvalidArgumentError('Not a valid file path!');
|
|
52
|
-
}
|
|
53
|
-
if (!fs.statSync(path).isDirectory()) {
|
|
54
|
-
throw new commander_1.InvalidArgumentError('Not a directory!');
|
|
55
|
-
}
|
|
56
|
-
return path;
|
|
57
|
-
}
|
|
58
|
-
exports.validateDirectory = validateDirectory;
|
|
59
|
-
function validateFile(filePath, hasToExist = false) {
|
|
60
|
-
const path = (0, path_1.resolve)(filePath);
|
|
61
|
-
if (hasToExist && !fs.existsSync(path)) {
|
|
62
|
-
throw new commander_1.InvalidArgumentError('Not a valid file path!');
|
|
63
|
-
}
|
|
64
|
-
if (!fs.statSync(path).isFile()) {
|
|
65
|
-
throw new commander_1.InvalidArgumentError('Not a file!');
|
|
66
|
-
}
|
|
67
|
-
return path;
|
|
68
|
-
}
|
|
69
|
-
exports.validateFile = validateFile;
|
|
70
|
-
function validateVersion(version) {
|
|
71
|
-
logger_1.LOGGER.debug(`Validate version format of: ${version}`);
|
|
72
|
-
if (!semver.valid(version)) {
|
|
73
|
-
throw new commander_1.InvalidArgumentError(`Not a valid version: ${version}`);
|
|
74
|
-
}
|
|
75
|
-
return version;
|
|
76
|
-
}
|
|
77
|
-
exports.validateVersion = validateVersion;
|
|
78
|
-
function validateGitDirectory(repository) {
|
|
79
|
-
const repoPath = validateDirectory(repository);
|
|
80
|
-
if (!(0, git_util_1.isGitRepository)(repoPath)) {
|
|
81
|
-
throw new commander_1.InvalidArgumentError('Not a valid git repository');
|
|
82
|
-
}
|
|
83
|
-
return (0, git_util_1.getGitRoot)(repository);
|
|
84
|
-
}
|
|
85
|
-
exports.validateGitDirectory = validateGitDirectory;
|
|
86
|
-
//# sourceMappingURL=validation-util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-util.js","sourceRoot":"","sources":["../../src/util/validation-util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA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AAC;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/src/app.ts
DELETED
|
@@ -1,34 +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 { CheckHeaderCommand } from './commands/check-header';
|
|
17
|
-
import { CoverageReportCommand } from './commands/coverage-report';
|
|
18
|
-
import { GenerateIndex } from './commands/generate-index';
|
|
19
|
-
import { ReleaseCommand } from './commands/release/release';
|
|
20
|
-
import { UpdateNextCommand } from './commands/update-next';
|
|
21
|
-
import { baseCommand } from './util/command-util';
|
|
22
|
-
|
|
23
|
-
export const COMMAND_VERSION = '1.1.0-next';
|
|
24
|
-
|
|
25
|
-
const app = baseCommand() //
|
|
26
|
-
.version(COMMAND_VERSION)
|
|
27
|
-
.name('glsp')
|
|
28
|
-
.addCommand(CoverageReportCommand)
|
|
29
|
-
.addCommand(ReleaseCommand)
|
|
30
|
-
.addCommand(CheckHeaderCommand)
|
|
31
|
-
.addCommand(UpdateNextCommand)
|
|
32
|
-
.addCommand(GenerateIndex);
|
|
33
|
-
|
|
34
|
-
app.parse(process.argv);
|
|
@@ -1,280 +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
|
-
/* eslint-disable max-len */
|
|
17
|
-
import { Option } from 'commander';
|
|
18
|
-
import * as fs from 'fs';
|
|
19
|
-
import { glob } from 'glob';
|
|
20
|
-
import * as minimatch from 'minimatch';
|
|
21
|
-
import * as readline from 'readline-sync';
|
|
22
|
-
import sh from 'shelljs';
|
|
23
|
-
import { baseCommand, configureShell, getShellConfig } from '../util/command-util';
|
|
24
|
-
import { getChangesOfLastCommit, getLastModificationDate, getUncommittedChanges } from '../util/git-util';
|
|
25
|
-
|
|
26
|
-
import * as path from 'path';
|
|
27
|
-
import { LOGGER } from '../util/logger';
|
|
28
|
-
import { validateGitDirectory } from '../util/validation-util';
|
|
29
|
-
|
|
30
|
-
export interface HeaderCheckOptions {
|
|
31
|
-
type: CheckType;
|
|
32
|
-
exclude: string[];
|
|
33
|
-
fileExtensions: string[];
|
|
34
|
-
json: boolean;
|
|
35
|
-
excludeDefaults: boolean;
|
|
36
|
-
autoFix: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const checkTypes = ['full', 'changes', 'lastCommit'] as const;
|
|
40
|
-
type CheckType = (typeof checkTypes)[number];
|
|
41
|
-
|
|
42
|
-
const DEFAULT_EXCLUDES = ['**/@(node_modules|lib|dist|bundle)/**'];
|
|
43
|
-
const YEAR_RANGE_REGEX = /\d{4}/g;
|
|
44
|
-
const HEADER_PATTERN = 'Copyright \\([cC]\\) \\d{4}';
|
|
45
|
-
const AUTO_FIX_MESSAGE = 'Fix copyright header violations';
|
|
46
|
-
|
|
47
|
-
export const CheckHeaderCommand = baseCommand() //
|
|
48
|
-
.name('checkHeaders')
|
|
49
|
-
.description('Validates the copyright year range (end year) of license header files')
|
|
50
|
-
.argument('<rootDir>', 'The starting directory for the check', validateGitDirectory)
|
|
51
|
-
.addOption(
|
|
52
|
-
new Option(
|
|
53
|
-
'-t, --type <type>',
|
|
54
|
-
'The scope of the check. In addition to a full recursive check, is also possible to only' +
|
|
55
|
-
' consider pending changes or the last commit'
|
|
56
|
-
)
|
|
57
|
-
.choices(checkTypes)
|
|
58
|
-
.default('full')
|
|
59
|
-
)
|
|
60
|
-
.option('-f, --fileExtensions <extensions...>', 'File extensions that should be checked', ['ts', 'tsx'])
|
|
61
|
-
.addOption(
|
|
62
|
-
new Option(
|
|
63
|
-
'-e, --exclude <exclude...>',
|
|
64
|
-
'File patterns that should be excluded from the check. New exclude patterns are added to the default patterns'
|
|
65
|
-
).default([], `[${DEFAULT_EXCLUDES}]`)
|
|
66
|
-
)
|
|
67
|
-
.option(
|
|
68
|
-
'--no-exclude-defaults',
|
|
69
|
-
'Disables the default excludes patterns. Only explicitly passed exclude patterns (-e, --exclude) are considered'
|
|
70
|
-
)
|
|
71
|
-
.option('-j, --json', 'Also persist validation results as json file', false)
|
|
72
|
-
.option('-a, --autoFix', 'Auto apply & commit fixes without prompting the user', false)
|
|
73
|
-
.action(checkHeaders);
|
|
74
|
-
|
|
75
|
-
export function checkHeaders(rootDir: string, options: HeaderCheckOptions): void {
|
|
76
|
-
configureShell({ silent: true, fatal: true });
|
|
77
|
-
|
|
78
|
-
if (options.excludeDefaults) {
|
|
79
|
-
options.exclude.push(...DEFAULT_EXCLUDES);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
sh.cd(rootDir);
|
|
83
|
-
const files = getFiles(rootDir, options);
|
|
84
|
-
LOGGER.info(`Check copy right headers of ${files.length} files`);
|
|
85
|
-
if (files.length === 0) {
|
|
86
|
-
LOGGER.info('Check completed');
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const results = validate(rootDir, files, options);
|
|
90
|
-
handleValidationResults(rootDir, results, options);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function getFiles(rootDir: string, options: HeaderCheckOptions): string[] {
|
|
94
|
-
const includePattern = `**/*.@(${options.fileExtensions.join('|')})`;
|
|
95
|
-
const excludePattern = options.exclude;
|
|
96
|
-
|
|
97
|
-
if (options.type === 'full') {
|
|
98
|
-
return glob.sync(includePattern, {
|
|
99
|
-
cwd: rootDir,
|
|
100
|
-
ignore: excludePattern
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let changedFiles = options.type === 'changes' ? getUncommittedChanges(rootDir) : getChangesOfLastCommit(rootDir);
|
|
105
|
-
changedFiles = changedFiles.filter(minimatch.filter(includePattern));
|
|
106
|
-
|
|
107
|
-
excludePattern.forEach(pattern => {
|
|
108
|
-
changedFiles = changedFiles.filter(minimatch.filter(`!${pattern}`));
|
|
109
|
-
});
|
|
110
|
-
return changedFiles.filter(file => fs.existsSync(file));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function validate(rootDir: string, files: string[], options: HeaderCheckOptions): ValidationResult[] {
|
|
114
|
-
// Derives all files with valid headers and all files with no or invalid headers
|
|
115
|
-
const filesWithHeader = sh.grep('-l', HEADER_PATTERN, files).stdout.trim().split('\n');
|
|
116
|
-
const noHeaders = files.filter(file => !filesWithHeader.includes(file));
|
|
117
|
-
|
|
118
|
-
const results: ValidationResult[] = [];
|
|
119
|
-
const allFilesLength = files.length;
|
|
120
|
-
|
|
121
|
-
// Create validation results for all files with no or invalid headers
|
|
122
|
-
const noHeadersLength = noHeaders.length;
|
|
123
|
-
if (noHeadersLength > 0) {
|
|
124
|
-
LOGGER.info(`Found ${noHeadersLength} files with no (or an invalid) copyright header`);
|
|
125
|
-
}
|
|
126
|
-
noHeaders.forEach((file, i) => {
|
|
127
|
-
printFileProgress(i + 1, allFilesLength, `Validating ${file}`);
|
|
128
|
-
results.push({ file: path.resolve(rootDir, file), violation: 'noOrMissingHeader' });
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Performance optimization: avoid retrieving the dates for each individual file by precalculating the endYear if possible.
|
|
132
|
-
let defaultEndYear: number | undefined;
|
|
133
|
-
if (options.type === 'changes') {
|
|
134
|
-
defaultEndYear = new Date().getFullYear();
|
|
135
|
-
} else if (options.type === 'lastCommit') {
|
|
136
|
-
defaultEndYear = getLastModificationDate(undefined, rootDir)?.getFullYear();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Create validation results for all files with valid headers
|
|
140
|
-
filesWithHeader.forEach((file, i) => {
|
|
141
|
-
printFileProgress(i + 1 + noHeadersLength, allFilesLength, `Validating ${file}`);
|
|
142
|
-
const copyrightLine = sh.head({ '-n': 2 }, file).stdout.trim().split('\n')[1];
|
|
143
|
-
const copyRightYears = copyrightLine.match(YEAR_RANGE_REGEX)!;
|
|
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
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
results.sort((a, b) => a.file.localeCompare(b.file));
|
|
163
|
-
|
|
164
|
-
process.stdout.clearLine(0);
|
|
165
|
-
return results;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function validateEndYear(result: DateValidationResult): void {
|
|
169
|
-
const { currentStartYear, expectedEndYear, currentEndYear } = result;
|
|
170
|
-
result.violation = 'invalidEndYear';
|
|
171
|
-
|
|
172
|
-
const valid = currentEndYear ? currentEndYear === expectedEndYear : currentStartYear === expectedEndYear;
|
|
173
|
-
|
|
174
|
-
if (valid) {
|
|
175
|
-
result.violation = 'none';
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function printFileProgress(currentFileCount: number, maxFileCount: number, message: string, clear = true): void {
|
|
181
|
-
if (clear) {
|
|
182
|
-
process.stdout.clearLine(0);
|
|
183
|
-
process.stdout.cursorTo(0);
|
|
184
|
-
}
|
|
185
|
-
process.stdout.write(`[${currentFileCount} of ${maxFileCount}] ${message}`);
|
|
186
|
-
if (!clear) {
|
|
187
|
-
process.stdout.write('\n');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export function handleValidationResults(rootDir: string, results: ValidationResult[], options: HeaderCheckOptions): void {
|
|
192
|
-
LOGGER.newLine();
|
|
193
|
-
LOGGER.info(`Header validation for ${results.length} files completed`);
|
|
194
|
-
const violations = results.filter(result => result.violation !== 'none');
|
|
195
|
-
// Adjust results to print based on configured severity level
|
|
196
|
-
const toPrint = violations;
|
|
197
|
-
|
|
198
|
-
LOGGER.info(`Found ${toPrint.length} copyright header violations:`);
|
|
199
|
-
LOGGER.newLine();
|
|
200
|
-
|
|
201
|
-
toPrint.forEach((result, i) => LOGGER.info(`${i + 1}. `, result.file, ':', toPrintMessage(result)));
|
|
202
|
-
|
|
203
|
-
LOGGER.newLine();
|
|
204
|
-
|
|
205
|
-
if (options.json) {
|
|
206
|
-
fs.writeFileSync(path.join(rootDir, 'headerCheck.json'), JSON.stringify(results, undefined, 2));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
violations.length > 0 &&
|
|
211
|
-
(options.autoFix || readline.keyInYN('Do you want to automatically fix copyright year range violations?'))
|
|
212
|
-
) {
|
|
213
|
-
const toFix = violations.filter(violation => isDateValidationResult(violation)) as DateValidationResult[];
|
|
214
|
-
fixViolations(rootDir, toFix, options);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
LOGGER.info('Check completed');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function toPrintMessage(result: ValidationResult): string {
|
|
221
|
-
const error = '\x1b[31m';
|
|
222
|
-
const info = '\x1b[32m';
|
|
223
|
-
|
|
224
|
-
if (isDateValidationResult(result) && result.violation === 'invalidEndYear') {
|
|
225
|
-
const expected = result.expectedEndYear.toString();
|
|
226
|
-
const actual = result.currentEndYear
|
|
227
|
-
? `${result.currentEndYear} (${result.currentStartYear}-${result.currentEndYear})`
|
|
228
|
-
: result.currentStartYear.toString();
|
|
229
|
-
const message = 'Invalid copyright end year';
|
|
230
|
-
return `${error} ${message}! Expected end year '${expected}' but is '${actual}'`;
|
|
231
|
-
} else if (result.violation === 'noOrMissingHeader') {
|
|
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 + ')' : ''}`;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return `${info} OK`;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function fixViolations(rootDir: string, violations: DateValidationResult[], options: HeaderCheckOptions): void {
|
|
241
|
-
LOGGER.newLine();
|
|
242
|
-
violations.forEach((violation, i) => {
|
|
243
|
-
printFileProgress(i + 1, violations.length, `Fix ${violation.file}`, false);
|
|
244
|
-
|
|
245
|
-
const currentRange = `${violation.currentStartYear}${violation.currentEndYear ? '-' + violation.currentEndYear : ''}`;
|
|
246
|
-
const fixedRange =
|
|
247
|
-
violation.currentEndYear || violation.currentStartYear < violation.expectedEndYear
|
|
248
|
-
? `${violation.currentStartYear}-${violation.expectedEndYear}`
|
|
249
|
-
: `${violation.expectedEndYear}`;
|
|
250
|
-
|
|
251
|
-
sh.sed('-i', RegExp('Copyright \\([cC]\\) ' + currentRange), `Copyright (c) ${fixedRange}`, violation.file);
|
|
252
|
-
});
|
|
253
|
-
LOGGER.newLine();
|
|
254
|
-
if (options.autoFix || readline.keyInYN('Do you want to create a commit for the fixed files?')) {
|
|
255
|
-
LOGGER.newLine();
|
|
256
|
-
const files = violations.map(violation => violation.file).join(' ');
|
|
257
|
-
sh.exec(`git add ${files}`, getShellConfig());
|
|
258
|
-
sh.exec(`git commit -m "${AUTO_FIX_MESSAGE}"`);
|
|
259
|
-
LOGGER.newLine();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Helper types
|
|
264
|
-
interface ValidationResult {
|
|
265
|
-
file: string;
|
|
266
|
-
violation: Violation;
|
|
267
|
-
line?: string;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
interface DateValidationResult extends ValidationResult {
|
|
271
|
-
currentStartYear: number;
|
|
272
|
-
currentEndYear?: number;
|
|
273
|
-
expectedEndYear: number;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function isDateValidationResult(object: ValidationResult): object is DateValidationResult {
|
|
277
|
-
return 'currentStartYear' in object && 'expectedEndYear' in object;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
type Violation = 'none' | 'noOrMissingHeader' | 'invalidEndYear' | 'noYear';
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
*
|
|
8
|
-
* This Source Code may also be made available under the following Secondary
|
|
9
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
* with the GNU Classpath Exception which is available at
|
|
12
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
*
|
|
14
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
|
|
17
|
-
import * as fs from 'fs';
|
|
18
|
-
import * as path from 'path';
|
|
19
|
-
import sh from 'shelljs';
|
|
20
|
-
import { baseCommand, fatalExec, getShellConfig } from '../util/command-util';
|
|
21
|
-
import { LOGGER } from '../util/logger';
|
|
22
|
-
import { validateDirectory } from '../util/validation-util';
|
|
23
|
-
|
|
24
|
-
export interface CoverageCmdOptions {
|
|
25
|
-
coverageScript: string;
|
|
26
|
-
projectRoot: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const CoverageReportCommand = baseCommand() //
|
|
30
|
-
.name('coverageReport')
|
|
31
|
-
.description('Generate a test coverage report for a glsp component')
|
|
32
|
-
.option('-p, --projectRoot <projectRoot>', 'The root directory of the GLSP component', validateDirectory, process.cwd())
|
|
33
|
-
.option('-c, --coverageScript <script>', 'Script command of the package root for creating coverage reports', 'test:coverage')
|
|
34
|
-
.action(generateCoverageReport);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Generates and aggregates an 'nyc' coverage report for lerna/yarn mono repositories.
|
|
38
|
-
* First, individual reports for each package are generated. Then, they are aggregated into one combined HTML report.
|
|
39
|
-
* @param options configuration options
|
|
40
|
-
*/
|
|
41
|
-
export function generateCoverageReport(options: CoverageCmdOptions): void {
|
|
42
|
-
sh.cd(options.projectRoot);
|
|
43
|
-
const packages = validateAndRetrievePackages(options);
|
|
44
|
-
LOGGER.info('Create individual package coverage reports');
|
|
45
|
-
const jsonReports = collectPackageReportFiles(packages, options);
|
|
46
|
-
combineReports(jsonReports, options);
|
|
47
|
-
LOGGER.info('Coverage reported generation successful');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function validateAndRetrievePackages(options: CoverageCmdOptions): string[] {
|
|
51
|
-
const packagePath = path.join(options.projectRoot, 'package.json');
|
|
52
|
-
if (!fs.existsSync(packagePath)) {
|
|
53
|
-
CoverageReportCommand.error(`Invalid root directory. '${options.projectRoot}' does not contain a package.json.`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
fatalExec('yarn nyc -h', 'Nyc is not installed!', getShellConfig({ silent: true }));
|
|
57
|
-
|
|
58
|
-
const packageJson = JSON.parse(fs.readFileSync(packagePath).toString());
|
|
59
|
-
|
|
60
|
-
if (!packageJson?.scripts?.[options.coverageScript]) {
|
|
61
|
-
CoverageReportCommand.error(
|
|
62
|
-
`Invalid coverage script! The package.json does not have a script with name '${options.coverageScript}'!`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!Array.isArray(packageJson.workspaces)) {
|
|
67
|
-
CoverageReportCommand.error('Invalid package.json! No yarn workspaces are configured!');
|
|
68
|
-
}
|
|
69
|
-
return (packageJson.workspaces as string[]).map(pkg => pkg.replace('/*', ''));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function collectPackageReportFiles(packages: string[], options: CoverageCmdOptions): string[] {
|
|
73
|
-
LOGGER.info('Create combined report');
|
|
74
|
-
sh.exec(`yarn ${options.coverageScript}`);
|
|
75
|
-
// collect reports
|
|
76
|
-
const reports: string[] = [];
|
|
77
|
-
packages.forEach(pkg => {
|
|
78
|
-
sh.find(pkg)
|
|
79
|
-
.filter(file => file.endsWith('coverage-final.json'))
|
|
80
|
-
.forEach(json => reports.push(path.resolve(options.projectRoot, json)));
|
|
81
|
-
});
|
|
82
|
-
return reports;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function combineReports(reportFiles: string[], options: CoverageCmdOptions): void {
|
|
86
|
-
// Copy coverage into root/.nyc_output
|
|
87
|
-
const reportsDir = path.join(options.projectRoot, '.nyc_output');
|
|
88
|
-
if (fs.existsSync(reportsDir)) {
|
|
89
|
-
fs.rmSync(reportsDir, { force: true, recursive: true });
|
|
90
|
-
}
|
|
91
|
-
fs.mkdirSync(reportsDir);
|
|
92
|
-
|
|
93
|
-
for (let i = 0; i < reportFiles.length; i++) {
|
|
94
|
-
fs.copyFileSync(reportFiles[i], path.resolve('.nyc_output', `coverage-final-${i}.json`));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Temporarily remove root nyc configs otherwise the report command might fail.
|
|
98
|
-
sh.cd(options.projectRoot);
|
|
99
|
-
const configFiles = ['.nycrc', '.nycrc.json', '.nyc-config.js'];
|
|
100
|
-
const tempFiles: string[] = [];
|
|
101
|
-
configFiles.forEach(config => {
|
|
102
|
-
if (fs.existsSync(path.join(options.projectRoot, config))) {
|
|
103
|
-
sh.mv(config, '_' + config);
|
|
104
|
-
tempFiles.push('_' + config);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Generate report
|
|
109
|
-
sh.exec('yarn nyc report --reporter html', getShellConfig());
|
|
110
|
-
|
|
111
|
-
// Restore nyc configs (if any)
|
|
112
|
-
tempFiles.forEach(config => sh.mv(config, config.substring(1)));
|
|
113
|
-
}
|