@backstage/cli 0.36.3-next.0 → 0.36.3
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @backstage/cli
|
|
2
2
|
|
|
3
|
+
## 0.36.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b521571: Improved validation of conflicting CLI module commands, including conflicts between parent and nested command paths.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/cli-module-build@0.1.4
|
|
10
|
+
- @backstage/cli-module-test-jest@0.1.3
|
|
11
|
+
- @backstage/cli-node@0.3.3
|
|
12
|
+
- @backstage/eslint-plugin@0.3.1
|
|
13
|
+
- @backstage/cli-defaults@0.1.3
|
|
14
|
+
|
|
15
|
+
## 0.36.3-next.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/eslint-plugin@0.3.1-next.0
|
|
21
|
+
- @backstage/cli-defaults@0.1.3-next.1
|
|
22
|
+
|
|
3
23
|
## 0.36.3-next.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -2,24 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var OpaqueType = require('../../opaque-internal/src/OpaqueType.cjs.js');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
OpaqueType.OpaqueType.create({
|
|
6
6
|
type: "@backstage/CommandTreeNode",
|
|
7
7
|
versions: ["v1"]
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
OpaqueType.OpaqueType.create({
|
|
10
10
|
type: "@backstage/CommandLeafNode",
|
|
11
11
|
versions: ["v1"]
|
|
12
12
|
});
|
|
13
|
-
function isCommandNodeHidden(node) {
|
|
14
|
-
if (OpaqueCommandLeafNode.isType(node)) {
|
|
15
|
-
const { command } = OpaqueCommandLeafNode.toInternal(node);
|
|
16
|
-
return !!command.deprecated || !!command.experimental;
|
|
17
|
-
}
|
|
18
|
-
const { children } = OpaqueCommandTreeNode.toInternal(node);
|
|
19
|
-
return children.every((child) => isCommandNodeHidden(child));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.OpaqueCommandLeafNode = OpaqueCommandLeafNode;
|
|
23
|
-
exports.OpaqueCommandTreeNode = OpaqueCommandTreeNode;
|
|
24
|
-
exports.isCommandNodeHidden = isCommandNodeHidden;
|
|
25
13
|
//# sourceMappingURL=InternalCommandNode.cjs.js.map
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var CommandGraph = require('./CommandGraph.cjs.js');
|
|
4
3
|
var InternalCliModule = require('../cli-internal/src/InternalCliModule.cjs.js');
|
|
5
|
-
|
|
4
|
+
require('../cli-internal/src/InternalCommandNode.cjs.js');
|
|
6
5
|
require('node:fs');
|
|
7
6
|
require('node:os');
|
|
8
7
|
require('node:path');
|
|
9
8
|
require('../cli-internal/src/knownPluginPackages.cjs.js');
|
|
10
|
-
var
|
|
9
|
+
var cliNode = require('@backstage/cli-node');
|
|
11
10
|
var version = require('./version.cjs.js');
|
|
12
|
-
var chalk = require('chalk');
|
|
13
|
-
var errors = require('./errors.cjs.js');
|
|
14
|
-
var errors$1 = require('@backstage/errors');
|
|
15
11
|
var types = require('node:util/types');
|
|
16
12
|
|
|
17
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
18
|
-
|
|
19
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
20
|
-
|
|
21
13
|
class CliInitializer {
|
|
22
|
-
graph = new CommandGraph.CommandGraph();
|
|
23
14
|
#uninitiazedFeatures = [];
|
|
24
15
|
add(feature) {
|
|
25
16
|
if (types.isPromise(feature)) {
|
|
@@ -42,15 +33,6 @@ class CliInitializer {
|
|
|
42
33
|
);
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
|
-
async #register(feature) {
|
|
46
|
-
if (InternalCliModule.OpaqueCliModule.isType(feature)) {
|
|
47
|
-
for (const command of await InternalCliModule.OpaqueCliModule.toInternal(feature).commands) {
|
|
48
|
-
this.graph.add(command, feature);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
throw new Error(`Unsupported feature type: ${feature.$$type}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
36
|
async #doInit() {
|
|
55
37
|
const resolvedGroups = await Promise.all(this.#uninitiazedFeatures);
|
|
56
38
|
const allFeatures = resolvedGroups.flat();
|
|
@@ -63,90 +45,27 @@ class CliInitializer {
|
|
|
63
45
|
}
|
|
64
46
|
}
|
|
65
47
|
}
|
|
48
|
+
const modules = [];
|
|
66
49
|
for (const { feature, fromArray } of allFeatures) {
|
|
67
|
-
if (
|
|
50
|
+
if (!InternalCliModule.OpaqueCliModule.isType(feature)) {
|
|
51
|
+
throw new Error(`Unsupported feature type: ${feature.$$type}`);
|
|
52
|
+
}
|
|
53
|
+
if (fromArray) {
|
|
68
54
|
const cmds = await InternalCliModule.OpaqueCliModule.toInternal(feature).commands;
|
|
69
55
|
if (cmds.some((cmd) => individualPaths.has(cmd.path.join(" ")))) {
|
|
70
56
|
continue;
|
|
71
57
|
}
|
|
72
58
|
}
|
|
73
|
-
|
|
59
|
+
modules.push(feature);
|
|
74
60
|
}
|
|
61
|
+
return modules;
|
|
75
62
|
}
|
|
76
63
|
/**
|
|
77
64
|
* Actually parse argv and pass it to the command.
|
|
78
65
|
*/
|
|
79
66
|
async run() {
|
|
80
|
-
await this.#doInit();
|
|
81
|
-
|
|
82
|
-
const program = new commander.Command();
|
|
83
|
-
program.name(programName).version(version.version).allowUnknownOption(true).allowExcessArguments(true);
|
|
84
|
-
const queue = this.graph.atDepth(0).map((node) => ({
|
|
85
|
-
node,
|
|
86
|
-
argParser: program
|
|
87
|
-
}));
|
|
88
|
-
while (queue.length) {
|
|
89
|
-
const { node, argParser } = queue.shift();
|
|
90
|
-
if (InternalCommandNode.OpaqueCommandTreeNode.isType(node)) {
|
|
91
|
-
const internal = InternalCommandNode.OpaqueCommandTreeNode.toInternal(node);
|
|
92
|
-
const treeParser = argParser.command(`${internal.name} [command]`, {
|
|
93
|
-
hidden: InternalCommandNode.isCommandNodeHidden(node)
|
|
94
|
-
}).description(internal.name);
|
|
95
|
-
queue.push(
|
|
96
|
-
...internal.children.map((child) => ({
|
|
97
|
-
node: child,
|
|
98
|
-
argParser: treeParser
|
|
99
|
-
}))
|
|
100
|
-
);
|
|
101
|
-
} else {
|
|
102
|
-
const internal = InternalCommandNode.OpaqueCommandLeafNode.toInternal(node);
|
|
103
|
-
argParser.command(internal.name, {
|
|
104
|
-
hidden: !!internal.command.deprecated || !!internal.command.experimental
|
|
105
|
-
}).description(internal.command.description).helpOption(false).allowUnknownOption(true).allowExcessArguments(true).action(async () => {
|
|
106
|
-
try {
|
|
107
|
-
const args = program.parseOptions(process.argv);
|
|
108
|
-
const nonProcessArgs = args.operands.slice(2);
|
|
109
|
-
const positionalArgs = [];
|
|
110
|
-
let index = 0;
|
|
111
|
-
for (let argIndex = 0; argIndex < nonProcessArgs.length; argIndex++) {
|
|
112
|
-
if (argIndex === index && internal.command.path[argIndex] === nonProcessArgs[argIndex]) {
|
|
113
|
-
index += 1;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
positionalArgs.push(nonProcessArgs[argIndex]);
|
|
117
|
-
}
|
|
118
|
-
const context = {
|
|
119
|
-
args: [...positionalArgs, ...args.unknown],
|
|
120
|
-
info: {
|
|
121
|
-
usage: [programName, ...internal.command.path].join(" "),
|
|
122
|
-
name: internal.command.path.join(" ")
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
if (typeof internal.command.execute === "function") {
|
|
126
|
-
await internal.command.execute(context);
|
|
127
|
-
} else {
|
|
128
|
-
const mod = await internal.command.execute.loader();
|
|
129
|
-
const fn = typeof mod.default === "function" ? mod.default : mod.default.default;
|
|
130
|
-
await fn(context);
|
|
131
|
-
}
|
|
132
|
-
process.exit(0);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
errors.exitWithError(error);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
program.on("command:*", () => {
|
|
140
|
-
console.log();
|
|
141
|
-
console.log(chalk__default.default.red(`Invalid command: ${program.args.join(" ")}`));
|
|
142
|
-
console.log();
|
|
143
|
-
program.outputHelp();
|
|
144
|
-
process.exit(1);
|
|
145
|
-
});
|
|
146
|
-
process.on("unhandledRejection", (rejection) => {
|
|
147
|
-
errors.exitWithError(new errors$1.ForwardedError("Unhandled rejection", rejection));
|
|
148
|
-
});
|
|
149
|
-
await program.parseAsync(process.argv);
|
|
67
|
+
const modules = await this.#doInit();
|
|
68
|
+
await cliNode.runCli({ modules, name: "backstage-cli", version: version.version });
|
|
150
69
|
}
|
|
151
70
|
}
|
|
152
71
|
function unwrapFeature(feature) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/cli",
|
|
3
|
-
"version": "0.36.3
|
|
3
|
+
"version": "0.36.3",
|
|
4
4
|
"description": "CLI for developing Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "cli"
|
|
@@ -42,13 +42,12 @@
|
|
|
42
42
|
"watch": "./src"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@backstage/cli-common": "0.2.2",
|
|
46
|
-
"@backstage/cli-defaults": "0.1.3
|
|
47
|
-
"@backstage/cli-module-build": "0.1.4
|
|
48
|
-
"@backstage/cli-module-test-jest": "0.1.
|
|
49
|
-
"@backstage/cli-node": "0.3.
|
|
50
|
-
"@backstage/
|
|
51
|
-
"@backstage/eslint-plugin": "0.3.0",
|
|
45
|
+
"@backstage/cli-common": "^0.2.2",
|
|
46
|
+
"@backstage/cli-defaults": "^0.1.3",
|
|
47
|
+
"@backstage/cli-module-build": "^0.1.4",
|
|
48
|
+
"@backstage/cli-module-test-jest": "^0.1.3",
|
|
49
|
+
"@backstage/cli-node": "^0.3.3",
|
|
50
|
+
"@backstage/eslint-plugin": "^0.3.1",
|
|
52
51
|
"@manypkg/get-packages": "^1.1.3",
|
|
53
52
|
"@spotify/eslint-config-base": "^15.0.0",
|
|
54
53
|
"@spotify/eslint-config-react": "^15.0.0",
|
|
@@ -59,7 +58,6 @@
|
|
|
59
58
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
60
59
|
"@typescript-eslint/parser": "^8.16.0",
|
|
61
60
|
"chalk": "^4.0.0",
|
|
62
|
-
"commander": "^14.0.3",
|
|
63
61
|
"cross-fetch": "^4.0.0",
|
|
64
62
|
"eslint": "^8.6.0",
|
|
65
63
|
"eslint-config-prettier": "^9.0.0",
|
|
@@ -79,21 +77,21 @@
|
|
|
79
77
|
"yaml": "^2.0.0"
|
|
80
78
|
},
|
|
81
79
|
"devDependencies": {
|
|
82
|
-
"@backstage/backend-plugin-api": "1.9.2
|
|
83
|
-
"@backstage/backend-test-utils": "1.11.4
|
|
84
|
-
"@backstage/catalog-client": "1.16.0
|
|
85
|
-
"@backstage/config": "1.3.8",
|
|
86
|
-
"@backstage/core-app-api": "1.20.
|
|
87
|
-
"@backstage/core-components": "0.18.11
|
|
88
|
-
"@backstage/core-plugin-api": "1.12.
|
|
89
|
-
"@backstage/dev-utils": "1.1.24
|
|
90
|
-
"@backstage/plugin-auth-backend": "0.29.1
|
|
91
|
-
"@backstage/plugin-auth-backend-module-guest-provider": "0.2.20
|
|
92
|
-
"@backstage/plugin-catalog-node": "2.2.2
|
|
93
|
-
"@backstage/plugin-scaffolder-node": "0.13.4
|
|
94
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.3.12
|
|
95
|
-
"@backstage/test-utils": "1.7.
|
|
96
|
-
"@backstage/theme": "0.7.3",
|
|
80
|
+
"@backstage/backend-plugin-api": "^1.9.2",
|
|
81
|
+
"@backstage/backend-test-utils": "^1.11.4",
|
|
82
|
+
"@backstage/catalog-client": "^1.16.0",
|
|
83
|
+
"@backstage/config": "^1.3.8",
|
|
84
|
+
"@backstage/core-app-api": "^1.20.2",
|
|
85
|
+
"@backstage/core-components": "^0.18.11",
|
|
86
|
+
"@backstage/core-plugin-api": "^1.12.7",
|
|
87
|
+
"@backstage/dev-utils": "^1.1.24",
|
|
88
|
+
"@backstage/plugin-auth-backend": "^0.29.1",
|
|
89
|
+
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.20",
|
|
90
|
+
"@backstage/plugin-catalog-node": "^2.2.2",
|
|
91
|
+
"@backstage/plugin-scaffolder-node": "^0.13.4",
|
|
92
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.12",
|
|
93
|
+
"@backstage/test-utils": "^1.7.19",
|
|
94
|
+
"@backstage/theme": "^0.7.3",
|
|
97
95
|
"@jest/environment-jsdom-abstract": "~30.2.0",
|
|
98
96
|
"@types/fs-extra": "^11.0.0",
|
|
99
97
|
"@types/jest": "^30.0.0",
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var InternalCliModule = require('../cli-internal/src/InternalCliModule.cjs.js');
|
|
4
|
-
var InternalCommandNode = require('../cli-internal/src/InternalCommandNode.cjs.js');
|
|
5
|
-
require('node:fs');
|
|
6
|
-
require('node:os');
|
|
7
|
-
require('node:path');
|
|
8
|
-
require('../cli-internal/src/knownPluginPackages.cjs.js');
|
|
9
|
-
|
|
10
|
-
class CommandGraph {
|
|
11
|
-
graph = [];
|
|
12
|
-
/**
|
|
13
|
-
* Adds a command to the graph. The graph is sparse, so we use the path to determine the nodes
|
|
14
|
-
* to traverse. Only leaf nodes should have a command/action.
|
|
15
|
-
*/
|
|
16
|
-
add(command, module) {
|
|
17
|
-
const path = command.path;
|
|
18
|
-
let current = this.graph;
|
|
19
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
20
|
-
const name = path[i];
|
|
21
|
-
let next = current.find(
|
|
22
|
-
(n) => InternalCommandNode.OpaqueCommandTreeNode.isType(n) && InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === name || InternalCommandNode.OpaqueCommandLeafNode.isType(n) && InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === name
|
|
23
|
-
);
|
|
24
|
-
if (!next) {
|
|
25
|
-
next = InternalCommandNode.OpaqueCommandTreeNode.createInstance("v1", {
|
|
26
|
-
name,
|
|
27
|
-
children: []
|
|
28
|
-
});
|
|
29
|
-
current.push(next);
|
|
30
|
-
} else if (InternalCommandNode.OpaqueCommandLeafNode.isType(next)) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
formatConflictError(
|
|
33
|
-
path,
|
|
34
|
-
module,
|
|
35
|
-
InternalCommandNode.OpaqueCommandLeafNode.toInternal(next).module
|
|
36
|
-
)
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
current = InternalCommandNode.OpaqueCommandTreeNode.toInternal(next).children;
|
|
40
|
-
}
|
|
41
|
-
const lastName = path[path.length - 1];
|
|
42
|
-
const last = current.find((n) => {
|
|
43
|
-
if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
|
|
44
|
-
return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === lastName;
|
|
45
|
-
}
|
|
46
|
-
return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === lastName;
|
|
47
|
-
});
|
|
48
|
-
if (last && InternalCommandNode.OpaqueCommandLeafNode.isType(last)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
formatConflictError(
|
|
51
|
-
path,
|
|
52
|
-
module,
|
|
53
|
-
InternalCommandNode.OpaqueCommandLeafNode.toInternal(last).module
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
} else {
|
|
57
|
-
current.push(
|
|
58
|
-
InternalCommandNode.OpaqueCommandLeafNode.createInstance("v1", {
|
|
59
|
-
name: lastName,
|
|
60
|
-
command,
|
|
61
|
-
module
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Given a path, try to find a command that matches it.
|
|
68
|
-
*/
|
|
69
|
-
find(path) {
|
|
70
|
-
let current = this.graph;
|
|
71
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
72
|
-
const name = path[i];
|
|
73
|
-
const next = current.find((n) => {
|
|
74
|
-
if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
|
|
75
|
-
return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === name;
|
|
76
|
-
}
|
|
77
|
-
return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === name;
|
|
78
|
-
});
|
|
79
|
-
if (!next || InternalCommandNode.OpaqueCommandLeafNode.isType(next)) {
|
|
80
|
-
return void 0;
|
|
81
|
-
}
|
|
82
|
-
current = InternalCommandNode.OpaqueCommandTreeNode.toInternal(next).children;
|
|
83
|
-
}
|
|
84
|
-
const lastName = path[path.length - 1];
|
|
85
|
-
const last = current.find((n) => {
|
|
86
|
-
if (InternalCommandNode.OpaqueCommandTreeNode.isType(n)) {
|
|
87
|
-
return InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).name === lastName;
|
|
88
|
-
}
|
|
89
|
-
return InternalCommandNode.OpaqueCommandLeafNode.toInternal(n).name === lastName;
|
|
90
|
-
});
|
|
91
|
-
if (!last || InternalCommandNode.OpaqueCommandTreeNode.isType(last)) {
|
|
92
|
-
return void 0;
|
|
93
|
-
}
|
|
94
|
-
return InternalCommandNode.OpaqueCommandLeafNode.toInternal(last).command;
|
|
95
|
-
}
|
|
96
|
-
atDepth(depth) {
|
|
97
|
-
let current = this.graph;
|
|
98
|
-
for (let i = 0; i < depth; i++) {
|
|
99
|
-
current = current.flatMap(
|
|
100
|
-
(n) => InternalCommandNode.OpaqueCommandTreeNode.isType(n) ? InternalCommandNode.OpaqueCommandTreeNode.toInternal(n).children : []
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return current;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function getModuleName(module) {
|
|
107
|
-
if (module && InternalCliModule.OpaqueCliModule.isType(module)) {
|
|
108
|
-
return InternalCliModule.OpaqueCliModule.toInternal(module).packageName;
|
|
109
|
-
}
|
|
110
|
-
return void 0;
|
|
111
|
-
}
|
|
112
|
-
function formatConflictError(path, newModule, existingModule) {
|
|
113
|
-
const cmd = path.join(" ");
|
|
114
|
-
const newPkg = getModuleName(newModule);
|
|
115
|
-
const existingPkg = getModuleName(existingModule);
|
|
116
|
-
if (newPkg && existingPkg) {
|
|
117
|
-
return `Command "${cmd}" from "${newPkg}" conflicts with an existing command from "${existingPkg}"`;
|
|
118
|
-
}
|
|
119
|
-
if (newPkg) {
|
|
120
|
-
return `Command "${cmd}" from "${newPkg}" conflicts with an existing command`;
|
|
121
|
-
}
|
|
122
|
-
if (existingPkg) {
|
|
123
|
-
return `Command "${cmd}" conflicts with an existing command from "${existingPkg}"`;
|
|
124
|
-
}
|
|
125
|
-
return `Command "${cmd}" conflicts with an existing command`;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
exports.CommandGraph = CommandGraph;
|
|
129
|
-
//# sourceMappingURL=CommandGraph.cjs.js.map
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var errors = require('@backstage/errors');
|
|
4
|
-
var chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
|
|
9
|
-
|
|
10
|
-
function exit(message, code = 1) {
|
|
11
|
-
process.stderr.write(`
|
|
12
|
-
${chalk__default.default.red(message)}
|
|
13
|
-
|
|
14
|
-
`);
|
|
15
|
-
process.exit(code);
|
|
16
|
-
}
|
|
17
|
-
function exitWithError(error) {
|
|
18
|
-
if (!errors.isError(error)) {
|
|
19
|
-
process.stderr.write(`
|
|
20
|
-
${chalk__default.default.red(errors.stringifyError(error))}
|
|
21
|
-
|
|
22
|
-
`);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
switch (error.name) {
|
|
26
|
-
case "InputError":
|
|
27
|
-
return exit(
|
|
28
|
-
error.message,
|
|
29
|
-
74
|
|
30
|
-
/* input/output error */
|
|
31
|
-
);
|
|
32
|
-
case "NotFoundError":
|
|
33
|
-
return exit(
|
|
34
|
-
error.message,
|
|
35
|
-
127
|
|
36
|
-
/* command not found */
|
|
37
|
-
);
|
|
38
|
-
case "NotImplementedError":
|
|
39
|
-
return exit(
|
|
40
|
-
error.message,
|
|
41
|
-
64
|
|
42
|
-
/* command line usage error */
|
|
43
|
-
);
|
|
44
|
-
case "AuthenticationError":
|
|
45
|
-
case "NotAllowedError":
|
|
46
|
-
return exit(
|
|
47
|
-
error.message,
|
|
48
|
-
77
|
|
49
|
-
/* permission denied */
|
|
50
|
-
);
|
|
51
|
-
case "ExitCodeError":
|
|
52
|
-
return exit(
|
|
53
|
-
error.message,
|
|
54
|
-
"code" in error && typeof error.code === "number" ? error.code : 1
|
|
55
|
-
);
|
|
56
|
-
default:
|
|
57
|
-
return exit(errors.stringifyError(error), 1);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.exitWithError = exitWithError;
|
|
62
|
-
//# sourceMappingURL=errors.cjs.js.map
|