@betty-blocks/cli 26.0.0-beta.9 → 26.0.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/assets/app-functions/wasm-template/.wasm-functions +0 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Cargo.lock +449 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Cargo.toml +10 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Justfile +12 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/function.json +35 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/src/lib.rs +19 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/wit/world.wit +13 -0
- package/build/bb-blocks-new.d.ts +1 -0
- package/build/bb-blocks-new.js +26 -0
- package/build/bb-blocks-new.js.map +1 -0
- package/build/bb-blocks-publish.d.ts +1 -0
- package/build/bb-blocks-publish.js +98 -0
- package/build/bb-blocks-publish.js.map +1 -0
- package/build/bb-blocks-release.d.ts +1 -0
- package/build/bb-blocks-release.js +18 -0
- package/build/bb-blocks-release.js.map +1 -0
- package/build/bb-blocks.d.ts +1 -0
- package/build/bb-blocks.js +17 -0
- package/build/bb-blocks.js.map +1 -0
- package/build/bb-bundle-init.d.ts +1 -0
- package/build/bb-bundle-init.js +33 -0
- package/build/bb-bundle-init.js.map +1 -0
- package/build/bb-bundle.d.ts +1 -0
- package/build/bb-bundle.js +17 -0
- package/build/bb-bundle.js.map +1 -0
- package/build/bb-components-build.d.ts +1 -0
- package/build/bb-components-build.js +416 -0
- package/build/bb-components-build.js.map +1 -0
- package/build/bb-components-create.d.ts +1 -0
- package/build/bb-components-create.js +41 -0
- package/build/bb-components-create.js.map +1 -0
- package/build/bb-components-generate.d.ts +1 -0
- package/build/bb-components-generate.js +168 -0
- package/build/bb-components-generate.js.map +1 -0
- package/build/bb-components-publish-bundle.d.ts +1 -0
- package/build/bb-components-publish-bundle.js +50 -0
- package/build/bb-components-publish-bundle.js.map +1 -0
- package/build/bb-components-publish.d.ts +1 -0
- package/build/bb-components-publish.js +57 -0
- package/build/bb-components-publish.js.map +1 -0
- package/build/bb-components-serve.d.ts +1 -0
- package/build/bb-components-serve.js +35 -0
- package/build/bb-components-serve.js.map +1 -0
- package/build/bb-components.d.ts +1 -0
- package/build/bb-components.js +29 -0
- package/build/bb-components.js.map +1 -0
- package/build/bb-functions-bump.d.ts +1 -0
- package/build/bb-functions-bump.js +37 -0
- package/build/bb-functions-bump.js.map +1 -0
- package/build/bb-functions-init.d.ts +1 -0
- package/build/bb-functions-init.js +31 -0
- package/build/bb-functions-init.js.map +1 -0
- package/build/bb-functions-login.d.ts +1 -0
- package/build/bb-functions-login.js +17 -0
- package/build/bb-functions-login.js.map +1 -0
- package/build/bb-functions-logout.d.ts +1 -0
- package/build/bb-functions-logout.js +10 -0
- package/build/bb-functions-logout.js.map +1 -0
- package/build/bb-functions-new.d.ts +1 -0
- package/build/bb-functions-new.js +25 -0
- package/build/bb-functions-new.js.map +1 -0
- package/build/bb-functions-publish.d.ts +1 -0
- package/build/bb-functions-publish.js +52 -0
- package/build/bb-functions-publish.js.map +1 -0
- package/build/bb-functions-validate.d.ts +1 -0
- package/build/bb-functions-validate.js +17 -0
- package/build/bb-functions-validate.js.map +1 -0
- package/build/bb-functions.d.ts +1 -0
- package/build/bb-functions.js +29 -0
- package/build/bb-functions.js.map +1 -0
- package/build/bb.d.ts +2 -0
- package/build/bb.js +27 -0
- package/build/bb.js.map +1 -0
- package/build/blocks/blockDefinitions.d.ts +10 -0
- package/build/blocks/blockDefinitions.js +62 -0
- package/build/blocks/blockDefinitions.js.map +1 -0
- package/build/blocks/publishBlocks.d.ts +2 -0
- package/build/blocks/publishBlocks.js +54 -0
- package/build/blocks/publishBlocks.js.map +1 -0
- package/build/blocks/releaseBlocks.d.ts +5 -0
- package/build/blocks/releaseBlocks.js +78 -0
- package/build/blocks/releaseBlocks.js.map +1 -0
- package/build/components/bb-components-functions.d.ts +10 -0
- package/build/components/bb-components-functions.js +40 -0
- package/build/components/bb-components-functions.js.map +1 -0
- package/build/components/comments.d.ts +3 -0
- package/build/components/comments.js +78 -0
- package/build/components/comments.js.map +1 -0
- package/build/components/compatibility.d.ts +7 -0
- package/build/components/compatibility.js +60 -0
- package/build/components/compatibility.js.map +1 -0
- package/build/components/transformers/index.d.ts +3 -0
- package/build/components/transformers/index.js +36 -0
- package/build/components/transformers/index.js.map +1 -0
- package/build/components-build/index.d.ts +2 -0
- package/build/components-build/index.js +3 -0
- package/build/components-build/index.js.map +1 -0
- package/build/components-build/reportDiagnostics.d.ts +2 -0
- package/build/components-build/reportDiagnostics.js +13 -0
- package/build/components-build/reportDiagnostics.js.map +1 -0
- package/build/components-build/styles.d.ts +4 -0
- package/build/components-build/styles.js +87 -0
- package/build/components-build/styles.js.map +1 -0
- package/build/functions/config.d.ts +67 -0
- package/build/functions/config.js +190 -0
- package/build/functions/config.js.map +1 -0
- package/build/functions/createWasmDefinitionFiles.d.ts +4 -0
- package/build/functions/createWasmDefinitionFiles.js +61 -0
- package/build/functions/createWasmDefinitionFiles.js.map +1 -0
- package/build/functions/functionDefinitions.d.ts +23 -0
- package/build/functions/functionDefinitions.js +229 -0
- package/build/functions/functionDefinitions.js.map +1 -0
- package/build/functions/functionVersionBump.d.ts +19 -0
- package/build/functions/functionVersionBump.js +62 -0
- package/build/functions/functionVersionBump.js.map +1 -0
- package/build/functions/publishAppFunctions.d.ts +13 -0
- package/build/functions/publishAppFunctions.js +90 -0
- package/build/functions/publishAppFunctions.js.map +1 -0
- package/build/functions/publishWasmBlockStoreFunctions.d.ts +1 -0
- package/build/functions/publishWasmBlockStoreFunctions.js +100 -0
- package/build/functions/publishWasmBlockStoreFunctions.js.map +1 -0
- package/build/functions/utils.d.ts +2 -0
- package/build/functions/utils.js +20 -0
- package/build/functions/utils.js.map +1 -0
- package/build/functions/validateFunctions.d.ts +3 -0
- package/build/functions/validateFunctions.js +23 -0
- package/build/functions/validateFunctions.js.map +1 -0
- package/build/functions/validations.d.ts +31 -0
- package/build/functions/validations.js +140 -0
- package/build/functions/validations.js.map +1 -0
- package/build/interactions/compatibility.d.ts +3 -0
- package/build/interactions/compatibility.js +84 -0
- package/build/interactions/compatibility.js.map +1 -0
- package/build/interactions/diagnostics.d.ts +2 -0
- package/build/interactions/diagnostics.js +23 -0
- package/build/interactions/diagnostics.js.map +1 -0
- package/build/types.d.ts +377 -0
- package/build/types.js +40 -0
- package/build/types.js.map +1 -0
- package/build/utils/arguments.d.ts +2 -0
- package/build/utils/arguments.js +6 -0
- package/build/utils/arguments.js.map +1 -0
- package/build/utils/checkPackageVersion.d.ts +1 -0
- package/build/utils/checkPackageVersion.js +10 -0
- package/build/utils/checkPackageVersion.js.map +1 -0
- package/build/utils/checkUpdateAvailable.d.ts +1 -0
- package/build/utils/checkUpdateAvailable.js +65 -0
- package/build/utils/checkUpdateAvailable.js.map +1 -0
- package/build/utils/fusionAuth.d.ts +21 -0
- package/build/utils/fusionAuth.js +108 -0
- package/build/utils/fusionAuth.js.map +1 -0
- package/build/utils/hash.d.ts +2 -0
- package/build/utils/hash.js +3 -0
- package/build/utils/hash.js.map +1 -0
- package/build/utils/login.d.ts +15 -0
- package/build/utils/login.js +116 -0
- package/build/utils/login.js.map +1 -0
- package/build/utils/pick.d.ts +7 -0
- package/build/utils/pick.js +16 -0
- package/build/utils/pick.js.map +1 -0
- package/build/utils/readFilesByType.d.ts +2 -0
- package/build/utils/readFilesByType.js +23 -0
- package/build/utils/readFilesByType.js.map +1 -0
- package/build/utils/rootDir.d.ts +2 -0
- package/build/utils/rootDir.js +4 -0
- package/build/utils/rootDir.js.map +1 -0
- package/build/utils/serveComponentSet.d.ts +3 -0
- package/build/utils/serveComponentSet.js +52 -0
- package/build/utils/serveComponentSet.js.map +1 -0
- package/build/utils/transpile.d.ts +2 -0
- package/build/utils/transpile.js +25 -0
- package/build/utils/transpile.js.map +1 -0
- package/build/utils/uploadBlob.d.ts +24 -0
- package/build/utils/uploadBlob.js +56 -0
- package/build/utils/uploadBlob.js.map +1 -0
- package/build/utils/validation.d.ts +4 -0
- package/build/utils/validation.js +74 -0
- package/build/utils/validation.js.map +1 -0
- package/build/validations/component.d.ts +3 -0
- package/build/validations/component.js +56 -0
- package/build/validations/component.js.map +1 -0
- package/build/validations/constants.d.ts +16 -0
- package/build/validations/constants.js +208 -0
- package/build/validations/constants.js.map +1 -0
- package/build/validations/function-block-validations/index.d.ts +22 -0
- package/build/validations/function-block-validations/index.js +72 -0
- package/build/validations/function-block-validations/index.js.map +1 -0
- package/build/validations/interaction.d.ts +3 -0
- package/build/validations/interaction.js +22 -0
- package/build/validations/interaction.js.map +1 -0
- package/build/validations/prefab/action.d.ts +2 -0
- package/build/validations/prefab/action.js +99 -0
- package/build/validations/prefab/action.js.map +1 -0
- package/build/validations/prefab/component.d.ts +10 -0
- package/build/validations/prefab/component.js +290 -0
- package/build/validations/prefab/component.js.map +1 -0
- package/build/validations/prefab/componentOption.d.ts +3 -0
- package/build/validations/prefab/componentOption.js +176 -0
- package/build/validations/prefab/componentOption.js.map +1 -0
- package/build/validations/prefab/interaction.d.ts +2 -0
- package/build/validations/prefab/interaction.js +38 -0
- package/build/validations/prefab/interaction.js.map +1 -0
- package/build/validations/prefab/linkedOption.d.ts +3 -0
- package/build/validations/prefab/linkedOption.js +39 -0
- package/build/validations/prefab/linkedOption.js.map +1 -0
- package/build/validations/prefab/linkedPartial.d.ts +3 -0
- package/build/validations/prefab/linkedPartial.js +30 -0
- package/build/validations/prefab/linkedPartial.js.map +1 -0
- package/build/validations/prefab/variable.d.ts +3 -0
- package/build/validations/prefab/variable.js +36 -0
- package/build/validations/prefab/variable.js.map +1 -0
- package/build/validations/prefab.d.ts +17 -0
- package/build/validations/prefab.js +66 -0
- package/build/validations/prefab.js.map +1 -0
- package/build/validations/styles.d.ts +6 -0
- package/build/validations/styles.js +103 -0
- package/build/validations/styles.js.map +1 -0
- package/package.json +38 -40
- package/assets/app-functions/templates/test/helpers.js +0 -3
- package/assets/app-functions/templates/test/say-hello.test.js +0 -4
- package/assets/functions/packer/package.json +0 -9
- package/assets/functions/packer/webpack.config.js +0 -12
- package/assets/functions/templates/functions.json +0 -14
- package/assets/functions/templates/package.json +0 -11
- package/assets/functions/templates/src/all-users.js +0 -14
- package/assets/functions/templates/src/get-json.js +0 -9
- package/assets/functions/templates/src/index.js +0 -5
- package/assets/functions/templates/src/say-hello.js +0 -13
- package/build/src/bb-blocks-new.js +0 -6789
- package/build/src/bb-blocks-publish.js +0 -32641
- package/build/src/bb-blocks-release.js +0 -15528
- package/build/src/bb-blocks.js +0 -2149
- package/build/src/bb-bundle-init.js +0 -6034
- package/build/src/bb-bundle.js +0 -2636
- package/build/src/bb-components-build.js +0 -240546
- package/build/src/bb-components-create.js +0 -6045
- package/build/src/bb-components-generate.js +0 -6173
- package/build/src/bb-components-publish-bundle.js +0 -43346
- package/build/src/bb-components-publish.js +0 -43353
- package/build/src/bb-components-serve.js +0 -15326
- package/build/src/bb-components.js +0 -2157
- package/build/src/bb-functions-build.js +0 -4284
- package/build/src/bb-functions-bump.js +0 -14582
- package/build/src/bb-functions-init.js +0 -4749
- package/build/src/bb-functions-login.js +0 -15440
- package/build/src/bb-functions-logout.js +0 -15434
- package/build/src/bb-functions-new.js +0 -9144
- package/build/src/bb-functions-publish.js +0 -86693
- package/build/src/bb-functions-validate.js +0 -22160
- package/build/src/bb-functions.js +0 -2159
- package/build/src/bb.js +0 -2740
- /package/assets/app-functions/{templates → js-template}/.app-functions +0 -0
- /package/assets/app-functions/{templates → js-template}/functions/say-hello/1.0/function.json +0 -0
- /package/assets/app-functions/{templates → js-template}/functions/say-hello/1.0/index.js +0 -0
- /package/assets/app-functions/{templates → js-template}/package.json +0 -0
|
@@ -1,4284 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
-
var __export = (target, all) => {
|
|
20
|
-
for (var name in all)
|
|
21
|
-
__defProp(target, name, {
|
|
22
|
-
get: all[name],
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
set: (newValue) => all[name] = () => newValue
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
-
|
|
31
|
-
// node_modules/commander/lib/error.js
|
|
32
|
-
var require_error = __commonJS((exports) => {
|
|
33
|
-
class CommanderError extends Error {
|
|
34
|
-
constructor(exitCode, code, message) {
|
|
35
|
-
super(message);
|
|
36
|
-
Error.captureStackTrace(this, this.constructor);
|
|
37
|
-
this.name = this.constructor.name;
|
|
38
|
-
this.code = code;
|
|
39
|
-
this.exitCode = exitCode;
|
|
40
|
-
this.nestedError = undefined;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class InvalidArgumentError extends CommanderError {
|
|
45
|
-
constructor(message) {
|
|
46
|
-
super(1, "commander.invalidArgument", message);
|
|
47
|
-
Error.captureStackTrace(this, this.constructor);
|
|
48
|
-
this.name = this.constructor.name;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.CommanderError = CommanderError;
|
|
52
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// node_modules/commander/lib/argument.js
|
|
56
|
-
var require_argument = __commonJS((exports) => {
|
|
57
|
-
var { InvalidArgumentError } = require_error();
|
|
58
|
-
|
|
59
|
-
class Argument {
|
|
60
|
-
constructor(name, description) {
|
|
61
|
-
this.description = description || "";
|
|
62
|
-
this.variadic = false;
|
|
63
|
-
this.parseArg = undefined;
|
|
64
|
-
this.defaultValue = undefined;
|
|
65
|
-
this.defaultValueDescription = undefined;
|
|
66
|
-
this.argChoices = undefined;
|
|
67
|
-
switch (name[0]) {
|
|
68
|
-
case "<":
|
|
69
|
-
this.required = true;
|
|
70
|
-
this._name = name.slice(1, -1);
|
|
71
|
-
break;
|
|
72
|
-
case "[":
|
|
73
|
-
this.required = false;
|
|
74
|
-
this._name = name.slice(1, -1);
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
this.required = true;
|
|
78
|
-
this._name = name;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
if (this._name.length > 3 && this._name.slice(-3) === "...") {
|
|
82
|
-
this.variadic = true;
|
|
83
|
-
this._name = this._name.slice(0, -3);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
name() {
|
|
87
|
-
return this._name;
|
|
88
|
-
}
|
|
89
|
-
_concatValue(value, previous) {
|
|
90
|
-
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
91
|
-
return [value];
|
|
92
|
-
}
|
|
93
|
-
return previous.concat(value);
|
|
94
|
-
}
|
|
95
|
-
default(value, description) {
|
|
96
|
-
this.defaultValue = value;
|
|
97
|
-
this.defaultValueDescription = description;
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
argParser(fn) {
|
|
101
|
-
this.parseArg = fn;
|
|
102
|
-
return this;
|
|
103
|
-
}
|
|
104
|
-
choices(values) {
|
|
105
|
-
this.argChoices = values.slice();
|
|
106
|
-
this.parseArg = (arg, previous) => {
|
|
107
|
-
if (!this.argChoices.includes(arg)) {
|
|
108
|
-
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
109
|
-
}
|
|
110
|
-
if (this.variadic) {
|
|
111
|
-
return this._concatValue(arg, previous);
|
|
112
|
-
}
|
|
113
|
-
return arg;
|
|
114
|
-
};
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
argRequired() {
|
|
118
|
-
this.required = true;
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
argOptional() {
|
|
122
|
-
this.required = false;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function humanReadableArgName(arg) {
|
|
127
|
-
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
128
|
-
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
129
|
-
}
|
|
130
|
-
exports.Argument = Argument;
|
|
131
|
-
exports.humanReadableArgName = humanReadableArgName;
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// node_modules/commander/lib/help.js
|
|
135
|
-
var require_help = __commonJS((exports) => {
|
|
136
|
-
var { humanReadableArgName } = require_argument();
|
|
137
|
-
|
|
138
|
-
class Help {
|
|
139
|
-
constructor() {
|
|
140
|
-
this.helpWidth = undefined;
|
|
141
|
-
this.minWidthToWrap = 40;
|
|
142
|
-
this.sortSubcommands = false;
|
|
143
|
-
this.sortOptions = false;
|
|
144
|
-
this.showGlobalOptions = false;
|
|
145
|
-
}
|
|
146
|
-
prepareContext(contextOptions) {
|
|
147
|
-
this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
|
|
148
|
-
}
|
|
149
|
-
visibleCommands(cmd) {
|
|
150
|
-
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
151
|
-
const helpCommand = cmd._getHelpCommand();
|
|
152
|
-
if (helpCommand && !helpCommand._hidden) {
|
|
153
|
-
visibleCommands.push(helpCommand);
|
|
154
|
-
}
|
|
155
|
-
if (this.sortSubcommands) {
|
|
156
|
-
visibleCommands.sort((a, b) => {
|
|
157
|
-
return a.name().localeCompare(b.name());
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return visibleCommands;
|
|
161
|
-
}
|
|
162
|
-
compareOptions(a, b) {
|
|
163
|
-
const getSortKey = (option) => {
|
|
164
|
-
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
165
|
-
};
|
|
166
|
-
return getSortKey(a).localeCompare(getSortKey(b));
|
|
167
|
-
}
|
|
168
|
-
visibleOptions(cmd) {
|
|
169
|
-
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
170
|
-
const helpOption = cmd._getHelpOption();
|
|
171
|
-
if (helpOption && !helpOption.hidden) {
|
|
172
|
-
const removeShort = helpOption.short && cmd._findOption(helpOption.short);
|
|
173
|
-
const removeLong = helpOption.long && cmd._findOption(helpOption.long);
|
|
174
|
-
if (!removeShort && !removeLong) {
|
|
175
|
-
visibleOptions.push(helpOption);
|
|
176
|
-
} else if (helpOption.long && !removeLong) {
|
|
177
|
-
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
|
|
178
|
-
} else if (helpOption.short && !removeShort) {
|
|
179
|
-
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (this.sortOptions) {
|
|
183
|
-
visibleOptions.sort(this.compareOptions);
|
|
184
|
-
}
|
|
185
|
-
return visibleOptions;
|
|
186
|
-
}
|
|
187
|
-
visibleGlobalOptions(cmd) {
|
|
188
|
-
if (!this.showGlobalOptions)
|
|
189
|
-
return [];
|
|
190
|
-
const globalOptions = [];
|
|
191
|
-
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
192
|
-
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
|
|
193
|
-
globalOptions.push(...visibleOptions);
|
|
194
|
-
}
|
|
195
|
-
if (this.sortOptions) {
|
|
196
|
-
globalOptions.sort(this.compareOptions);
|
|
197
|
-
}
|
|
198
|
-
return globalOptions;
|
|
199
|
-
}
|
|
200
|
-
visibleArguments(cmd) {
|
|
201
|
-
if (cmd._argsDescription) {
|
|
202
|
-
cmd.registeredArguments.forEach((argument) => {
|
|
203
|
-
argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (cmd.registeredArguments.find((argument) => argument.description)) {
|
|
207
|
-
return cmd.registeredArguments;
|
|
208
|
-
}
|
|
209
|
-
return [];
|
|
210
|
-
}
|
|
211
|
-
subcommandTerm(cmd) {
|
|
212
|
-
const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" ");
|
|
213
|
-
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : "");
|
|
214
|
-
}
|
|
215
|
-
optionTerm(option) {
|
|
216
|
-
return option.flags;
|
|
217
|
-
}
|
|
218
|
-
argumentTerm(argument) {
|
|
219
|
-
return argument.name();
|
|
220
|
-
}
|
|
221
|
-
longestSubcommandTermLength(cmd, helper) {
|
|
222
|
-
return helper.visibleCommands(cmd).reduce((max, command) => {
|
|
223
|
-
return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
|
|
224
|
-
}, 0);
|
|
225
|
-
}
|
|
226
|
-
longestOptionTermLength(cmd, helper) {
|
|
227
|
-
return helper.visibleOptions(cmd).reduce((max, option) => {
|
|
228
|
-
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
229
|
-
}, 0);
|
|
230
|
-
}
|
|
231
|
-
longestGlobalOptionTermLength(cmd, helper) {
|
|
232
|
-
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
233
|
-
return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
|
|
234
|
-
}, 0);
|
|
235
|
-
}
|
|
236
|
-
longestArgumentTermLength(cmd, helper) {
|
|
237
|
-
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
238
|
-
return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
|
|
239
|
-
}, 0);
|
|
240
|
-
}
|
|
241
|
-
commandUsage(cmd) {
|
|
242
|
-
let cmdName = cmd._name;
|
|
243
|
-
if (cmd._aliases[0]) {
|
|
244
|
-
cmdName = cmdName + "|" + cmd._aliases[0];
|
|
245
|
-
}
|
|
246
|
-
let ancestorCmdNames = "";
|
|
247
|
-
for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) {
|
|
248
|
-
ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames;
|
|
249
|
-
}
|
|
250
|
-
return ancestorCmdNames + cmdName + " " + cmd.usage();
|
|
251
|
-
}
|
|
252
|
-
commandDescription(cmd) {
|
|
253
|
-
return cmd.description();
|
|
254
|
-
}
|
|
255
|
-
subcommandDescription(cmd) {
|
|
256
|
-
return cmd.summary() || cmd.description();
|
|
257
|
-
}
|
|
258
|
-
optionDescription(option) {
|
|
259
|
-
const extraInfo = [];
|
|
260
|
-
if (option.argChoices) {
|
|
261
|
-
extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
262
|
-
}
|
|
263
|
-
if (option.defaultValue !== undefined) {
|
|
264
|
-
const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean";
|
|
265
|
-
if (showDefault) {
|
|
266
|
-
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (option.presetArg !== undefined && option.optional) {
|
|
270
|
-
extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);
|
|
271
|
-
}
|
|
272
|
-
if (option.envVar !== undefined) {
|
|
273
|
-
extraInfo.push(`env: ${option.envVar}`);
|
|
274
|
-
}
|
|
275
|
-
if (extraInfo.length > 0) {
|
|
276
|
-
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
277
|
-
if (option.description) {
|
|
278
|
-
return `${option.description} ${extraDescription}`;
|
|
279
|
-
}
|
|
280
|
-
return extraDescription;
|
|
281
|
-
}
|
|
282
|
-
return option.description;
|
|
283
|
-
}
|
|
284
|
-
argumentDescription(argument) {
|
|
285
|
-
const extraInfo = [];
|
|
286
|
-
if (argument.argChoices) {
|
|
287
|
-
extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`);
|
|
288
|
-
}
|
|
289
|
-
if (argument.defaultValue !== undefined) {
|
|
290
|
-
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
|
|
291
|
-
}
|
|
292
|
-
if (extraInfo.length > 0) {
|
|
293
|
-
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
294
|
-
if (argument.description) {
|
|
295
|
-
return `${argument.description} ${extraDescription}`;
|
|
296
|
-
}
|
|
297
|
-
return extraDescription;
|
|
298
|
-
}
|
|
299
|
-
return argument.description;
|
|
300
|
-
}
|
|
301
|
-
formatItemList(heading, items, helper) {
|
|
302
|
-
if (items.length === 0)
|
|
303
|
-
return [];
|
|
304
|
-
return [helper.styleTitle(heading), ...items, ""];
|
|
305
|
-
}
|
|
306
|
-
groupItems(unsortedItems, visibleItems, getGroup) {
|
|
307
|
-
const result = new Map;
|
|
308
|
-
unsortedItems.forEach((item) => {
|
|
309
|
-
const group = getGroup(item);
|
|
310
|
-
if (!result.has(group))
|
|
311
|
-
result.set(group, []);
|
|
312
|
-
});
|
|
313
|
-
visibleItems.forEach((item) => {
|
|
314
|
-
const group = getGroup(item);
|
|
315
|
-
if (!result.has(group)) {
|
|
316
|
-
result.set(group, []);
|
|
317
|
-
}
|
|
318
|
-
result.get(group).push(item);
|
|
319
|
-
});
|
|
320
|
-
return result;
|
|
321
|
-
}
|
|
322
|
-
formatHelp(cmd, helper) {
|
|
323
|
-
const termWidth = helper.padWidth(cmd, helper);
|
|
324
|
-
const helpWidth = helper.helpWidth ?? 80;
|
|
325
|
-
function callFormatItem(term, description) {
|
|
326
|
-
return helper.formatItem(term, termWidth, description, helper);
|
|
327
|
-
}
|
|
328
|
-
let output = [
|
|
329
|
-
`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
|
|
330
|
-
""
|
|
331
|
-
];
|
|
332
|
-
const commandDescription = helper.commandDescription(cmd);
|
|
333
|
-
if (commandDescription.length > 0) {
|
|
334
|
-
output = output.concat([
|
|
335
|
-
helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth),
|
|
336
|
-
""
|
|
337
|
-
]);
|
|
338
|
-
}
|
|
339
|
-
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
340
|
-
return callFormatItem(helper.styleArgumentTerm(helper.argumentTerm(argument)), helper.styleArgumentDescription(helper.argumentDescription(argument)));
|
|
341
|
-
});
|
|
342
|
-
output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
|
|
343
|
-
const optionGroups = this.groupItems(cmd.options, helper.visibleOptions(cmd), (option) => option.helpGroupHeading ?? "Options:");
|
|
344
|
-
optionGroups.forEach((options, group) => {
|
|
345
|
-
const optionList = options.map((option) => {
|
|
346
|
-
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
347
|
-
});
|
|
348
|
-
output = output.concat(this.formatItemList(group, optionList, helper));
|
|
349
|
-
});
|
|
350
|
-
if (helper.showGlobalOptions) {
|
|
351
|
-
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
352
|
-
return callFormatItem(helper.styleOptionTerm(helper.optionTerm(option)), helper.styleOptionDescription(helper.optionDescription(option)));
|
|
353
|
-
});
|
|
354
|
-
output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
|
|
355
|
-
}
|
|
356
|
-
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
|
|
357
|
-
commandGroups.forEach((commands, group) => {
|
|
358
|
-
const commandList = commands.map((sub) => {
|
|
359
|
-
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
|
|
360
|
-
});
|
|
361
|
-
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
362
|
-
});
|
|
363
|
-
return output.join(`
|
|
364
|
-
`);
|
|
365
|
-
}
|
|
366
|
-
displayWidth(str) {
|
|
367
|
-
return stripColor(str).length;
|
|
368
|
-
}
|
|
369
|
-
styleTitle(str) {
|
|
370
|
-
return str;
|
|
371
|
-
}
|
|
372
|
-
styleUsage(str) {
|
|
373
|
-
return str.split(" ").map((word) => {
|
|
374
|
-
if (word === "[options]")
|
|
375
|
-
return this.styleOptionText(word);
|
|
376
|
-
if (word === "[command]")
|
|
377
|
-
return this.styleSubcommandText(word);
|
|
378
|
-
if (word[0] === "[" || word[0] === "<")
|
|
379
|
-
return this.styleArgumentText(word);
|
|
380
|
-
return this.styleCommandText(word);
|
|
381
|
-
}).join(" ");
|
|
382
|
-
}
|
|
383
|
-
styleCommandDescription(str) {
|
|
384
|
-
return this.styleDescriptionText(str);
|
|
385
|
-
}
|
|
386
|
-
styleOptionDescription(str) {
|
|
387
|
-
return this.styleDescriptionText(str);
|
|
388
|
-
}
|
|
389
|
-
styleSubcommandDescription(str) {
|
|
390
|
-
return this.styleDescriptionText(str);
|
|
391
|
-
}
|
|
392
|
-
styleArgumentDescription(str) {
|
|
393
|
-
return this.styleDescriptionText(str);
|
|
394
|
-
}
|
|
395
|
-
styleDescriptionText(str) {
|
|
396
|
-
return str;
|
|
397
|
-
}
|
|
398
|
-
styleOptionTerm(str) {
|
|
399
|
-
return this.styleOptionText(str);
|
|
400
|
-
}
|
|
401
|
-
styleSubcommandTerm(str) {
|
|
402
|
-
return str.split(" ").map((word) => {
|
|
403
|
-
if (word === "[options]")
|
|
404
|
-
return this.styleOptionText(word);
|
|
405
|
-
if (word[0] === "[" || word[0] === "<")
|
|
406
|
-
return this.styleArgumentText(word);
|
|
407
|
-
return this.styleSubcommandText(word);
|
|
408
|
-
}).join(" ");
|
|
409
|
-
}
|
|
410
|
-
styleArgumentTerm(str) {
|
|
411
|
-
return this.styleArgumentText(str);
|
|
412
|
-
}
|
|
413
|
-
styleOptionText(str) {
|
|
414
|
-
return str;
|
|
415
|
-
}
|
|
416
|
-
styleArgumentText(str) {
|
|
417
|
-
return str;
|
|
418
|
-
}
|
|
419
|
-
styleSubcommandText(str) {
|
|
420
|
-
return str;
|
|
421
|
-
}
|
|
422
|
-
styleCommandText(str) {
|
|
423
|
-
return str;
|
|
424
|
-
}
|
|
425
|
-
padWidth(cmd, helper) {
|
|
426
|
-
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
427
|
-
}
|
|
428
|
-
preformatted(str) {
|
|
429
|
-
return /\n[^\S\r\n]/.test(str);
|
|
430
|
-
}
|
|
431
|
-
formatItem(term, termWidth, description, helper) {
|
|
432
|
-
const itemIndent = 2;
|
|
433
|
-
const itemIndentStr = " ".repeat(itemIndent);
|
|
434
|
-
if (!description)
|
|
435
|
-
return itemIndentStr + term;
|
|
436
|
-
const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
|
|
437
|
-
const spacerWidth = 2;
|
|
438
|
-
const helpWidth = this.helpWidth ?? 80;
|
|
439
|
-
const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
|
|
440
|
-
let formattedDescription;
|
|
441
|
-
if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
|
|
442
|
-
formattedDescription = description;
|
|
443
|
-
} else {
|
|
444
|
-
const wrappedDescription = helper.boxWrap(description, remainingWidth);
|
|
445
|
-
formattedDescription = wrappedDescription.replace(/\n/g, `
|
|
446
|
-
` + " ".repeat(termWidth + spacerWidth));
|
|
447
|
-
}
|
|
448
|
-
return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
|
|
449
|
-
${itemIndentStr}`);
|
|
450
|
-
}
|
|
451
|
-
boxWrap(str, width) {
|
|
452
|
-
if (width < this.minWidthToWrap)
|
|
453
|
-
return str;
|
|
454
|
-
const rawLines = str.split(/\r\n|\n/);
|
|
455
|
-
const chunkPattern = /[\s]*[^\s]+/g;
|
|
456
|
-
const wrappedLines = [];
|
|
457
|
-
rawLines.forEach((line) => {
|
|
458
|
-
const chunks = line.match(chunkPattern);
|
|
459
|
-
if (chunks === null) {
|
|
460
|
-
wrappedLines.push("");
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
let sumChunks = [chunks.shift()];
|
|
464
|
-
let sumWidth = this.displayWidth(sumChunks[0]);
|
|
465
|
-
chunks.forEach((chunk) => {
|
|
466
|
-
const visibleWidth = this.displayWidth(chunk);
|
|
467
|
-
if (sumWidth + visibleWidth <= width) {
|
|
468
|
-
sumChunks.push(chunk);
|
|
469
|
-
sumWidth += visibleWidth;
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
wrappedLines.push(sumChunks.join(""));
|
|
473
|
-
const nextChunk = chunk.trimStart();
|
|
474
|
-
sumChunks = [nextChunk];
|
|
475
|
-
sumWidth = this.displayWidth(nextChunk);
|
|
476
|
-
});
|
|
477
|
-
wrappedLines.push(sumChunks.join(""));
|
|
478
|
-
});
|
|
479
|
-
return wrappedLines.join(`
|
|
480
|
-
`);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
function stripColor(str) {
|
|
484
|
-
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
485
|
-
return str.replace(sgrPattern, "");
|
|
486
|
-
}
|
|
487
|
-
exports.Help = Help;
|
|
488
|
-
exports.stripColor = stripColor;
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
// node_modules/commander/lib/option.js
|
|
492
|
-
var require_option = __commonJS((exports) => {
|
|
493
|
-
var { InvalidArgumentError } = require_error();
|
|
494
|
-
|
|
495
|
-
class Option {
|
|
496
|
-
constructor(flags, description) {
|
|
497
|
-
this.flags = flags;
|
|
498
|
-
this.description = description || "";
|
|
499
|
-
this.required = flags.includes("<");
|
|
500
|
-
this.optional = flags.includes("[");
|
|
501
|
-
this.variadic = /\w\.\.\.[>\]]$/.test(flags);
|
|
502
|
-
this.mandatory = false;
|
|
503
|
-
const optionFlags = splitOptionFlags(flags);
|
|
504
|
-
this.short = optionFlags.shortFlag;
|
|
505
|
-
this.long = optionFlags.longFlag;
|
|
506
|
-
this.negate = false;
|
|
507
|
-
if (this.long) {
|
|
508
|
-
this.negate = this.long.startsWith("--no-");
|
|
509
|
-
}
|
|
510
|
-
this.defaultValue = undefined;
|
|
511
|
-
this.defaultValueDescription = undefined;
|
|
512
|
-
this.presetArg = undefined;
|
|
513
|
-
this.envVar = undefined;
|
|
514
|
-
this.parseArg = undefined;
|
|
515
|
-
this.hidden = false;
|
|
516
|
-
this.argChoices = undefined;
|
|
517
|
-
this.conflictsWith = [];
|
|
518
|
-
this.implied = undefined;
|
|
519
|
-
this.helpGroupHeading = undefined;
|
|
520
|
-
}
|
|
521
|
-
default(value, description) {
|
|
522
|
-
this.defaultValue = value;
|
|
523
|
-
this.defaultValueDescription = description;
|
|
524
|
-
return this;
|
|
525
|
-
}
|
|
526
|
-
preset(arg) {
|
|
527
|
-
this.presetArg = arg;
|
|
528
|
-
return this;
|
|
529
|
-
}
|
|
530
|
-
conflicts(names) {
|
|
531
|
-
this.conflictsWith = this.conflictsWith.concat(names);
|
|
532
|
-
return this;
|
|
533
|
-
}
|
|
534
|
-
implies(impliedOptionValues) {
|
|
535
|
-
let newImplied = impliedOptionValues;
|
|
536
|
-
if (typeof impliedOptionValues === "string") {
|
|
537
|
-
newImplied = { [impliedOptionValues]: true };
|
|
538
|
-
}
|
|
539
|
-
this.implied = Object.assign(this.implied || {}, newImplied);
|
|
540
|
-
return this;
|
|
541
|
-
}
|
|
542
|
-
env(name) {
|
|
543
|
-
this.envVar = name;
|
|
544
|
-
return this;
|
|
545
|
-
}
|
|
546
|
-
argParser(fn) {
|
|
547
|
-
this.parseArg = fn;
|
|
548
|
-
return this;
|
|
549
|
-
}
|
|
550
|
-
makeOptionMandatory(mandatory = true) {
|
|
551
|
-
this.mandatory = !!mandatory;
|
|
552
|
-
return this;
|
|
553
|
-
}
|
|
554
|
-
hideHelp(hide = true) {
|
|
555
|
-
this.hidden = !!hide;
|
|
556
|
-
return this;
|
|
557
|
-
}
|
|
558
|
-
_concatValue(value, previous) {
|
|
559
|
-
if (previous === this.defaultValue || !Array.isArray(previous)) {
|
|
560
|
-
return [value];
|
|
561
|
-
}
|
|
562
|
-
return previous.concat(value);
|
|
563
|
-
}
|
|
564
|
-
choices(values) {
|
|
565
|
-
this.argChoices = values.slice();
|
|
566
|
-
this.parseArg = (arg, previous) => {
|
|
567
|
-
if (!this.argChoices.includes(arg)) {
|
|
568
|
-
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`);
|
|
569
|
-
}
|
|
570
|
-
if (this.variadic) {
|
|
571
|
-
return this._concatValue(arg, previous);
|
|
572
|
-
}
|
|
573
|
-
return arg;
|
|
574
|
-
};
|
|
575
|
-
return this;
|
|
576
|
-
}
|
|
577
|
-
name() {
|
|
578
|
-
if (this.long) {
|
|
579
|
-
return this.long.replace(/^--/, "");
|
|
580
|
-
}
|
|
581
|
-
return this.short.replace(/^-/, "");
|
|
582
|
-
}
|
|
583
|
-
attributeName() {
|
|
584
|
-
if (this.negate) {
|
|
585
|
-
return camelcase(this.name().replace(/^no-/, ""));
|
|
586
|
-
}
|
|
587
|
-
return camelcase(this.name());
|
|
588
|
-
}
|
|
589
|
-
helpGroup(heading) {
|
|
590
|
-
this.helpGroupHeading = heading;
|
|
591
|
-
return this;
|
|
592
|
-
}
|
|
593
|
-
is(arg) {
|
|
594
|
-
return this.short === arg || this.long === arg;
|
|
595
|
-
}
|
|
596
|
-
isBoolean() {
|
|
597
|
-
return !this.required && !this.optional && !this.negate;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
class DualOptions {
|
|
602
|
-
constructor(options) {
|
|
603
|
-
this.positiveOptions = new Map;
|
|
604
|
-
this.negativeOptions = new Map;
|
|
605
|
-
this.dualOptions = new Set;
|
|
606
|
-
options.forEach((option) => {
|
|
607
|
-
if (option.negate) {
|
|
608
|
-
this.negativeOptions.set(option.attributeName(), option);
|
|
609
|
-
} else {
|
|
610
|
-
this.positiveOptions.set(option.attributeName(), option);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
this.negativeOptions.forEach((value, key) => {
|
|
614
|
-
if (this.positiveOptions.has(key)) {
|
|
615
|
-
this.dualOptions.add(key);
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
valueFromOption(value, option) {
|
|
620
|
-
const optionKey = option.attributeName();
|
|
621
|
-
if (!this.dualOptions.has(optionKey))
|
|
622
|
-
return true;
|
|
623
|
-
const preset = this.negativeOptions.get(optionKey).presetArg;
|
|
624
|
-
const negativeValue = preset !== undefined ? preset : false;
|
|
625
|
-
return option.negate === (negativeValue === value);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
function camelcase(str) {
|
|
629
|
-
return str.split("-").reduce((str2, word) => {
|
|
630
|
-
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
function splitOptionFlags(flags) {
|
|
634
|
-
let shortFlag;
|
|
635
|
-
let longFlag;
|
|
636
|
-
const shortFlagExp = /^-[^-]$/;
|
|
637
|
-
const longFlagExp = /^--[^-]/;
|
|
638
|
-
const flagParts = flags.split(/[ |,]+/).concat("guard");
|
|
639
|
-
if (shortFlagExp.test(flagParts[0]))
|
|
640
|
-
shortFlag = flagParts.shift();
|
|
641
|
-
if (longFlagExp.test(flagParts[0]))
|
|
642
|
-
longFlag = flagParts.shift();
|
|
643
|
-
if (!shortFlag && shortFlagExp.test(flagParts[0]))
|
|
644
|
-
shortFlag = flagParts.shift();
|
|
645
|
-
if (!shortFlag && longFlagExp.test(flagParts[0])) {
|
|
646
|
-
shortFlag = longFlag;
|
|
647
|
-
longFlag = flagParts.shift();
|
|
648
|
-
}
|
|
649
|
-
if (flagParts[0].startsWith("-")) {
|
|
650
|
-
const unsupportedFlag = flagParts[0];
|
|
651
|
-
const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;
|
|
652
|
-
if (/^-[^-][^-]/.test(unsupportedFlag))
|
|
653
|
-
throw new Error(`${baseError}
|
|
654
|
-
- a short flag is a single dash and a single character
|
|
655
|
-
- either use a single dash and a single character (for a short flag)
|
|
656
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);
|
|
657
|
-
if (shortFlagExp.test(unsupportedFlag))
|
|
658
|
-
throw new Error(`${baseError}
|
|
659
|
-
- too many short flags`);
|
|
660
|
-
if (longFlagExp.test(unsupportedFlag))
|
|
661
|
-
throw new Error(`${baseError}
|
|
662
|
-
- too many long flags`);
|
|
663
|
-
throw new Error(`${baseError}
|
|
664
|
-
- unrecognised flag format`);
|
|
665
|
-
}
|
|
666
|
-
if (shortFlag === undefined && longFlag === undefined)
|
|
667
|
-
throw new Error(`option creation failed due to no flags found in '${flags}'.`);
|
|
668
|
-
return { shortFlag, longFlag };
|
|
669
|
-
}
|
|
670
|
-
exports.Option = Option;
|
|
671
|
-
exports.DualOptions = DualOptions;
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
// node_modules/commander/lib/suggestSimilar.js
|
|
675
|
-
var require_suggestSimilar = __commonJS((exports) => {
|
|
676
|
-
var maxDistance = 3;
|
|
677
|
-
function editDistance(a, b) {
|
|
678
|
-
if (Math.abs(a.length - b.length) > maxDistance)
|
|
679
|
-
return Math.max(a.length, b.length);
|
|
680
|
-
const d = [];
|
|
681
|
-
for (let i = 0;i <= a.length; i++) {
|
|
682
|
-
d[i] = [i];
|
|
683
|
-
}
|
|
684
|
-
for (let j = 0;j <= b.length; j++) {
|
|
685
|
-
d[0][j] = j;
|
|
686
|
-
}
|
|
687
|
-
for (let j = 1;j <= b.length; j++) {
|
|
688
|
-
for (let i = 1;i <= a.length; i++) {
|
|
689
|
-
let cost = 1;
|
|
690
|
-
if (a[i - 1] === b[j - 1]) {
|
|
691
|
-
cost = 0;
|
|
692
|
-
} else {
|
|
693
|
-
cost = 1;
|
|
694
|
-
}
|
|
695
|
-
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
696
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
697
|
-
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
return d[a.length][b.length];
|
|
702
|
-
}
|
|
703
|
-
function suggestSimilar(word, candidates) {
|
|
704
|
-
if (!candidates || candidates.length === 0)
|
|
705
|
-
return "";
|
|
706
|
-
candidates = Array.from(new Set(candidates));
|
|
707
|
-
const searchingOptions = word.startsWith("--");
|
|
708
|
-
if (searchingOptions) {
|
|
709
|
-
word = word.slice(2);
|
|
710
|
-
candidates = candidates.map((candidate) => candidate.slice(2));
|
|
711
|
-
}
|
|
712
|
-
let similar = [];
|
|
713
|
-
let bestDistance = maxDistance;
|
|
714
|
-
const minSimilarity = 0.4;
|
|
715
|
-
candidates.forEach((candidate) => {
|
|
716
|
-
if (candidate.length <= 1)
|
|
717
|
-
return;
|
|
718
|
-
const distance = editDistance(word, candidate);
|
|
719
|
-
const length = Math.max(word.length, candidate.length);
|
|
720
|
-
const similarity = (length - distance) / length;
|
|
721
|
-
if (similarity > minSimilarity) {
|
|
722
|
-
if (distance < bestDistance) {
|
|
723
|
-
bestDistance = distance;
|
|
724
|
-
similar = [candidate];
|
|
725
|
-
} else if (distance === bestDistance) {
|
|
726
|
-
similar.push(candidate);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
similar.sort((a, b) => a.localeCompare(b));
|
|
731
|
-
if (searchingOptions) {
|
|
732
|
-
similar = similar.map((candidate) => `--${candidate}`);
|
|
733
|
-
}
|
|
734
|
-
if (similar.length > 1) {
|
|
735
|
-
return `
|
|
736
|
-
(Did you mean one of ${similar.join(", ")}?)`;
|
|
737
|
-
}
|
|
738
|
-
if (similar.length === 1) {
|
|
739
|
-
return `
|
|
740
|
-
(Did you mean ${similar[0]}?)`;
|
|
741
|
-
}
|
|
742
|
-
return "";
|
|
743
|
-
}
|
|
744
|
-
exports.suggestSimilar = suggestSimilar;
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
// node_modules/commander/lib/command.js
|
|
748
|
-
var require_command = __commonJS((exports) => {
|
|
749
|
-
var EventEmitter = __require("node:events").EventEmitter;
|
|
750
|
-
var childProcess = __require("node:child_process");
|
|
751
|
-
var path = __require("node:path");
|
|
752
|
-
var fs = __require("node:fs");
|
|
753
|
-
var process2 = __require("node:process");
|
|
754
|
-
var { Argument, humanReadableArgName } = require_argument();
|
|
755
|
-
var { CommanderError } = require_error();
|
|
756
|
-
var { Help, stripColor } = require_help();
|
|
757
|
-
var { Option, DualOptions } = require_option();
|
|
758
|
-
var { suggestSimilar } = require_suggestSimilar();
|
|
759
|
-
|
|
760
|
-
class Command extends EventEmitter {
|
|
761
|
-
constructor(name) {
|
|
762
|
-
super();
|
|
763
|
-
this.commands = [];
|
|
764
|
-
this.options = [];
|
|
765
|
-
this.parent = null;
|
|
766
|
-
this._allowUnknownOption = false;
|
|
767
|
-
this._allowExcessArguments = false;
|
|
768
|
-
this.registeredArguments = [];
|
|
769
|
-
this._args = this.registeredArguments;
|
|
770
|
-
this.args = [];
|
|
771
|
-
this.rawArgs = [];
|
|
772
|
-
this.processedArgs = [];
|
|
773
|
-
this._scriptPath = null;
|
|
774
|
-
this._name = name || "";
|
|
775
|
-
this._optionValues = {};
|
|
776
|
-
this._optionValueSources = {};
|
|
777
|
-
this._storeOptionsAsProperties = false;
|
|
778
|
-
this._actionHandler = null;
|
|
779
|
-
this._executableHandler = false;
|
|
780
|
-
this._executableFile = null;
|
|
781
|
-
this._executableDir = null;
|
|
782
|
-
this._defaultCommandName = null;
|
|
783
|
-
this._exitCallback = null;
|
|
784
|
-
this._aliases = [];
|
|
785
|
-
this._combineFlagAndOptionalValue = true;
|
|
786
|
-
this._description = "";
|
|
787
|
-
this._summary = "";
|
|
788
|
-
this._argsDescription = undefined;
|
|
789
|
-
this._enablePositionalOptions = false;
|
|
790
|
-
this._passThroughOptions = false;
|
|
791
|
-
this._lifeCycleHooks = {};
|
|
792
|
-
this._showHelpAfterError = false;
|
|
793
|
-
this._showSuggestionAfterError = true;
|
|
794
|
-
this._savedState = null;
|
|
795
|
-
this._outputConfiguration = {
|
|
796
|
-
writeOut: (str) => process2.stdout.write(str),
|
|
797
|
-
writeErr: (str) => process2.stderr.write(str),
|
|
798
|
-
outputError: (str, write) => write(str),
|
|
799
|
-
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
|
|
800
|
-
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
|
|
801
|
-
getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
|
|
802
|
-
getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
|
|
803
|
-
stripColor: (str) => stripColor(str)
|
|
804
|
-
};
|
|
805
|
-
this._hidden = false;
|
|
806
|
-
this._helpOption = undefined;
|
|
807
|
-
this._addImplicitHelpCommand = undefined;
|
|
808
|
-
this._helpCommand = undefined;
|
|
809
|
-
this._helpConfiguration = {};
|
|
810
|
-
this._helpGroupHeading = undefined;
|
|
811
|
-
this._defaultCommandGroup = undefined;
|
|
812
|
-
this._defaultOptionGroup = undefined;
|
|
813
|
-
}
|
|
814
|
-
copyInheritedSettings(sourceCommand) {
|
|
815
|
-
this._outputConfiguration = sourceCommand._outputConfiguration;
|
|
816
|
-
this._helpOption = sourceCommand._helpOption;
|
|
817
|
-
this._helpCommand = sourceCommand._helpCommand;
|
|
818
|
-
this._helpConfiguration = sourceCommand._helpConfiguration;
|
|
819
|
-
this._exitCallback = sourceCommand._exitCallback;
|
|
820
|
-
this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
|
|
821
|
-
this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
|
|
822
|
-
this._allowExcessArguments = sourceCommand._allowExcessArguments;
|
|
823
|
-
this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
|
|
824
|
-
this._showHelpAfterError = sourceCommand._showHelpAfterError;
|
|
825
|
-
this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
|
|
826
|
-
return this;
|
|
827
|
-
}
|
|
828
|
-
_getCommandAndAncestors() {
|
|
829
|
-
const result = [];
|
|
830
|
-
for (let command = this;command; command = command.parent) {
|
|
831
|
-
result.push(command);
|
|
832
|
-
}
|
|
833
|
-
return result;
|
|
834
|
-
}
|
|
835
|
-
command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
|
836
|
-
let desc = actionOptsOrExecDesc;
|
|
837
|
-
let opts = execOpts;
|
|
838
|
-
if (typeof desc === "object" && desc !== null) {
|
|
839
|
-
opts = desc;
|
|
840
|
-
desc = null;
|
|
841
|
-
}
|
|
842
|
-
opts = opts || {};
|
|
843
|
-
const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
844
|
-
const cmd = this.createCommand(name);
|
|
845
|
-
if (desc) {
|
|
846
|
-
cmd.description(desc);
|
|
847
|
-
cmd._executableHandler = true;
|
|
848
|
-
}
|
|
849
|
-
if (opts.isDefault)
|
|
850
|
-
this._defaultCommandName = cmd._name;
|
|
851
|
-
cmd._hidden = !!(opts.noHelp || opts.hidden);
|
|
852
|
-
cmd._executableFile = opts.executableFile || null;
|
|
853
|
-
if (args)
|
|
854
|
-
cmd.arguments(args);
|
|
855
|
-
this._registerCommand(cmd);
|
|
856
|
-
cmd.parent = this;
|
|
857
|
-
cmd.copyInheritedSettings(this);
|
|
858
|
-
if (desc)
|
|
859
|
-
return this;
|
|
860
|
-
return cmd;
|
|
861
|
-
}
|
|
862
|
-
createCommand(name) {
|
|
863
|
-
return new Command(name);
|
|
864
|
-
}
|
|
865
|
-
createHelp() {
|
|
866
|
-
return Object.assign(new Help, this.configureHelp());
|
|
867
|
-
}
|
|
868
|
-
configureHelp(configuration) {
|
|
869
|
-
if (configuration === undefined)
|
|
870
|
-
return this._helpConfiguration;
|
|
871
|
-
this._helpConfiguration = configuration;
|
|
872
|
-
return this;
|
|
873
|
-
}
|
|
874
|
-
configureOutput(configuration) {
|
|
875
|
-
if (configuration === undefined)
|
|
876
|
-
return this._outputConfiguration;
|
|
877
|
-
this._outputConfiguration = Object.assign({}, this._outputConfiguration, configuration);
|
|
878
|
-
return this;
|
|
879
|
-
}
|
|
880
|
-
showHelpAfterError(displayHelp = true) {
|
|
881
|
-
if (typeof displayHelp !== "string")
|
|
882
|
-
displayHelp = !!displayHelp;
|
|
883
|
-
this._showHelpAfterError = displayHelp;
|
|
884
|
-
return this;
|
|
885
|
-
}
|
|
886
|
-
showSuggestionAfterError(displaySuggestion = true) {
|
|
887
|
-
this._showSuggestionAfterError = !!displaySuggestion;
|
|
888
|
-
return this;
|
|
889
|
-
}
|
|
890
|
-
addCommand(cmd, opts) {
|
|
891
|
-
if (!cmd._name) {
|
|
892
|
-
throw new Error(`Command passed to .addCommand() must have a name
|
|
893
|
-
- specify the name in Command constructor or using .name()`);
|
|
894
|
-
}
|
|
895
|
-
opts = opts || {};
|
|
896
|
-
if (opts.isDefault)
|
|
897
|
-
this._defaultCommandName = cmd._name;
|
|
898
|
-
if (opts.noHelp || opts.hidden)
|
|
899
|
-
cmd._hidden = true;
|
|
900
|
-
this._registerCommand(cmd);
|
|
901
|
-
cmd.parent = this;
|
|
902
|
-
cmd._checkForBrokenPassThrough();
|
|
903
|
-
return this;
|
|
904
|
-
}
|
|
905
|
-
createArgument(name, description) {
|
|
906
|
-
return new Argument(name, description);
|
|
907
|
-
}
|
|
908
|
-
argument(name, description, parseArg, defaultValue) {
|
|
909
|
-
const argument = this.createArgument(name, description);
|
|
910
|
-
if (typeof parseArg === "function") {
|
|
911
|
-
argument.default(defaultValue).argParser(parseArg);
|
|
912
|
-
} else {
|
|
913
|
-
argument.default(parseArg);
|
|
914
|
-
}
|
|
915
|
-
this.addArgument(argument);
|
|
916
|
-
return this;
|
|
917
|
-
}
|
|
918
|
-
arguments(names) {
|
|
919
|
-
names.trim().split(/ +/).forEach((detail) => {
|
|
920
|
-
this.argument(detail);
|
|
921
|
-
});
|
|
922
|
-
return this;
|
|
923
|
-
}
|
|
924
|
-
addArgument(argument) {
|
|
925
|
-
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
926
|
-
if (previousArgument && previousArgument.variadic) {
|
|
927
|
-
throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
|
|
928
|
-
}
|
|
929
|
-
if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
|
|
930
|
-
throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
|
|
931
|
-
}
|
|
932
|
-
this.registeredArguments.push(argument);
|
|
933
|
-
return this;
|
|
934
|
-
}
|
|
935
|
-
helpCommand(enableOrNameAndArgs, description) {
|
|
936
|
-
if (typeof enableOrNameAndArgs === "boolean") {
|
|
937
|
-
this._addImplicitHelpCommand = enableOrNameAndArgs;
|
|
938
|
-
if (enableOrNameAndArgs && this._defaultCommandGroup) {
|
|
939
|
-
this._initCommandGroup(this._getHelpCommand());
|
|
940
|
-
}
|
|
941
|
-
return this;
|
|
942
|
-
}
|
|
943
|
-
const nameAndArgs = enableOrNameAndArgs ?? "help [command]";
|
|
944
|
-
const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);
|
|
945
|
-
const helpDescription = description ?? "display help for command";
|
|
946
|
-
const helpCommand = this.createCommand(helpName);
|
|
947
|
-
helpCommand.helpOption(false);
|
|
948
|
-
if (helpArgs)
|
|
949
|
-
helpCommand.arguments(helpArgs);
|
|
950
|
-
if (helpDescription)
|
|
951
|
-
helpCommand.description(helpDescription);
|
|
952
|
-
this._addImplicitHelpCommand = true;
|
|
953
|
-
this._helpCommand = helpCommand;
|
|
954
|
-
if (enableOrNameAndArgs || description)
|
|
955
|
-
this._initCommandGroup(helpCommand);
|
|
956
|
-
return this;
|
|
957
|
-
}
|
|
958
|
-
addHelpCommand(helpCommand, deprecatedDescription) {
|
|
959
|
-
if (typeof helpCommand !== "object") {
|
|
960
|
-
this.helpCommand(helpCommand, deprecatedDescription);
|
|
961
|
-
return this;
|
|
962
|
-
}
|
|
963
|
-
this._addImplicitHelpCommand = true;
|
|
964
|
-
this._helpCommand = helpCommand;
|
|
965
|
-
this._initCommandGroup(helpCommand);
|
|
966
|
-
return this;
|
|
967
|
-
}
|
|
968
|
-
_getHelpCommand() {
|
|
969
|
-
const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help"));
|
|
970
|
-
if (hasImplicitHelpCommand) {
|
|
971
|
-
if (this._helpCommand === undefined) {
|
|
972
|
-
this.helpCommand(undefined, undefined);
|
|
973
|
-
}
|
|
974
|
-
return this._helpCommand;
|
|
975
|
-
}
|
|
976
|
-
return null;
|
|
977
|
-
}
|
|
978
|
-
hook(event, listener) {
|
|
979
|
-
const allowedValues = ["preSubcommand", "preAction", "postAction"];
|
|
980
|
-
if (!allowedValues.includes(event)) {
|
|
981
|
-
throw new Error(`Unexpected value for event passed to hook : '${event}'.
|
|
982
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
983
|
-
}
|
|
984
|
-
if (this._lifeCycleHooks[event]) {
|
|
985
|
-
this._lifeCycleHooks[event].push(listener);
|
|
986
|
-
} else {
|
|
987
|
-
this._lifeCycleHooks[event] = [listener];
|
|
988
|
-
}
|
|
989
|
-
return this;
|
|
990
|
-
}
|
|
991
|
-
exitOverride(fn) {
|
|
992
|
-
if (fn) {
|
|
993
|
-
this._exitCallback = fn;
|
|
994
|
-
} else {
|
|
995
|
-
this._exitCallback = (err) => {
|
|
996
|
-
if (err.code !== "commander.executeSubCommandAsync") {
|
|
997
|
-
throw err;
|
|
998
|
-
} else {}
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
return this;
|
|
1002
|
-
}
|
|
1003
|
-
_exit(exitCode, code, message) {
|
|
1004
|
-
if (this._exitCallback) {
|
|
1005
|
-
this._exitCallback(new CommanderError(exitCode, code, message));
|
|
1006
|
-
}
|
|
1007
|
-
process2.exit(exitCode);
|
|
1008
|
-
}
|
|
1009
|
-
action(fn) {
|
|
1010
|
-
const listener = (args) => {
|
|
1011
|
-
const expectedArgsCount = this.registeredArguments.length;
|
|
1012
|
-
const actionArgs = args.slice(0, expectedArgsCount);
|
|
1013
|
-
if (this._storeOptionsAsProperties) {
|
|
1014
|
-
actionArgs[expectedArgsCount] = this;
|
|
1015
|
-
} else {
|
|
1016
|
-
actionArgs[expectedArgsCount] = this.opts();
|
|
1017
|
-
}
|
|
1018
|
-
actionArgs.push(this);
|
|
1019
|
-
return fn.apply(this, actionArgs);
|
|
1020
|
-
};
|
|
1021
|
-
this._actionHandler = listener;
|
|
1022
|
-
return this;
|
|
1023
|
-
}
|
|
1024
|
-
createOption(flags, description) {
|
|
1025
|
-
return new Option(flags, description);
|
|
1026
|
-
}
|
|
1027
|
-
_callParseArg(target, value, previous, invalidArgumentMessage) {
|
|
1028
|
-
try {
|
|
1029
|
-
return target.parseArg(value, previous);
|
|
1030
|
-
} catch (err) {
|
|
1031
|
-
if (err.code === "commander.invalidArgument") {
|
|
1032
|
-
const message = `${invalidArgumentMessage} ${err.message}`;
|
|
1033
|
-
this.error(message, { exitCode: err.exitCode, code: err.code });
|
|
1034
|
-
}
|
|
1035
|
-
throw err;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
_registerOption(option) {
|
|
1039
|
-
const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long);
|
|
1040
|
-
if (matchingOption) {
|
|
1041
|
-
const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short;
|
|
1042
|
-
throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
|
|
1043
|
-
- already used by option '${matchingOption.flags}'`);
|
|
1044
|
-
}
|
|
1045
|
-
this._initOptionGroup(option);
|
|
1046
|
-
this.options.push(option);
|
|
1047
|
-
}
|
|
1048
|
-
_registerCommand(command) {
|
|
1049
|
-
const knownBy = (cmd) => {
|
|
1050
|
-
return [cmd.name()].concat(cmd.aliases());
|
|
1051
|
-
};
|
|
1052
|
-
const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
|
|
1053
|
-
if (alreadyUsed) {
|
|
1054
|
-
const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|");
|
|
1055
|
-
const newCmd = knownBy(command).join("|");
|
|
1056
|
-
throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
|
|
1057
|
-
}
|
|
1058
|
-
this._initCommandGroup(command);
|
|
1059
|
-
this.commands.push(command);
|
|
1060
|
-
}
|
|
1061
|
-
addOption(option) {
|
|
1062
|
-
this._registerOption(option);
|
|
1063
|
-
const oname = option.name();
|
|
1064
|
-
const name = option.attributeName();
|
|
1065
|
-
if (option.negate) {
|
|
1066
|
-
const positiveLongFlag = option.long.replace(/^--no-/, "--");
|
|
1067
|
-
if (!this._findOption(positiveLongFlag)) {
|
|
1068
|
-
this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, "default");
|
|
1069
|
-
}
|
|
1070
|
-
} else if (option.defaultValue !== undefined) {
|
|
1071
|
-
this.setOptionValueWithSource(name, option.defaultValue, "default");
|
|
1072
|
-
}
|
|
1073
|
-
const handleOptionValue = (val, invalidValueMessage, valueSource) => {
|
|
1074
|
-
if (val == null && option.presetArg !== undefined) {
|
|
1075
|
-
val = option.presetArg;
|
|
1076
|
-
}
|
|
1077
|
-
const oldValue = this.getOptionValue(name);
|
|
1078
|
-
if (val !== null && option.parseArg) {
|
|
1079
|
-
val = this._callParseArg(option, val, oldValue, invalidValueMessage);
|
|
1080
|
-
} else if (val !== null && option.variadic) {
|
|
1081
|
-
val = option._concatValue(val, oldValue);
|
|
1082
|
-
}
|
|
1083
|
-
if (val == null) {
|
|
1084
|
-
if (option.negate) {
|
|
1085
|
-
val = false;
|
|
1086
|
-
} else if (option.isBoolean() || option.optional) {
|
|
1087
|
-
val = true;
|
|
1088
|
-
} else {
|
|
1089
|
-
val = "";
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
this.setOptionValueWithSource(name, val, valueSource);
|
|
1093
|
-
};
|
|
1094
|
-
this.on("option:" + oname, (val) => {
|
|
1095
|
-
const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;
|
|
1096
|
-
handleOptionValue(val, invalidValueMessage, "cli");
|
|
1097
|
-
});
|
|
1098
|
-
if (option.envVar) {
|
|
1099
|
-
this.on("optionEnv:" + oname, (val) => {
|
|
1100
|
-
const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;
|
|
1101
|
-
handleOptionValue(val, invalidValueMessage, "env");
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
return this;
|
|
1105
|
-
}
|
|
1106
|
-
_optionEx(config, flags, description, fn, defaultValue) {
|
|
1107
|
-
if (typeof flags === "object" && flags instanceof Option) {
|
|
1108
|
-
throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
|
|
1109
|
-
}
|
|
1110
|
-
const option = this.createOption(flags, description);
|
|
1111
|
-
option.makeOptionMandatory(!!config.mandatory);
|
|
1112
|
-
if (typeof fn === "function") {
|
|
1113
|
-
option.default(defaultValue).argParser(fn);
|
|
1114
|
-
} else if (fn instanceof RegExp) {
|
|
1115
|
-
const regex = fn;
|
|
1116
|
-
fn = (val, def) => {
|
|
1117
|
-
const m = regex.exec(val);
|
|
1118
|
-
return m ? m[0] : def;
|
|
1119
|
-
};
|
|
1120
|
-
option.default(defaultValue).argParser(fn);
|
|
1121
|
-
} else {
|
|
1122
|
-
option.default(fn);
|
|
1123
|
-
}
|
|
1124
|
-
return this.addOption(option);
|
|
1125
|
-
}
|
|
1126
|
-
option(flags, description, parseArg, defaultValue) {
|
|
1127
|
-
return this._optionEx({}, flags, description, parseArg, defaultValue);
|
|
1128
|
-
}
|
|
1129
|
-
requiredOption(flags, description, parseArg, defaultValue) {
|
|
1130
|
-
return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
|
|
1131
|
-
}
|
|
1132
|
-
combineFlagAndOptionalValue(combine = true) {
|
|
1133
|
-
this._combineFlagAndOptionalValue = !!combine;
|
|
1134
|
-
return this;
|
|
1135
|
-
}
|
|
1136
|
-
allowUnknownOption(allowUnknown = true) {
|
|
1137
|
-
this._allowUnknownOption = !!allowUnknown;
|
|
1138
|
-
return this;
|
|
1139
|
-
}
|
|
1140
|
-
allowExcessArguments(allowExcess = true) {
|
|
1141
|
-
this._allowExcessArguments = !!allowExcess;
|
|
1142
|
-
return this;
|
|
1143
|
-
}
|
|
1144
|
-
enablePositionalOptions(positional = true) {
|
|
1145
|
-
this._enablePositionalOptions = !!positional;
|
|
1146
|
-
return this;
|
|
1147
|
-
}
|
|
1148
|
-
passThroughOptions(passThrough = true) {
|
|
1149
|
-
this._passThroughOptions = !!passThrough;
|
|
1150
|
-
this._checkForBrokenPassThrough();
|
|
1151
|
-
return this;
|
|
1152
|
-
}
|
|
1153
|
-
_checkForBrokenPassThrough() {
|
|
1154
|
-
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
|
|
1155
|
-
throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
storeOptionsAsProperties(storeAsProperties = true) {
|
|
1159
|
-
if (this.options.length) {
|
|
1160
|
-
throw new Error("call .storeOptionsAsProperties() before adding options");
|
|
1161
|
-
}
|
|
1162
|
-
if (Object.keys(this._optionValues).length) {
|
|
1163
|
-
throw new Error("call .storeOptionsAsProperties() before setting option values");
|
|
1164
|
-
}
|
|
1165
|
-
this._storeOptionsAsProperties = !!storeAsProperties;
|
|
1166
|
-
return this;
|
|
1167
|
-
}
|
|
1168
|
-
getOptionValue(key) {
|
|
1169
|
-
if (this._storeOptionsAsProperties) {
|
|
1170
|
-
return this[key];
|
|
1171
|
-
}
|
|
1172
|
-
return this._optionValues[key];
|
|
1173
|
-
}
|
|
1174
|
-
setOptionValue(key, value) {
|
|
1175
|
-
return this.setOptionValueWithSource(key, value, undefined);
|
|
1176
|
-
}
|
|
1177
|
-
setOptionValueWithSource(key, value, source) {
|
|
1178
|
-
if (this._storeOptionsAsProperties) {
|
|
1179
|
-
this[key] = value;
|
|
1180
|
-
} else {
|
|
1181
|
-
this._optionValues[key] = value;
|
|
1182
|
-
}
|
|
1183
|
-
this._optionValueSources[key] = source;
|
|
1184
|
-
return this;
|
|
1185
|
-
}
|
|
1186
|
-
getOptionValueSource(key) {
|
|
1187
|
-
return this._optionValueSources[key];
|
|
1188
|
-
}
|
|
1189
|
-
getOptionValueSourceWithGlobals(key) {
|
|
1190
|
-
let source;
|
|
1191
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1192
|
-
if (cmd.getOptionValueSource(key) !== undefined) {
|
|
1193
|
-
source = cmd.getOptionValueSource(key);
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
return source;
|
|
1197
|
-
}
|
|
1198
|
-
_prepareUserArgs(argv, parseOptions) {
|
|
1199
|
-
if (argv !== undefined && !Array.isArray(argv)) {
|
|
1200
|
-
throw new Error("first parameter to parse must be array or undefined");
|
|
1201
|
-
}
|
|
1202
|
-
parseOptions = parseOptions || {};
|
|
1203
|
-
if (argv === undefined && parseOptions.from === undefined) {
|
|
1204
|
-
if (process2.versions?.electron) {
|
|
1205
|
-
parseOptions.from = "electron";
|
|
1206
|
-
}
|
|
1207
|
-
const execArgv = process2.execArgv ?? [];
|
|
1208
|
-
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
1209
|
-
parseOptions.from = "eval";
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
if (argv === undefined) {
|
|
1213
|
-
argv = process2.argv;
|
|
1214
|
-
}
|
|
1215
|
-
this.rawArgs = argv.slice();
|
|
1216
|
-
let userArgs;
|
|
1217
|
-
switch (parseOptions.from) {
|
|
1218
|
-
case undefined:
|
|
1219
|
-
case "node":
|
|
1220
|
-
this._scriptPath = argv[1];
|
|
1221
|
-
userArgs = argv.slice(2);
|
|
1222
|
-
break;
|
|
1223
|
-
case "electron":
|
|
1224
|
-
if (process2.defaultApp) {
|
|
1225
|
-
this._scriptPath = argv[1];
|
|
1226
|
-
userArgs = argv.slice(2);
|
|
1227
|
-
} else {
|
|
1228
|
-
userArgs = argv.slice(1);
|
|
1229
|
-
}
|
|
1230
|
-
break;
|
|
1231
|
-
case "user":
|
|
1232
|
-
userArgs = argv.slice(0);
|
|
1233
|
-
break;
|
|
1234
|
-
case "eval":
|
|
1235
|
-
userArgs = argv.slice(1);
|
|
1236
|
-
break;
|
|
1237
|
-
default:
|
|
1238
|
-
throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
|
|
1239
|
-
}
|
|
1240
|
-
if (!this._name && this._scriptPath)
|
|
1241
|
-
this.nameFromFilename(this._scriptPath);
|
|
1242
|
-
this._name = this._name || "program";
|
|
1243
|
-
return userArgs;
|
|
1244
|
-
}
|
|
1245
|
-
parse(argv, parseOptions) {
|
|
1246
|
-
this._prepareForParse();
|
|
1247
|
-
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1248
|
-
this._parseCommand([], userArgs);
|
|
1249
|
-
return this;
|
|
1250
|
-
}
|
|
1251
|
-
async parseAsync(argv, parseOptions) {
|
|
1252
|
-
this._prepareForParse();
|
|
1253
|
-
const userArgs = this._prepareUserArgs(argv, parseOptions);
|
|
1254
|
-
await this._parseCommand([], userArgs);
|
|
1255
|
-
return this;
|
|
1256
|
-
}
|
|
1257
|
-
_prepareForParse() {
|
|
1258
|
-
if (this._savedState === null) {
|
|
1259
|
-
this.saveStateBeforeParse();
|
|
1260
|
-
} else {
|
|
1261
|
-
this.restoreStateBeforeParse();
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
saveStateBeforeParse() {
|
|
1265
|
-
this._savedState = {
|
|
1266
|
-
_name: this._name,
|
|
1267
|
-
_optionValues: { ...this._optionValues },
|
|
1268
|
-
_optionValueSources: { ...this._optionValueSources }
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
restoreStateBeforeParse() {
|
|
1272
|
-
if (this._storeOptionsAsProperties)
|
|
1273
|
-
throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
1274
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);
|
|
1275
|
-
this._name = this._savedState._name;
|
|
1276
|
-
this._scriptPath = null;
|
|
1277
|
-
this.rawArgs = [];
|
|
1278
|
-
this._optionValues = { ...this._savedState._optionValues };
|
|
1279
|
-
this._optionValueSources = { ...this._savedState._optionValueSources };
|
|
1280
|
-
this.args = [];
|
|
1281
|
-
this.processedArgs = [];
|
|
1282
|
-
}
|
|
1283
|
-
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1284
|
-
if (fs.existsSync(executableFile))
|
|
1285
|
-
return;
|
|
1286
|
-
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
1287
|
-
const executableMissing = `'${executableFile}' does not exist
|
|
1288
|
-
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
1289
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
1290
|
-
- ${executableDirMessage}`;
|
|
1291
|
-
throw new Error(executableMissing);
|
|
1292
|
-
}
|
|
1293
|
-
_executeSubCommand(subcommand, args) {
|
|
1294
|
-
args = args.slice();
|
|
1295
|
-
let launchWithNode = false;
|
|
1296
|
-
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1297
|
-
function findFile(baseDir, baseName) {
|
|
1298
|
-
const localBin = path.resolve(baseDir, baseName);
|
|
1299
|
-
if (fs.existsSync(localBin))
|
|
1300
|
-
return localBin;
|
|
1301
|
-
if (sourceExt.includes(path.extname(baseName)))
|
|
1302
|
-
return;
|
|
1303
|
-
const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
|
|
1304
|
-
if (foundExt)
|
|
1305
|
-
return `${localBin}${foundExt}`;
|
|
1306
|
-
return;
|
|
1307
|
-
}
|
|
1308
|
-
this._checkForMissingMandatoryOptions();
|
|
1309
|
-
this._checkForConflictingOptions();
|
|
1310
|
-
let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
|
|
1311
|
-
let executableDir = this._executableDir || "";
|
|
1312
|
-
if (this._scriptPath) {
|
|
1313
|
-
let resolvedScriptPath;
|
|
1314
|
-
try {
|
|
1315
|
-
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
1316
|
-
} catch {
|
|
1317
|
-
resolvedScriptPath = this._scriptPath;
|
|
1318
|
-
}
|
|
1319
|
-
executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
|
|
1320
|
-
}
|
|
1321
|
-
if (executableDir) {
|
|
1322
|
-
let localFile = findFile(executableDir, executableFile);
|
|
1323
|
-
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1324
|
-
const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
|
|
1325
|
-
if (legacyName !== this._name) {
|
|
1326
|
-
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
executableFile = localFile || executableFile;
|
|
1330
|
-
}
|
|
1331
|
-
launchWithNode = sourceExt.includes(path.extname(executableFile));
|
|
1332
|
-
let proc;
|
|
1333
|
-
if (process2.platform !== "win32") {
|
|
1334
|
-
if (launchWithNode) {
|
|
1335
|
-
args.unshift(executableFile);
|
|
1336
|
-
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1337
|
-
proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
|
|
1338
|
-
} else {
|
|
1339
|
-
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1340
|
-
}
|
|
1341
|
-
} else {
|
|
1342
|
-
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1343
|
-
args.unshift(executableFile);
|
|
1344
|
-
args = incrementNodeInspectorPort(process2.execArgv).concat(args);
|
|
1345
|
-
proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
|
|
1346
|
-
}
|
|
1347
|
-
if (!proc.killed) {
|
|
1348
|
-
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1349
|
-
signals.forEach((signal) => {
|
|
1350
|
-
process2.on(signal, () => {
|
|
1351
|
-
if (proc.killed === false && proc.exitCode === null) {
|
|
1352
|
-
proc.kill(signal);
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
const exitCallback = this._exitCallback;
|
|
1358
|
-
proc.on("close", (code) => {
|
|
1359
|
-
code = code ?? 1;
|
|
1360
|
-
if (!exitCallback) {
|
|
1361
|
-
process2.exit(code);
|
|
1362
|
-
} else {
|
|
1363
|
-
exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
1364
|
-
}
|
|
1365
|
-
});
|
|
1366
|
-
proc.on("error", (err) => {
|
|
1367
|
-
if (err.code === "ENOENT") {
|
|
1368
|
-
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
1369
|
-
} else if (err.code === "EACCES") {
|
|
1370
|
-
throw new Error(`'${executableFile}' not executable`);
|
|
1371
|
-
}
|
|
1372
|
-
if (!exitCallback) {
|
|
1373
|
-
process2.exit(1);
|
|
1374
|
-
} else {
|
|
1375
|
-
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
1376
|
-
wrappedError.nestedError = err;
|
|
1377
|
-
exitCallback(wrappedError);
|
|
1378
|
-
}
|
|
1379
|
-
});
|
|
1380
|
-
this.runningCommand = proc;
|
|
1381
|
-
}
|
|
1382
|
-
_dispatchSubcommand(commandName, operands, unknown) {
|
|
1383
|
-
const subCommand = this._findCommand(commandName);
|
|
1384
|
-
if (!subCommand)
|
|
1385
|
-
this.help({ error: true });
|
|
1386
|
-
subCommand._prepareForParse();
|
|
1387
|
-
let promiseChain;
|
|
1388
|
-
promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand");
|
|
1389
|
-
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
1390
|
-
if (subCommand._executableHandler) {
|
|
1391
|
-
this._executeSubCommand(subCommand, operands.concat(unknown));
|
|
1392
|
-
} else {
|
|
1393
|
-
return subCommand._parseCommand(operands, unknown);
|
|
1394
|
-
}
|
|
1395
|
-
});
|
|
1396
|
-
return promiseChain;
|
|
1397
|
-
}
|
|
1398
|
-
_dispatchHelpCommand(subcommandName) {
|
|
1399
|
-
if (!subcommandName) {
|
|
1400
|
-
this.help();
|
|
1401
|
-
}
|
|
1402
|
-
const subCommand = this._findCommand(subcommandName);
|
|
1403
|
-
if (subCommand && !subCommand._executableHandler) {
|
|
1404
|
-
subCommand.help();
|
|
1405
|
-
}
|
|
1406
|
-
return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]);
|
|
1407
|
-
}
|
|
1408
|
-
_checkNumberOfArguments() {
|
|
1409
|
-
this.registeredArguments.forEach((arg, i) => {
|
|
1410
|
-
if (arg.required && this.args[i] == null) {
|
|
1411
|
-
this.missingArgument(arg.name());
|
|
1412
|
-
}
|
|
1413
|
-
});
|
|
1414
|
-
if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
|
|
1415
|
-
return;
|
|
1416
|
-
}
|
|
1417
|
-
if (this.args.length > this.registeredArguments.length) {
|
|
1418
|
-
this._excessArguments(this.args);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
_processArguments() {
|
|
1422
|
-
const myParseArg = (argument, value, previous) => {
|
|
1423
|
-
let parsedValue = value;
|
|
1424
|
-
if (value !== null && argument.parseArg) {
|
|
1425
|
-
const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
|
|
1426
|
-
parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
|
|
1427
|
-
}
|
|
1428
|
-
return parsedValue;
|
|
1429
|
-
};
|
|
1430
|
-
this._checkNumberOfArguments();
|
|
1431
|
-
const processedArgs = [];
|
|
1432
|
-
this.registeredArguments.forEach((declaredArg, index) => {
|
|
1433
|
-
let value = declaredArg.defaultValue;
|
|
1434
|
-
if (declaredArg.variadic) {
|
|
1435
|
-
if (index < this.args.length) {
|
|
1436
|
-
value = this.args.slice(index);
|
|
1437
|
-
if (declaredArg.parseArg) {
|
|
1438
|
-
value = value.reduce((processed, v) => {
|
|
1439
|
-
return myParseArg(declaredArg, v, processed);
|
|
1440
|
-
}, declaredArg.defaultValue);
|
|
1441
|
-
}
|
|
1442
|
-
} else if (value === undefined) {
|
|
1443
|
-
value = [];
|
|
1444
|
-
}
|
|
1445
|
-
} else if (index < this.args.length) {
|
|
1446
|
-
value = this.args[index];
|
|
1447
|
-
if (declaredArg.parseArg) {
|
|
1448
|
-
value = myParseArg(declaredArg, value, declaredArg.defaultValue);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
processedArgs[index] = value;
|
|
1452
|
-
});
|
|
1453
|
-
this.processedArgs = processedArgs;
|
|
1454
|
-
}
|
|
1455
|
-
_chainOrCall(promise, fn) {
|
|
1456
|
-
if (promise && promise.then && typeof promise.then === "function") {
|
|
1457
|
-
return promise.then(() => fn());
|
|
1458
|
-
}
|
|
1459
|
-
return fn();
|
|
1460
|
-
}
|
|
1461
|
-
_chainOrCallHooks(promise, event) {
|
|
1462
|
-
let result = promise;
|
|
1463
|
-
const hooks = [];
|
|
1464
|
-
this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
|
|
1465
|
-
hookedCommand._lifeCycleHooks[event].forEach((callback) => {
|
|
1466
|
-
hooks.push({ hookedCommand, callback });
|
|
1467
|
-
});
|
|
1468
|
-
});
|
|
1469
|
-
if (event === "postAction") {
|
|
1470
|
-
hooks.reverse();
|
|
1471
|
-
}
|
|
1472
|
-
hooks.forEach((hookDetail) => {
|
|
1473
|
-
result = this._chainOrCall(result, () => {
|
|
1474
|
-
return hookDetail.callback(hookDetail.hookedCommand, this);
|
|
1475
|
-
});
|
|
1476
|
-
});
|
|
1477
|
-
return result;
|
|
1478
|
-
}
|
|
1479
|
-
_chainOrCallSubCommandHook(promise, subCommand, event) {
|
|
1480
|
-
let result = promise;
|
|
1481
|
-
if (this._lifeCycleHooks[event] !== undefined) {
|
|
1482
|
-
this._lifeCycleHooks[event].forEach((hook) => {
|
|
1483
|
-
result = this._chainOrCall(result, () => {
|
|
1484
|
-
return hook(this, subCommand);
|
|
1485
|
-
});
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
return result;
|
|
1489
|
-
}
|
|
1490
|
-
_parseCommand(operands, unknown) {
|
|
1491
|
-
const parsed = this.parseOptions(unknown);
|
|
1492
|
-
this._parseOptionsEnv();
|
|
1493
|
-
this._parseOptionsImplied();
|
|
1494
|
-
operands = operands.concat(parsed.operands);
|
|
1495
|
-
unknown = parsed.unknown;
|
|
1496
|
-
this.args = operands.concat(unknown);
|
|
1497
|
-
if (operands && this._findCommand(operands[0])) {
|
|
1498
|
-
return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
|
|
1499
|
-
}
|
|
1500
|
-
if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
|
|
1501
|
-
return this._dispatchHelpCommand(operands[1]);
|
|
1502
|
-
}
|
|
1503
|
-
if (this._defaultCommandName) {
|
|
1504
|
-
this._outputHelpIfRequested(unknown);
|
|
1505
|
-
return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
|
|
1506
|
-
}
|
|
1507
|
-
if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
|
|
1508
|
-
this.help({ error: true });
|
|
1509
|
-
}
|
|
1510
|
-
this._outputHelpIfRequested(parsed.unknown);
|
|
1511
|
-
this._checkForMissingMandatoryOptions();
|
|
1512
|
-
this._checkForConflictingOptions();
|
|
1513
|
-
const checkForUnknownOptions = () => {
|
|
1514
|
-
if (parsed.unknown.length > 0) {
|
|
1515
|
-
this.unknownOption(parsed.unknown[0]);
|
|
1516
|
-
}
|
|
1517
|
-
};
|
|
1518
|
-
const commandEvent = `command:${this.name()}`;
|
|
1519
|
-
if (this._actionHandler) {
|
|
1520
|
-
checkForUnknownOptions();
|
|
1521
|
-
this._processArguments();
|
|
1522
|
-
let promiseChain;
|
|
1523
|
-
promiseChain = this._chainOrCallHooks(promiseChain, "preAction");
|
|
1524
|
-
promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
|
|
1525
|
-
if (this.parent) {
|
|
1526
|
-
promiseChain = this._chainOrCall(promiseChain, () => {
|
|
1527
|
-
this.parent.emit(commandEvent, operands, unknown);
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
promiseChain = this._chainOrCallHooks(promiseChain, "postAction");
|
|
1531
|
-
return promiseChain;
|
|
1532
|
-
}
|
|
1533
|
-
if (this.parent && this.parent.listenerCount(commandEvent)) {
|
|
1534
|
-
checkForUnknownOptions();
|
|
1535
|
-
this._processArguments();
|
|
1536
|
-
this.parent.emit(commandEvent, operands, unknown);
|
|
1537
|
-
} else if (operands.length) {
|
|
1538
|
-
if (this._findCommand("*")) {
|
|
1539
|
-
return this._dispatchSubcommand("*", operands, unknown);
|
|
1540
|
-
}
|
|
1541
|
-
if (this.listenerCount("command:*")) {
|
|
1542
|
-
this.emit("command:*", operands, unknown);
|
|
1543
|
-
} else if (this.commands.length) {
|
|
1544
|
-
this.unknownCommand();
|
|
1545
|
-
} else {
|
|
1546
|
-
checkForUnknownOptions();
|
|
1547
|
-
this._processArguments();
|
|
1548
|
-
}
|
|
1549
|
-
} else if (this.commands.length) {
|
|
1550
|
-
checkForUnknownOptions();
|
|
1551
|
-
this.help({ error: true });
|
|
1552
|
-
} else {
|
|
1553
|
-
checkForUnknownOptions();
|
|
1554
|
-
this._processArguments();
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
_findCommand(name) {
|
|
1558
|
-
if (!name)
|
|
1559
|
-
return;
|
|
1560
|
-
return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
|
|
1561
|
-
}
|
|
1562
|
-
_findOption(arg) {
|
|
1563
|
-
return this.options.find((option) => option.is(arg));
|
|
1564
|
-
}
|
|
1565
|
-
_checkForMissingMandatoryOptions() {
|
|
1566
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1567
|
-
cmd.options.forEach((anOption) => {
|
|
1568
|
-
if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) {
|
|
1569
|
-
cmd.missingMandatoryOptionValue(anOption);
|
|
1570
|
-
}
|
|
1571
|
-
});
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
_checkForConflictingLocalOptions() {
|
|
1575
|
-
const definedNonDefaultOptions = this.options.filter((option) => {
|
|
1576
|
-
const optionKey = option.attributeName();
|
|
1577
|
-
if (this.getOptionValue(optionKey) === undefined) {
|
|
1578
|
-
return false;
|
|
1579
|
-
}
|
|
1580
|
-
return this.getOptionValueSource(optionKey) !== "default";
|
|
1581
|
-
});
|
|
1582
|
-
const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0);
|
|
1583
|
-
optionsWithConflicting.forEach((option) => {
|
|
1584
|
-
const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName()));
|
|
1585
|
-
if (conflictingAndDefined) {
|
|
1586
|
-
this._conflictingOption(option, conflictingAndDefined);
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
_checkForConflictingOptions() {
|
|
1591
|
-
this._getCommandAndAncestors().forEach((cmd) => {
|
|
1592
|
-
cmd._checkForConflictingLocalOptions();
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
|
-
parseOptions(argv) {
|
|
1596
|
-
const operands = [];
|
|
1597
|
-
const unknown = [];
|
|
1598
|
-
let dest = operands;
|
|
1599
|
-
const args = argv.slice();
|
|
1600
|
-
function maybeOption(arg) {
|
|
1601
|
-
return arg.length > 1 && arg[0] === "-";
|
|
1602
|
-
}
|
|
1603
|
-
const negativeNumberArg = (arg) => {
|
|
1604
|
-
if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg))
|
|
1605
|
-
return false;
|
|
1606
|
-
return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
|
|
1607
|
-
};
|
|
1608
|
-
let activeVariadicOption = null;
|
|
1609
|
-
while (args.length) {
|
|
1610
|
-
const arg = args.shift();
|
|
1611
|
-
if (arg === "--") {
|
|
1612
|
-
if (dest === unknown)
|
|
1613
|
-
dest.push(arg);
|
|
1614
|
-
dest.push(...args);
|
|
1615
|
-
break;
|
|
1616
|
-
}
|
|
1617
|
-
if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) {
|
|
1618
|
-
this.emit(`option:${activeVariadicOption.name()}`, arg);
|
|
1619
|
-
continue;
|
|
1620
|
-
}
|
|
1621
|
-
activeVariadicOption = null;
|
|
1622
|
-
if (maybeOption(arg)) {
|
|
1623
|
-
const option = this._findOption(arg);
|
|
1624
|
-
if (option) {
|
|
1625
|
-
if (option.required) {
|
|
1626
|
-
const value = args.shift();
|
|
1627
|
-
if (value === undefined)
|
|
1628
|
-
this.optionMissingArgument(option);
|
|
1629
|
-
this.emit(`option:${option.name()}`, value);
|
|
1630
|
-
} else if (option.optional) {
|
|
1631
|
-
let value = null;
|
|
1632
|
-
if (args.length > 0 && (!maybeOption(args[0]) || negativeNumberArg(args[0]))) {
|
|
1633
|
-
value = args.shift();
|
|
1634
|
-
}
|
|
1635
|
-
this.emit(`option:${option.name()}`, value);
|
|
1636
|
-
} else {
|
|
1637
|
-
this.emit(`option:${option.name()}`);
|
|
1638
|
-
}
|
|
1639
|
-
activeVariadicOption = option.variadic ? option : null;
|
|
1640
|
-
continue;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
|
|
1644
|
-
const option = this._findOption(`-${arg[1]}`);
|
|
1645
|
-
if (option) {
|
|
1646
|
-
if (option.required || option.optional && this._combineFlagAndOptionalValue) {
|
|
1647
|
-
this.emit(`option:${option.name()}`, arg.slice(2));
|
|
1648
|
-
} else {
|
|
1649
|
-
this.emit(`option:${option.name()}`);
|
|
1650
|
-
args.unshift(`-${arg.slice(2)}`);
|
|
1651
|
-
}
|
|
1652
|
-
continue;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
if (/^--[^=]+=/.test(arg)) {
|
|
1656
|
-
const index = arg.indexOf("=");
|
|
1657
|
-
const option = this._findOption(arg.slice(0, index));
|
|
1658
|
-
if (option && (option.required || option.optional)) {
|
|
1659
|
-
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
1660
|
-
continue;
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) {
|
|
1664
|
-
dest = unknown;
|
|
1665
|
-
}
|
|
1666
|
-
if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
|
|
1667
|
-
if (this._findCommand(arg)) {
|
|
1668
|
-
operands.push(arg);
|
|
1669
|
-
if (args.length > 0)
|
|
1670
|
-
unknown.push(...args);
|
|
1671
|
-
break;
|
|
1672
|
-
} else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
|
|
1673
|
-
operands.push(arg);
|
|
1674
|
-
if (args.length > 0)
|
|
1675
|
-
operands.push(...args);
|
|
1676
|
-
break;
|
|
1677
|
-
} else if (this._defaultCommandName) {
|
|
1678
|
-
unknown.push(arg);
|
|
1679
|
-
if (args.length > 0)
|
|
1680
|
-
unknown.push(...args);
|
|
1681
|
-
break;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
if (this._passThroughOptions) {
|
|
1685
|
-
dest.push(arg);
|
|
1686
|
-
if (args.length > 0)
|
|
1687
|
-
dest.push(...args);
|
|
1688
|
-
break;
|
|
1689
|
-
}
|
|
1690
|
-
dest.push(arg);
|
|
1691
|
-
}
|
|
1692
|
-
return { operands, unknown };
|
|
1693
|
-
}
|
|
1694
|
-
opts() {
|
|
1695
|
-
if (this._storeOptionsAsProperties) {
|
|
1696
|
-
const result = {};
|
|
1697
|
-
const len = this.options.length;
|
|
1698
|
-
for (let i = 0;i < len; i++) {
|
|
1699
|
-
const key = this.options[i].attributeName();
|
|
1700
|
-
result[key] = key === this._versionOptionName ? this._version : this[key];
|
|
1701
|
-
}
|
|
1702
|
-
return result;
|
|
1703
|
-
}
|
|
1704
|
-
return this._optionValues;
|
|
1705
|
-
}
|
|
1706
|
-
optsWithGlobals() {
|
|
1707
|
-
return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
|
|
1708
|
-
}
|
|
1709
|
-
error(message, errorOptions) {
|
|
1710
|
-
this._outputConfiguration.outputError(`${message}
|
|
1711
|
-
`, this._outputConfiguration.writeErr);
|
|
1712
|
-
if (typeof this._showHelpAfterError === "string") {
|
|
1713
|
-
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1714
|
-
`);
|
|
1715
|
-
} else if (this._showHelpAfterError) {
|
|
1716
|
-
this._outputConfiguration.writeErr(`
|
|
1717
|
-
`);
|
|
1718
|
-
this.outputHelp({ error: true });
|
|
1719
|
-
}
|
|
1720
|
-
const config = errorOptions || {};
|
|
1721
|
-
const exitCode = config.exitCode || 1;
|
|
1722
|
-
const code = config.code || "commander.error";
|
|
1723
|
-
this._exit(exitCode, code, message);
|
|
1724
|
-
}
|
|
1725
|
-
_parseOptionsEnv() {
|
|
1726
|
-
this.options.forEach((option) => {
|
|
1727
|
-
if (option.envVar && option.envVar in process2.env) {
|
|
1728
|
-
const optionKey = option.attributeName();
|
|
1729
|
-
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1730
|
-
if (option.required || option.optional) {
|
|
1731
|
-
this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
|
|
1732
|
-
} else {
|
|
1733
|
-
this.emit(`optionEnv:${option.name()}`);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
_parseOptionsImplied() {
|
|
1740
|
-
const dualHelper = new DualOptions(this.options);
|
|
1741
|
-
const hasCustomOptionValue = (optionKey) => {
|
|
1742
|
-
return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
|
|
1743
|
-
};
|
|
1744
|
-
this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => {
|
|
1745
|
-
Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
|
|
1746
|
-
this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied");
|
|
1747
|
-
});
|
|
1748
|
-
});
|
|
1749
|
-
}
|
|
1750
|
-
missingArgument(name) {
|
|
1751
|
-
const message = `error: missing required argument '${name}'`;
|
|
1752
|
-
this.error(message, { code: "commander.missingArgument" });
|
|
1753
|
-
}
|
|
1754
|
-
optionMissingArgument(option) {
|
|
1755
|
-
const message = `error: option '${option.flags}' argument missing`;
|
|
1756
|
-
this.error(message, { code: "commander.optionMissingArgument" });
|
|
1757
|
-
}
|
|
1758
|
-
missingMandatoryOptionValue(option) {
|
|
1759
|
-
const message = `error: required option '${option.flags}' not specified`;
|
|
1760
|
-
this.error(message, { code: "commander.missingMandatoryOptionValue" });
|
|
1761
|
-
}
|
|
1762
|
-
_conflictingOption(option, conflictingOption) {
|
|
1763
|
-
const findBestOptionFromValue = (option2) => {
|
|
1764
|
-
const optionKey = option2.attributeName();
|
|
1765
|
-
const optionValue = this.getOptionValue(optionKey);
|
|
1766
|
-
const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
|
|
1767
|
-
const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
|
|
1768
|
-
if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
|
|
1769
|
-
return negativeOption;
|
|
1770
|
-
}
|
|
1771
|
-
return positiveOption || option2;
|
|
1772
|
-
};
|
|
1773
|
-
const getErrorMessage = (option2) => {
|
|
1774
|
-
const bestOption = findBestOptionFromValue(option2);
|
|
1775
|
-
const optionKey = bestOption.attributeName();
|
|
1776
|
-
const source = this.getOptionValueSource(optionKey);
|
|
1777
|
-
if (source === "env") {
|
|
1778
|
-
return `environment variable '${bestOption.envVar}'`;
|
|
1779
|
-
}
|
|
1780
|
-
return `option '${bestOption.flags}'`;
|
|
1781
|
-
};
|
|
1782
|
-
const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;
|
|
1783
|
-
this.error(message, { code: "commander.conflictingOption" });
|
|
1784
|
-
}
|
|
1785
|
-
unknownOption(flag) {
|
|
1786
|
-
if (this._allowUnknownOption)
|
|
1787
|
-
return;
|
|
1788
|
-
let suggestion = "";
|
|
1789
|
-
if (flag.startsWith("--") && this._showSuggestionAfterError) {
|
|
1790
|
-
let candidateFlags = [];
|
|
1791
|
-
let command = this;
|
|
1792
|
-
do {
|
|
1793
|
-
const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long);
|
|
1794
|
-
candidateFlags = candidateFlags.concat(moreFlags);
|
|
1795
|
-
command = command.parent;
|
|
1796
|
-
} while (command && !command._enablePositionalOptions);
|
|
1797
|
-
suggestion = suggestSimilar(flag, candidateFlags);
|
|
1798
|
-
}
|
|
1799
|
-
const message = `error: unknown option '${flag}'${suggestion}`;
|
|
1800
|
-
this.error(message, { code: "commander.unknownOption" });
|
|
1801
|
-
}
|
|
1802
|
-
_excessArguments(receivedArgs) {
|
|
1803
|
-
if (this._allowExcessArguments)
|
|
1804
|
-
return;
|
|
1805
|
-
const expected = this.registeredArguments.length;
|
|
1806
|
-
const s = expected === 1 ? "" : "s";
|
|
1807
|
-
const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
|
|
1808
|
-
const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
|
|
1809
|
-
this.error(message, { code: "commander.excessArguments" });
|
|
1810
|
-
}
|
|
1811
|
-
unknownCommand() {
|
|
1812
|
-
const unknownName = this.args[0];
|
|
1813
|
-
let suggestion = "";
|
|
1814
|
-
if (this._showSuggestionAfterError) {
|
|
1815
|
-
const candidateNames = [];
|
|
1816
|
-
this.createHelp().visibleCommands(this).forEach((command) => {
|
|
1817
|
-
candidateNames.push(command.name());
|
|
1818
|
-
if (command.alias())
|
|
1819
|
-
candidateNames.push(command.alias());
|
|
1820
|
-
});
|
|
1821
|
-
suggestion = suggestSimilar(unknownName, candidateNames);
|
|
1822
|
-
}
|
|
1823
|
-
const message = `error: unknown command '${unknownName}'${suggestion}`;
|
|
1824
|
-
this.error(message, { code: "commander.unknownCommand" });
|
|
1825
|
-
}
|
|
1826
|
-
version(str, flags, description) {
|
|
1827
|
-
if (str === undefined)
|
|
1828
|
-
return this._version;
|
|
1829
|
-
this._version = str;
|
|
1830
|
-
flags = flags || "-V, --version";
|
|
1831
|
-
description = description || "output the version number";
|
|
1832
|
-
const versionOption = this.createOption(flags, description);
|
|
1833
|
-
this._versionOptionName = versionOption.attributeName();
|
|
1834
|
-
this._registerOption(versionOption);
|
|
1835
|
-
this.on("option:" + versionOption.name(), () => {
|
|
1836
|
-
this._outputConfiguration.writeOut(`${str}
|
|
1837
|
-
`);
|
|
1838
|
-
this._exit(0, "commander.version", str);
|
|
1839
|
-
});
|
|
1840
|
-
return this;
|
|
1841
|
-
}
|
|
1842
|
-
description(str, argsDescription) {
|
|
1843
|
-
if (str === undefined && argsDescription === undefined)
|
|
1844
|
-
return this._description;
|
|
1845
|
-
this._description = str;
|
|
1846
|
-
if (argsDescription) {
|
|
1847
|
-
this._argsDescription = argsDescription;
|
|
1848
|
-
}
|
|
1849
|
-
return this;
|
|
1850
|
-
}
|
|
1851
|
-
summary(str) {
|
|
1852
|
-
if (str === undefined)
|
|
1853
|
-
return this._summary;
|
|
1854
|
-
this._summary = str;
|
|
1855
|
-
return this;
|
|
1856
|
-
}
|
|
1857
|
-
alias(alias) {
|
|
1858
|
-
if (alias === undefined)
|
|
1859
|
-
return this._aliases[0];
|
|
1860
|
-
let command = this;
|
|
1861
|
-
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
|
|
1862
|
-
command = this.commands[this.commands.length - 1];
|
|
1863
|
-
}
|
|
1864
|
-
if (alias === command._name)
|
|
1865
|
-
throw new Error("Command alias can't be the same as its name");
|
|
1866
|
-
const matchingCommand = this.parent?._findCommand(alias);
|
|
1867
|
-
if (matchingCommand) {
|
|
1868
|
-
const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|");
|
|
1869
|
-
throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
|
|
1870
|
-
}
|
|
1871
|
-
command._aliases.push(alias);
|
|
1872
|
-
return this;
|
|
1873
|
-
}
|
|
1874
|
-
aliases(aliases) {
|
|
1875
|
-
if (aliases === undefined)
|
|
1876
|
-
return this._aliases;
|
|
1877
|
-
aliases.forEach((alias) => this.alias(alias));
|
|
1878
|
-
return this;
|
|
1879
|
-
}
|
|
1880
|
-
usage(str) {
|
|
1881
|
-
if (str === undefined) {
|
|
1882
|
-
if (this._usage)
|
|
1883
|
-
return this._usage;
|
|
1884
|
-
const args = this.registeredArguments.map((arg) => {
|
|
1885
|
-
return humanReadableArgName(arg);
|
|
1886
|
-
});
|
|
1887
|
-
return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" ");
|
|
1888
|
-
}
|
|
1889
|
-
this._usage = str;
|
|
1890
|
-
return this;
|
|
1891
|
-
}
|
|
1892
|
-
name(str) {
|
|
1893
|
-
if (str === undefined)
|
|
1894
|
-
return this._name;
|
|
1895
|
-
this._name = str;
|
|
1896
|
-
return this;
|
|
1897
|
-
}
|
|
1898
|
-
helpGroup(heading) {
|
|
1899
|
-
if (heading === undefined)
|
|
1900
|
-
return this._helpGroupHeading ?? "";
|
|
1901
|
-
this._helpGroupHeading = heading;
|
|
1902
|
-
return this;
|
|
1903
|
-
}
|
|
1904
|
-
commandsGroup(heading) {
|
|
1905
|
-
if (heading === undefined)
|
|
1906
|
-
return this._defaultCommandGroup ?? "";
|
|
1907
|
-
this._defaultCommandGroup = heading;
|
|
1908
|
-
return this;
|
|
1909
|
-
}
|
|
1910
|
-
optionsGroup(heading) {
|
|
1911
|
-
if (heading === undefined)
|
|
1912
|
-
return this._defaultOptionGroup ?? "";
|
|
1913
|
-
this._defaultOptionGroup = heading;
|
|
1914
|
-
return this;
|
|
1915
|
-
}
|
|
1916
|
-
_initOptionGroup(option) {
|
|
1917
|
-
if (this._defaultOptionGroup && !option.helpGroupHeading)
|
|
1918
|
-
option.helpGroup(this._defaultOptionGroup);
|
|
1919
|
-
}
|
|
1920
|
-
_initCommandGroup(cmd) {
|
|
1921
|
-
if (this._defaultCommandGroup && !cmd.helpGroup())
|
|
1922
|
-
cmd.helpGroup(this._defaultCommandGroup);
|
|
1923
|
-
}
|
|
1924
|
-
nameFromFilename(filename) {
|
|
1925
|
-
this._name = path.basename(filename, path.extname(filename));
|
|
1926
|
-
return this;
|
|
1927
|
-
}
|
|
1928
|
-
executableDir(path2) {
|
|
1929
|
-
if (path2 === undefined)
|
|
1930
|
-
return this._executableDir;
|
|
1931
|
-
this._executableDir = path2;
|
|
1932
|
-
return this;
|
|
1933
|
-
}
|
|
1934
|
-
helpInformation(contextOptions) {
|
|
1935
|
-
const helper = this.createHelp();
|
|
1936
|
-
const context = this._getOutputContext(contextOptions);
|
|
1937
|
-
helper.prepareContext({
|
|
1938
|
-
error: context.error,
|
|
1939
|
-
helpWidth: context.helpWidth,
|
|
1940
|
-
outputHasColors: context.hasColors
|
|
1941
|
-
});
|
|
1942
|
-
const text = helper.formatHelp(this, helper);
|
|
1943
|
-
if (context.hasColors)
|
|
1944
|
-
return text;
|
|
1945
|
-
return this._outputConfiguration.stripColor(text);
|
|
1946
|
-
}
|
|
1947
|
-
_getOutputContext(contextOptions) {
|
|
1948
|
-
contextOptions = contextOptions || {};
|
|
1949
|
-
const error = !!contextOptions.error;
|
|
1950
|
-
let baseWrite;
|
|
1951
|
-
let hasColors;
|
|
1952
|
-
let helpWidth;
|
|
1953
|
-
if (error) {
|
|
1954
|
-
baseWrite = (str) => this._outputConfiguration.writeErr(str);
|
|
1955
|
-
hasColors = this._outputConfiguration.getErrHasColors();
|
|
1956
|
-
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
1957
|
-
} else {
|
|
1958
|
-
baseWrite = (str) => this._outputConfiguration.writeOut(str);
|
|
1959
|
-
hasColors = this._outputConfiguration.getOutHasColors();
|
|
1960
|
-
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
1961
|
-
}
|
|
1962
|
-
const write = (str) => {
|
|
1963
|
-
if (!hasColors)
|
|
1964
|
-
str = this._outputConfiguration.stripColor(str);
|
|
1965
|
-
return baseWrite(str);
|
|
1966
|
-
};
|
|
1967
|
-
return { error, write, hasColors, helpWidth };
|
|
1968
|
-
}
|
|
1969
|
-
outputHelp(contextOptions) {
|
|
1970
|
-
let deprecatedCallback;
|
|
1971
|
-
if (typeof contextOptions === "function") {
|
|
1972
|
-
deprecatedCallback = contextOptions;
|
|
1973
|
-
contextOptions = undefined;
|
|
1974
|
-
}
|
|
1975
|
-
const outputContext = this._getOutputContext(contextOptions);
|
|
1976
|
-
const eventContext = {
|
|
1977
|
-
error: outputContext.error,
|
|
1978
|
-
write: outputContext.write,
|
|
1979
|
-
command: this
|
|
1980
|
-
};
|
|
1981
|
-
this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext));
|
|
1982
|
-
this.emit("beforeHelp", eventContext);
|
|
1983
|
-
let helpInformation = this.helpInformation({ error: outputContext.error });
|
|
1984
|
-
if (deprecatedCallback) {
|
|
1985
|
-
helpInformation = deprecatedCallback(helpInformation);
|
|
1986
|
-
if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
|
|
1987
|
-
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
outputContext.write(helpInformation);
|
|
1991
|
-
if (this._getHelpOption()?.long) {
|
|
1992
|
-
this.emit(this._getHelpOption().long);
|
|
1993
|
-
}
|
|
1994
|
-
this.emit("afterHelp", eventContext);
|
|
1995
|
-
this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", eventContext));
|
|
1996
|
-
}
|
|
1997
|
-
helpOption(flags, description) {
|
|
1998
|
-
if (typeof flags === "boolean") {
|
|
1999
|
-
if (flags) {
|
|
2000
|
-
if (this._helpOption === null)
|
|
2001
|
-
this._helpOption = undefined;
|
|
2002
|
-
if (this._defaultOptionGroup) {
|
|
2003
|
-
this._initOptionGroup(this._getHelpOption());
|
|
2004
|
-
}
|
|
2005
|
-
} else {
|
|
2006
|
-
this._helpOption = null;
|
|
2007
|
-
}
|
|
2008
|
-
return this;
|
|
2009
|
-
}
|
|
2010
|
-
this._helpOption = this.createOption(flags ?? "-h, --help", description ?? "display help for command");
|
|
2011
|
-
if (flags || description)
|
|
2012
|
-
this._initOptionGroup(this._helpOption);
|
|
2013
|
-
return this;
|
|
2014
|
-
}
|
|
2015
|
-
_getHelpOption() {
|
|
2016
|
-
if (this._helpOption === undefined) {
|
|
2017
|
-
this.helpOption(undefined, undefined);
|
|
2018
|
-
}
|
|
2019
|
-
return this._helpOption;
|
|
2020
|
-
}
|
|
2021
|
-
addHelpOption(option) {
|
|
2022
|
-
this._helpOption = option;
|
|
2023
|
-
this._initOptionGroup(option);
|
|
2024
|
-
return this;
|
|
2025
|
-
}
|
|
2026
|
-
help(contextOptions) {
|
|
2027
|
-
this.outputHelp(contextOptions);
|
|
2028
|
-
let exitCode = Number(process2.exitCode ?? 0);
|
|
2029
|
-
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
2030
|
-
exitCode = 1;
|
|
2031
|
-
}
|
|
2032
|
-
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
2033
|
-
}
|
|
2034
|
-
addHelpText(position, text) {
|
|
2035
|
-
const allowedValues = ["beforeAll", "before", "after", "afterAll"];
|
|
2036
|
-
if (!allowedValues.includes(position)) {
|
|
2037
|
-
throw new Error(`Unexpected value for position to addHelpText.
|
|
2038
|
-
Expecting one of '${allowedValues.join("', '")}'`);
|
|
2039
|
-
}
|
|
2040
|
-
const helpEvent = `${position}Help`;
|
|
2041
|
-
this.on(helpEvent, (context) => {
|
|
2042
|
-
let helpStr;
|
|
2043
|
-
if (typeof text === "function") {
|
|
2044
|
-
helpStr = text({ error: context.error, command: context.command });
|
|
2045
|
-
} else {
|
|
2046
|
-
helpStr = text;
|
|
2047
|
-
}
|
|
2048
|
-
if (helpStr) {
|
|
2049
|
-
context.write(`${helpStr}
|
|
2050
|
-
`);
|
|
2051
|
-
}
|
|
2052
|
-
});
|
|
2053
|
-
return this;
|
|
2054
|
-
}
|
|
2055
|
-
_outputHelpIfRequested(args) {
|
|
2056
|
-
const helpOption = this._getHelpOption();
|
|
2057
|
-
const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
|
|
2058
|
-
if (helpRequested) {
|
|
2059
|
-
this.outputHelp();
|
|
2060
|
-
this._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
function incrementNodeInspectorPort(args) {
|
|
2065
|
-
return args.map((arg) => {
|
|
2066
|
-
if (!arg.startsWith("--inspect")) {
|
|
2067
|
-
return arg;
|
|
2068
|
-
}
|
|
2069
|
-
let debugOption;
|
|
2070
|
-
let debugHost = "127.0.0.1";
|
|
2071
|
-
let debugPort = "9229";
|
|
2072
|
-
let match;
|
|
2073
|
-
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
2074
|
-
debugOption = match[1];
|
|
2075
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
2076
|
-
debugOption = match[1];
|
|
2077
|
-
if (/^\d+$/.test(match[3])) {
|
|
2078
|
-
debugPort = match[3];
|
|
2079
|
-
} else {
|
|
2080
|
-
debugHost = match[3];
|
|
2081
|
-
}
|
|
2082
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
2083
|
-
debugOption = match[1];
|
|
2084
|
-
debugHost = match[3];
|
|
2085
|
-
debugPort = match[4];
|
|
2086
|
-
}
|
|
2087
|
-
if (debugOption && debugPort !== "0") {
|
|
2088
|
-
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
2089
|
-
}
|
|
2090
|
-
return arg;
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
|
-
function useColor() {
|
|
2094
|
-
if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false")
|
|
2095
|
-
return false;
|
|
2096
|
-
if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== undefined)
|
|
2097
|
-
return true;
|
|
2098
|
-
return;
|
|
2099
|
-
}
|
|
2100
|
-
exports.Command = Command;
|
|
2101
|
-
exports.useColor = useColor;
|
|
2102
|
-
});
|
|
2103
|
-
|
|
2104
|
-
// node_modules/commander/index.js
|
|
2105
|
-
var require_commander = __commonJS((exports) => {
|
|
2106
|
-
var { Argument } = require_argument();
|
|
2107
|
-
var { Command } = require_command();
|
|
2108
|
-
var { CommanderError, InvalidArgumentError } = require_error();
|
|
2109
|
-
var { Help } = require_help();
|
|
2110
|
-
var { Option } = require_option();
|
|
2111
|
-
exports.program = new Command;
|
|
2112
|
-
exports.createCommand = (name) => new Command(name);
|
|
2113
|
-
exports.createOption = (flags, description) => new Option(flags, description);
|
|
2114
|
-
exports.createArgument = (name, description) => new Argument(name, description);
|
|
2115
|
-
exports.Command = Command;
|
|
2116
|
-
exports.Option = Option;
|
|
2117
|
-
exports.Argument = Argument;
|
|
2118
|
-
exports.Help = Help;
|
|
2119
|
-
exports.CommanderError = CommanderError;
|
|
2120
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2121
|
-
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2122
|
-
});
|
|
2123
|
-
|
|
2124
|
-
// node_modules/universalify/index.js
|
|
2125
|
-
var require_universalify = __commonJS((exports) => {
|
|
2126
|
-
exports.fromCallback = function(fn) {
|
|
2127
|
-
return Object.defineProperty(function(...args) {
|
|
2128
|
-
if (typeof args[args.length - 1] === "function")
|
|
2129
|
-
fn.apply(this, args);
|
|
2130
|
-
else {
|
|
2131
|
-
return new Promise((resolve, reject) => {
|
|
2132
|
-
args.push((err, res) => err != null ? reject(err) : resolve(res));
|
|
2133
|
-
fn.apply(this, args);
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
}, "name", { value: fn.name });
|
|
2137
|
-
};
|
|
2138
|
-
exports.fromPromise = function(fn) {
|
|
2139
|
-
return Object.defineProperty(function(...args) {
|
|
2140
|
-
const cb = args[args.length - 1];
|
|
2141
|
-
if (typeof cb !== "function")
|
|
2142
|
-
return fn.apply(this, args);
|
|
2143
|
-
else {
|
|
2144
|
-
args.pop();
|
|
2145
|
-
fn.apply(this, args).then((r) => cb(null, r), cb);
|
|
2146
|
-
}
|
|
2147
|
-
}, "name", { value: fn.name });
|
|
2148
|
-
};
|
|
2149
|
-
});
|
|
2150
|
-
|
|
2151
|
-
// node_modules/graceful-fs/polyfills.js
|
|
2152
|
-
var require_polyfills = __commonJS((exports, module) => {
|
|
2153
|
-
var constants = __require("constants");
|
|
2154
|
-
var origCwd = process.cwd;
|
|
2155
|
-
var cwd = null;
|
|
2156
|
-
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
2157
|
-
process.cwd = function() {
|
|
2158
|
-
if (!cwd)
|
|
2159
|
-
cwd = origCwd.call(process);
|
|
2160
|
-
return cwd;
|
|
2161
|
-
};
|
|
2162
|
-
try {
|
|
2163
|
-
process.cwd();
|
|
2164
|
-
} catch (er) {}
|
|
2165
|
-
if (typeof process.chdir === "function") {
|
|
2166
|
-
chdir = process.chdir;
|
|
2167
|
-
process.chdir = function(d) {
|
|
2168
|
-
cwd = null;
|
|
2169
|
-
chdir.call(process, d);
|
|
2170
|
-
};
|
|
2171
|
-
if (Object.setPrototypeOf)
|
|
2172
|
-
Object.setPrototypeOf(process.chdir, chdir);
|
|
2173
|
-
}
|
|
2174
|
-
var chdir;
|
|
2175
|
-
module.exports = patch;
|
|
2176
|
-
function patch(fs) {
|
|
2177
|
-
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
2178
|
-
patchLchmod(fs);
|
|
2179
|
-
}
|
|
2180
|
-
if (!fs.lutimes) {
|
|
2181
|
-
patchLutimes(fs);
|
|
2182
|
-
}
|
|
2183
|
-
fs.chown = chownFix(fs.chown);
|
|
2184
|
-
fs.fchown = chownFix(fs.fchown);
|
|
2185
|
-
fs.lchown = chownFix(fs.lchown);
|
|
2186
|
-
fs.chmod = chmodFix(fs.chmod);
|
|
2187
|
-
fs.fchmod = chmodFix(fs.fchmod);
|
|
2188
|
-
fs.lchmod = chmodFix(fs.lchmod);
|
|
2189
|
-
fs.chownSync = chownFixSync(fs.chownSync);
|
|
2190
|
-
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
2191
|
-
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
2192
|
-
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
2193
|
-
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
2194
|
-
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
2195
|
-
fs.stat = statFix(fs.stat);
|
|
2196
|
-
fs.fstat = statFix(fs.fstat);
|
|
2197
|
-
fs.lstat = statFix(fs.lstat);
|
|
2198
|
-
fs.statSync = statFixSync(fs.statSync);
|
|
2199
|
-
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
2200
|
-
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
2201
|
-
if (fs.chmod && !fs.lchmod) {
|
|
2202
|
-
fs.lchmod = function(path, mode, cb) {
|
|
2203
|
-
if (cb)
|
|
2204
|
-
process.nextTick(cb);
|
|
2205
|
-
};
|
|
2206
|
-
fs.lchmodSync = function() {};
|
|
2207
|
-
}
|
|
2208
|
-
if (fs.chown && !fs.lchown) {
|
|
2209
|
-
fs.lchown = function(path, uid, gid, cb) {
|
|
2210
|
-
if (cb)
|
|
2211
|
-
process.nextTick(cb);
|
|
2212
|
-
};
|
|
2213
|
-
fs.lchownSync = function() {};
|
|
2214
|
-
}
|
|
2215
|
-
if (platform === "win32") {
|
|
2216
|
-
fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
|
|
2217
|
-
function rename(from, to, cb) {
|
|
2218
|
-
var start = Date.now();
|
|
2219
|
-
var backoff = 0;
|
|
2220
|
-
fs$rename(from, to, function CB(er) {
|
|
2221
|
-
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
|
|
2222
|
-
setTimeout(function() {
|
|
2223
|
-
fs.stat(to, function(stater, st) {
|
|
2224
|
-
if (stater && stater.code === "ENOENT")
|
|
2225
|
-
fs$rename(from, to, CB);
|
|
2226
|
-
else
|
|
2227
|
-
cb(er);
|
|
2228
|
-
});
|
|
2229
|
-
}, backoff);
|
|
2230
|
-
if (backoff < 100)
|
|
2231
|
-
backoff += 10;
|
|
2232
|
-
return;
|
|
2233
|
-
}
|
|
2234
|
-
if (cb)
|
|
2235
|
-
cb(er);
|
|
2236
|
-
});
|
|
2237
|
-
}
|
|
2238
|
-
if (Object.setPrototypeOf)
|
|
2239
|
-
Object.setPrototypeOf(rename, fs$rename);
|
|
2240
|
-
return rename;
|
|
2241
|
-
}(fs.rename);
|
|
2242
|
-
}
|
|
2243
|
-
fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
|
|
2244
|
-
function read(fd, buffer, offset, length, position, callback_) {
|
|
2245
|
-
var callback;
|
|
2246
|
-
if (callback_ && typeof callback_ === "function") {
|
|
2247
|
-
var eagCounter = 0;
|
|
2248
|
-
callback = function(er, _, __) {
|
|
2249
|
-
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
2250
|
-
eagCounter++;
|
|
2251
|
-
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
2252
|
-
}
|
|
2253
|
-
callback_.apply(this, arguments);
|
|
2254
|
-
};
|
|
2255
|
-
}
|
|
2256
|
-
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
2257
|
-
}
|
|
2258
|
-
if (Object.setPrototypeOf)
|
|
2259
|
-
Object.setPrototypeOf(read, fs$read);
|
|
2260
|
-
return read;
|
|
2261
|
-
}(fs.read);
|
|
2262
|
-
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : function(fs$readSync) {
|
|
2263
|
-
return function(fd, buffer, offset, length, position) {
|
|
2264
|
-
var eagCounter = 0;
|
|
2265
|
-
while (true) {
|
|
2266
|
-
try {
|
|
2267
|
-
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
2268
|
-
} catch (er) {
|
|
2269
|
-
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
2270
|
-
eagCounter++;
|
|
2271
|
-
continue;
|
|
2272
|
-
}
|
|
2273
|
-
throw er;
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
};
|
|
2277
|
-
}(fs.readSync);
|
|
2278
|
-
function patchLchmod(fs2) {
|
|
2279
|
-
fs2.lchmod = function(path, mode, callback) {
|
|
2280
|
-
fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
2281
|
-
if (err) {
|
|
2282
|
-
if (callback)
|
|
2283
|
-
callback(err);
|
|
2284
|
-
return;
|
|
2285
|
-
}
|
|
2286
|
-
fs2.fchmod(fd, mode, function(err2) {
|
|
2287
|
-
fs2.close(fd, function(err22) {
|
|
2288
|
-
if (callback)
|
|
2289
|
-
callback(err2 || err22);
|
|
2290
|
-
});
|
|
2291
|
-
});
|
|
2292
|
-
});
|
|
2293
|
-
};
|
|
2294
|
-
fs2.lchmodSync = function(path, mode) {
|
|
2295
|
-
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
2296
|
-
var threw = true;
|
|
2297
|
-
var ret;
|
|
2298
|
-
try {
|
|
2299
|
-
ret = fs2.fchmodSync(fd, mode);
|
|
2300
|
-
threw = false;
|
|
2301
|
-
} finally {
|
|
2302
|
-
if (threw) {
|
|
2303
|
-
try {
|
|
2304
|
-
fs2.closeSync(fd);
|
|
2305
|
-
} catch (er) {}
|
|
2306
|
-
} else {
|
|
2307
|
-
fs2.closeSync(fd);
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
return ret;
|
|
2311
|
-
};
|
|
2312
|
-
}
|
|
2313
|
-
function patchLutimes(fs2) {
|
|
2314
|
-
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
2315
|
-
fs2.lutimes = function(path, at, mt, cb) {
|
|
2316
|
-
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
2317
|
-
if (er) {
|
|
2318
|
-
if (cb)
|
|
2319
|
-
cb(er);
|
|
2320
|
-
return;
|
|
2321
|
-
}
|
|
2322
|
-
fs2.futimes(fd, at, mt, function(er2) {
|
|
2323
|
-
fs2.close(fd, function(er22) {
|
|
2324
|
-
if (cb)
|
|
2325
|
-
cb(er2 || er22);
|
|
2326
|
-
});
|
|
2327
|
-
});
|
|
2328
|
-
});
|
|
2329
|
-
};
|
|
2330
|
-
fs2.lutimesSync = function(path, at, mt) {
|
|
2331
|
-
var fd = fs2.openSync(path, constants.O_SYMLINK);
|
|
2332
|
-
var ret;
|
|
2333
|
-
var threw = true;
|
|
2334
|
-
try {
|
|
2335
|
-
ret = fs2.futimesSync(fd, at, mt);
|
|
2336
|
-
threw = false;
|
|
2337
|
-
} finally {
|
|
2338
|
-
if (threw) {
|
|
2339
|
-
try {
|
|
2340
|
-
fs2.closeSync(fd);
|
|
2341
|
-
} catch (er) {}
|
|
2342
|
-
} else {
|
|
2343
|
-
fs2.closeSync(fd);
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
return ret;
|
|
2347
|
-
};
|
|
2348
|
-
} else if (fs2.futimes) {
|
|
2349
|
-
fs2.lutimes = function(_a, _b, _c, cb) {
|
|
2350
|
-
if (cb)
|
|
2351
|
-
process.nextTick(cb);
|
|
2352
|
-
};
|
|
2353
|
-
fs2.lutimesSync = function() {};
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
function chmodFix(orig) {
|
|
2357
|
-
if (!orig)
|
|
2358
|
-
return orig;
|
|
2359
|
-
return function(target, mode, cb) {
|
|
2360
|
-
return orig.call(fs, target, mode, function(er) {
|
|
2361
|
-
if (chownErOk(er))
|
|
2362
|
-
er = null;
|
|
2363
|
-
if (cb)
|
|
2364
|
-
cb.apply(this, arguments);
|
|
2365
|
-
});
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2368
|
-
function chmodFixSync(orig) {
|
|
2369
|
-
if (!orig)
|
|
2370
|
-
return orig;
|
|
2371
|
-
return function(target, mode) {
|
|
2372
|
-
try {
|
|
2373
|
-
return orig.call(fs, target, mode);
|
|
2374
|
-
} catch (er) {
|
|
2375
|
-
if (!chownErOk(er))
|
|
2376
|
-
throw er;
|
|
2377
|
-
}
|
|
2378
|
-
};
|
|
2379
|
-
}
|
|
2380
|
-
function chownFix(orig) {
|
|
2381
|
-
if (!orig)
|
|
2382
|
-
return orig;
|
|
2383
|
-
return function(target, uid, gid, cb) {
|
|
2384
|
-
return orig.call(fs, target, uid, gid, function(er) {
|
|
2385
|
-
if (chownErOk(er))
|
|
2386
|
-
er = null;
|
|
2387
|
-
if (cb)
|
|
2388
|
-
cb.apply(this, arguments);
|
|
2389
|
-
});
|
|
2390
|
-
};
|
|
2391
|
-
}
|
|
2392
|
-
function chownFixSync(orig) {
|
|
2393
|
-
if (!orig)
|
|
2394
|
-
return orig;
|
|
2395
|
-
return function(target, uid, gid) {
|
|
2396
|
-
try {
|
|
2397
|
-
return orig.call(fs, target, uid, gid);
|
|
2398
|
-
} catch (er) {
|
|
2399
|
-
if (!chownErOk(er))
|
|
2400
|
-
throw er;
|
|
2401
|
-
}
|
|
2402
|
-
};
|
|
2403
|
-
}
|
|
2404
|
-
function statFix(orig) {
|
|
2405
|
-
if (!orig)
|
|
2406
|
-
return orig;
|
|
2407
|
-
return function(target, options, cb) {
|
|
2408
|
-
if (typeof options === "function") {
|
|
2409
|
-
cb = options;
|
|
2410
|
-
options = null;
|
|
2411
|
-
}
|
|
2412
|
-
function callback(er, stats) {
|
|
2413
|
-
if (stats) {
|
|
2414
|
-
if (stats.uid < 0)
|
|
2415
|
-
stats.uid += 4294967296;
|
|
2416
|
-
if (stats.gid < 0)
|
|
2417
|
-
stats.gid += 4294967296;
|
|
2418
|
-
}
|
|
2419
|
-
if (cb)
|
|
2420
|
-
cb.apply(this, arguments);
|
|
2421
|
-
}
|
|
2422
|
-
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
2423
|
-
};
|
|
2424
|
-
}
|
|
2425
|
-
function statFixSync(orig) {
|
|
2426
|
-
if (!orig)
|
|
2427
|
-
return orig;
|
|
2428
|
-
return function(target, options) {
|
|
2429
|
-
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
2430
|
-
if (stats) {
|
|
2431
|
-
if (stats.uid < 0)
|
|
2432
|
-
stats.uid += 4294967296;
|
|
2433
|
-
if (stats.gid < 0)
|
|
2434
|
-
stats.gid += 4294967296;
|
|
2435
|
-
}
|
|
2436
|
-
return stats;
|
|
2437
|
-
};
|
|
2438
|
-
}
|
|
2439
|
-
function chownErOk(er) {
|
|
2440
|
-
if (!er)
|
|
2441
|
-
return true;
|
|
2442
|
-
if (er.code === "ENOSYS")
|
|
2443
|
-
return true;
|
|
2444
|
-
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
2445
|
-
if (nonroot) {
|
|
2446
|
-
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
2447
|
-
return true;
|
|
2448
|
-
}
|
|
2449
|
-
return false;
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
|
|
2454
|
-
// node_modules/graceful-fs/legacy-streams.js
|
|
2455
|
-
var require_legacy_streams = __commonJS((exports, module) => {
|
|
2456
|
-
var Stream = __require("stream").Stream;
|
|
2457
|
-
module.exports = legacy;
|
|
2458
|
-
function legacy(fs) {
|
|
2459
|
-
return {
|
|
2460
|
-
ReadStream,
|
|
2461
|
-
WriteStream
|
|
2462
|
-
};
|
|
2463
|
-
function ReadStream(path, options) {
|
|
2464
|
-
if (!(this instanceof ReadStream))
|
|
2465
|
-
return new ReadStream(path, options);
|
|
2466
|
-
Stream.call(this);
|
|
2467
|
-
var self = this;
|
|
2468
|
-
this.path = path;
|
|
2469
|
-
this.fd = null;
|
|
2470
|
-
this.readable = true;
|
|
2471
|
-
this.paused = false;
|
|
2472
|
-
this.flags = "r";
|
|
2473
|
-
this.mode = 438;
|
|
2474
|
-
this.bufferSize = 64 * 1024;
|
|
2475
|
-
options = options || {};
|
|
2476
|
-
var keys = Object.keys(options);
|
|
2477
|
-
for (var index = 0, length = keys.length;index < length; index++) {
|
|
2478
|
-
var key = keys[index];
|
|
2479
|
-
this[key] = options[key];
|
|
2480
|
-
}
|
|
2481
|
-
if (this.encoding)
|
|
2482
|
-
this.setEncoding(this.encoding);
|
|
2483
|
-
if (this.start !== undefined) {
|
|
2484
|
-
if (typeof this.start !== "number") {
|
|
2485
|
-
throw TypeError("start must be a Number");
|
|
2486
|
-
}
|
|
2487
|
-
if (this.end === undefined) {
|
|
2488
|
-
this.end = Infinity;
|
|
2489
|
-
} else if (typeof this.end !== "number") {
|
|
2490
|
-
throw TypeError("end must be a Number");
|
|
2491
|
-
}
|
|
2492
|
-
if (this.start > this.end) {
|
|
2493
|
-
throw new Error("start must be <= end");
|
|
2494
|
-
}
|
|
2495
|
-
this.pos = this.start;
|
|
2496
|
-
}
|
|
2497
|
-
if (this.fd !== null) {
|
|
2498
|
-
process.nextTick(function() {
|
|
2499
|
-
self._read();
|
|
2500
|
-
});
|
|
2501
|
-
return;
|
|
2502
|
-
}
|
|
2503
|
-
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
2504
|
-
if (err) {
|
|
2505
|
-
self.emit("error", err);
|
|
2506
|
-
self.readable = false;
|
|
2507
|
-
return;
|
|
2508
|
-
}
|
|
2509
|
-
self.fd = fd;
|
|
2510
|
-
self.emit("open", fd);
|
|
2511
|
-
self._read();
|
|
2512
|
-
});
|
|
2513
|
-
}
|
|
2514
|
-
function WriteStream(path, options) {
|
|
2515
|
-
if (!(this instanceof WriteStream))
|
|
2516
|
-
return new WriteStream(path, options);
|
|
2517
|
-
Stream.call(this);
|
|
2518
|
-
this.path = path;
|
|
2519
|
-
this.fd = null;
|
|
2520
|
-
this.writable = true;
|
|
2521
|
-
this.flags = "w";
|
|
2522
|
-
this.encoding = "binary";
|
|
2523
|
-
this.mode = 438;
|
|
2524
|
-
this.bytesWritten = 0;
|
|
2525
|
-
options = options || {};
|
|
2526
|
-
var keys = Object.keys(options);
|
|
2527
|
-
for (var index = 0, length = keys.length;index < length; index++) {
|
|
2528
|
-
var key = keys[index];
|
|
2529
|
-
this[key] = options[key];
|
|
2530
|
-
}
|
|
2531
|
-
if (this.start !== undefined) {
|
|
2532
|
-
if (typeof this.start !== "number") {
|
|
2533
|
-
throw TypeError("start must be a Number");
|
|
2534
|
-
}
|
|
2535
|
-
if (this.start < 0) {
|
|
2536
|
-
throw new Error("start must be >= zero");
|
|
2537
|
-
}
|
|
2538
|
-
this.pos = this.start;
|
|
2539
|
-
}
|
|
2540
|
-
this.busy = false;
|
|
2541
|
-
this._queue = [];
|
|
2542
|
-
if (this.fd === null) {
|
|
2543
|
-
this._open = fs.open;
|
|
2544
|
-
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
|
2545
|
-
this.flush();
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
});
|
|
2550
|
-
|
|
2551
|
-
// node_modules/graceful-fs/clone.js
|
|
2552
|
-
var require_clone = __commonJS((exports, module) => {
|
|
2553
|
-
module.exports = clone;
|
|
2554
|
-
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
2555
|
-
return obj.__proto__;
|
|
2556
|
-
};
|
|
2557
|
-
function clone(obj) {
|
|
2558
|
-
if (obj === null || typeof obj !== "object")
|
|
2559
|
-
return obj;
|
|
2560
|
-
if (obj instanceof Object)
|
|
2561
|
-
var copy = { __proto__: getPrototypeOf(obj) };
|
|
2562
|
-
else
|
|
2563
|
-
var copy = Object.create(null);
|
|
2564
|
-
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
2565
|
-
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
2566
|
-
});
|
|
2567
|
-
return copy;
|
|
2568
|
-
}
|
|
2569
|
-
});
|
|
2570
|
-
|
|
2571
|
-
// node_modules/graceful-fs/graceful-fs.js
|
|
2572
|
-
var require_graceful_fs = __commonJS((exports, module) => {
|
|
2573
|
-
var fs = __require("fs");
|
|
2574
|
-
var polyfills = require_polyfills();
|
|
2575
|
-
var legacy = require_legacy_streams();
|
|
2576
|
-
var clone = require_clone();
|
|
2577
|
-
var util = __require("util");
|
|
2578
|
-
var gracefulQueue;
|
|
2579
|
-
var previousSymbol;
|
|
2580
|
-
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
2581
|
-
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
2582
|
-
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
2583
|
-
} else {
|
|
2584
|
-
gracefulQueue = "___graceful-fs.queue";
|
|
2585
|
-
previousSymbol = "___graceful-fs.previous";
|
|
2586
|
-
}
|
|
2587
|
-
function noop() {}
|
|
2588
|
-
function publishQueue(context, queue2) {
|
|
2589
|
-
Object.defineProperty(context, gracefulQueue, {
|
|
2590
|
-
get: function() {
|
|
2591
|
-
return queue2;
|
|
2592
|
-
}
|
|
2593
|
-
});
|
|
2594
|
-
}
|
|
2595
|
-
var debug = noop;
|
|
2596
|
-
if (util.debuglog)
|
|
2597
|
-
debug = util.debuglog("gfs4");
|
|
2598
|
-
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
2599
|
-
debug = function() {
|
|
2600
|
-
var m = util.format.apply(util, arguments);
|
|
2601
|
-
m = "GFS4: " + m.split(/\n/).join(`
|
|
2602
|
-
GFS4: `);
|
|
2603
|
-
console.error(m);
|
|
2604
|
-
};
|
|
2605
|
-
if (!fs[gracefulQueue]) {
|
|
2606
|
-
queue = global[gracefulQueue] || [];
|
|
2607
|
-
publishQueue(fs, queue);
|
|
2608
|
-
fs.close = function(fs$close) {
|
|
2609
|
-
function close(fd, cb) {
|
|
2610
|
-
return fs$close.call(fs, fd, function(err) {
|
|
2611
|
-
if (!err) {
|
|
2612
|
-
resetQueue();
|
|
2613
|
-
}
|
|
2614
|
-
if (typeof cb === "function")
|
|
2615
|
-
cb.apply(this, arguments);
|
|
2616
|
-
});
|
|
2617
|
-
}
|
|
2618
|
-
Object.defineProperty(close, previousSymbol, {
|
|
2619
|
-
value: fs$close
|
|
2620
|
-
});
|
|
2621
|
-
return close;
|
|
2622
|
-
}(fs.close);
|
|
2623
|
-
fs.closeSync = function(fs$closeSync) {
|
|
2624
|
-
function closeSync(fd) {
|
|
2625
|
-
fs$closeSync.apply(fs, arguments);
|
|
2626
|
-
resetQueue();
|
|
2627
|
-
}
|
|
2628
|
-
Object.defineProperty(closeSync, previousSymbol, {
|
|
2629
|
-
value: fs$closeSync
|
|
2630
|
-
});
|
|
2631
|
-
return closeSync;
|
|
2632
|
-
}(fs.closeSync);
|
|
2633
|
-
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
2634
|
-
process.on("exit", function() {
|
|
2635
|
-
debug(fs[gracefulQueue]);
|
|
2636
|
-
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
2637
|
-
});
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
var queue;
|
|
2641
|
-
if (!global[gracefulQueue]) {
|
|
2642
|
-
publishQueue(global, fs[gracefulQueue]);
|
|
2643
|
-
}
|
|
2644
|
-
module.exports = patch(clone(fs));
|
|
2645
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
2646
|
-
module.exports = patch(fs);
|
|
2647
|
-
fs.__patched = true;
|
|
2648
|
-
}
|
|
2649
|
-
function patch(fs2) {
|
|
2650
|
-
polyfills(fs2);
|
|
2651
|
-
fs2.gracefulify = patch;
|
|
2652
|
-
fs2.createReadStream = createReadStream;
|
|
2653
|
-
fs2.createWriteStream = createWriteStream;
|
|
2654
|
-
var fs$readFile = fs2.readFile;
|
|
2655
|
-
fs2.readFile = readFile;
|
|
2656
|
-
function readFile(path, options, cb) {
|
|
2657
|
-
if (typeof options === "function")
|
|
2658
|
-
cb = options, options = null;
|
|
2659
|
-
return go$readFile(path, options, cb);
|
|
2660
|
-
function go$readFile(path2, options2, cb2, startTime) {
|
|
2661
|
-
return fs$readFile(path2, options2, function(err) {
|
|
2662
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2663
|
-
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
2664
|
-
else {
|
|
2665
|
-
if (typeof cb2 === "function")
|
|
2666
|
-
cb2.apply(this, arguments);
|
|
2667
|
-
}
|
|
2668
|
-
});
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
var fs$writeFile = fs2.writeFile;
|
|
2672
|
-
fs2.writeFile = writeFile;
|
|
2673
|
-
function writeFile(path, data, options, cb) {
|
|
2674
|
-
if (typeof options === "function")
|
|
2675
|
-
cb = options, options = null;
|
|
2676
|
-
return go$writeFile(path, data, options, cb);
|
|
2677
|
-
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
2678
|
-
return fs$writeFile(path2, data2, options2, function(err) {
|
|
2679
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2680
|
-
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
2681
|
-
else {
|
|
2682
|
-
if (typeof cb2 === "function")
|
|
2683
|
-
cb2.apply(this, arguments);
|
|
2684
|
-
}
|
|
2685
|
-
});
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
var fs$appendFile = fs2.appendFile;
|
|
2689
|
-
if (fs$appendFile)
|
|
2690
|
-
fs2.appendFile = appendFile;
|
|
2691
|
-
function appendFile(path, data, options, cb) {
|
|
2692
|
-
if (typeof options === "function")
|
|
2693
|
-
cb = options, options = null;
|
|
2694
|
-
return go$appendFile(path, data, options, cb);
|
|
2695
|
-
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
2696
|
-
return fs$appendFile(path2, data2, options2, function(err) {
|
|
2697
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2698
|
-
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
2699
|
-
else {
|
|
2700
|
-
if (typeof cb2 === "function")
|
|
2701
|
-
cb2.apply(this, arguments);
|
|
2702
|
-
}
|
|
2703
|
-
});
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
var fs$copyFile = fs2.copyFile;
|
|
2707
|
-
if (fs$copyFile)
|
|
2708
|
-
fs2.copyFile = copyFile;
|
|
2709
|
-
function copyFile(src, dest, flags, cb) {
|
|
2710
|
-
if (typeof flags === "function") {
|
|
2711
|
-
cb = flags;
|
|
2712
|
-
flags = 0;
|
|
2713
|
-
}
|
|
2714
|
-
return go$copyFile(src, dest, flags, cb);
|
|
2715
|
-
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
2716
|
-
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
2717
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2718
|
-
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
2719
|
-
else {
|
|
2720
|
-
if (typeof cb2 === "function")
|
|
2721
|
-
cb2.apply(this, arguments);
|
|
2722
|
-
}
|
|
2723
|
-
});
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
var fs$readdir = fs2.readdir;
|
|
2727
|
-
fs2.readdir = readdir;
|
|
2728
|
-
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
2729
|
-
function readdir(path, options, cb) {
|
|
2730
|
-
if (typeof options === "function")
|
|
2731
|
-
cb = options, options = null;
|
|
2732
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path2, options2, cb2, startTime) {
|
|
2733
|
-
return fs$readdir(path2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
2734
|
-
} : function go$readdir(path2, options2, cb2, startTime) {
|
|
2735
|
-
return fs$readdir(path2, options2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
2736
|
-
};
|
|
2737
|
-
return go$readdir(path, options, cb);
|
|
2738
|
-
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
2739
|
-
return function(err, files) {
|
|
2740
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2741
|
-
enqueue([
|
|
2742
|
-
go$readdir,
|
|
2743
|
-
[path2, options2, cb2],
|
|
2744
|
-
err,
|
|
2745
|
-
startTime || Date.now(),
|
|
2746
|
-
Date.now()
|
|
2747
|
-
]);
|
|
2748
|
-
else {
|
|
2749
|
-
if (files && files.sort)
|
|
2750
|
-
files.sort();
|
|
2751
|
-
if (typeof cb2 === "function")
|
|
2752
|
-
cb2.call(this, err, files);
|
|
2753
|
-
}
|
|
2754
|
-
};
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
if (process.version.substr(0, 4) === "v0.8") {
|
|
2758
|
-
var legStreams = legacy(fs2);
|
|
2759
|
-
ReadStream = legStreams.ReadStream;
|
|
2760
|
-
WriteStream = legStreams.WriteStream;
|
|
2761
|
-
}
|
|
2762
|
-
var fs$ReadStream = fs2.ReadStream;
|
|
2763
|
-
if (fs$ReadStream) {
|
|
2764
|
-
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
2765
|
-
ReadStream.prototype.open = ReadStream$open;
|
|
2766
|
-
}
|
|
2767
|
-
var fs$WriteStream = fs2.WriteStream;
|
|
2768
|
-
if (fs$WriteStream) {
|
|
2769
|
-
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
2770
|
-
WriteStream.prototype.open = WriteStream$open;
|
|
2771
|
-
}
|
|
2772
|
-
Object.defineProperty(fs2, "ReadStream", {
|
|
2773
|
-
get: function() {
|
|
2774
|
-
return ReadStream;
|
|
2775
|
-
},
|
|
2776
|
-
set: function(val) {
|
|
2777
|
-
ReadStream = val;
|
|
2778
|
-
},
|
|
2779
|
-
enumerable: true,
|
|
2780
|
-
configurable: true
|
|
2781
|
-
});
|
|
2782
|
-
Object.defineProperty(fs2, "WriteStream", {
|
|
2783
|
-
get: function() {
|
|
2784
|
-
return WriteStream;
|
|
2785
|
-
},
|
|
2786
|
-
set: function(val) {
|
|
2787
|
-
WriteStream = val;
|
|
2788
|
-
},
|
|
2789
|
-
enumerable: true,
|
|
2790
|
-
configurable: true
|
|
2791
|
-
});
|
|
2792
|
-
var FileReadStream = ReadStream;
|
|
2793
|
-
Object.defineProperty(fs2, "FileReadStream", {
|
|
2794
|
-
get: function() {
|
|
2795
|
-
return FileReadStream;
|
|
2796
|
-
},
|
|
2797
|
-
set: function(val) {
|
|
2798
|
-
FileReadStream = val;
|
|
2799
|
-
},
|
|
2800
|
-
enumerable: true,
|
|
2801
|
-
configurable: true
|
|
2802
|
-
});
|
|
2803
|
-
var FileWriteStream = WriteStream;
|
|
2804
|
-
Object.defineProperty(fs2, "FileWriteStream", {
|
|
2805
|
-
get: function() {
|
|
2806
|
-
return FileWriteStream;
|
|
2807
|
-
},
|
|
2808
|
-
set: function(val) {
|
|
2809
|
-
FileWriteStream = val;
|
|
2810
|
-
},
|
|
2811
|
-
enumerable: true,
|
|
2812
|
-
configurable: true
|
|
2813
|
-
});
|
|
2814
|
-
function ReadStream(path, options) {
|
|
2815
|
-
if (this instanceof ReadStream)
|
|
2816
|
-
return fs$ReadStream.apply(this, arguments), this;
|
|
2817
|
-
else
|
|
2818
|
-
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
2819
|
-
}
|
|
2820
|
-
function ReadStream$open() {
|
|
2821
|
-
var that = this;
|
|
2822
|
-
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
2823
|
-
if (err) {
|
|
2824
|
-
if (that.autoClose)
|
|
2825
|
-
that.destroy();
|
|
2826
|
-
that.emit("error", err);
|
|
2827
|
-
} else {
|
|
2828
|
-
that.fd = fd;
|
|
2829
|
-
that.emit("open", fd);
|
|
2830
|
-
that.read();
|
|
2831
|
-
}
|
|
2832
|
-
});
|
|
2833
|
-
}
|
|
2834
|
-
function WriteStream(path, options) {
|
|
2835
|
-
if (this instanceof WriteStream)
|
|
2836
|
-
return fs$WriteStream.apply(this, arguments), this;
|
|
2837
|
-
else
|
|
2838
|
-
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
2839
|
-
}
|
|
2840
|
-
function WriteStream$open() {
|
|
2841
|
-
var that = this;
|
|
2842
|
-
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
2843
|
-
if (err) {
|
|
2844
|
-
that.destroy();
|
|
2845
|
-
that.emit("error", err);
|
|
2846
|
-
} else {
|
|
2847
|
-
that.fd = fd;
|
|
2848
|
-
that.emit("open", fd);
|
|
2849
|
-
}
|
|
2850
|
-
});
|
|
2851
|
-
}
|
|
2852
|
-
function createReadStream(path, options) {
|
|
2853
|
-
return new fs2.ReadStream(path, options);
|
|
2854
|
-
}
|
|
2855
|
-
function createWriteStream(path, options) {
|
|
2856
|
-
return new fs2.WriteStream(path, options);
|
|
2857
|
-
}
|
|
2858
|
-
var fs$open = fs2.open;
|
|
2859
|
-
fs2.open = open;
|
|
2860
|
-
function open(path, flags, mode, cb) {
|
|
2861
|
-
if (typeof mode === "function")
|
|
2862
|
-
cb = mode, mode = null;
|
|
2863
|
-
return go$open(path, flags, mode, cb);
|
|
2864
|
-
function go$open(path2, flags2, mode2, cb2, startTime) {
|
|
2865
|
-
return fs$open(path2, flags2, mode2, function(err, fd) {
|
|
2866
|
-
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
2867
|
-
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
2868
|
-
else {
|
|
2869
|
-
if (typeof cb2 === "function")
|
|
2870
|
-
cb2.apply(this, arguments);
|
|
2871
|
-
}
|
|
2872
|
-
});
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
return fs2;
|
|
2876
|
-
}
|
|
2877
|
-
function enqueue(elem) {
|
|
2878
|
-
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
2879
|
-
fs[gracefulQueue].push(elem);
|
|
2880
|
-
retry();
|
|
2881
|
-
}
|
|
2882
|
-
var retryTimer;
|
|
2883
|
-
function resetQueue() {
|
|
2884
|
-
var now = Date.now();
|
|
2885
|
-
for (var i = 0;i < fs[gracefulQueue].length; ++i) {
|
|
2886
|
-
if (fs[gracefulQueue][i].length > 2) {
|
|
2887
|
-
fs[gracefulQueue][i][3] = now;
|
|
2888
|
-
fs[gracefulQueue][i][4] = now;
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
retry();
|
|
2892
|
-
}
|
|
2893
|
-
function retry() {
|
|
2894
|
-
clearTimeout(retryTimer);
|
|
2895
|
-
retryTimer = undefined;
|
|
2896
|
-
if (fs[gracefulQueue].length === 0)
|
|
2897
|
-
return;
|
|
2898
|
-
var elem = fs[gracefulQueue].shift();
|
|
2899
|
-
var fn = elem[0];
|
|
2900
|
-
var args = elem[1];
|
|
2901
|
-
var err = elem[2];
|
|
2902
|
-
var startTime = elem[3];
|
|
2903
|
-
var lastTime = elem[4];
|
|
2904
|
-
if (startTime === undefined) {
|
|
2905
|
-
debug("RETRY", fn.name, args);
|
|
2906
|
-
fn.apply(null, args);
|
|
2907
|
-
} else if (Date.now() - startTime >= 60000) {
|
|
2908
|
-
debug("TIMEOUT", fn.name, args);
|
|
2909
|
-
var cb = args.pop();
|
|
2910
|
-
if (typeof cb === "function")
|
|
2911
|
-
cb.call(null, err);
|
|
2912
|
-
} else {
|
|
2913
|
-
var sinceAttempt = Date.now() - lastTime;
|
|
2914
|
-
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
2915
|
-
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
2916
|
-
if (sinceAttempt >= desiredDelay) {
|
|
2917
|
-
debug("RETRY", fn.name, args);
|
|
2918
|
-
fn.apply(null, args.concat([startTime]));
|
|
2919
|
-
} else {
|
|
2920
|
-
fs[gracefulQueue].push(elem);
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
if (retryTimer === undefined) {
|
|
2924
|
-
retryTimer = setTimeout(retry, 0);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
});
|
|
2928
|
-
|
|
2929
|
-
// node_modules/fs-extra/lib/fs/index.js
|
|
2930
|
-
var require_fs = __commonJS((exports) => {
|
|
2931
|
-
var u = require_universalify().fromCallback;
|
|
2932
|
-
var fs = require_graceful_fs();
|
|
2933
|
-
var api = [
|
|
2934
|
-
"access",
|
|
2935
|
-
"appendFile",
|
|
2936
|
-
"chmod",
|
|
2937
|
-
"chown",
|
|
2938
|
-
"close",
|
|
2939
|
-
"copyFile",
|
|
2940
|
-
"cp",
|
|
2941
|
-
"fchmod",
|
|
2942
|
-
"fchown",
|
|
2943
|
-
"fdatasync",
|
|
2944
|
-
"fstat",
|
|
2945
|
-
"fsync",
|
|
2946
|
-
"ftruncate",
|
|
2947
|
-
"futimes",
|
|
2948
|
-
"glob",
|
|
2949
|
-
"lchmod",
|
|
2950
|
-
"lchown",
|
|
2951
|
-
"lutimes",
|
|
2952
|
-
"link",
|
|
2953
|
-
"lstat",
|
|
2954
|
-
"mkdir",
|
|
2955
|
-
"mkdtemp",
|
|
2956
|
-
"open",
|
|
2957
|
-
"opendir",
|
|
2958
|
-
"readdir",
|
|
2959
|
-
"readFile",
|
|
2960
|
-
"readlink",
|
|
2961
|
-
"realpath",
|
|
2962
|
-
"rename",
|
|
2963
|
-
"rm",
|
|
2964
|
-
"rmdir",
|
|
2965
|
-
"stat",
|
|
2966
|
-
"statfs",
|
|
2967
|
-
"symlink",
|
|
2968
|
-
"truncate",
|
|
2969
|
-
"unlink",
|
|
2970
|
-
"utimes",
|
|
2971
|
-
"writeFile"
|
|
2972
|
-
].filter((key) => {
|
|
2973
|
-
return typeof fs[key] === "function";
|
|
2974
|
-
});
|
|
2975
|
-
Object.assign(exports, fs);
|
|
2976
|
-
api.forEach((method) => {
|
|
2977
|
-
exports[method] = u(fs[method]);
|
|
2978
|
-
});
|
|
2979
|
-
exports.exists = function(filename, callback) {
|
|
2980
|
-
if (typeof callback === "function") {
|
|
2981
|
-
return fs.exists(filename, callback);
|
|
2982
|
-
}
|
|
2983
|
-
return new Promise((resolve) => {
|
|
2984
|
-
return fs.exists(filename, resolve);
|
|
2985
|
-
});
|
|
2986
|
-
};
|
|
2987
|
-
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
2988
|
-
if (typeof callback === "function") {
|
|
2989
|
-
return fs.read(fd, buffer, offset, length, position, callback);
|
|
2990
|
-
}
|
|
2991
|
-
return new Promise((resolve, reject) => {
|
|
2992
|
-
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
|
|
2993
|
-
if (err)
|
|
2994
|
-
return reject(err);
|
|
2995
|
-
resolve({ bytesRead, buffer: buffer2 });
|
|
2996
|
-
});
|
|
2997
|
-
});
|
|
2998
|
-
};
|
|
2999
|
-
exports.write = function(fd, buffer, ...args) {
|
|
3000
|
-
if (typeof args[args.length - 1] === "function") {
|
|
3001
|
-
return fs.write(fd, buffer, ...args);
|
|
3002
|
-
}
|
|
3003
|
-
return new Promise((resolve, reject) => {
|
|
3004
|
-
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
|
|
3005
|
-
if (err)
|
|
3006
|
-
return reject(err);
|
|
3007
|
-
resolve({ bytesWritten, buffer: buffer2 });
|
|
3008
|
-
});
|
|
3009
|
-
});
|
|
3010
|
-
};
|
|
3011
|
-
exports.readv = function(fd, buffers, ...args) {
|
|
3012
|
-
if (typeof args[args.length - 1] === "function") {
|
|
3013
|
-
return fs.readv(fd, buffers, ...args);
|
|
3014
|
-
}
|
|
3015
|
-
return new Promise((resolve, reject) => {
|
|
3016
|
-
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
|
|
3017
|
-
if (err)
|
|
3018
|
-
return reject(err);
|
|
3019
|
-
resolve({ bytesRead, buffers: buffers2 });
|
|
3020
|
-
});
|
|
3021
|
-
});
|
|
3022
|
-
};
|
|
3023
|
-
exports.writev = function(fd, buffers, ...args) {
|
|
3024
|
-
if (typeof args[args.length - 1] === "function") {
|
|
3025
|
-
return fs.writev(fd, buffers, ...args);
|
|
3026
|
-
}
|
|
3027
|
-
return new Promise((resolve, reject) => {
|
|
3028
|
-
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
|
3029
|
-
if (err)
|
|
3030
|
-
return reject(err);
|
|
3031
|
-
resolve({ bytesWritten, buffers: buffers2 });
|
|
3032
|
-
});
|
|
3033
|
-
});
|
|
3034
|
-
};
|
|
3035
|
-
if (typeof fs.realpath.native === "function") {
|
|
3036
|
-
exports.realpath.native = u(fs.realpath.native);
|
|
3037
|
-
} else {
|
|
3038
|
-
process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?", "Warning", "fs-extra-WARN0003");
|
|
3039
|
-
}
|
|
3040
|
-
});
|
|
3041
|
-
|
|
3042
|
-
// node_modules/fs-extra/lib/mkdirs/utils.js
|
|
3043
|
-
var require_utils = __commonJS((exports, module) => {
|
|
3044
|
-
var path = __require("path");
|
|
3045
|
-
exports.checkPath = function checkPath(pth) {
|
|
3046
|
-
if (process.platform === "win32") {
|
|
3047
|
-
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ""));
|
|
3048
|
-
if (pathHasInvalidWinCharacters) {
|
|
3049
|
-
const error = new Error(`Path contains invalid characters: ${pth}`);
|
|
3050
|
-
error.code = "EINVAL";
|
|
3051
|
-
throw error;
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
};
|
|
3055
|
-
});
|
|
3056
|
-
|
|
3057
|
-
// node_modules/fs-extra/lib/mkdirs/make-dir.js
|
|
3058
|
-
var require_make_dir = __commonJS((exports, module) => {
|
|
3059
|
-
var fs = require_fs();
|
|
3060
|
-
var { checkPath } = require_utils();
|
|
3061
|
-
var getMode = (options) => {
|
|
3062
|
-
const defaults = { mode: 511 };
|
|
3063
|
-
if (typeof options === "number")
|
|
3064
|
-
return options;
|
|
3065
|
-
return { ...defaults, ...options }.mode;
|
|
3066
|
-
};
|
|
3067
|
-
exports.makeDir = async (dir, options) => {
|
|
3068
|
-
checkPath(dir);
|
|
3069
|
-
return fs.mkdir(dir, {
|
|
3070
|
-
mode: getMode(options),
|
|
3071
|
-
recursive: true
|
|
3072
|
-
});
|
|
3073
|
-
};
|
|
3074
|
-
exports.makeDirSync = (dir, options) => {
|
|
3075
|
-
checkPath(dir);
|
|
3076
|
-
return fs.mkdirSync(dir, {
|
|
3077
|
-
mode: getMode(options),
|
|
3078
|
-
recursive: true
|
|
3079
|
-
});
|
|
3080
|
-
};
|
|
3081
|
-
});
|
|
3082
|
-
|
|
3083
|
-
// node_modules/fs-extra/lib/mkdirs/index.js
|
|
3084
|
-
var require_mkdirs = __commonJS((exports, module) => {
|
|
3085
|
-
var u = require_universalify().fromPromise;
|
|
3086
|
-
var { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
3087
|
-
var makeDir = u(_makeDir);
|
|
3088
|
-
module.exports = {
|
|
3089
|
-
mkdirs: makeDir,
|
|
3090
|
-
mkdirsSync: makeDirSync,
|
|
3091
|
-
mkdirp: makeDir,
|
|
3092
|
-
mkdirpSync: makeDirSync,
|
|
3093
|
-
ensureDir: makeDir,
|
|
3094
|
-
ensureDirSync: makeDirSync
|
|
3095
|
-
};
|
|
3096
|
-
});
|
|
3097
|
-
|
|
3098
|
-
// node_modules/fs-extra/lib/path-exists/index.js
|
|
3099
|
-
var require_path_exists = __commonJS((exports, module) => {
|
|
3100
|
-
var u = require_universalify().fromPromise;
|
|
3101
|
-
var fs = require_fs();
|
|
3102
|
-
function pathExists(path) {
|
|
3103
|
-
return fs.access(path).then(() => true).catch(() => false);
|
|
3104
|
-
}
|
|
3105
|
-
module.exports = {
|
|
3106
|
-
pathExists: u(pathExists),
|
|
3107
|
-
pathExistsSync: fs.existsSync
|
|
3108
|
-
};
|
|
3109
|
-
});
|
|
3110
|
-
|
|
3111
|
-
// node_modules/fs-extra/lib/util/utimes.js
|
|
3112
|
-
var require_utimes = __commonJS((exports, module) => {
|
|
3113
|
-
var fs = require_fs();
|
|
3114
|
-
var u = require_universalify().fromPromise;
|
|
3115
|
-
async function utimesMillis(path, atime, mtime) {
|
|
3116
|
-
const fd = await fs.open(path, "r+");
|
|
3117
|
-
let closeErr = null;
|
|
3118
|
-
try {
|
|
3119
|
-
await fs.futimes(fd, atime, mtime);
|
|
3120
|
-
} finally {
|
|
3121
|
-
try {
|
|
3122
|
-
await fs.close(fd);
|
|
3123
|
-
} catch (e) {
|
|
3124
|
-
closeErr = e;
|
|
3125
|
-
}
|
|
3126
|
-
}
|
|
3127
|
-
if (closeErr) {
|
|
3128
|
-
throw closeErr;
|
|
3129
|
-
}
|
|
3130
|
-
}
|
|
3131
|
-
function utimesMillisSync(path, atime, mtime) {
|
|
3132
|
-
const fd = fs.openSync(path, "r+");
|
|
3133
|
-
fs.futimesSync(fd, atime, mtime);
|
|
3134
|
-
return fs.closeSync(fd);
|
|
3135
|
-
}
|
|
3136
|
-
module.exports = {
|
|
3137
|
-
utimesMillis: u(utimesMillis),
|
|
3138
|
-
utimesMillisSync
|
|
3139
|
-
};
|
|
3140
|
-
});
|
|
3141
|
-
|
|
3142
|
-
// node_modules/fs-extra/lib/util/stat.js
|
|
3143
|
-
var require_stat = __commonJS((exports, module) => {
|
|
3144
|
-
var fs = require_fs();
|
|
3145
|
-
var path = __require("path");
|
|
3146
|
-
var u = require_universalify().fromPromise;
|
|
3147
|
-
function getStats(src, dest, opts) {
|
|
3148
|
-
const statFunc = opts.dereference ? (file) => fs.stat(file, { bigint: true }) : (file) => fs.lstat(file, { bigint: true });
|
|
3149
|
-
return Promise.all([
|
|
3150
|
-
statFunc(src),
|
|
3151
|
-
statFunc(dest).catch((err) => {
|
|
3152
|
-
if (err.code === "ENOENT")
|
|
3153
|
-
return null;
|
|
3154
|
-
throw err;
|
|
3155
|
-
})
|
|
3156
|
-
]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
|
|
3157
|
-
}
|
|
3158
|
-
function getStatsSync(src, dest, opts) {
|
|
3159
|
-
let destStat;
|
|
3160
|
-
const statFunc = opts.dereference ? (file) => fs.statSync(file, { bigint: true }) : (file) => fs.lstatSync(file, { bigint: true });
|
|
3161
|
-
const srcStat = statFunc(src);
|
|
3162
|
-
try {
|
|
3163
|
-
destStat = statFunc(dest);
|
|
3164
|
-
} catch (err) {
|
|
3165
|
-
if (err.code === "ENOENT")
|
|
3166
|
-
return { srcStat, destStat: null };
|
|
3167
|
-
throw err;
|
|
3168
|
-
}
|
|
3169
|
-
return { srcStat, destStat };
|
|
3170
|
-
}
|
|
3171
|
-
async function checkPaths(src, dest, funcName, opts) {
|
|
3172
|
-
const { srcStat, destStat } = await getStats(src, dest, opts);
|
|
3173
|
-
if (destStat) {
|
|
3174
|
-
if (areIdentical(srcStat, destStat)) {
|
|
3175
|
-
const srcBaseName = path.basename(src);
|
|
3176
|
-
const destBaseName = path.basename(dest);
|
|
3177
|
-
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
3178
|
-
return { srcStat, destStat, isChangingCase: true };
|
|
3179
|
-
}
|
|
3180
|
-
throw new Error("Source and destination must not be the same.");
|
|
3181
|
-
}
|
|
3182
|
-
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
3183
|
-
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
3184
|
-
}
|
|
3185
|
-
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
3186
|
-
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
3190
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
3191
|
-
}
|
|
3192
|
-
return { srcStat, destStat };
|
|
3193
|
-
}
|
|
3194
|
-
function checkPathsSync(src, dest, funcName, opts) {
|
|
3195
|
-
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
3196
|
-
if (destStat) {
|
|
3197
|
-
if (areIdentical(srcStat, destStat)) {
|
|
3198
|
-
const srcBaseName = path.basename(src);
|
|
3199
|
-
const destBaseName = path.basename(dest);
|
|
3200
|
-
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
3201
|
-
return { srcStat, destStat, isChangingCase: true };
|
|
3202
|
-
}
|
|
3203
|
-
throw new Error("Source and destination must not be the same.");
|
|
3204
|
-
}
|
|
3205
|
-
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
3206
|
-
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
3207
|
-
}
|
|
3208
|
-
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
3209
|
-
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
3213
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
3214
|
-
}
|
|
3215
|
-
return { srcStat, destStat };
|
|
3216
|
-
}
|
|
3217
|
-
async function checkParentPaths(src, srcStat, dest, funcName) {
|
|
3218
|
-
const srcParent = path.resolve(path.dirname(src));
|
|
3219
|
-
const destParent = path.resolve(path.dirname(dest));
|
|
3220
|
-
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
|
3221
|
-
return;
|
|
3222
|
-
let destStat;
|
|
3223
|
-
try {
|
|
3224
|
-
destStat = await fs.stat(destParent, { bigint: true });
|
|
3225
|
-
} catch (err) {
|
|
3226
|
-
if (err.code === "ENOENT")
|
|
3227
|
-
return;
|
|
3228
|
-
throw err;
|
|
3229
|
-
}
|
|
3230
|
-
if (areIdentical(srcStat, destStat)) {
|
|
3231
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
3232
|
-
}
|
|
3233
|
-
return checkParentPaths(src, srcStat, destParent, funcName);
|
|
3234
|
-
}
|
|
3235
|
-
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
3236
|
-
const srcParent = path.resolve(path.dirname(src));
|
|
3237
|
-
const destParent = path.resolve(path.dirname(dest));
|
|
3238
|
-
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
|
3239
|
-
return;
|
|
3240
|
-
let destStat;
|
|
3241
|
-
try {
|
|
3242
|
-
destStat = fs.statSync(destParent, { bigint: true });
|
|
3243
|
-
} catch (err) {
|
|
3244
|
-
if (err.code === "ENOENT")
|
|
3245
|
-
return;
|
|
3246
|
-
throw err;
|
|
3247
|
-
}
|
|
3248
|
-
if (areIdentical(srcStat, destStat)) {
|
|
3249
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
3250
|
-
}
|
|
3251
|
-
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
3252
|
-
}
|
|
3253
|
-
function areIdentical(srcStat, destStat) {
|
|
3254
|
-
return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
3255
|
-
}
|
|
3256
|
-
function isSrcSubdir(src, dest) {
|
|
3257
|
-
const srcArr = path.resolve(src).split(path.sep).filter((i) => i);
|
|
3258
|
-
const destArr = path.resolve(dest).split(path.sep).filter((i) => i);
|
|
3259
|
-
return srcArr.every((cur, i) => destArr[i] === cur);
|
|
3260
|
-
}
|
|
3261
|
-
function errMsg(src, dest, funcName) {
|
|
3262
|
-
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
3263
|
-
}
|
|
3264
|
-
module.exports = {
|
|
3265
|
-
checkPaths: u(checkPaths),
|
|
3266
|
-
checkPathsSync,
|
|
3267
|
-
checkParentPaths: u(checkParentPaths),
|
|
3268
|
-
checkParentPathsSync,
|
|
3269
|
-
isSrcSubdir,
|
|
3270
|
-
areIdentical
|
|
3271
|
-
};
|
|
3272
|
-
});
|
|
3273
|
-
|
|
3274
|
-
// node_modules/fs-extra/lib/copy/copy.js
|
|
3275
|
-
var require_copy = __commonJS((exports, module) => {
|
|
3276
|
-
var fs = require_fs();
|
|
3277
|
-
var path = __require("path");
|
|
3278
|
-
var { mkdirs } = require_mkdirs();
|
|
3279
|
-
var { pathExists } = require_path_exists();
|
|
3280
|
-
var { utimesMillis } = require_utimes();
|
|
3281
|
-
var stat = require_stat();
|
|
3282
|
-
async function copy(src, dest, opts = {}) {
|
|
3283
|
-
if (typeof opts === "function") {
|
|
3284
|
-
opts = { filter: opts };
|
|
3285
|
-
}
|
|
3286
|
-
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
3287
|
-
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
3288
|
-
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
3289
|
-
process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
3290
|
-
|
|
3291
|
-
` + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
|
|
3292
|
-
}
|
|
3293
|
-
const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
|
|
3294
|
-
await stat.checkParentPaths(src, srcStat, dest, "copy");
|
|
3295
|
-
const include = await runFilter(src, dest, opts);
|
|
3296
|
-
if (!include)
|
|
3297
|
-
return;
|
|
3298
|
-
const destParent = path.dirname(dest);
|
|
3299
|
-
const dirExists = await pathExists(destParent);
|
|
3300
|
-
if (!dirExists) {
|
|
3301
|
-
await mkdirs(destParent);
|
|
3302
|
-
}
|
|
3303
|
-
await getStatsAndPerformCopy(destStat, src, dest, opts);
|
|
3304
|
-
}
|
|
3305
|
-
async function runFilter(src, dest, opts) {
|
|
3306
|
-
if (!opts.filter)
|
|
3307
|
-
return true;
|
|
3308
|
-
return opts.filter(src, dest);
|
|
3309
|
-
}
|
|
3310
|
-
async function getStatsAndPerformCopy(destStat, src, dest, opts) {
|
|
3311
|
-
const statFn = opts.dereference ? fs.stat : fs.lstat;
|
|
3312
|
-
const srcStat = await statFn(src);
|
|
3313
|
-
if (srcStat.isDirectory())
|
|
3314
|
-
return onDir(srcStat, destStat, src, dest, opts);
|
|
3315
|
-
if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
|
3316
|
-
return onFile(srcStat, destStat, src, dest, opts);
|
|
3317
|
-
if (srcStat.isSymbolicLink())
|
|
3318
|
-
return onLink(destStat, src, dest, opts);
|
|
3319
|
-
if (srcStat.isSocket())
|
|
3320
|
-
throw new Error(`Cannot copy a socket file: ${src}`);
|
|
3321
|
-
if (srcStat.isFIFO())
|
|
3322
|
-
throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
3323
|
-
throw new Error(`Unknown file: ${src}`);
|
|
3324
|
-
}
|
|
3325
|
-
async function onFile(srcStat, destStat, src, dest, opts) {
|
|
3326
|
-
if (!destStat)
|
|
3327
|
-
return copyFile(srcStat, src, dest, opts);
|
|
3328
|
-
if (opts.overwrite) {
|
|
3329
|
-
await fs.unlink(dest);
|
|
3330
|
-
return copyFile(srcStat, src, dest, opts);
|
|
3331
|
-
}
|
|
3332
|
-
if (opts.errorOnExist) {
|
|
3333
|
-
throw new Error(`'${dest}' already exists`);
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
async function copyFile(srcStat, src, dest, opts) {
|
|
3337
|
-
await fs.copyFile(src, dest);
|
|
3338
|
-
if (opts.preserveTimestamps) {
|
|
3339
|
-
if (fileIsNotWritable(srcStat.mode)) {
|
|
3340
|
-
await makeFileWritable(dest, srcStat.mode);
|
|
3341
|
-
}
|
|
3342
|
-
const updatedSrcStat = await fs.stat(src);
|
|
3343
|
-
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
3344
|
-
}
|
|
3345
|
-
return fs.chmod(dest, srcStat.mode);
|
|
3346
|
-
}
|
|
3347
|
-
function fileIsNotWritable(srcMode) {
|
|
3348
|
-
return (srcMode & 128) === 0;
|
|
3349
|
-
}
|
|
3350
|
-
function makeFileWritable(dest, srcMode) {
|
|
3351
|
-
return fs.chmod(dest, srcMode | 128);
|
|
3352
|
-
}
|
|
3353
|
-
async function onDir(srcStat, destStat, src, dest, opts) {
|
|
3354
|
-
if (!destStat) {
|
|
3355
|
-
await fs.mkdir(dest);
|
|
3356
|
-
}
|
|
3357
|
-
const promises = [];
|
|
3358
|
-
for await (const item of await fs.opendir(src)) {
|
|
3359
|
-
const srcItem = path.join(src, item.name);
|
|
3360
|
-
const destItem = path.join(dest, item.name);
|
|
3361
|
-
promises.push(runFilter(srcItem, destItem, opts).then((include) => {
|
|
3362
|
-
if (include) {
|
|
3363
|
-
return stat.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat2 }) => {
|
|
3364
|
-
return getStatsAndPerformCopy(destStat2, srcItem, destItem, opts);
|
|
3365
|
-
});
|
|
3366
|
-
}
|
|
3367
|
-
}));
|
|
3368
|
-
}
|
|
3369
|
-
await Promise.all(promises);
|
|
3370
|
-
if (!destStat) {
|
|
3371
|
-
await fs.chmod(dest, srcStat.mode);
|
|
3372
|
-
}
|
|
3373
|
-
}
|
|
3374
|
-
async function onLink(destStat, src, dest, opts) {
|
|
3375
|
-
let resolvedSrc = await fs.readlink(src);
|
|
3376
|
-
if (opts.dereference) {
|
|
3377
|
-
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
|
3378
|
-
}
|
|
3379
|
-
if (!destStat) {
|
|
3380
|
-
return fs.symlink(resolvedSrc, dest);
|
|
3381
|
-
}
|
|
3382
|
-
let resolvedDest = null;
|
|
3383
|
-
try {
|
|
3384
|
-
resolvedDest = await fs.readlink(dest);
|
|
3385
|
-
} catch (e) {
|
|
3386
|
-
if (e.code === "EINVAL" || e.code === "UNKNOWN")
|
|
3387
|
-
return fs.symlink(resolvedSrc, dest);
|
|
3388
|
-
throw e;
|
|
3389
|
-
}
|
|
3390
|
-
if (opts.dereference) {
|
|
3391
|
-
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
3392
|
-
}
|
|
3393
|
-
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
3394
|
-
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
3395
|
-
}
|
|
3396
|
-
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
3397
|
-
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
3398
|
-
}
|
|
3399
|
-
await fs.unlink(dest);
|
|
3400
|
-
return fs.symlink(resolvedSrc, dest);
|
|
3401
|
-
}
|
|
3402
|
-
module.exports = copy;
|
|
3403
|
-
});
|
|
3404
|
-
|
|
3405
|
-
// node_modules/fs-extra/lib/copy/copy-sync.js
|
|
3406
|
-
var require_copy_sync = __commonJS((exports, module) => {
|
|
3407
|
-
var fs = require_graceful_fs();
|
|
3408
|
-
var path = __require("path");
|
|
3409
|
-
var mkdirsSync = require_mkdirs().mkdirsSync;
|
|
3410
|
-
var utimesMillisSync = require_utimes().utimesMillisSync;
|
|
3411
|
-
var stat = require_stat();
|
|
3412
|
-
function copySync(src, dest, opts) {
|
|
3413
|
-
if (typeof opts === "function") {
|
|
3414
|
-
opts = { filter: opts };
|
|
3415
|
-
}
|
|
3416
|
-
opts = opts || {};
|
|
3417
|
-
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
3418
|
-
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
3419
|
-
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
3420
|
-
process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
3421
|
-
|
|
3422
|
-
` + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
|
|
3423
|
-
}
|
|
3424
|
-
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
3425
|
-
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
3426
|
-
if (opts.filter && !opts.filter(src, dest))
|
|
3427
|
-
return;
|
|
3428
|
-
const destParent = path.dirname(dest);
|
|
3429
|
-
if (!fs.existsSync(destParent))
|
|
3430
|
-
mkdirsSync(destParent);
|
|
3431
|
-
return getStats(destStat, src, dest, opts);
|
|
3432
|
-
}
|
|
3433
|
-
function getStats(destStat, src, dest, opts) {
|
|
3434
|
-
const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
|
|
3435
|
-
const srcStat = statSync(src);
|
|
3436
|
-
if (srcStat.isDirectory())
|
|
3437
|
-
return onDir(srcStat, destStat, src, dest, opts);
|
|
3438
|
-
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
|
3439
|
-
return onFile(srcStat, destStat, src, dest, opts);
|
|
3440
|
-
else if (srcStat.isSymbolicLink())
|
|
3441
|
-
return onLink(destStat, src, dest, opts);
|
|
3442
|
-
else if (srcStat.isSocket())
|
|
3443
|
-
throw new Error(`Cannot copy a socket file: ${src}`);
|
|
3444
|
-
else if (srcStat.isFIFO())
|
|
3445
|
-
throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
3446
|
-
throw new Error(`Unknown file: ${src}`);
|
|
3447
|
-
}
|
|
3448
|
-
function onFile(srcStat, destStat, src, dest, opts) {
|
|
3449
|
-
if (!destStat)
|
|
3450
|
-
return copyFile(srcStat, src, dest, opts);
|
|
3451
|
-
return mayCopyFile(srcStat, src, dest, opts);
|
|
3452
|
-
}
|
|
3453
|
-
function mayCopyFile(srcStat, src, dest, opts) {
|
|
3454
|
-
if (opts.overwrite) {
|
|
3455
|
-
fs.unlinkSync(dest);
|
|
3456
|
-
return copyFile(srcStat, src, dest, opts);
|
|
3457
|
-
} else if (opts.errorOnExist) {
|
|
3458
|
-
throw new Error(`'${dest}' already exists`);
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3461
|
-
function copyFile(srcStat, src, dest, opts) {
|
|
3462
|
-
fs.copyFileSync(src, dest);
|
|
3463
|
-
if (opts.preserveTimestamps)
|
|
3464
|
-
handleTimestamps(srcStat.mode, src, dest);
|
|
3465
|
-
return setDestMode(dest, srcStat.mode);
|
|
3466
|
-
}
|
|
3467
|
-
function handleTimestamps(srcMode, src, dest) {
|
|
3468
|
-
if (fileIsNotWritable(srcMode))
|
|
3469
|
-
makeFileWritable(dest, srcMode);
|
|
3470
|
-
return setDestTimestamps(src, dest);
|
|
3471
|
-
}
|
|
3472
|
-
function fileIsNotWritable(srcMode) {
|
|
3473
|
-
return (srcMode & 128) === 0;
|
|
3474
|
-
}
|
|
3475
|
-
function makeFileWritable(dest, srcMode) {
|
|
3476
|
-
return setDestMode(dest, srcMode | 128);
|
|
3477
|
-
}
|
|
3478
|
-
function setDestMode(dest, srcMode) {
|
|
3479
|
-
return fs.chmodSync(dest, srcMode);
|
|
3480
|
-
}
|
|
3481
|
-
function setDestTimestamps(src, dest) {
|
|
3482
|
-
const updatedSrcStat = fs.statSync(src);
|
|
3483
|
-
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
3484
|
-
}
|
|
3485
|
-
function onDir(srcStat, destStat, src, dest, opts) {
|
|
3486
|
-
if (!destStat)
|
|
3487
|
-
return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
3488
|
-
return copyDir(src, dest, opts);
|
|
3489
|
-
}
|
|
3490
|
-
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
3491
|
-
fs.mkdirSync(dest);
|
|
3492
|
-
copyDir(src, dest, opts);
|
|
3493
|
-
return setDestMode(dest, srcMode);
|
|
3494
|
-
}
|
|
3495
|
-
function copyDir(src, dest, opts) {
|
|
3496
|
-
const dir = fs.opendirSync(src);
|
|
3497
|
-
try {
|
|
3498
|
-
let dirent;
|
|
3499
|
-
while ((dirent = dir.readSync()) !== null) {
|
|
3500
|
-
copyDirItem(dirent.name, src, dest, opts);
|
|
3501
|
-
}
|
|
3502
|
-
} finally {
|
|
3503
|
-
dir.closeSync();
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
function copyDirItem(item, src, dest, opts) {
|
|
3507
|
-
const srcItem = path.join(src, item);
|
|
3508
|
-
const destItem = path.join(dest, item);
|
|
3509
|
-
if (opts.filter && !opts.filter(srcItem, destItem))
|
|
3510
|
-
return;
|
|
3511
|
-
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
3512
|
-
return getStats(destStat, srcItem, destItem, opts);
|
|
3513
|
-
}
|
|
3514
|
-
function onLink(destStat, src, dest, opts) {
|
|
3515
|
-
let resolvedSrc = fs.readlinkSync(src);
|
|
3516
|
-
if (opts.dereference) {
|
|
3517
|
-
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
|
3518
|
-
}
|
|
3519
|
-
if (!destStat) {
|
|
3520
|
-
return fs.symlinkSync(resolvedSrc, dest);
|
|
3521
|
-
} else {
|
|
3522
|
-
let resolvedDest;
|
|
3523
|
-
try {
|
|
3524
|
-
resolvedDest = fs.readlinkSync(dest);
|
|
3525
|
-
} catch (err) {
|
|
3526
|
-
if (err.code === "EINVAL" || err.code === "UNKNOWN")
|
|
3527
|
-
return fs.symlinkSync(resolvedSrc, dest);
|
|
3528
|
-
throw err;
|
|
3529
|
-
}
|
|
3530
|
-
if (opts.dereference) {
|
|
3531
|
-
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
3532
|
-
}
|
|
3533
|
-
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
3534
|
-
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
3535
|
-
}
|
|
3536
|
-
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
3537
|
-
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
3538
|
-
}
|
|
3539
|
-
return copyLink(resolvedSrc, dest);
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
|
-
function copyLink(resolvedSrc, dest) {
|
|
3543
|
-
fs.unlinkSync(dest);
|
|
3544
|
-
return fs.symlinkSync(resolvedSrc, dest);
|
|
3545
|
-
}
|
|
3546
|
-
module.exports = copySync;
|
|
3547
|
-
});
|
|
3548
|
-
|
|
3549
|
-
// node_modules/fs-extra/lib/copy/index.js
|
|
3550
|
-
var require_copy2 = __commonJS((exports, module) => {
|
|
3551
|
-
var u = require_universalify().fromPromise;
|
|
3552
|
-
module.exports = {
|
|
3553
|
-
copy: u(require_copy()),
|
|
3554
|
-
copySync: require_copy_sync()
|
|
3555
|
-
};
|
|
3556
|
-
});
|
|
3557
|
-
|
|
3558
|
-
// node_modules/fs-extra/lib/remove/index.js
|
|
3559
|
-
var require_remove = __commonJS((exports, module) => {
|
|
3560
|
-
var fs = require_graceful_fs();
|
|
3561
|
-
var u = require_universalify().fromCallback;
|
|
3562
|
-
function remove(path, callback) {
|
|
3563
|
-
fs.rm(path, { recursive: true, force: true }, callback);
|
|
3564
|
-
}
|
|
3565
|
-
function removeSync(path) {
|
|
3566
|
-
fs.rmSync(path, { recursive: true, force: true });
|
|
3567
|
-
}
|
|
3568
|
-
module.exports = {
|
|
3569
|
-
remove: u(remove),
|
|
3570
|
-
removeSync
|
|
3571
|
-
};
|
|
3572
|
-
});
|
|
3573
|
-
|
|
3574
|
-
// node_modules/fs-extra/lib/empty/index.js
|
|
3575
|
-
var require_empty = __commonJS((exports, module) => {
|
|
3576
|
-
var u = require_universalify().fromPromise;
|
|
3577
|
-
var fs = require_fs();
|
|
3578
|
-
var path = __require("path");
|
|
3579
|
-
var mkdir = require_mkdirs();
|
|
3580
|
-
var remove = require_remove();
|
|
3581
|
-
var emptyDir = u(async function emptyDir(dir) {
|
|
3582
|
-
let items;
|
|
3583
|
-
try {
|
|
3584
|
-
items = await fs.readdir(dir);
|
|
3585
|
-
} catch {
|
|
3586
|
-
return mkdir.mkdirs(dir);
|
|
3587
|
-
}
|
|
3588
|
-
return Promise.all(items.map((item) => remove.remove(path.join(dir, item))));
|
|
3589
|
-
});
|
|
3590
|
-
function emptyDirSync(dir) {
|
|
3591
|
-
let items;
|
|
3592
|
-
try {
|
|
3593
|
-
items = fs.readdirSync(dir);
|
|
3594
|
-
} catch {
|
|
3595
|
-
return mkdir.mkdirsSync(dir);
|
|
3596
|
-
}
|
|
3597
|
-
items.forEach((item) => {
|
|
3598
|
-
item = path.join(dir, item);
|
|
3599
|
-
remove.removeSync(item);
|
|
3600
|
-
});
|
|
3601
|
-
}
|
|
3602
|
-
module.exports = {
|
|
3603
|
-
emptyDirSync,
|
|
3604
|
-
emptydirSync: emptyDirSync,
|
|
3605
|
-
emptyDir,
|
|
3606
|
-
emptydir: emptyDir
|
|
3607
|
-
};
|
|
3608
|
-
});
|
|
3609
|
-
|
|
3610
|
-
// node_modules/fs-extra/lib/ensure/file.js
|
|
3611
|
-
var require_file = __commonJS((exports, module) => {
|
|
3612
|
-
var u = require_universalify().fromPromise;
|
|
3613
|
-
var path = __require("path");
|
|
3614
|
-
var fs = require_fs();
|
|
3615
|
-
var mkdir = require_mkdirs();
|
|
3616
|
-
async function createFile(file) {
|
|
3617
|
-
let stats;
|
|
3618
|
-
try {
|
|
3619
|
-
stats = await fs.stat(file);
|
|
3620
|
-
} catch {}
|
|
3621
|
-
if (stats && stats.isFile())
|
|
3622
|
-
return;
|
|
3623
|
-
const dir = path.dirname(file);
|
|
3624
|
-
let dirStats = null;
|
|
3625
|
-
try {
|
|
3626
|
-
dirStats = await fs.stat(dir);
|
|
3627
|
-
} catch (err) {
|
|
3628
|
-
if (err.code === "ENOENT") {
|
|
3629
|
-
await mkdir.mkdirs(dir);
|
|
3630
|
-
await fs.writeFile(file, "");
|
|
3631
|
-
return;
|
|
3632
|
-
} else {
|
|
3633
|
-
throw err;
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
if (dirStats.isDirectory()) {
|
|
3637
|
-
await fs.writeFile(file, "");
|
|
3638
|
-
} else {
|
|
3639
|
-
await fs.readdir(dir);
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
function createFileSync(file) {
|
|
3643
|
-
let stats;
|
|
3644
|
-
try {
|
|
3645
|
-
stats = fs.statSync(file);
|
|
3646
|
-
} catch {}
|
|
3647
|
-
if (stats && stats.isFile())
|
|
3648
|
-
return;
|
|
3649
|
-
const dir = path.dirname(file);
|
|
3650
|
-
try {
|
|
3651
|
-
if (!fs.statSync(dir).isDirectory()) {
|
|
3652
|
-
fs.readdirSync(dir);
|
|
3653
|
-
}
|
|
3654
|
-
} catch (err) {
|
|
3655
|
-
if (err && err.code === "ENOENT")
|
|
3656
|
-
mkdir.mkdirsSync(dir);
|
|
3657
|
-
else
|
|
3658
|
-
throw err;
|
|
3659
|
-
}
|
|
3660
|
-
fs.writeFileSync(file, "");
|
|
3661
|
-
}
|
|
3662
|
-
module.exports = {
|
|
3663
|
-
createFile: u(createFile),
|
|
3664
|
-
createFileSync
|
|
3665
|
-
};
|
|
3666
|
-
});
|
|
3667
|
-
|
|
3668
|
-
// node_modules/fs-extra/lib/ensure/link.js
|
|
3669
|
-
var require_link = __commonJS((exports, module) => {
|
|
3670
|
-
var u = require_universalify().fromPromise;
|
|
3671
|
-
var path = __require("path");
|
|
3672
|
-
var fs = require_fs();
|
|
3673
|
-
var mkdir = require_mkdirs();
|
|
3674
|
-
var { pathExists } = require_path_exists();
|
|
3675
|
-
var { areIdentical } = require_stat();
|
|
3676
|
-
async function createLink(srcpath, dstpath) {
|
|
3677
|
-
let dstStat;
|
|
3678
|
-
try {
|
|
3679
|
-
dstStat = await fs.lstat(dstpath);
|
|
3680
|
-
} catch {}
|
|
3681
|
-
let srcStat;
|
|
3682
|
-
try {
|
|
3683
|
-
srcStat = await fs.lstat(srcpath);
|
|
3684
|
-
} catch (err) {
|
|
3685
|
-
err.message = err.message.replace("lstat", "ensureLink");
|
|
3686
|
-
throw err;
|
|
3687
|
-
}
|
|
3688
|
-
if (dstStat && areIdentical(srcStat, dstStat))
|
|
3689
|
-
return;
|
|
3690
|
-
const dir = path.dirname(dstpath);
|
|
3691
|
-
const dirExists = await pathExists(dir);
|
|
3692
|
-
if (!dirExists) {
|
|
3693
|
-
await mkdir.mkdirs(dir);
|
|
3694
|
-
}
|
|
3695
|
-
await fs.link(srcpath, dstpath);
|
|
3696
|
-
}
|
|
3697
|
-
function createLinkSync(srcpath, dstpath) {
|
|
3698
|
-
let dstStat;
|
|
3699
|
-
try {
|
|
3700
|
-
dstStat = fs.lstatSync(dstpath);
|
|
3701
|
-
} catch {}
|
|
3702
|
-
try {
|
|
3703
|
-
const srcStat = fs.lstatSync(srcpath);
|
|
3704
|
-
if (dstStat && areIdentical(srcStat, dstStat))
|
|
3705
|
-
return;
|
|
3706
|
-
} catch (err) {
|
|
3707
|
-
err.message = err.message.replace("lstat", "ensureLink");
|
|
3708
|
-
throw err;
|
|
3709
|
-
}
|
|
3710
|
-
const dir = path.dirname(dstpath);
|
|
3711
|
-
const dirExists = fs.existsSync(dir);
|
|
3712
|
-
if (dirExists)
|
|
3713
|
-
return fs.linkSync(srcpath, dstpath);
|
|
3714
|
-
mkdir.mkdirsSync(dir);
|
|
3715
|
-
return fs.linkSync(srcpath, dstpath);
|
|
3716
|
-
}
|
|
3717
|
-
module.exports = {
|
|
3718
|
-
createLink: u(createLink),
|
|
3719
|
-
createLinkSync
|
|
3720
|
-
};
|
|
3721
|
-
});
|
|
3722
|
-
|
|
3723
|
-
// node_modules/fs-extra/lib/ensure/symlink-paths.js
|
|
3724
|
-
var require_symlink_paths = __commonJS((exports, module) => {
|
|
3725
|
-
var path = __require("path");
|
|
3726
|
-
var fs = require_fs();
|
|
3727
|
-
var { pathExists } = require_path_exists();
|
|
3728
|
-
var u = require_universalify().fromPromise;
|
|
3729
|
-
async function symlinkPaths(srcpath, dstpath) {
|
|
3730
|
-
if (path.isAbsolute(srcpath)) {
|
|
3731
|
-
try {
|
|
3732
|
-
await fs.lstat(srcpath);
|
|
3733
|
-
} catch (err) {
|
|
3734
|
-
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
3735
|
-
throw err;
|
|
3736
|
-
}
|
|
3737
|
-
return {
|
|
3738
|
-
toCwd: srcpath,
|
|
3739
|
-
toDst: srcpath
|
|
3740
|
-
};
|
|
3741
|
-
}
|
|
3742
|
-
const dstdir = path.dirname(dstpath);
|
|
3743
|
-
const relativeToDst = path.join(dstdir, srcpath);
|
|
3744
|
-
const exists = await pathExists(relativeToDst);
|
|
3745
|
-
if (exists) {
|
|
3746
|
-
return {
|
|
3747
|
-
toCwd: relativeToDst,
|
|
3748
|
-
toDst: srcpath
|
|
3749
|
-
};
|
|
3750
|
-
}
|
|
3751
|
-
try {
|
|
3752
|
-
await fs.lstat(srcpath);
|
|
3753
|
-
} catch (err) {
|
|
3754
|
-
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
3755
|
-
throw err;
|
|
3756
|
-
}
|
|
3757
|
-
return {
|
|
3758
|
-
toCwd: srcpath,
|
|
3759
|
-
toDst: path.relative(dstdir, srcpath)
|
|
3760
|
-
};
|
|
3761
|
-
}
|
|
3762
|
-
function symlinkPathsSync(srcpath, dstpath) {
|
|
3763
|
-
if (path.isAbsolute(srcpath)) {
|
|
3764
|
-
const exists2 = fs.existsSync(srcpath);
|
|
3765
|
-
if (!exists2)
|
|
3766
|
-
throw new Error("absolute srcpath does not exist");
|
|
3767
|
-
return {
|
|
3768
|
-
toCwd: srcpath,
|
|
3769
|
-
toDst: srcpath
|
|
3770
|
-
};
|
|
3771
|
-
}
|
|
3772
|
-
const dstdir = path.dirname(dstpath);
|
|
3773
|
-
const relativeToDst = path.join(dstdir, srcpath);
|
|
3774
|
-
const exists = fs.existsSync(relativeToDst);
|
|
3775
|
-
if (exists) {
|
|
3776
|
-
return {
|
|
3777
|
-
toCwd: relativeToDst,
|
|
3778
|
-
toDst: srcpath
|
|
3779
|
-
};
|
|
3780
|
-
}
|
|
3781
|
-
const srcExists = fs.existsSync(srcpath);
|
|
3782
|
-
if (!srcExists)
|
|
3783
|
-
throw new Error("relative srcpath does not exist");
|
|
3784
|
-
return {
|
|
3785
|
-
toCwd: srcpath,
|
|
3786
|
-
toDst: path.relative(dstdir, srcpath)
|
|
3787
|
-
};
|
|
3788
|
-
}
|
|
3789
|
-
module.exports = {
|
|
3790
|
-
symlinkPaths: u(symlinkPaths),
|
|
3791
|
-
symlinkPathsSync
|
|
3792
|
-
};
|
|
3793
|
-
});
|
|
3794
|
-
|
|
3795
|
-
// node_modules/fs-extra/lib/ensure/symlink-type.js
|
|
3796
|
-
var require_symlink_type = __commonJS((exports, module) => {
|
|
3797
|
-
var fs = require_fs();
|
|
3798
|
-
var u = require_universalify().fromPromise;
|
|
3799
|
-
async function symlinkType(srcpath, type) {
|
|
3800
|
-
if (type)
|
|
3801
|
-
return type;
|
|
3802
|
-
let stats;
|
|
3803
|
-
try {
|
|
3804
|
-
stats = await fs.lstat(srcpath);
|
|
3805
|
-
} catch {
|
|
3806
|
-
return "file";
|
|
3807
|
-
}
|
|
3808
|
-
return stats && stats.isDirectory() ? "dir" : "file";
|
|
3809
|
-
}
|
|
3810
|
-
function symlinkTypeSync(srcpath, type) {
|
|
3811
|
-
if (type)
|
|
3812
|
-
return type;
|
|
3813
|
-
let stats;
|
|
3814
|
-
try {
|
|
3815
|
-
stats = fs.lstatSync(srcpath);
|
|
3816
|
-
} catch {
|
|
3817
|
-
return "file";
|
|
3818
|
-
}
|
|
3819
|
-
return stats && stats.isDirectory() ? "dir" : "file";
|
|
3820
|
-
}
|
|
3821
|
-
module.exports = {
|
|
3822
|
-
symlinkType: u(symlinkType),
|
|
3823
|
-
symlinkTypeSync
|
|
3824
|
-
};
|
|
3825
|
-
});
|
|
3826
|
-
|
|
3827
|
-
// node_modules/fs-extra/lib/ensure/symlink.js
|
|
3828
|
-
var require_symlink = __commonJS((exports, module) => {
|
|
3829
|
-
var u = require_universalify().fromPromise;
|
|
3830
|
-
var path = __require("path");
|
|
3831
|
-
var fs = require_fs();
|
|
3832
|
-
var { mkdirs, mkdirsSync } = require_mkdirs();
|
|
3833
|
-
var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
|
|
3834
|
-
var { symlinkType, symlinkTypeSync } = require_symlink_type();
|
|
3835
|
-
var { pathExists } = require_path_exists();
|
|
3836
|
-
var { areIdentical } = require_stat();
|
|
3837
|
-
async function createSymlink(srcpath, dstpath, type) {
|
|
3838
|
-
let stats;
|
|
3839
|
-
try {
|
|
3840
|
-
stats = await fs.lstat(dstpath);
|
|
3841
|
-
} catch {}
|
|
3842
|
-
if (stats && stats.isSymbolicLink()) {
|
|
3843
|
-
const [srcStat, dstStat] = await Promise.all([
|
|
3844
|
-
fs.stat(srcpath),
|
|
3845
|
-
fs.stat(dstpath)
|
|
3846
|
-
]);
|
|
3847
|
-
if (areIdentical(srcStat, dstStat))
|
|
3848
|
-
return;
|
|
3849
|
-
}
|
|
3850
|
-
const relative = await symlinkPaths(srcpath, dstpath);
|
|
3851
|
-
srcpath = relative.toDst;
|
|
3852
|
-
const toType = await symlinkType(relative.toCwd, type);
|
|
3853
|
-
const dir = path.dirname(dstpath);
|
|
3854
|
-
if (!await pathExists(dir)) {
|
|
3855
|
-
await mkdirs(dir);
|
|
3856
|
-
}
|
|
3857
|
-
return fs.symlink(srcpath, dstpath, toType);
|
|
3858
|
-
}
|
|
3859
|
-
function createSymlinkSync(srcpath, dstpath, type) {
|
|
3860
|
-
let stats;
|
|
3861
|
-
try {
|
|
3862
|
-
stats = fs.lstatSync(dstpath);
|
|
3863
|
-
} catch {}
|
|
3864
|
-
if (stats && stats.isSymbolicLink()) {
|
|
3865
|
-
const srcStat = fs.statSync(srcpath);
|
|
3866
|
-
const dstStat = fs.statSync(dstpath);
|
|
3867
|
-
if (areIdentical(srcStat, dstStat))
|
|
3868
|
-
return;
|
|
3869
|
-
}
|
|
3870
|
-
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
3871
|
-
srcpath = relative.toDst;
|
|
3872
|
-
type = symlinkTypeSync(relative.toCwd, type);
|
|
3873
|
-
const dir = path.dirname(dstpath);
|
|
3874
|
-
const exists = fs.existsSync(dir);
|
|
3875
|
-
if (exists)
|
|
3876
|
-
return fs.symlinkSync(srcpath, dstpath, type);
|
|
3877
|
-
mkdirsSync(dir);
|
|
3878
|
-
return fs.symlinkSync(srcpath, dstpath, type);
|
|
3879
|
-
}
|
|
3880
|
-
module.exports = {
|
|
3881
|
-
createSymlink: u(createSymlink),
|
|
3882
|
-
createSymlinkSync
|
|
3883
|
-
};
|
|
3884
|
-
});
|
|
3885
|
-
|
|
3886
|
-
// node_modules/fs-extra/lib/ensure/index.js
|
|
3887
|
-
var require_ensure = __commonJS((exports, module) => {
|
|
3888
|
-
var { createFile, createFileSync } = require_file();
|
|
3889
|
-
var { createLink, createLinkSync } = require_link();
|
|
3890
|
-
var { createSymlink, createSymlinkSync } = require_symlink();
|
|
3891
|
-
module.exports = {
|
|
3892
|
-
createFile,
|
|
3893
|
-
createFileSync,
|
|
3894
|
-
ensureFile: createFile,
|
|
3895
|
-
ensureFileSync: createFileSync,
|
|
3896
|
-
createLink,
|
|
3897
|
-
createLinkSync,
|
|
3898
|
-
ensureLink: createLink,
|
|
3899
|
-
ensureLinkSync: createLinkSync,
|
|
3900
|
-
createSymlink,
|
|
3901
|
-
createSymlinkSync,
|
|
3902
|
-
ensureSymlink: createSymlink,
|
|
3903
|
-
ensureSymlinkSync: createSymlinkSync
|
|
3904
|
-
};
|
|
3905
|
-
});
|
|
3906
|
-
|
|
3907
|
-
// node_modules/jsonfile/utils.js
|
|
3908
|
-
var require_utils2 = __commonJS((exports, module) => {
|
|
3909
|
-
function stringify(obj, { EOL = `
|
|
3910
|
-
`, finalEOL = true, replacer = null, spaces } = {}) {
|
|
3911
|
-
const EOF = finalEOL ? EOL : "";
|
|
3912
|
-
const str = JSON.stringify(obj, replacer, spaces);
|
|
3913
|
-
return str.replace(/\n/g, EOL) + EOF;
|
|
3914
|
-
}
|
|
3915
|
-
function stripBom(content) {
|
|
3916
|
-
if (Buffer.isBuffer(content))
|
|
3917
|
-
content = content.toString("utf8");
|
|
3918
|
-
return content.replace(/^\uFEFF/, "");
|
|
3919
|
-
}
|
|
3920
|
-
module.exports = { stringify, stripBom };
|
|
3921
|
-
});
|
|
3922
|
-
|
|
3923
|
-
// node_modules/jsonfile/index.js
|
|
3924
|
-
var require_jsonfile = __commonJS((exports, module) => {
|
|
3925
|
-
var _fs;
|
|
3926
|
-
try {
|
|
3927
|
-
_fs = require_graceful_fs();
|
|
3928
|
-
} catch (_) {
|
|
3929
|
-
_fs = __require("fs");
|
|
3930
|
-
}
|
|
3931
|
-
var universalify = require_universalify();
|
|
3932
|
-
var { stringify, stripBom } = require_utils2();
|
|
3933
|
-
async function _readFile(file, options = {}) {
|
|
3934
|
-
if (typeof options === "string") {
|
|
3935
|
-
options = { encoding: options };
|
|
3936
|
-
}
|
|
3937
|
-
const fs = options.fs || _fs;
|
|
3938
|
-
const shouldThrow = "throws" in options ? options.throws : true;
|
|
3939
|
-
let data = await universalify.fromCallback(fs.readFile)(file, options);
|
|
3940
|
-
data = stripBom(data);
|
|
3941
|
-
let obj;
|
|
3942
|
-
try {
|
|
3943
|
-
obj = JSON.parse(data, options ? options.reviver : null);
|
|
3944
|
-
} catch (err) {
|
|
3945
|
-
if (shouldThrow) {
|
|
3946
|
-
err.message = `${file}: ${err.message}`;
|
|
3947
|
-
throw err;
|
|
3948
|
-
} else {
|
|
3949
|
-
return null;
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
return obj;
|
|
3953
|
-
}
|
|
3954
|
-
var readFile = universalify.fromPromise(_readFile);
|
|
3955
|
-
function readFileSync(file, options = {}) {
|
|
3956
|
-
if (typeof options === "string") {
|
|
3957
|
-
options = { encoding: options };
|
|
3958
|
-
}
|
|
3959
|
-
const fs = options.fs || _fs;
|
|
3960
|
-
const shouldThrow = "throws" in options ? options.throws : true;
|
|
3961
|
-
try {
|
|
3962
|
-
let content = fs.readFileSync(file, options);
|
|
3963
|
-
content = stripBom(content);
|
|
3964
|
-
return JSON.parse(content, options.reviver);
|
|
3965
|
-
} catch (err) {
|
|
3966
|
-
if (shouldThrow) {
|
|
3967
|
-
err.message = `${file}: ${err.message}`;
|
|
3968
|
-
throw err;
|
|
3969
|
-
} else {
|
|
3970
|
-
return null;
|
|
3971
|
-
}
|
|
3972
|
-
}
|
|
3973
|
-
}
|
|
3974
|
-
async function _writeFile(file, obj, options = {}) {
|
|
3975
|
-
const fs = options.fs || _fs;
|
|
3976
|
-
const str = stringify(obj, options);
|
|
3977
|
-
await universalify.fromCallback(fs.writeFile)(file, str, options);
|
|
3978
|
-
}
|
|
3979
|
-
var writeFile = universalify.fromPromise(_writeFile);
|
|
3980
|
-
function writeFileSync(file, obj, options = {}) {
|
|
3981
|
-
const fs = options.fs || _fs;
|
|
3982
|
-
const str = stringify(obj, options);
|
|
3983
|
-
return fs.writeFileSync(file, str, options);
|
|
3984
|
-
}
|
|
3985
|
-
module.exports = {
|
|
3986
|
-
readFile,
|
|
3987
|
-
readFileSync,
|
|
3988
|
-
writeFile,
|
|
3989
|
-
writeFileSync
|
|
3990
|
-
};
|
|
3991
|
-
});
|
|
3992
|
-
|
|
3993
|
-
// node_modules/fs-extra/lib/json/jsonfile.js
|
|
3994
|
-
var require_jsonfile2 = __commonJS((exports, module) => {
|
|
3995
|
-
var jsonFile = require_jsonfile();
|
|
3996
|
-
module.exports = {
|
|
3997
|
-
readJson: jsonFile.readFile,
|
|
3998
|
-
readJsonSync: jsonFile.readFileSync,
|
|
3999
|
-
writeJson: jsonFile.writeFile,
|
|
4000
|
-
writeJsonSync: jsonFile.writeFileSync
|
|
4001
|
-
};
|
|
4002
|
-
});
|
|
4003
|
-
|
|
4004
|
-
// node_modules/fs-extra/lib/output-file/index.js
|
|
4005
|
-
var require_output_file = __commonJS((exports, module) => {
|
|
4006
|
-
var u = require_universalify().fromPromise;
|
|
4007
|
-
var fs = require_fs();
|
|
4008
|
-
var path = __require("path");
|
|
4009
|
-
var mkdir = require_mkdirs();
|
|
4010
|
-
var pathExists = require_path_exists().pathExists;
|
|
4011
|
-
async function outputFile(file, data, encoding = "utf-8") {
|
|
4012
|
-
const dir = path.dirname(file);
|
|
4013
|
-
if (!await pathExists(dir)) {
|
|
4014
|
-
await mkdir.mkdirs(dir);
|
|
4015
|
-
}
|
|
4016
|
-
return fs.writeFile(file, data, encoding);
|
|
4017
|
-
}
|
|
4018
|
-
function outputFileSync(file, ...args) {
|
|
4019
|
-
const dir = path.dirname(file);
|
|
4020
|
-
if (!fs.existsSync(dir)) {
|
|
4021
|
-
mkdir.mkdirsSync(dir);
|
|
4022
|
-
}
|
|
4023
|
-
fs.writeFileSync(file, ...args);
|
|
4024
|
-
}
|
|
4025
|
-
module.exports = {
|
|
4026
|
-
outputFile: u(outputFile),
|
|
4027
|
-
outputFileSync
|
|
4028
|
-
};
|
|
4029
|
-
});
|
|
4030
|
-
|
|
4031
|
-
// node_modules/fs-extra/lib/json/output-json.js
|
|
4032
|
-
var require_output_json = __commonJS((exports, module) => {
|
|
4033
|
-
var { stringify } = require_utils2();
|
|
4034
|
-
var { outputFile } = require_output_file();
|
|
4035
|
-
async function outputJson(file, data, options = {}) {
|
|
4036
|
-
const str = stringify(data, options);
|
|
4037
|
-
await outputFile(file, str, options);
|
|
4038
|
-
}
|
|
4039
|
-
module.exports = outputJson;
|
|
4040
|
-
});
|
|
4041
|
-
|
|
4042
|
-
// node_modules/fs-extra/lib/json/output-json-sync.js
|
|
4043
|
-
var require_output_json_sync = __commonJS((exports, module) => {
|
|
4044
|
-
var { stringify } = require_utils2();
|
|
4045
|
-
var { outputFileSync } = require_output_file();
|
|
4046
|
-
function outputJsonSync(file, data, options) {
|
|
4047
|
-
const str = stringify(data, options);
|
|
4048
|
-
outputFileSync(file, str, options);
|
|
4049
|
-
}
|
|
4050
|
-
module.exports = outputJsonSync;
|
|
4051
|
-
});
|
|
4052
|
-
|
|
4053
|
-
// node_modules/fs-extra/lib/json/index.js
|
|
4054
|
-
var require_json = __commonJS((exports, module) => {
|
|
4055
|
-
var u = require_universalify().fromPromise;
|
|
4056
|
-
var jsonFile = require_jsonfile2();
|
|
4057
|
-
jsonFile.outputJson = u(require_output_json());
|
|
4058
|
-
jsonFile.outputJsonSync = require_output_json_sync();
|
|
4059
|
-
jsonFile.outputJSON = jsonFile.outputJson;
|
|
4060
|
-
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
4061
|
-
jsonFile.writeJSON = jsonFile.writeJson;
|
|
4062
|
-
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
4063
|
-
jsonFile.readJSON = jsonFile.readJson;
|
|
4064
|
-
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
4065
|
-
module.exports = jsonFile;
|
|
4066
|
-
});
|
|
4067
|
-
|
|
4068
|
-
// node_modules/fs-extra/lib/move/move.js
|
|
4069
|
-
var require_move = __commonJS((exports, module) => {
|
|
4070
|
-
var fs = require_fs();
|
|
4071
|
-
var path = __require("path");
|
|
4072
|
-
var { copy } = require_copy2();
|
|
4073
|
-
var { remove } = require_remove();
|
|
4074
|
-
var { mkdirp } = require_mkdirs();
|
|
4075
|
-
var { pathExists } = require_path_exists();
|
|
4076
|
-
var stat = require_stat();
|
|
4077
|
-
async function move(src, dest, opts = {}) {
|
|
4078
|
-
const overwrite = opts.overwrite || opts.clobber || false;
|
|
4079
|
-
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
|
|
4080
|
-
await stat.checkParentPaths(src, srcStat, dest, "move");
|
|
4081
|
-
const destParent = path.dirname(dest);
|
|
4082
|
-
const parsedParentPath = path.parse(destParent);
|
|
4083
|
-
if (parsedParentPath.root !== destParent) {
|
|
4084
|
-
await mkdirp(destParent);
|
|
4085
|
-
}
|
|
4086
|
-
return doRename(src, dest, overwrite, isChangingCase);
|
|
4087
|
-
}
|
|
4088
|
-
async function doRename(src, dest, overwrite, isChangingCase) {
|
|
4089
|
-
if (!isChangingCase) {
|
|
4090
|
-
if (overwrite) {
|
|
4091
|
-
await remove(dest);
|
|
4092
|
-
} else if (await pathExists(dest)) {
|
|
4093
|
-
throw new Error("dest already exists.");
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
try {
|
|
4097
|
-
await fs.rename(src, dest);
|
|
4098
|
-
} catch (err) {
|
|
4099
|
-
if (err.code !== "EXDEV") {
|
|
4100
|
-
throw err;
|
|
4101
|
-
}
|
|
4102
|
-
await moveAcrossDevice(src, dest, overwrite);
|
|
4103
|
-
}
|
|
4104
|
-
}
|
|
4105
|
-
async function moveAcrossDevice(src, dest, overwrite) {
|
|
4106
|
-
const opts = {
|
|
4107
|
-
overwrite,
|
|
4108
|
-
errorOnExist: true,
|
|
4109
|
-
preserveTimestamps: true
|
|
4110
|
-
};
|
|
4111
|
-
await copy(src, dest, opts);
|
|
4112
|
-
return remove(src);
|
|
4113
|
-
}
|
|
4114
|
-
module.exports = move;
|
|
4115
|
-
});
|
|
4116
|
-
|
|
4117
|
-
// node_modules/fs-extra/lib/move/move-sync.js
|
|
4118
|
-
var require_move_sync = __commonJS((exports, module) => {
|
|
4119
|
-
var fs = require_graceful_fs();
|
|
4120
|
-
var path = __require("path");
|
|
4121
|
-
var copySync = require_copy2().copySync;
|
|
4122
|
-
var removeSync = require_remove().removeSync;
|
|
4123
|
-
var mkdirpSync = require_mkdirs().mkdirpSync;
|
|
4124
|
-
var stat = require_stat();
|
|
4125
|
-
function moveSync(src, dest, opts) {
|
|
4126
|
-
opts = opts || {};
|
|
4127
|
-
const overwrite = opts.overwrite || opts.clobber || false;
|
|
4128
|
-
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
4129
|
-
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
4130
|
-
if (!isParentRoot(dest))
|
|
4131
|
-
mkdirpSync(path.dirname(dest));
|
|
4132
|
-
return doRename(src, dest, overwrite, isChangingCase);
|
|
4133
|
-
}
|
|
4134
|
-
function isParentRoot(dest) {
|
|
4135
|
-
const parent = path.dirname(dest);
|
|
4136
|
-
const parsedPath = path.parse(parent);
|
|
4137
|
-
return parsedPath.root === parent;
|
|
4138
|
-
}
|
|
4139
|
-
function doRename(src, dest, overwrite, isChangingCase) {
|
|
4140
|
-
if (isChangingCase)
|
|
4141
|
-
return rename(src, dest, overwrite);
|
|
4142
|
-
if (overwrite) {
|
|
4143
|
-
removeSync(dest);
|
|
4144
|
-
return rename(src, dest, overwrite);
|
|
4145
|
-
}
|
|
4146
|
-
if (fs.existsSync(dest))
|
|
4147
|
-
throw new Error("dest already exists.");
|
|
4148
|
-
return rename(src, dest, overwrite);
|
|
4149
|
-
}
|
|
4150
|
-
function rename(src, dest, overwrite) {
|
|
4151
|
-
try {
|
|
4152
|
-
fs.renameSync(src, dest);
|
|
4153
|
-
} catch (err) {
|
|
4154
|
-
if (err.code !== "EXDEV")
|
|
4155
|
-
throw err;
|
|
4156
|
-
return moveAcrossDevice(src, dest, overwrite);
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4159
|
-
function moveAcrossDevice(src, dest, overwrite) {
|
|
4160
|
-
const opts = {
|
|
4161
|
-
overwrite,
|
|
4162
|
-
errorOnExist: true,
|
|
4163
|
-
preserveTimestamps: true
|
|
4164
|
-
};
|
|
4165
|
-
copySync(src, dest, opts);
|
|
4166
|
-
return removeSync(src);
|
|
4167
|
-
}
|
|
4168
|
-
module.exports = moveSync;
|
|
4169
|
-
});
|
|
4170
|
-
|
|
4171
|
-
// node_modules/fs-extra/lib/move/index.js
|
|
4172
|
-
var require_move2 = __commonJS((exports, module) => {
|
|
4173
|
-
var u = require_universalify().fromPromise;
|
|
4174
|
-
module.exports = {
|
|
4175
|
-
move: u(require_move()),
|
|
4176
|
-
moveSync: require_move_sync()
|
|
4177
|
-
};
|
|
4178
|
-
});
|
|
4179
|
-
|
|
4180
|
-
// node_modules/fs-extra/lib/index.js
|
|
4181
|
-
var require_lib = __commonJS((exports, module) => {
|
|
4182
|
-
module.exports = {
|
|
4183
|
-
...require_fs(),
|
|
4184
|
-
...require_copy2(),
|
|
4185
|
-
...require_empty(),
|
|
4186
|
-
...require_ensure(),
|
|
4187
|
-
...require_json(),
|
|
4188
|
-
...require_mkdirs(),
|
|
4189
|
-
...require_move2(),
|
|
4190
|
-
...require_output_file(),
|
|
4191
|
-
...require_path_exists(),
|
|
4192
|
-
...require_remove()
|
|
4193
|
-
};
|
|
4194
|
-
});
|
|
4195
|
-
|
|
4196
|
-
// src/bb-functions-build.ts
|
|
4197
|
-
import { spawn } from "child_process";
|
|
4198
|
-
|
|
4199
|
-
// node_modules/commander/esm.mjs
|
|
4200
|
-
var import__ = __toESM(require_commander(), 1);
|
|
4201
|
-
var {
|
|
4202
|
-
program,
|
|
4203
|
-
createCommand,
|
|
4204
|
-
createArgument,
|
|
4205
|
-
createOption,
|
|
4206
|
-
CommanderError,
|
|
4207
|
-
InvalidArgumentError,
|
|
4208
|
-
InvalidOptionArgumentError,
|
|
4209
|
-
Command,
|
|
4210
|
-
Argument,
|
|
4211
|
-
Option,
|
|
4212
|
-
Help
|
|
4213
|
-
} = import__.default;
|
|
4214
|
-
|
|
4215
|
-
// src/bb-functions-build.ts
|
|
4216
|
-
var import_fs_extra = __toESM(require_lib(), 1);
|
|
4217
|
-
import os from "os";
|
|
4218
|
-
import path3 from "path";
|
|
4219
|
-
|
|
4220
|
-
// src/functions/acquireCustomFunctionsProject.ts
|
|
4221
|
-
import fs from "fs";
|
|
4222
|
-
import path from "path";
|
|
4223
|
-
var acquireCustomFunctionsProject = (dir) => {
|
|
4224
|
-
const expected = ["functions.json", "package.json", "src"];
|
|
4225
|
-
const intersection = fs.readdirSync(dir).filter((file) => expected.includes(file));
|
|
4226
|
-
if (intersection.length === expected.length) {
|
|
4227
|
-
return path.basename(dir);
|
|
4228
|
-
}
|
|
4229
|
-
console.log("The current directory is not a custom functions project. Abort.");
|
|
4230
|
-
process.exit();
|
|
4231
|
-
};
|
|
4232
|
-
var acquireCustomFunctionsProject_default = acquireCustomFunctionsProject;
|
|
4233
|
-
|
|
4234
|
-
// src/utils/rootDir.ts
|
|
4235
|
-
import path2 from "path";
|
|
4236
|
-
var rootDir = () => path2.join(process.mainModule.filename, "..", "..");
|
|
4237
|
-
var rootDir_default = rootDir;
|
|
4238
|
-
|
|
4239
|
-
// src/bb-functions-build.ts
|
|
4240
|
-
var program2 = new Command;
|
|
4241
|
-
program2.name("bb functions build").parse(process.argv);
|
|
4242
|
-
var workingDir = process.cwd();
|
|
4243
|
-
var identifier = acquireCustomFunctionsProject_default(workingDir);
|
|
4244
|
-
console.log(`Building ${identifier}.bettyblocks.com bundle (this can take a while) ...`);
|
|
4245
|
-
new Promise((resolve) => {
|
|
4246
|
-
const packerDir = path3.join(rootDir_default(), "assets", "functions", "packer");
|
|
4247
|
-
const buildDir = path3.join(os.tmpdir(), identifier);
|
|
4248
|
-
const sourceSrc = path3.join(workingDir, "src");
|
|
4249
|
-
const targetSrc = path3.join(buildDir, "src");
|
|
4250
|
-
const sourcePackage = path3.join(workingDir, "package.json");
|
|
4251
|
-
const targetPackage = path3.join(buildDir, "package.json");
|
|
4252
|
-
const sourceConfig = path3.join(workingDir, "webpack.config.js");
|
|
4253
|
-
const targetConfig = path3.join(buildDir, "webpack.config.js");
|
|
4254
|
-
if (!import_fs_extra.default.pathExistsSync(sourceConfig)) {
|
|
4255
|
-
import_fs_extra.default.copySync(path3.join(packerDir, "webpack.config.js"), sourceConfig);
|
|
4256
|
-
}
|
|
4257
|
-
import_fs_extra.default.emptyDir(buildDir, (err) => {
|
|
4258
|
-
if (err) {
|
|
4259
|
-
console.log(`${err.message}. Abort.`);
|
|
4260
|
-
}
|
|
4261
|
-
import_fs_extra.default.copySync(packerDir, buildDir);
|
|
4262
|
-
import_fs_extra.default.copySync(sourceSrc, targetSrc);
|
|
4263
|
-
import_fs_extra.default.copySync(sourceConfig, targetConfig);
|
|
4264
|
-
const sourceJson = import_fs_extra.default.readJsonSync(sourcePackage);
|
|
4265
|
-
const targetJson = import_fs_extra.default.readJsonSync(targetPackage);
|
|
4266
|
-
targetJson.dependencies = {
|
|
4267
|
-
...targetJson.dependencies,
|
|
4268
|
-
...sourceJson.dependencies
|
|
4269
|
-
};
|
|
4270
|
-
import_fs_extra.default.writeFileSync(targetPackage, JSON.stringify(targetJson, null, 2));
|
|
4271
|
-
const build = spawn(`cd ${buildDir} && npm install && npm run build`, {
|
|
4272
|
-
shell: true
|
|
4273
|
-
});
|
|
4274
|
-
build.stdout.pipe(process.stdout);
|
|
4275
|
-
build.stderr.pipe(process.stderr);
|
|
4276
|
-
build.on("close", resolve);
|
|
4277
|
-
});
|
|
4278
|
-
}).then(() => {
|
|
4279
|
-
console.log("Done.");
|
|
4280
|
-
}).catch((err) => {
|
|
4281
|
-
console.log(`${err}
|
|
4282
|
-
Abort.`);
|
|
4283
|
-
process.exit();
|
|
4284
|
-
});
|