@digigov/cli 2.0.0-rc.32 → 2.0.2
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 +21 -21
- package/lib/index.js +0 -0
- package/package.json +2 -2
package/lib/command.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import * as execa from
|
|
4
|
-
import * as commander from
|
|
5
|
-
import { fileURLToPath } from
|
|
6
|
-
import { logger } from
|
|
7
|
-
import { findPackageJson } from
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import * as execa from "execa";
|
|
4
|
+
import * as commander from "commander";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { logger } from "./logger.js";
|
|
7
|
+
import { findPackageJson } from "./project-utils.cjs";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A class that extends the Commander Command class with additional
|
|
@@ -33,14 +33,14 @@ export class DigigovCommand extends commander.Command {
|
|
|
33
33
|
? path.dirname(fileURLToPath(importMetaUrl))
|
|
34
34
|
: null;
|
|
35
35
|
|
|
36
|
-
this.option(
|
|
36
|
+
this.option("-d, --debug", "display debug information");
|
|
37
37
|
|
|
38
38
|
this.configureOutput({
|
|
39
|
-
writeErr: (str) => logger.error(str.replace(/^error: /i,
|
|
39
|
+
writeErr: (str) => logger.error(str.replace(/^error: /i, "")),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
if (this.context) {
|
|
43
|
-
if (this.context.endsWith(
|
|
43
|
+
if (this.context.endsWith("dist")) {
|
|
44
44
|
this.context = path.dirname(this.context);
|
|
45
45
|
}
|
|
46
46
|
const pkgPath = findPackageJson(this.context);
|
|
@@ -87,27 +87,27 @@ export class DigigovCommand extends commander.Command {
|
|
|
87
87
|
* @param {string[]} args - The arguments to pass to the script
|
|
88
88
|
* @param {execa.Options} [config] - The configuration for the script
|
|
89
89
|
*/
|
|
90
|
-
exec(script, args, config) {
|
|
90
|
+
exec(script, args, config, quiet = false) {
|
|
91
91
|
const __dirname =
|
|
92
92
|
this.context ?? path.dirname(fileURLToPath(import.meta.url));
|
|
93
93
|
const binLocation = [process.cwd(), __dirname].find((location) => {
|
|
94
|
-
return fs.existsSync(path.join(location,
|
|
94
|
+
return fs.existsSync(path.join(location, "node_modules", ".bin", script));
|
|
95
95
|
});
|
|
96
96
|
if (!binLocation || !fs.existsSync(binLocation)) {
|
|
97
97
|
this.#throwError(`Executable ${script} not installed`);
|
|
98
98
|
}
|
|
99
99
|
const executablePath = path.join(
|
|
100
100
|
binLocation,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
script
|
|
101
|
+
"node_modules",
|
|
102
|
+
".bin",
|
|
103
|
+
script,
|
|
104
104
|
);
|
|
105
105
|
const executableName = path.basename(executablePath);
|
|
106
|
-
logger.log(`Running: ${executableName} ${args.join(
|
|
106
|
+
if (!quiet) logger.log(`Running: ${executableName} ${args.join(" ")}`);
|
|
107
107
|
try {
|
|
108
108
|
return execa.execa(executablePath, args, {
|
|
109
109
|
...config,
|
|
110
|
-
stdio:
|
|
110
|
+
stdio: "inherit",
|
|
111
111
|
});
|
|
112
112
|
} catch (error) {
|
|
113
113
|
this.#throwError(error);
|
|
@@ -119,12 +119,12 @@ export class DigigovCommand extends commander.Command {
|
|
|
119
119
|
* @returns {never}
|
|
120
120
|
*/
|
|
121
121
|
#throwError(error) {
|
|
122
|
-
|
|
122
|
+
logger.error(error);
|
|
123
123
|
if (
|
|
124
|
-
typeof error ===
|
|
124
|
+
typeof error === "object" &&
|
|
125
125
|
error &&
|
|
126
|
-
|
|
127
|
-
typeof error.exitCode ===
|
|
126
|
+
"exitCode" in error &&
|
|
127
|
+
typeof error.exitCode === "number"
|
|
128
128
|
) {
|
|
129
129
|
process.exit(error.exitCode);
|
|
130
130
|
}
|
package/lib/index.js
CHANGED
|
File without changes
|
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.
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"lint": "echo 'no lint needed (yet)'",
|
|
45
45
|
"typecheck": "tsc"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|