@digigov/cli 2.0.0-aefd0709 → 2.0.0-b19b7fe2
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/lib/command.js +5 -4
- package/lib/logger.js +19 -0
- package/lib/project-utils.cjs +9 -3
- package/package.json +7 -3
- package/tsconfig.cli.json +3 -3
package/lib/command.js
CHANGED
|
@@ -15,7 +15,6 @@ import { findPackageJson } from "./project-utils.cjs";
|
|
|
15
15
|
export class DigigovCommand extends commander.Command {
|
|
16
16
|
/**
|
|
17
17
|
* The id of the command used for logging
|
|
18
|
-
* @private
|
|
19
18
|
* @type {string}
|
|
20
19
|
*/
|
|
21
20
|
#id;
|
|
@@ -57,6 +56,7 @@ export class DigigovCommand extends commander.Command {
|
|
|
57
56
|
* @override
|
|
58
57
|
* @param {string} message - The message to log
|
|
59
58
|
* @param {commander.ErrorOptions} [errorOptions] - The error options
|
|
59
|
+
* @returns {never}
|
|
60
60
|
*/
|
|
61
61
|
error(message, errorOptions) {
|
|
62
62
|
logger.error(message);
|
|
@@ -66,7 +66,7 @@ export class DigigovCommand extends commander.Command {
|
|
|
66
66
|
/**
|
|
67
67
|
* @override
|
|
68
68
|
* @param {(...args: any[]) => void | Promise<void>} fn - The function to run
|
|
69
|
-
* @returns {
|
|
69
|
+
* @returns {this} `this` command for chaining
|
|
70
70
|
*/
|
|
71
71
|
action(fn) {
|
|
72
72
|
return super.action(async (...args) => {
|
|
@@ -110,12 +110,13 @@ export class DigigovCommand extends commander.Command {
|
|
|
110
110
|
stdio: "inherit",
|
|
111
111
|
});
|
|
112
112
|
} catch (error) {
|
|
113
|
-
this.#throwError(error
|
|
113
|
+
this.#throwError(error);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* @
|
|
118
|
+
* @param {unknown} error - The error to log
|
|
119
|
+
* @returns {never}
|
|
119
120
|
*/
|
|
120
121
|
#throwError(error) {
|
|
121
122
|
if (typeof error === "string") logger.error(error);
|
package/lib/logger.js
CHANGED
|
@@ -3,25 +3,44 @@ import chalk from "chalk";
|
|
|
3
3
|
const args = process.argv.slice(2);
|
|
4
4
|
const IS_DEBUG = args.includes("--debug") || args.includes("-d");
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @param {any[]} data - The data to log
|
|
8
|
+
*/
|
|
6
9
|
function log(...data) {
|
|
7
10
|
console.log(chalk.bgWhite.black(" LOG "), ...data);
|
|
8
11
|
}
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @param {any[]} data - The data to log
|
|
15
|
+
*/
|
|
10
16
|
function info(...data) {
|
|
11
17
|
console.log(chalk.bgBlue(" INFO "), chalk.blue(...data));
|
|
12
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {any[]} data - The data to log
|
|
22
|
+
*/
|
|
13
23
|
function error(...data) {
|
|
14
24
|
console.error(chalk.bgRed(" ERROR "), chalk.red(...data));
|
|
15
25
|
}
|
|
16
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @param {any[]} data - The data to log
|
|
29
|
+
*/
|
|
17
30
|
function success(...data) {
|
|
18
31
|
console.log("✅ ", chalk.green(...data));
|
|
19
32
|
}
|
|
20
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @param {any[]} data - The data to log
|
|
36
|
+
*/
|
|
21
37
|
function warn(...data) {
|
|
22
38
|
console.log(chalk.bgYellow.black(" WARN "), chalk.yellow(...data));
|
|
23
39
|
}
|
|
24
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @param {any[]} data - The data to log
|
|
43
|
+
*/
|
|
25
44
|
function debug(...data) {
|
|
26
45
|
if (IS_DEBUG)
|
|
27
46
|
console.log(chalk.dim.bgWhite.black(" DEBUG "), chalk.dim(...data));
|
package/lib/project-utils.cjs
CHANGED
|
@@ -149,6 +149,7 @@ function localRequire(file) {
|
|
|
149
149
|
if (file.endsWith(".json")) return fs.readJSONSync(filePath);
|
|
150
150
|
else return require(filePath);
|
|
151
151
|
}
|
|
152
|
+
|
|
152
153
|
function makeConfig(file, cfg = {}) {
|
|
153
154
|
let hook = {};
|
|
154
155
|
if (file && typeof file !== "string") {
|
|
@@ -189,6 +190,7 @@ function resolveWorkspace() {
|
|
|
189
190
|
*/
|
|
190
191
|
function resolveLocalPackages(dependencies) {
|
|
191
192
|
const rush = resolveWorkspace();
|
|
193
|
+
/** @type {{ [key: string]: ReturnType<typeof resolveProject> }} */
|
|
192
194
|
let localPackages = {};
|
|
193
195
|
if (rush) {
|
|
194
196
|
const rushProjects = rush.projects;
|
|
@@ -212,17 +214,21 @@ function resolveLocalPackages(dependencies) {
|
|
|
212
214
|
*
|
|
213
215
|
*/
|
|
214
216
|
function aliases(absolute = false) {
|
|
217
|
+
/** @type {{ [key: string]: string }} */
|
|
215
218
|
const aliases = {};
|
|
216
219
|
const project = resolveProject();
|
|
217
220
|
const depKeys = ["dependencies", "peerDependencies", "devDependencies"];
|
|
218
221
|
const root = project.root;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
/** @type {string[]} */
|
|
223
|
+
let deps = [];
|
|
224
|
+
for (const key of depKeys) {
|
|
225
|
+
deps = deps.concat(Object.keys(project.package[key] || {}));
|
|
226
|
+
}
|
|
222
227
|
const packages = resolveLocalPackages(deps);
|
|
223
228
|
Object.keys(packages).forEach((key) => {
|
|
224
229
|
const project = packages[key];
|
|
225
230
|
if (
|
|
231
|
+
project &&
|
|
226
232
|
deps.includes(project.name) &&
|
|
227
233
|
project.package.devDependencies &&
|
|
228
234
|
project.package.devDependencies["@digigov/cli-build"] &&
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli",
|
|
3
3
|
"description": "CLI for Digigov apps and libs with plugin support",
|
|
4
|
-
"version": "2.0.0-
|
|
4
|
+
"version": "2.0.0-b19b7fe2",
|
|
5
5
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
"chalk": "4.1.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"publint": "0.1.8"
|
|
19
|
+
"publint": "0.1.8",
|
|
20
|
+
"typescript": "5.6.2",
|
|
21
|
+
"@types/fs-extra": "11.0.4",
|
|
22
|
+
"@types/node": "18.19.0"
|
|
20
23
|
},
|
|
21
24
|
"engines": {
|
|
22
25
|
"node": ">=18"
|
|
@@ -33,7 +36,8 @@
|
|
|
33
36
|
"./lib": {
|
|
34
37
|
"require": "./lib/project-utils.cjs",
|
|
35
38
|
"default": "./lib/index.js"
|
|
36
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"./tsconfig.cli": "./tsconfig.cli.json"
|
|
37
41
|
},
|
|
38
42
|
"scripts": {
|
|
39
43
|
"publint": "publint",
|
package/tsconfig.cli.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"module": "NodeNext",
|
|
4
4
|
"moduleResolution": "NodeNext",
|
|
5
|
-
"
|
|
5
|
+
"noEmit": true,
|
|
6
6
|
"allowJs": true,
|
|
7
|
-
"
|
|
7
|
+
"checkJs": true,
|
|
8
8
|
"strict": true,
|
|
9
9
|
"allowSyntheticDefaultImports": true,
|
|
10
10
|
"skipLibCheck": true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"forceConsistentCasingInFileNames": true,
|
|
14
14
|
"noImplicitReturns": true,
|
|
15
15
|
"noImplicitThis": true,
|
|
16
|
-
"noImplicitAny":
|
|
16
|
+
"noImplicitAny": false,
|
|
17
17
|
"strictNullChecks": true,
|
|
18
18
|
"noUnusedLocals": true,
|
|
19
19
|
"noUnusedParameters": true,
|