@teambit/cli 0.0.0-387ca83bd6d05e8441bf8d4e938b4a402307cc6b
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/cli.composition.tsx +7 -0
- package/cli.docs.mdx +12 -0
- package/dist/cli-parser.d.ts +38 -0
- package/dist/cli-parser.js +379 -0
- package/dist/cli-parser.js.map +1 -0
- package/dist/cli.aspect.d.ts +4 -0
- package/dist/cli.aspect.js +22 -0
- package/dist/cli.aspect.js.map +1 -0
- package/dist/cli.cmd.d.ts +32 -0
- package/dist/cli.cmd.js +151 -0
- package/dist/cli.cmd.js.map +1 -0
- package/dist/cli.composition.d.ts +1 -0
- package/dist/cli.composition.js +29 -0
- package/dist/cli.composition.js.map +1 -0
- package/dist/cli.docs.mdx +12 -0
- package/dist/cli.main.runtime.d.ts +86 -0
- package/dist/cli.main.runtime.js +304 -0
- package/dist/cli.main.runtime.js.map +1 -0
- package/dist/command-groups.d.ts +31 -0
- package/dist/command-groups.js +44 -0
- package/dist/command-groups.js.map +1 -0
- package/dist/command-helper.d.ts +25 -0
- package/dist/command-helper.js +59 -0
- package/dist/command-helper.js.map +1 -0
- package/dist/command-runner.d.ts +35 -0
- package/dist/command-runner.js +176 -0
- package/dist/command-runner.js.map +1 -0
- package/dist/command.d.ts +130 -0
- package/dist/command.js +3 -0
- package/dist/command.js.map +1 -0
- package/dist/completion.cmd.d.ts +9 -0
- package/dist/completion.cmd.js +22 -0
- package/dist/completion.cmd.js.map +1 -0
- package/dist/default-error-handler.d.ts +12 -0
- package/dist/default-error-handler.js +81 -0
- package/dist/default-error-handler.js.map +1 -0
- package/dist/esm.mjs +17 -0
- package/dist/exceptions/already-exists.d.ts +4 -0
- package/dist/exceptions/already-exists.js +21 -0
- package/dist/exceptions/already-exists.js.map +1 -0
- package/dist/exceptions/command-not-found.d.ts +7 -0
- package/dist/exceptions/command-not-found.js +44 -0
- package/dist/exceptions/command-not-found.js.map +1 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +33 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/yargs-exit-workaround.d.ts +6 -0
- package/dist/exceptions/yargs-exit-workaround.js +23 -0
- package/dist/exceptions/yargs-exit-workaround.js.map +1 -0
- package/dist/generate-doc-md.d.ts +25 -0
- package/dist/generate-doc-md.js +151 -0
- package/dist/generate-doc-md.js.map +1 -0
- package/dist/get-command-id.d.ts +1 -0
- package/dist/get-command-id.js +11 -0
- package/dist/get-command-id.js.map +1 -0
- package/dist/global-flags.d.ts +7 -0
- package/dist/global-flags.js +24 -0
- package/dist/global-flags.js.map +1 -0
- package/dist/handle-errors.d.ts +3 -0
- package/dist/handle-errors.js +78 -0
- package/dist/handle-errors.js.map +1 -0
- package/dist/help.cmd.d.ts +15 -0
- package/dist/help.cmd.js +36 -0
- package/dist/help.cmd.js.map +1 -0
- package/dist/help.d.ts +3 -0
- package/dist/help.js +88 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1752165283597.js +7 -0
- package/dist/version.cmd.d.ts +13 -0
- package/dist/version.cmd.js +39 -0
- package/dist/version.cmd.js.map +1 -0
- package/dist/yargs-adapter.d.ts +22 -0
- package/dist/yargs-adapter.js +114 -0
- package/dist/yargs-adapter.js.map +1 -0
- package/esm.mjs +17 -0
- package/exceptions/already-exists.ts +7 -0
- package/exceptions/command-not-found.ts +22 -0
- package/exceptions/index.ts +2 -0
- package/exceptions/yargs-exit-workaround.ts +10 -0
- package/package.json +73 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.sendToAnalyticsAndSentry = sendToAnalyticsAndSentry;
|
|
8
|
+
function _chalk() {
|
|
9
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
10
|
+
_chalk = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _bitError() {
|
|
16
|
+
const data = require("@teambit/bit-error");
|
|
17
|
+
_bitError = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _legacy() {
|
|
23
|
+
const data = require("@teambit/legacy.analytics");
|
|
24
|
+
_legacy = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _legacyCli() {
|
|
30
|
+
const data = require("@teambit/legacy.cli.error");
|
|
31
|
+
_legacyCli = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
37
|
+
// all errors that the command does not handle comes to this switch statement
|
|
38
|
+
// if you handle the error, then return true
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* if err.userError is set, it inherits from AbstractError, which are user errors not Bit errors
|
|
42
|
+
* and should not be reported to Sentry.
|
|
43
|
+
* reason why we don't check (err instanceof AbstractError) is that it could be thrown from a fork,
|
|
44
|
+
* in which case, it loses its class and has only the fields.
|
|
45
|
+
*/
|
|
46
|
+
function sendToAnalyticsAndSentry(err) {
|
|
47
|
+
const possiblyHashedError = (0, _legacyCli().hashErrorIfNeeded)(err);
|
|
48
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
49
|
+
const shouldNotReportToSentry = Boolean(err.isUserError || err.code === 'EACCES');
|
|
50
|
+
// only level FATAL are reported to Sentry.
|
|
51
|
+
const level = shouldNotReportToSentry ? _legacy().LEVEL.INFO : _legacy().LEVEL.FATAL;
|
|
52
|
+
_legacy().Analytics.setError(level, possiblyHashedError);
|
|
53
|
+
}
|
|
54
|
+
function handleNonBitCustomErrors(err) {
|
|
55
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
56
|
+
if (err.code === 'EACCES' && err.path) {
|
|
57
|
+
// see #1774
|
|
58
|
+
return _chalk().default.red(
|
|
59
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
60
|
+
`error: you do not have permissions to access '${err.path}', were you running bit, npm or git as root?`);
|
|
61
|
+
}
|
|
62
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
63
|
+
return _chalk().default.red(err.message || err);
|
|
64
|
+
}
|
|
65
|
+
var _default = err => {
|
|
66
|
+
const getErrMsg = () => {
|
|
67
|
+
if (err instanceof _bitError().BitError) {
|
|
68
|
+
return err.report();
|
|
69
|
+
}
|
|
70
|
+
return handleNonBitCustomErrors(err);
|
|
71
|
+
};
|
|
72
|
+
sendToAnalyticsAndSentry(err);
|
|
73
|
+
const errorMessage = getErrMsg();
|
|
74
|
+
return {
|
|
75
|
+
message: _chalk().default.red(errorMessage),
|
|
76
|
+
error: err
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.default = _default;
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=default-error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_bitError","_legacy","_legacyCli","e","__esModule","default","sendToAnalyticsAndSentry","err","possiblyHashedError","hashErrorIfNeeded","shouldNotReportToSentry","Boolean","isUserError","code","level","LEVEL","INFO","FATAL","Analytics","setError","handleNonBitCustomErrors","path","chalk","red","message","_default","getErrMsg","BitError","report","errorMessage","error","exports"],"sources":["default-error-handler.ts"],"sourcesContent":["// all errors that the command does not handle comes to this switch statement\n// if you handle the error, then return true\nimport chalk from 'chalk';\nimport { BitError } from '@teambit/bit-error';\nimport { Analytics, LEVEL } from '@teambit/legacy.analytics';\nimport { hashErrorIfNeeded } from '@teambit/legacy.cli.error';\n\n/**\n * if err.userError is set, it inherits from AbstractError, which are user errors not Bit errors\n * and should not be reported to Sentry.\n * reason why we don't check (err instanceof AbstractError) is that it could be thrown from a fork,\n * in which case, it loses its class and has only the fields.\n */\nexport function sendToAnalyticsAndSentry(err: Error) {\n const possiblyHashedError = hashErrorIfNeeded(err);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const shouldNotReportToSentry = Boolean(err.isUserError || err.code === 'EACCES');\n // only level FATAL are reported to Sentry.\n const level = shouldNotReportToSentry ? LEVEL.INFO : LEVEL.FATAL;\n Analytics.setError(level, possiblyHashedError);\n}\n\nfunction handleNonBitCustomErrors(err: Error): string {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (err.code === 'EACCES' && err.path) {\n // see #1774\n return chalk.red(\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n `error: you do not have permissions to access '${err.path}', were you running bit, npm or git as root?`\n );\n }\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return chalk.red(err.message || err);\n}\n\nexport default (err: Error): { message: string; error: Error } => {\n const getErrMsg = (): string => {\n if (err instanceof BitError) {\n return err.report();\n }\n return handleNonBitCustomErrors(err);\n };\n sendToAnalyticsAndSentry(err);\n const errorMessage = getErrMsg();\n return { message: chalk.red(errorMessage), error: err };\n};\n"],"mappings":";;;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA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qB,MAAM,CAAC,CAAC;IACrB;IACA,OAAOR,wBAAwB,CAACb,GAAG,CAAC;EACtC,CAAC;EACDD,wBAAwB,CAACC,GAAG,CAAC;EAC7B,MAAMsB,YAAY,GAAGH,SAAS,CAAC,CAAC;EAChC,OAAO;IAAEF,OAAO,EAAEF,gBAAK,CAACC,GAAG,CAACM,YAAY,CAAC;IAAEC,KAAK,EAAEvB;EAAI,CAAC;AACzD,CAAC;AAAAwB,OAAA,CAAA1B,OAAA,GAAAoB,QAAA","ignoreList":[]}
|
package/dist/esm.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-unresolved
|
|
2
|
+
import cjsModule from './index.js';
|
|
3
|
+
|
|
4
|
+
export const CLIAspect = cjsModule.CLIAspect;
|
|
5
|
+
export const MainRuntime = cjsModule.MainRuntime;
|
|
6
|
+
export const handleUnhandledRejection = cjsModule.handleUnhandledRejection;
|
|
7
|
+
export const handleErrorAndExit = cjsModule.handleErrorAndExit;
|
|
8
|
+
export const setExitOnUnhandledRejection = cjsModule.setExitOnUnhandledRejection;
|
|
9
|
+
export const defaultErrorHandler = cjsModule.defaultErrorHandler;
|
|
10
|
+
export const globalFlags = cjsModule.globalFlags;
|
|
11
|
+
export const CLIParser = cjsModule.CLIParser;
|
|
12
|
+
export const YargsExitWorkaround = cjsModule.YargsExitWorkaround;
|
|
13
|
+
export const getArgsData = cjsModule.getArgsData;
|
|
14
|
+
export const getCommandName = cjsModule.getCommandName;
|
|
15
|
+
export const getFlagsData = cjsModule.getFlagsData;
|
|
16
|
+
|
|
17
|
+
export default cjsModule;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AlreadyExistsError = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
class AlreadyExistsError extends _bitError().BitError {
|
|
15
|
+
constructor(type, name) {
|
|
16
|
+
super(`${type} ${name} already exists.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AlreadyExistsError = AlreadyExistsError;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=already-exists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","AlreadyExistsError","BitError","constructor","type","name","exports"],"sources":["already-exists.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class AlreadyExistsError extends BitError {\n constructor(type: string, name: string) {\n super(`${type} ${name} already exists.`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,kBAAkB,SAASC,oBAAQ,CAAC;EAC/CC,WAAWA,CAACC,IAAY,EAAEC,IAAY,EAAE;IACtC,KAAK,CAAC,GAAGD,IAAI,IAAIC,IAAI,kBAAkB,CAAC;EAC1C;AACF;AAACC,OAAA,CAAAL,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CommandNotFound = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _chalk() {
|
|
15
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
16
|
+
_chalk = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
24
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
|
+
class CommandNotFound extends _bitError().BitError {
|
|
26
|
+
constructor(commandName, suggestion) {
|
|
27
|
+
super(`command ${commandName} was not found`);
|
|
28
|
+
_defineProperty(this, "commandName", void 0);
|
|
29
|
+
_defineProperty(this, "suggestion", void 0);
|
|
30
|
+
this.commandName = commandName;
|
|
31
|
+
this.suggestion = suggestion;
|
|
32
|
+
}
|
|
33
|
+
report() {
|
|
34
|
+
let output = _chalk().default.yellow(`warning: '${_chalk().default.bold(this.commandName)}' is not a valid command.
|
|
35
|
+
see 'bit help' for additional information`);
|
|
36
|
+
if (this.suggestion) {
|
|
37
|
+
output += `\nDid you mean ${_chalk().default.bold(this.suggestion)}?`;
|
|
38
|
+
}
|
|
39
|
+
return output;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CommandNotFound = CommandNotFound;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=command-not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_chalk","_interopRequireDefault","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CommandNotFound","BitError","constructor","commandName","suggestion","report","output","chalk","yellow","bold","exports"],"sources":["command-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport chalk from 'chalk';\n\nexport class CommandNotFound extends BitError {\n commandName: string;\n suggestion?: string;\n constructor(commandName: string, suggestion?: string) {\n super(`command ${commandName} was not found`);\n this.commandName = commandName;\n this.suggestion = suggestion;\n }\n report() {\n let output = chalk.yellow(\n `warning: '${chalk.bold(this.commandName)}' is not a valid command.\nsee 'bit help' for additional information`\n );\n if (this.suggestion) {\n output += `\\nDid you mean ${chalk.bold(this.suggestion)}?`;\n }\n return output;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAEnB,MAAMgB,eAAe,SAASC,oBAAQ,CAAC;EAG5CC,WAAWA,CAACC,WAAmB,EAAEC,UAAmB,EAAE;IACpD,KAAK,CAAC,WAAWD,WAAW,gBAAgB,CAAC;IAACrB,eAAA;IAAAA,eAAA;IAC9C,IAAI,CAACqB,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,UAAU,GAAGA,UAAU;EAC9B;EACAC,MAAMA,CAAA,EAAG;IACP,IAAIC,MAAM,GAAGC,gBAAK,CAACC,MAAM,CACvB,aAAaD,gBAAK,CAACE,IAAI,CAAC,IAAI,CAACN,WAAW,CAAC;AAC/C,0CACI,CAAC;IACD,IAAI,IAAI,CAACC,UAAU,EAAE;MACnBE,MAAM,IAAI,kBAAkBC,gBAAK,CAACE,IAAI,CAAC,IAAI,CAACL,UAAU,CAAC,GAAG;IAC5D;IACA,OAAOE,MAAM;EACf;AACF;AAACI,OAAA,CAAAV,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AlreadyExistsError", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _alreadyExists().AlreadyExistsError;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "YargsExitWorkaround", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _yargsExitWorkaround().YargsExitWorkaround;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function _alreadyExists() {
|
|
19
|
+
const data = require("./already-exists");
|
|
20
|
+
_alreadyExists = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function _yargsExitWorkaround() {
|
|
26
|
+
const data = require("./yargs-exit-workaround");
|
|
27
|
+
_yargsExitWorkaround = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_alreadyExists","data","require","_yargsExitWorkaround"],"sources":["index.ts"],"sourcesContent":["export { AlreadyExistsError } from './already-exists';\nexport { YargsExitWorkaround } from './yargs-exit-workaround';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.YargsExitWorkaround = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
class YargsExitWorkaround extends _bitError().BitError {
|
|
15
|
+
constructor(exitCode, helpMsg) {
|
|
16
|
+
super('Workaround for yargs exit issue');
|
|
17
|
+
this.exitCode = exitCode;
|
|
18
|
+
this.helpMsg = helpMsg;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.YargsExitWorkaround = YargsExitWorkaround;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=yargs-exit-workaround.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","YargsExitWorkaround","BitError","constructor","exitCode","helpMsg","exports"],"sources":["yargs-exit-workaround.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class YargsExitWorkaround extends BitError {\n constructor(\n public exitCode: number,\n public helpMsg: string\n ) {\n super('Workaround for yargs exit issue');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,mBAAmB,SAASC,oBAAQ,CAAC;EAChDC,WAAWA,CACFC,QAAgB,EAChBC,OAAe,EACtB;IACA,KAAK,CAAC,iCAAiC,CAAC;IAAC,KAHlCD,QAAgB,GAAhBA,QAAgB;IAAA,KAChBC,OAAe,GAAfA,OAAe;EAGxB;AACF;AAACC,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from './command';
|
|
2
|
+
export type GenerateOpts = {
|
|
3
|
+
metadata?: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
type CommandObject = ReturnType<typeof oneCommandToObject> & {
|
|
6
|
+
commands?: any;
|
|
7
|
+
};
|
|
8
|
+
export declare class GenerateCommandsDoc {
|
|
9
|
+
private commands;
|
|
10
|
+
private options;
|
|
11
|
+
constructor(commands: Command[], options: GenerateOpts);
|
|
12
|
+
generate(): string;
|
|
13
|
+
generateJson(): CommandObject[];
|
|
14
|
+
private commandsToObjects;
|
|
15
|
+
private getFrontmatter;
|
|
16
|
+
private getAllPublicCommandsSorted;
|
|
17
|
+
private generateCommand;
|
|
18
|
+
private generateSubCommands;
|
|
19
|
+
private generateArguments;
|
|
20
|
+
private generateOptions;
|
|
21
|
+
private formatStringToMD;
|
|
22
|
+
private formatDescription;
|
|
23
|
+
}
|
|
24
|
+
declare function oneCommandToObject(command: Command): Partial<Command>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GenerateCommandsDoc = void 0;
|
|
7
|
+
function _lodash() {
|
|
8
|
+
const data = require("lodash");
|
|
9
|
+
_lodash = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _getCommandId() {
|
|
15
|
+
const data = require("./get-command-id");
|
|
16
|
+
_getCommandId = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
class GenerateCommandsDoc {
|
|
22
|
+
constructor(commands, options) {
|
|
23
|
+
this.commands = commands;
|
|
24
|
+
this.options = options;
|
|
25
|
+
}
|
|
26
|
+
generate() {
|
|
27
|
+
const commands = this.getAllPublicCommandsSorted();
|
|
28
|
+
let output = `${this.getFrontmatter()}
|
|
29
|
+
# CLI Reference
|
|
30
|
+
|
|
31
|
+
Run the following to list all available Bit commands (alternatively, use the \`-h\` alias, instead of \`--help\`):
|
|
32
|
+
|
|
33
|
+
\`\`\`sh
|
|
34
|
+
bit --help
|
|
35
|
+
\`\`\`
|
|
36
|
+
|
|
37
|
+
Run the following to get help on a specific command:
|
|
38
|
+
|
|
39
|
+
\`\`\`sh
|
|
40
|
+
bit COMMAND --help
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
Run the following to get help on a specific sub-command:
|
|
44
|
+
|
|
45
|
+
\`\`\`sh
|
|
46
|
+
bit COMMAND SUB_COMMAND --help
|
|
47
|
+
\`\`\`
|
|
48
|
+
`;
|
|
49
|
+
output += commands.map(cmd => this.generateCommand(cmd)).join('\n');
|
|
50
|
+
return output;
|
|
51
|
+
}
|
|
52
|
+
generateJson() {
|
|
53
|
+
return this.commandsToObjects();
|
|
54
|
+
}
|
|
55
|
+
commandsToObjects(commands = this.commands) {
|
|
56
|
+
return commands.map(command => {
|
|
57
|
+
const cmdObject = oneCommandToObject(command);
|
|
58
|
+
if (command.commands?.length) {
|
|
59
|
+
cmdObject.commands = this.commandsToObjects(command.commands);
|
|
60
|
+
}
|
|
61
|
+
return cmdObject;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getFrontmatter() {
|
|
65
|
+
const metadata = this.options.metadata;
|
|
66
|
+
if (!metadata) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
const metadataStr = Object.keys(metadata).map(key => `${key}: ${metadata[key]}`).join('\n');
|
|
70
|
+
return `---
|
|
71
|
+
${metadataStr}
|
|
72
|
+
---
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
getAllPublicCommandsSorted() {
|
|
76
|
+
const publicCommands = this.commands.filter(cmd => !cmd.private);
|
|
77
|
+
return publicCommands.sort((a, b) => a.name.localeCompare(b.name));
|
|
78
|
+
}
|
|
79
|
+
generateCommand(cmd) {
|
|
80
|
+
const commandName = (0, _getCommandId().getCommandId)(cmd.name);
|
|
81
|
+
let result = `## ${commandName} \n\n`;
|
|
82
|
+
if (cmd.alias && cmd.alias.length > 0) {
|
|
83
|
+
result += `**Alias**: \`${cmd.alias}\` \n`;
|
|
84
|
+
}
|
|
85
|
+
result += `**Description**: ${this.formatDescription(cmd)}`;
|
|
86
|
+
result += `\`bit ${cmd.name}\` \n\n`;
|
|
87
|
+
if (cmd.commands && cmd.commands.length > 0) {
|
|
88
|
+
result += this.generateSubCommands(cmd.commands, cmd);
|
|
89
|
+
}
|
|
90
|
+
result += this.generateArguments(cmd.arguments);
|
|
91
|
+
result += this.generateOptions(cmd.options);
|
|
92
|
+
result += `--- \n`;
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
generateSubCommands(subCommands, command) {
|
|
96
|
+
let ret = '';
|
|
97
|
+
subCommands.forEach(subCommand => {
|
|
98
|
+
const commandName = (0, _getCommandId().getCommandId)(command.name);
|
|
99
|
+
const subcommandName = (0, _getCommandId().getCommandId)(subCommand.name);
|
|
100
|
+
const usage = `${commandName} ${subCommand.name}`;
|
|
101
|
+
ret += `### ${commandName} ${subcommandName} \n`;
|
|
102
|
+
ret += `**Usage**: \`${usage}\` \n\n`;
|
|
103
|
+
ret += `**Description**: ${this.formatDescription(subCommand)}`;
|
|
104
|
+
ret += '\n';
|
|
105
|
+
ret += this.generateArguments(subCommand.arguments);
|
|
106
|
+
ret += this.generateOptions(subCommand.options);
|
|
107
|
+
});
|
|
108
|
+
return ret;
|
|
109
|
+
}
|
|
110
|
+
generateArguments(args) {
|
|
111
|
+
if (!args || !args.length) return '';
|
|
112
|
+
let output = `| **Arg** | **Description** | \n`;
|
|
113
|
+
output += `|---|:-----:|\n`;
|
|
114
|
+
args.forEach(arg => {
|
|
115
|
+
const {
|
|
116
|
+
name,
|
|
117
|
+
description
|
|
118
|
+
} = arg;
|
|
119
|
+
output += `|\`${name}\`|${(description || '').replaceAll('\n', ' ')}|\n`;
|
|
120
|
+
});
|
|
121
|
+
output += `\n`;
|
|
122
|
+
return output;
|
|
123
|
+
}
|
|
124
|
+
generateOptions(options) {
|
|
125
|
+
if (!options || options.length <= 0) return '';
|
|
126
|
+
let output = `| **Option** | **Option alias** | **Description**| \n`;
|
|
127
|
+
output += `|---|:-----:|---|\n`;
|
|
128
|
+
options.forEach(opt => {
|
|
129
|
+
const [alias, flag, description] = opt;
|
|
130
|
+
const aliasFormatted = alias ? `\`-${alias}\`` : ' ';
|
|
131
|
+
const flagFormatted = `--${flag}`;
|
|
132
|
+
output += `|\`${flagFormatted}\`|${aliasFormatted}|${description.replaceAll('\n', ' ')}|\n`;
|
|
133
|
+
});
|
|
134
|
+
output += `\n`;
|
|
135
|
+
return output;
|
|
136
|
+
}
|
|
137
|
+
formatStringToMD(str) {
|
|
138
|
+
return str.split('\n').join(' \n');
|
|
139
|
+
}
|
|
140
|
+
formatDescription(command) {
|
|
141
|
+
const extendedDescription = command.extendedDescription ? ` \n${this.formatStringToMD(command.extendedDescription)}` : '';
|
|
142
|
+
const description = this.formatStringToMD(command.description);
|
|
143
|
+
return `${description}${extendedDescription} \n\n`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.GenerateCommandsDoc = GenerateCommandsDoc;
|
|
147
|
+
function oneCommandToObject(command) {
|
|
148
|
+
return (0, _lodash().pick)(command, ['name', 'alias', 'options', 'description', 'extendedDescription', 'group', 'private', 'internal', 'remoteOp', 'skipWorkspace', 'arguments', 'examples']);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=generate-doc-md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_lodash","data","require","_getCommandId","GenerateCommandsDoc","constructor","commands","options","generate","getAllPublicCommandsSorted","output","getFrontmatter","map","cmd","generateCommand","join","generateJson","commandsToObjects","command","cmdObject","oneCommandToObject","length","metadata","metadataStr","Object","keys","key","publicCommands","filter","private","sort","a","b","name","localeCompare","commandName","getCommandId","result","alias","formatDescription","generateSubCommands","generateArguments","arguments","generateOptions","subCommands","ret","forEach","subCommand","subcommandName","usage","args","arg","description","replaceAll","opt","flag","aliasFormatted","flagFormatted","formatStringToMD","str","split","extendedDescription","exports","pick"],"sources":["generate-doc-md.ts"],"sourcesContent":["import { CommandOptions, Command, CommandArg } from './command';\nimport { pick } from 'lodash';\nimport { getCommandId } from './get-command-id';\n\nexport type GenerateOpts = {\n metadata?: Record<string, string>;\n};\n\ntype CommandObject = ReturnType<typeof oneCommandToObject> & { commands?: any };\n\nexport class GenerateCommandsDoc {\n constructor(\n private commands: Command[],\n private options: GenerateOpts\n ) {}\n\n generate(): string {\n const commands = this.getAllPublicCommandsSorted();\n let output = `${this.getFrontmatter()}\n# CLI Reference\n\nRun the following to list all available Bit commands (alternatively, use the \\`-h\\` alias, instead of \\`--help\\`):\n\n\\`\\`\\`sh\nbit --help\n\\`\\`\\`\n\nRun the following to get help on a specific command:\n\n\\`\\`\\`sh\nbit COMMAND --help\n\\`\\`\\`\n\nRun the following to get help on a specific sub-command:\n\n\\`\\`\\`sh\nbit COMMAND SUB_COMMAND --help\n\\`\\`\\`\n`;\n output += commands.map((cmd) => this.generateCommand(cmd)).join('\\n');\n\n return output;\n }\n\n generateJson() {\n return this.commandsToObjects();\n }\n\n private commandsToObjects(commands: Command[] = this.commands): CommandObject[] {\n return commands.map((command) => {\n const cmdObject: CommandObject = oneCommandToObject(command);\n if (command.commands?.length) {\n cmdObject.commands = this.commandsToObjects(command.commands);\n }\n return cmdObject;\n });\n }\n\n private getFrontmatter() {\n const metadata = this.options.metadata;\n if (!metadata) {\n return '';\n }\n const metadataStr = Object.keys(metadata)\n .map((key) => `${key}: ${metadata[key]}`)\n .join('\\n');\n\n return `---\n ${metadataStr}\n ---\n`;\n }\n\n private getAllPublicCommandsSorted() {\n const publicCommands = this.commands.filter((cmd) => !cmd.private);\n return publicCommands.sort((a, b) => a.name.localeCompare(b.name));\n }\n\n private generateCommand(cmd: Command) {\n const commandName = getCommandId(cmd.name);\n let result = `## ${commandName} \\n\\n`;\n if (cmd.alias && cmd.alias.length > 0) {\n result += `**Alias**: \\`${cmd.alias}\\` \\n`;\n }\n result += `**Description**: ${this.formatDescription(cmd)}`;\n result += `\\`bit ${cmd.name}\\` \\n\\n`;\n\n if (cmd.commands && cmd.commands.length > 0) {\n result += this.generateSubCommands(cmd.commands, cmd);\n }\n result += this.generateArguments(cmd.arguments);\n result += this.generateOptions(cmd.options);\n result += `--- \\n`;\n\n return result;\n }\n\n private generateSubCommands(subCommands: Command[], command: Command) {\n let ret = '';\n subCommands.forEach((subCommand) => {\n const commandName = getCommandId(command.name);\n const subcommandName = getCommandId(subCommand.name);\n const usage = `${commandName} ${subCommand.name}`;\n ret += `### ${commandName} ${subcommandName} \\n`;\n ret += `**Usage**: \\`${usage}\\` \\n\\n`;\n ret += `**Description**: ${this.formatDescription(subCommand)}`;\n\n ret += '\\n';\n ret += this.generateArguments(subCommand.arguments);\n ret += this.generateOptions(subCommand.options);\n });\n return ret;\n }\n\n private generateArguments(args?: CommandArg[]): string {\n if (!args || !args.length) return '';\n let output = `| **Arg** | **Description** | \\n`;\n output += `|---|:-----:|\\n`;\n args.forEach((arg) => {\n const { name, description } = arg;\n output += `|\\`${name}\\`|${(description || '').replaceAll('\\n', ' ')}|\\n`;\n });\n output += `\\n`;\n return output;\n }\n\n private generateOptions(options: CommandOptions): string {\n if (!options || options.length <= 0) return '';\n let output = `| **Option** | **Option alias** | **Description**| \\n`;\n output += `|---|:-----:|---|\\n`;\n options.forEach((opt) => {\n const [alias, flag, description] = opt;\n const aliasFormatted = alias ? `\\`-${alias}\\`` : ' ';\n const flagFormatted = `--${flag}`;\n output += `|\\`${flagFormatted}\\`|${aliasFormatted}|${description.replaceAll('\\n', ' ')}|\\n`;\n });\n output += `\\n`;\n return output;\n }\n\n private formatStringToMD(str: string): string {\n return str.split('\\n').join(' \\n');\n }\n\n private formatDescription(command: Command): string {\n const extendedDescription = command.extendedDescription\n ? ` \\n${this.formatStringToMD(command.extendedDescription)}`\n : '';\n const description = this.formatStringToMD(command.description as string);\n return `${description}${extendedDescription} \\n\\n`;\n }\n}\n\nfunction oneCommandToObject(command: Command) {\n return pick(command, [\n 'name',\n 'alias',\n 'options',\n 'description',\n 'extendedDescription',\n 'group',\n 'private',\n 'internal',\n 'remoteOp',\n 'skipWorkspace',\n 'arguments',\n 'examples',\n ]);\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAA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A,CAAA1D,mBAAA,GAAAA,mBAAA;AAED,SAASgB,kBAAkBA,CAACF,OAAgB,EAAE;EAC5C,OAAO,IAAA6C,cAAI,EAAC7C,OAAO,EAAE,CACnB,MAAM,EACN,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,CACX,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCommandId(cmdName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCommandId","cmdName","split","trim"],"sources":["get-command-id.ts"],"sourcesContent":["export function getCommandId(cmdName: string) {\n return cmdName.split(' ')[0].trim();\n}\n"],"mappings":";;;;;;AAAO,SAASA,YAAYA,CAACC,OAAe,EAAE;EAC5C,OAAOA,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;AACrC","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
class GlobalFlags {
|
|
11
|
+
constructor() {
|
|
12
|
+
_defineProperty(this, "_token", void 0);
|
|
13
|
+
}
|
|
14
|
+
get token() {
|
|
15
|
+
return this._token;
|
|
16
|
+
}
|
|
17
|
+
set token(token) {
|
|
18
|
+
this._token = token;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const globalFlags = new GlobalFlags();
|
|
22
|
+
var _default = exports.default = globalFlags;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=global-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GlobalFlags","constructor","_defineProperty","token","_token","globalFlags","_default","exports","default"],"sources":["global-flags.ts"],"sourcesContent":["class GlobalFlags {\n private _token?: string;\n get token(): string | undefined {\n return this._token;\n }\n\n set token(token: string | undefined) {\n this._token = token;\n }\n}\n\nconst globalFlags = new GlobalFlags();\n\nexport default globalFlags;\n"],"mappings":";;;;;;;;;AAAA,MAAMA,WAAW,CAAC;EAAAC,YAAA;IAAAC,eAAA;EAAA;EAEhB,IAAIC,KAAKA,CAAA,EAAuB;IAC9B,OAAO,IAAI,CAACC,MAAM;EACpB;EAEA,IAAID,KAAKA,CAACA,KAAyB,EAAE;IACnC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;AACF;AAEA,MAAME,WAAW,GAAG,IAAIL,WAAW,CAAC,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEvBH,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleErrorAndExit = handleErrorAndExit;
|
|
7
|
+
exports.handleUnhandledRejection = handleUnhandledRejection;
|
|
8
|
+
exports.setExitOnUnhandledRejection = setExitOnUnhandledRejection;
|
|
9
|
+
function _legacy() {
|
|
10
|
+
const data = require("@teambit/legacy.logger");
|
|
11
|
+
_legacy = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _defaultErrorHandler() {
|
|
17
|
+
const data = _interopRequireDefault(require("./default-error-handler"));
|
|
18
|
+
_defaultErrorHandler = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _legacy2() {
|
|
24
|
+
const data = require("@teambit/legacy.loader");
|
|
25
|
+
_legacy2 = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
|
+
let exitOnUnhandled = true;
|
|
32
|
+
|
|
33
|
+
// This provide a way to not exit when an unhandled rejection is found
|
|
34
|
+
// This is main required when we load plugins which are esm modules and they require cjs modules
|
|
35
|
+
// and there is as an error in the cjs module
|
|
36
|
+
// in such case the regular catch will not catch the error and the process will exit
|
|
37
|
+
// we don't want to exit in such case (of plugins load) so we provide a way to not exit
|
|
38
|
+
function setExitOnUnhandledRejection(exit) {
|
|
39
|
+
exitOnUnhandled = exit;
|
|
40
|
+
}
|
|
41
|
+
async function handleErrorAndExit(err, commandName) {
|
|
42
|
+
try {
|
|
43
|
+
_legacy2().loader.off();
|
|
44
|
+
_legacy().logger.error(`got an error from command ${commandName}: ${err}`, err);
|
|
45
|
+
const {
|
|
46
|
+
message
|
|
47
|
+
} = (0, _defaultErrorHandler().default)(err);
|
|
48
|
+
await logErrAndExit(message, commandName, err);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
console.error('failed to log the error properly, failure error', e);
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.error('failed to log the error properly, original error', err);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function handleUnhandledRejection(err) {
|
|
58
|
+
// eslint-disable-next-line no-console
|
|
59
|
+
console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);
|
|
60
|
+
if (!exitOnUnhandled) {
|
|
61
|
+
_legacy().logger.error(`ignoring unhandled rejection error:`, err);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (err instanceof Error) {
|
|
65
|
+
return handleErrorAndExit(err, process.argv[2]);
|
|
66
|
+
}
|
|
67
|
+
console.error(err); // eslint-disable-line
|
|
68
|
+
return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);
|
|
69
|
+
}
|
|
70
|
+
async function logErrAndExit(errMsg, commandName, errObj) {
|
|
71
|
+
if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);
|
|
72
|
+
console.error(errMsg); // eslint-disable-line
|
|
73
|
+
// for CI, print the entire error with the stacktrace
|
|
74
|
+
if (process.env.CI) console.error(errObj); // eslint-disable-line
|
|
75
|
+
await _legacy().logger.exitAfterFlush(1, commandName, errMsg.toString());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=handle-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_legacy","data","require","_defaultErrorHandler","_interopRequireDefault","_legacy2","e","__esModule","default","exitOnUnhandled","setExitOnUnhandledRejection","exit","handleErrorAndExit","err","commandName","loader","off","logger","error","message","defaultHandleError","logErrAndExit","console","process","handleUnhandledRejection","Error","argv","errMsg","errObj","env","CI","exitAfterFlush","toString"],"sources":["handle-errors.ts"],"sourcesContent":["import { logger } from '@teambit/legacy.logger';\nimport defaultHandleError from './default-error-handler';\nimport { loader } from '@teambit/legacy.loader';\n\nlet exitOnUnhandled = true;\n\n// This provide a way to not exit when an unhandled rejection is found\n// This is main required when we load plugins which are esm modules and they require cjs modules\n// and there is as an error in the cjs module\n// in such case the regular catch will not catch the error and the process will exit\n// we don't want to exit in such case (of plugins load) so we provide a way to not exit\nexport function setExitOnUnhandledRejection(exit: boolean) {\n exitOnUnhandled = exit;\n}\n\nexport async function handleErrorAndExit(err: Error, commandName: string): Promise<void> {\n try {\n loader.off();\n logger.error(`got an error from command ${commandName}: ${err}`, err);\n const { message } = defaultHandleError(err);\n await logErrAndExit(message, commandName, err);\n } catch (e: any) {\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, failure error', e);\n // eslint-disable-next-line no-console\n console.error('failed to log the error properly, original error', err);\n process.exit(1);\n }\n}\n\nexport async function handleUnhandledRejection(err: Error | null | undefined | {}) {\n // eslint-disable-next-line no-console\n console.error('** unhandled rejection found, please make sure the promise is resolved/rejected correctly! **', err);\n if (!exitOnUnhandled) {\n logger.error(`ignoring unhandled rejection error:`, err);\n return;\n }\n if (err instanceof Error) {\n return handleErrorAndExit(err, process.argv[2]);\n }\n console.error(err); // eslint-disable-line\n return handleErrorAndExit(new Error(`unhandledRejections found. err ${err}`), process.argv[2]);\n}\n\nasync function logErrAndExit(errMsg: Error | string, commandName: string, errObj: Error) {\n if (!errMsg) throw new Error(`logErrAndExit expects to get either an Error or a string, got nothing`);\n console.error(errMsg); // eslint-disable-line\n // for CI, print the entire error with the stacktrace\n if (process.env.CI) console.error(errObj); // eslint-disable-line\n await logger.exitAfterFlush(1, commandName, errMsg.toString());\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CA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