@teambit/cli 0.0.0-00805bd6ead01ffad26e598a8de15824e876ee5a
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/.npmignore +18 -0
- package/cli-output-style-guide.md +132 -0
- package/cli.composition.tsx +7 -0
- package/cli.docs.mdx +12 -0
- package/dist/cli-output-style-guide.md +132 -0
- package/dist/cli-parser.d.ts +38 -0
- package/dist/cli-parser.js +388 -0
- package/dist/cli-parser.js.map +1 -0
- package/dist/cli-parser.spec.d.ts +1 -0
- package/dist/cli-parser.spec.js +113 -0
- package/dist/cli-parser.spec.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 +34 -0
- package/dist/cli.cmd.js +163 -0
- package/dist/cli.cmd.js.map +1 -0
- package/dist/cli.composition.d.ts +2 -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 +270 -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 +38 -0
- package/dist/command-runner.js +227 -0
- package/dist/command-runner.js.map +1 -0
- package/dist/command.d.ts +145 -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 +80 -0
- package/dist/default-error-handler.js.map +1 -0
- package/dist/details.cmd.d.ts +12 -0
- package/dist/details.cmd.js +78 -0
- package/dist/details.cmd.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 +39 -0
- package/dist/generate-doc-md.js +266 -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 +16 -0
- package/dist/help.cmd.js +37 -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 +14 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/dist/output-formatter.d.ts +40 -0
- package/dist/output-formatter.js +115 -0
- package/dist/output-formatter.js.map +1 -0
- package/dist/pager.d.ts +35 -0
- package/dist/pager.js +178 -0
- package/dist/pager.js.map +1 -0
- package/dist/preview-1787076242549.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 +133 -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 +74 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +46 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.groups = void 0;
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
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; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
+
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); }
|
|
12
|
+
/**
|
|
13
|
+
* They might be needed for backward compatibility.
|
|
14
|
+
*/
|
|
15
|
+
const oldGroups = {
|
|
16
|
+
start: 'Start a working area',
|
|
17
|
+
development: 'Develop components',
|
|
18
|
+
discover: 'Explore components',
|
|
19
|
+
info: 'View components',
|
|
20
|
+
general: 'Workspace commands'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* These are the main group.
|
|
25
|
+
* It's possible to create new groups by calling `cliMain.registerGroup()`.
|
|
26
|
+
*/
|
|
27
|
+
const groups = exports.groups = _objectSpread(_objectSpread({}, oldGroups), {}, {
|
|
28
|
+
'workspace-setup': 'Workspace & Project Setup',
|
|
29
|
+
collaborate: 'Collaboration & Remote',
|
|
30
|
+
'info-analysis': 'Information & Analysis',
|
|
31
|
+
'workspace-tools': 'Workspace Tools',
|
|
32
|
+
'component-config': 'Component Configuration',
|
|
33
|
+
'component-development': 'Component Development',
|
|
34
|
+
dependencies: 'Dependencies & Packages',
|
|
35
|
+
'version-control': 'Version Control',
|
|
36
|
+
testing: 'Testing & Quality',
|
|
37
|
+
'run-serve': 'Run & Serve',
|
|
38
|
+
system: 'System & Utility',
|
|
39
|
+
auth: 'Authentication & Cloud',
|
|
40
|
+
advanced: 'Advanced/Debug',
|
|
41
|
+
ungrouped: 'Ungrouped'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=command-groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["oldGroups","start","development","discover","info","general","groups","exports","_objectSpread","collaborate","dependencies","testing","system","auth","advanced","ungrouped"],"sources":["command-groups.ts"],"sourcesContent":["/**\n * They might be needed for backward compatibility.\n */\nconst oldGroups = {\n start: 'Start a working area',\n development: 'Develop components',\n discover: 'Explore components',\n info: 'View components',\n general: 'Workspace commands',\n};\n\n/**\n * These are the main group.\n * It's possible to create new groups by calling `cliMain.registerGroup()`.\n */\nexport const groups = {\n ...oldGroups,\n 'workspace-setup': 'Workspace & Project Setup',\n collaborate: 'Collaboration & Remote',\n 'info-analysis': 'Information & Analysis',\n 'workspace-tools': 'Workspace Tools',\n 'component-config': 'Component Configuration',\n 'component-development': 'Component Development',\n dependencies: 'Dependencies & Packages',\n 'version-control': 'Version Control',\n testing: 'Testing & Quality',\n 'run-serve': 'Run & Serve',\n system: 'System & Utility',\n auth: 'Authentication & Cloud',\n advanced: 'Advanced/Debug',\n ungrouped: 'Ungrouped',\n};\n\nexport type Group = keyof typeof groups;\n\ntype GroupDescription = string;\n\nexport type GroupsType = { [groupName: string]: GroupDescription };\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA,MAAMA,SAAS,GAAG;EAChBC,KAAK,EAAE,sBAAsB;EAC7BC,WAAW,EAAE,oBAAoB;EACjCC,QAAQ,EAAE,oBAAoB;EAC9BC,IAAI,EAAE,iBAAiB;EACvBC,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAAE,aAAA,CAAAA,aAAA,KACdR,SAAS;EACZ,iBAAiB,EAAE,2BAA2B;EAC9CS,WAAW,EAAE,wBAAwB;EACrC,eAAe,EAAE,wBAAwB;EACzC,iBAAiB,EAAE,iBAAiB;EACpC,kBAAkB,EAAE,yBAAyB;EAC7C,uBAAuB,EAAE,uBAAuB;EAChDC,YAAY,EAAE,yBAAyB;EACvC,iBAAiB,EAAE,iBAAiB;EACpCC,OAAO,EAAE,mBAAmB;EAC5B,WAAW,EAAE,aAAa;EAC1BC,MAAM,EAAE,kBAAkB;EAC1BC,IAAI,EAAE,wBAAwB;EAC9BC,QAAQ,EAAE,gBAAgB;EAC1BC,SAAS,EAAE;AAAW,EACvB","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Command } from './command';
|
|
2
|
+
type ArgData = {
|
|
3
|
+
/**
|
|
4
|
+
* as it appears in the command name, e.g. "component-pattern..."
|
|
5
|
+
*/
|
|
6
|
+
nameRaw: string;
|
|
7
|
+
/**
|
|
8
|
+
* to make it valid as a js variable name, e.g. "componentPattern"
|
|
9
|
+
*/
|
|
10
|
+
nameCamelCase: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
isArray?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function getArgsData(cmd: Command): ArgData[];
|
|
16
|
+
type FlagData = {
|
|
17
|
+
name: string;
|
|
18
|
+
alias?: string;
|
|
19
|
+
description: string;
|
|
20
|
+
type: 'string' | 'boolean';
|
|
21
|
+
requiresArg: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function getFlagsData(cmd: Command): FlagData[];
|
|
24
|
+
export declare function getCommandName(cmd: Command): string;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getArgsData = getArgsData;
|
|
7
|
+
exports.getCommandName = getCommandName;
|
|
8
|
+
exports.getFlagsData = getFlagsData;
|
|
9
|
+
function _lodash() {
|
|
10
|
+
const data = require("lodash");
|
|
11
|
+
_lodash = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function getArgsData(cmd) {
|
|
17
|
+
const commandSplit = cmd.name.split(' ');
|
|
18
|
+
commandSplit.shift(); // remove the first element, it's the command-name
|
|
19
|
+
|
|
20
|
+
return commandSplit.map(existArg => {
|
|
21
|
+
const trimmed = existArg.trim();
|
|
22
|
+
if (!trimmed.startsWith('<') && !trimmed.startsWith('[') || !trimmed.endsWith('>') && !trimmed.endsWith(']')) {
|
|
23
|
+
throw new Error(`expect arg "${trimmed}" of "${cmd.name}" to be wrapped with "[]" or "<>"`);
|
|
24
|
+
}
|
|
25
|
+
// remove the opening and closing brackets
|
|
26
|
+
const withoutBrackets = trimmed.slice(1, -1);
|
|
27
|
+
const foundInArguments = cmd.arguments?.find(arg => arg.name === withoutBrackets);
|
|
28
|
+
return {
|
|
29
|
+
nameRaw: withoutBrackets,
|
|
30
|
+
nameCamelCase: (0, _lodash().camelCase)(withoutBrackets),
|
|
31
|
+
// it also removes the "..." if exists
|
|
32
|
+
required: trimmed.startsWith('<'),
|
|
33
|
+
description: foundInArguments?.description,
|
|
34
|
+
isArray: withoutBrackets.endsWith('...')
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function getFlagsData(cmd) {
|
|
39
|
+
const options = cmd.options;
|
|
40
|
+
if (!options) return [];
|
|
41
|
+
return options.map(opt => {
|
|
42
|
+
const [alias, flag, description] = opt;
|
|
43
|
+
const name = flag.split(' ')[0];
|
|
44
|
+
const type = flag.includes('<') || flag.includes('[') ? 'string' : 'boolean';
|
|
45
|
+
const requiresArg = flag.includes('<');
|
|
46
|
+
return {
|
|
47
|
+
name,
|
|
48
|
+
alias,
|
|
49
|
+
description,
|
|
50
|
+
type,
|
|
51
|
+
requiresArg
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function getCommandName(cmd) {
|
|
56
|
+
return cmd.name.split(' ')[0];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=command-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_lodash","data","require","getArgsData","cmd","commandSplit","name","split","shift","map","existArg","trimmed","trim","startsWith","endsWith","Error","withoutBrackets","slice","foundInArguments","arguments","find","arg","nameRaw","nameCamelCase","camelCase","required","description","isArray","getFlagsData","options","opt","alias","flag","type","includes","requiresArg","getCommandName"],"sources":["command-helper.ts"],"sourcesContent":["import type { Command } from './command';\nimport { camelCase } from 'lodash';\n\ntype ArgData = {\n /**\n * as it appears in the command name, e.g. \"component-pattern...\"\n */\n nameRaw: string;\n /**\n * to make it valid as a js variable name, e.g. \"componentPattern\"\n */\n nameCamelCase: string;\n required: boolean;\n description?: string;\n isArray?: boolean;\n};\n\nexport function getArgsData(cmd: Command): ArgData[] {\n const commandSplit = cmd.name.split(' ');\n commandSplit.shift(); // remove the first element, it's the command-name\n\n return commandSplit.map((existArg) => {\n const trimmed = existArg.trim();\n if ((!trimmed.startsWith('<') && !trimmed.startsWith('[')) || (!trimmed.endsWith('>') && !trimmed.endsWith(']'))) {\n throw new Error(`expect arg \"${trimmed}\" of \"${cmd.name}\" to be wrapped with \"[]\" or \"<>\"`);\n }\n // remove the opening and closing brackets\n const withoutBrackets = trimmed.slice(1, -1);\n const foundInArguments = cmd.arguments?.find((arg) => arg.name === withoutBrackets);\n\n return {\n nameRaw: withoutBrackets,\n nameCamelCase: camelCase(withoutBrackets), // it also removes the \"...\" if exists\n required: trimmed.startsWith('<'),\n description: foundInArguments?.description,\n isArray: withoutBrackets.endsWith('...'),\n };\n });\n}\n\ntype FlagData = {\n name: string;\n alias?: string;\n description: string;\n type: 'string' | 'boolean';\n requiresArg: boolean; // a value is required after the flag. e.g. 'message <message>'\n};\n\nexport function getFlagsData(cmd: Command): FlagData[] {\n const options = cmd.options;\n if (!options) return [];\n return options.map((opt) => {\n const [alias, flag, description] = opt;\n const name = flag.split(' ')[0];\n const type = flag.includes('<') || flag.includes('[') ? 'string' : 'boolean';\n const requiresArg = flag.includes('<');\n\n return {\n name,\n alias,\n description,\n type,\n requiresArg,\n };\n });\n}\n\nexport function getCommandName(cmd: Command): string {\n return cmd.name.split(' ')[0];\n}\n"],"mappings":";;;;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAgBO,SAASE,WAAWA,CAACC,GAAY,EAAa;EACnD,MAAMC,YAAY,GAAGD,GAAG,CAACE,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC;EACxCF,YAAY,CAACG,KAAK,CAAC,CAAC,CAAC,CAAC;;EAEtB,OAAOH,YAAY,CAACI,GAAG,CAAEC,QAAQ,IAAK;IACpC,MAAMC,OAAO,GAAGD,QAAQ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CAACE,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,GAAG,SAAS;IAC5E,MAAMC,WAAW,GAAGH,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC;IAEtC,OAAO;MACL5B,IAAI;MACJyB,KAAK;MACLL,WAAW;MACXO,IAAI;MACJE;IACF,CAAC;EACH,CAAC,CAAC;AACJ;AAEO,SAASC,cAAcA,CAAChC,GAAY,EAAU;EACnD,OAAOA,GAAG,CAACE,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CLIArgs, Command, Flags } from './command';
|
|
2
|
+
import type { OnCommandStartSlot } from './cli.main.runtime';
|
|
3
|
+
export declare const LAST_COMMAND_DETAILS_DIR: string;
|
|
4
|
+
type CommandResult = {
|
|
5
|
+
data: any;
|
|
6
|
+
exitCode: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class CommandRunner {
|
|
9
|
+
private command;
|
|
10
|
+
private args;
|
|
11
|
+
private flags;
|
|
12
|
+
private onCommandStartSlot;
|
|
13
|
+
private commandName;
|
|
14
|
+
constructor(command: Command, args: CLIArgs, flags: Flags, onCommandStartSlot: OnCommandStartSlot);
|
|
15
|
+
/**
|
|
16
|
+
* run command using one of the handler, "json"/"report"/"render". once done, exit the process.
|
|
17
|
+
*/
|
|
18
|
+
runCommand(shouldReturnResult?: boolean): Promise<void | CommandResult>;
|
|
19
|
+
private bootstrapCommand;
|
|
20
|
+
private getRedactedFlagsForReporting;
|
|
21
|
+
private invokeOnCommandStart;
|
|
22
|
+
/**
|
|
23
|
+
* this works for both, Harmony commands and Legacy commands (the legacy-command-adapter
|
|
24
|
+
* implements json() method)
|
|
25
|
+
*/
|
|
26
|
+
private runJsonHandler;
|
|
27
|
+
private runReportHandler;
|
|
28
|
+
private persistDetails;
|
|
29
|
+
private runWaitHandler;
|
|
30
|
+
/**
|
|
31
|
+
* the loader and logger.console write output to the console during the command execution.
|
|
32
|
+
* for internals commands, such as, _put, _fetch, the command.loader = false.
|
|
33
|
+
*/
|
|
34
|
+
private determineConsoleWritingDuringCommand;
|
|
35
|
+
private writeAndExit;
|
|
36
|
+
}
|
|
37
|
+
export declare function parseCommandName(commandName: string): string;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LAST_COMMAND_DETAILS_DIR = exports.CommandRunner = void 0;
|
|
7
|
+
exports.parseCommandName = parseCommandName;
|
|
8
|
+
function _legacy() {
|
|
9
|
+
const data = require("@teambit/legacy.logger");
|
|
10
|
+
_legacy = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _legacy2() {
|
|
16
|
+
const data = require("@teambit/legacy.loader");
|
|
17
|
+
_legacy2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _handleErrors() {
|
|
23
|
+
const data = require("./handle-errors");
|
|
24
|
+
_handleErrors = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
function _legacy3() {
|
|
30
|
+
const data = require("@teambit/legacy.constants");
|
|
31
|
+
_legacy3 = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
function _globalFlags() {
|
|
37
|
+
const data = _interopRequireDefault(require("./global-flags"));
|
|
38
|
+
_globalFlags = function () {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
function _pager() {
|
|
44
|
+
const data = require("./pager");
|
|
45
|
+
_pager = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function _legacy4() {
|
|
51
|
+
const data = require("@teambit/legacy.analytics");
|
|
52
|
+
_legacy4 = function () {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _pMapSeries() {
|
|
58
|
+
const data = _interopRequireDefault(require("p-map-series"));
|
|
59
|
+
_pMapSeries = function () {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
function _fsExtra() {
|
|
65
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
66
|
+
_fsExtra = function () {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
function _path() {
|
|
72
|
+
const data = _interopRequireDefault(require("path"));
|
|
73
|
+
_path = function () {
|
|
74
|
+
return data;
|
|
75
|
+
};
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
79
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
80
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
81
|
+
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; }
|
|
82
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
83
|
+
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); }
|
|
84
|
+
const LAST_COMMAND_DETAILS_DIR = exports.LAST_COMMAND_DETAILS_DIR = _path().default.join(_legacy3().CACHE_ROOT, 'last-command-details');
|
|
85
|
+
class CommandRunner {
|
|
86
|
+
constructor(command, args, flags, onCommandStartSlot) {
|
|
87
|
+
this.command = command;
|
|
88
|
+
this.args = args;
|
|
89
|
+
this.flags = flags;
|
|
90
|
+
this.onCommandStartSlot = onCommandStartSlot;
|
|
91
|
+
_defineProperty(this, "commandName", void 0);
|
|
92
|
+
this.commandName = parseCommandName(this.command.name);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* run command using one of the handler, "json"/"report"/"render". once done, exit the process.
|
|
97
|
+
*/
|
|
98
|
+
async runCommand(shouldReturnResult = false) {
|
|
99
|
+
try {
|
|
100
|
+
this.bootstrapCommand();
|
|
101
|
+
await this.invokeOnCommandStart();
|
|
102
|
+
this.determineConsoleWritingDuringCommand();
|
|
103
|
+
if (this.flags.json) {
|
|
104
|
+
return await this.runJsonHandler(shouldReturnResult);
|
|
105
|
+
}
|
|
106
|
+
if (this.command.report) {
|
|
107
|
+
return await this.runReportHandler(shouldReturnResult);
|
|
108
|
+
}
|
|
109
|
+
if (this.command.wait) {
|
|
110
|
+
return await this.runWaitHandler();
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (shouldReturnResult) throw err;
|
|
114
|
+
return (0, _handleErrors().handleErrorAndExit)(err, this.commandName);
|
|
115
|
+
}
|
|
116
|
+
throw new Error(`command "${this.commandName}" doesn't implement "render" nor "report" nor "wait" methods`);
|
|
117
|
+
}
|
|
118
|
+
bootstrapCommand() {
|
|
119
|
+
// Redact --token before anything is logged or sent to analytics. The raw token
|
|
120
|
+
// is the user's bit.cloud credential; debug logs are persisted to disk and
|
|
121
|
+
// routinely shared in support tickets / issues.
|
|
122
|
+
const redactedFlags = this.getRedactedFlagsForReporting();
|
|
123
|
+
try {
|
|
124
|
+
_legacy4().Analytics.init(this.commandName, redactedFlags, this.args);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
// ignoring the error, we don't want to fail the app if analytics failed.
|
|
127
|
+
_legacy().logger.error('failed to initialize analytics', err);
|
|
128
|
+
}
|
|
129
|
+
_legacy().logger.info(`[*] started a new command: "${this.commandName}" with the following data:`, {
|
|
130
|
+
args: this.args,
|
|
131
|
+
flags: redactedFlags
|
|
132
|
+
});
|
|
133
|
+
const token = this.flags[_legacy3().TOKEN_FLAG_NAME];
|
|
134
|
+
if (token) {
|
|
135
|
+
_globalFlags().default.token = token.toString();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
getRedactedFlagsForReporting() {
|
|
139
|
+
if (this.flags[_legacy3().TOKEN_FLAG_NAME] == null) return this.flags;
|
|
140
|
+
return _objectSpread(_objectSpread({}, this.flags), {}, {
|
|
141
|
+
[_legacy3().TOKEN_FLAG_NAME]: '<redacted>'
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async invokeOnCommandStart() {
|
|
145
|
+
const funcs = this.onCommandStartSlot.values();
|
|
146
|
+
await (0, _pMapSeries().default)(funcs, onCommandStart => onCommandStart(this.commandName, this.args, this.flags));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* this works for both, Harmony commands and Legacy commands (the legacy-command-adapter
|
|
151
|
+
* implements json() method)
|
|
152
|
+
*/
|
|
153
|
+
async runJsonHandler(shouldReturnResult = false) {
|
|
154
|
+
if (!this.flags.json) return undefined;
|
|
155
|
+
if (!this.command.json) throw new Error(`command "${this.commandName}" doesn't implement "json" method`);
|
|
156
|
+
const result = await this.command.json(this.args, this.flags);
|
|
157
|
+
const code = result.code || 0;
|
|
158
|
+
const data = result.data || result;
|
|
159
|
+
if (shouldReturnResult) return {
|
|
160
|
+
data,
|
|
161
|
+
exitCode: code
|
|
162
|
+
};
|
|
163
|
+
const isJsonStream = Boolean(this.flags.stream);
|
|
164
|
+
if (isJsonStream) data.end = true;
|
|
165
|
+
const jsonStr = isJsonStream ? `${JSON.stringify(data)}\n` : JSON.stringify(data, null, 2);
|
|
166
|
+
await this.writeAndExit(jsonStr, code);
|
|
167
|
+
}
|
|
168
|
+
async runReportHandler(shouldReturnResult = false) {
|
|
169
|
+
if (!this.command.report) throw new Error('runReportHandler expects command.report to be implemented');
|
|
170
|
+
const result = await this.command.report(this.args, this.flags);
|
|
171
|
+
_legacy2().loader.off();
|
|
172
|
+
const data = typeof result === 'string' ? result : result.data;
|
|
173
|
+
const exitCode = typeof result === 'string' ? 0 : result.code;
|
|
174
|
+
if (shouldReturnResult) return {
|
|
175
|
+
data,
|
|
176
|
+
exitCode
|
|
177
|
+
};
|
|
178
|
+
const details = typeof result === 'string' ? undefined : result.details;
|
|
179
|
+
if (details) {
|
|
180
|
+
await this.persistDetails(details).catch(err => _legacy().logger.error('failed to persist command details', err));
|
|
181
|
+
}
|
|
182
|
+
await this.writeAndExit(`${data}\n`, exitCode);
|
|
183
|
+
}
|
|
184
|
+
async persistDetails(details) {
|
|
185
|
+
await _fsExtra().default.ensureDir(LAST_COMMAND_DETAILS_DIR);
|
|
186
|
+
const meta = JSON.stringify({
|
|
187
|
+
command: this.commandName,
|
|
188
|
+
timestamp: new Date().toISOString()
|
|
189
|
+
});
|
|
190
|
+
await Promise.all([_fsExtra().default.writeFile(_path().default.join(LAST_COMMAND_DETAILS_DIR, 'content'), details), _fsExtra().default.writeFile(_path().default.join(LAST_COMMAND_DETAILS_DIR, 'meta.json'), meta)]);
|
|
191
|
+
}
|
|
192
|
+
async runWaitHandler() {
|
|
193
|
+
if (!this.command.wait) throw new Error('runReportHandler expects command.wait to be implemented');
|
|
194
|
+
await this.command.wait(this.args, this.flags);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* the loader and logger.console write output to the console during the command execution.
|
|
199
|
+
* for internals commands, such as, _put, _fetch, the command.loader = false.
|
|
200
|
+
*/
|
|
201
|
+
determineConsoleWritingDuringCommand() {
|
|
202
|
+
if (this.command.loader && !this.flags.json && !this.flags['get-yargs-completions'] && !_legacy().shouldDisableLoader) {
|
|
203
|
+
_legacy2().loader.on();
|
|
204
|
+
_legacy2().loader.start(`running command "${this.commandName}"...`);
|
|
205
|
+
_legacy().logger.shouldWriteToConsole = true;
|
|
206
|
+
} else {
|
|
207
|
+
_legacy2().loader.off();
|
|
208
|
+
_legacy().logger.shouldWriteToConsole = false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async writeAndExit(data, exitCode) {
|
|
212
|
+
if ((0, _pager().shouldUsePager)(this.command, this.flags, data)) {
|
|
213
|
+
const paged = await (0, _pager().writeToPager)(data, Boolean(this.flags.pager));
|
|
214
|
+
// if the pager couldn't launch, fall through to a direct write so output is never lost.
|
|
215
|
+
if (paged) return _legacy().logger.exitAfterFlush(exitCode, this.commandName, data);
|
|
216
|
+
}
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
218
|
+
return process.stdout.write(data, async () => _legacy().logger.exitAfterFlush(exitCode, this.commandName, data));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.CommandRunner = CommandRunner;
|
|
222
|
+
function parseCommandName(commandName) {
|
|
223
|
+
if (!commandName) return '';
|
|
224
|
+
return commandName.split(' ')[0];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=command-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_legacy","data","require","_legacy2","_handleErrors","_legacy3","_globalFlags","_interopRequireDefault","_pager","_legacy4","_pMapSeries","_fsExtra","_path","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LAST_COMMAND_DETAILS_DIR","exports","path","join","CACHE_ROOT","CommandRunner","constructor","command","args","flags","onCommandStartSlot","commandName","parseCommandName","name","runCommand","shouldReturnResult","bootstrapCommand","invokeOnCommandStart","determineConsoleWritingDuringCommand","json","runJsonHandler","report","runReportHandler","wait","runWaitHandler","err","handleErrorAndExit","Error","redactedFlags","getRedactedFlagsForReporting","Analytics","init","logger","error","info","token","TOKEN_FLAG_NAME","globalFlags","toString","funcs","values","pMapSeries","onCommandStart","undefined","result","code","exitCode","isJsonStream","Boolean","stream","end","jsonStr","JSON","stringify","writeAndExit","loader","off","details","persistDetails","catch","fs","ensureDir","meta","timestamp","Date","toISOString","Promise","all","writeFile","shouldDisableLoader","on","start","shouldWriteToConsole","shouldUsePager","paged","writeToPager","pager","exitAfterFlush","process","stdout","write","split"],"sources":["command-runner.ts"],"sourcesContent":["import { logger, shouldDisableLoader } from '@teambit/legacy.logger';\nimport type { CLIArgs, Command, Flags } from './command';\nimport { loader } from '@teambit/legacy.loader';\nimport { handleErrorAndExit } from './handle-errors';\nimport { TOKEN_FLAG_NAME, CACHE_ROOT } from '@teambit/legacy.constants';\nimport globalFlags from './global-flags';\nimport { shouldUsePager, writeToPager } from './pager';\nimport { Analytics } from '@teambit/legacy.analytics';\nimport type { OnCommandStartSlot } from './cli.main.runtime';\nimport pMapSeries from 'p-map-series';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport const LAST_COMMAND_DETAILS_DIR = path.join(CACHE_ROOT, 'last-command-details');\n\ntype CommandResult = { data: any; exitCode: number };\n\nexport class CommandRunner {\n private commandName: string;\n constructor(\n private command: Command,\n private args: CLIArgs,\n private flags: Flags,\n private onCommandStartSlot: OnCommandStartSlot\n ) {\n this.commandName = parseCommandName(this.command.name);\n }\n\n /**\n * run command using one of the handler, \"json\"/\"report\"/\"render\". once done, exit the process.\n */\n async runCommand(shouldReturnResult = false): Promise<void | CommandResult> {\n try {\n this.bootstrapCommand();\n await this.invokeOnCommandStart();\n this.determineConsoleWritingDuringCommand();\n if (this.flags.json) {\n return await this.runJsonHandler(shouldReturnResult);\n }\n if (this.command.report) {\n return await this.runReportHandler(shouldReturnResult);\n }\n if (this.command.wait) {\n return await this.runWaitHandler();\n }\n } catch (err: any) {\n if (shouldReturnResult) throw err;\n return handleErrorAndExit(err, this.commandName);\n }\n\n throw new Error(`command \"${this.commandName}\" doesn't implement \"render\" nor \"report\" nor \"wait\" methods`);\n }\n\n private bootstrapCommand() {\n // Redact --token before anything is logged or sent to analytics. The raw token\n // is the user's bit.cloud credential; debug logs are persisted to disk and\n // routinely shared in support tickets / issues.\n const redactedFlags = this.getRedactedFlagsForReporting();\n try {\n Analytics.init(this.commandName, redactedFlags, this.args);\n } catch (err: any) {\n // ignoring the error, we don't want to fail the app if analytics failed.\n logger.error('failed to initialize analytics', err);\n }\n logger.info(`[*] started a new command: \"${this.commandName}\" with the following data:`, {\n args: this.args,\n flags: redactedFlags,\n });\n const token = this.flags[TOKEN_FLAG_NAME];\n if (token) {\n globalFlags.token = token.toString();\n }\n }\n\n private getRedactedFlagsForReporting(): Flags {\n if (this.flags[TOKEN_FLAG_NAME] == null) return this.flags;\n return { ...this.flags, [TOKEN_FLAG_NAME]: '<redacted>' };\n }\n\n private async invokeOnCommandStart() {\n const funcs = this.onCommandStartSlot.values();\n await pMapSeries(funcs, (onCommandStart) => onCommandStart(this.commandName, this.args, this.flags));\n }\n\n /**\n * this works for both, Harmony commands and Legacy commands (the legacy-command-adapter\n * implements json() method)\n */\n private async runJsonHandler(shouldReturnResult = false): Promise<CommandResult | undefined> {\n if (!this.flags.json) return undefined;\n if (!this.command.json) throw new Error(`command \"${this.commandName}\" doesn't implement \"json\" method`);\n const result = await this.command.json(this.args, this.flags);\n const code = result.code || 0;\n const data = result.data || result;\n if (shouldReturnResult) return { data, exitCode: code };\n const isJsonStream = Boolean(this.flags.stream);\n if (isJsonStream) data.end = true;\n const jsonStr = isJsonStream ? `${JSON.stringify(data)}\\n` : JSON.stringify(data, null, 2);\n await this.writeAndExit(jsonStr, code);\n }\n\n private async runReportHandler(shouldReturnResult = false): Promise<CommandResult | undefined> {\n if (!this.command.report) throw new Error('runReportHandler expects command.report to be implemented');\n const result = await this.command.report(this.args, this.flags);\n loader.off();\n const data = typeof result === 'string' ? result : result.data;\n const exitCode = typeof result === 'string' ? 0 : result.code;\n if (shouldReturnResult) return { data, exitCode };\n const details = typeof result === 'string' ? undefined : result.details;\n if (details) {\n await this.persistDetails(details).catch((err) => logger.error('failed to persist command details', err));\n }\n await this.writeAndExit(`${data}\\n`, exitCode);\n }\n\n private async persistDetails(details: string) {\n await fs.ensureDir(LAST_COMMAND_DETAILS_DIR);\n const meta = JSON.stringify({ command: this.commandName, timestamp: new Date().toISOString() });\n await Promise.all([\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'content'), details),\n fs.writeFile(path.join(LAST_COMMAND_DETAILS_DIR, 'meta.json'), meta),\n ]);\n }\n\n private async runWaitHandler() {\n if (!this.command.wait) throw new Error('runReportHandler expects command.wait to be implemented');\n await this.command.wait(this.args, this.flags);\n }\n\n /**\n * the loader and logger.console write output to the console during the command execution.\n * for internals commands, such as, _put, _fetch, the command.loader = false.\n */\n private determineConsoleWritingDuringCommand() {\n if (this.command.loader && !this.flags.json && !this.flags['get-yargs-completions'] && !shouldDisableLoader) {\n loader.on();\n loader.start(`running command \"${this.commandName}\"...`);\n logger.shouldWriteToConsole = true;\n } else {\n loader.off();\n logger.shouldWriteToConsole = false;\n }\n }\n\n private async writeAndExit(data: string, exitCode: number) {\n if (shouldUsePager(this.command, this.flags, data)) {\n const paged = await writeToPager(data, Boolean(this.flags.pager));\n // if the pager couldn't launch, fall through to a direct write so output is never lost.\n if (paged) return logger.exitAfterFlush(exitCode, this.commandName, data);\n }\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return process.stdout.write(data, async () => logger.exitAfterFlush(exitCode, this.commandName, data));\n }\n}\n\nexport function parseCommandName(commandName: string): string {\n if (!commandName) return '';\n return commandName.split(' ')[0];\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,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;AACA,SAAAK,aAAA;EAAA,MAAAL,IAAA,GAAAM,sBAAA,CAAAL,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,MAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,SAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,QAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAS,YAAA;EAAA,MAAAT,IAAA,GAAAM,sBAAA,CAAAL,OAAA;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6BAAmB,EAAE;MAC3Gd,iBAAM,CAACe,EAAE,CAAC,CAAC;MACXf,iBAAM,CAACgB,KAAK,CAAC,oBAAoB,IAAI,CAAC5D,WAAW,MAAM,CAAC;MACxDqB,gBAAM,CAACwC,oBAAoB,GAAG,IAAI;IACpC,CAAC,MAAM;MACLjB,iBAAM,CAACC,GAAG,CAAC,CAAC;MACZxB,gBAAM,CAACwC,oBAAoB,GAAG,KAAK;IACrC;EACF;EAEA,MAAclB,YAAYA,CAACrG,IAAY,EAAE6F,QAAgB,EAAE;IACzD,IAAI,IAAA2B,uBAAc,EAAC,IAAI,CAAClE,OAAO,EAAE,IAAI,CAACE,KAAK,EAAExD,IAAI,CAAC,EAAE;MAClD,MAAMyH,KAAK,GAAG,MAAM,IAAAC,qBAAY,EAAC1H,IAAI,EAAE+F,OAAO,CAAC,IAAI,CAACvC,KAAK,CAACmE,KAAK,CAAC,CAAC;MACjE;MACA,IAAIF,KAAK,EAAE,OAAO1C,gBAAM,CAAC6C,cAAc,CAAC/B,QAAQ,EAAE,IAAI,CAACnC,WAAW,EAAE1D,IAAI,CAAC;IAC3E;IACA;IACA,OAAO6H,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC/H,IAAI,EAAE,YAAY+E,gBAAM,CAAC6C,cAAc,CAAC/B,QAAQ,EAAE,IAAI,CAACnC,WAAW,EAAE1D,IAAI,CAAC,CAAC;EACxG;AACF;AAACgD,OAAA,CAAAI,aAAA,GAAAA,aAAA;AAEM,SAASO,gBAAgBA,CAACD,WAAmB,EAAU;EAC5D,IAAI,CAACA,WAAW,EAAE,OAAO,EAAE;EAC3B,OAAOA,WAAW,CAACsE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClC","ignoreList":[]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Group } from './command-groups';
|
|
2
|
+
type CommandOption = [string, string, string];
|
|
3
|
+
export type CommandOptions = Array<CommandOption>;
|
|
4
|
+
export interface Command {
|
|
5
|
+
/**
|
|
6
|
+
* Name of command with arguments:
|
|
7
|
+
* <> for mandatory arguments.
|
|
8
|
+
* [] for optional arguments.
|
|
9
|
+
* e.g. 'add <path>'
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* command alias (for example: 't' for 'tag')
|
|
14
|
+
*/
|
|
15
|
+
alias?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The description of the command. Being used in the commands summery (`bit --help`) and the help (e.g. `bit create --help`).
|
|
18
|
+
* should be short and precise. not more than one line. (use extendedDescription for more info).
|
|
19
|
+
*/
|
|
20
|
+
description: string;
|
|
21
|
+
/**
|
|
22
|
+
* The extended description of the command. Will be seen in only in the command help, just after the description.
|
|
23
|
+
*/
|
|
24
|
+
extendedDescription?: string;
|
|
25
|
+
/**
|
|
26
|
+
* url to a doc page explaining the command. shown in the command help just after the extendedDescription.
|
|
27
|
+
* if a relative url is entered, the base url will be retrieved from `teambit.community/community` aspect.
|
|
28
|
+
*/
|
|
29
|
+
helpUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* allow grouping of commands to hint summery renderer
|
|
32
|
+
* Places in default automatic help
|
|
33
|
+
*/
|
|
34
|
+
group?: Group | string;
|
|
35
|
+
/**
|
|
36
|
+
* should a command be exposed to the user (by bit help).
|
|
37
|
+
* e.g. experimental or plumbing commands should be hidden.
|
|
38
|
+
*/
|
|
39
|
+
private?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* should turn on Loader.
|
|
42
|
+
* the default is false for internal-commands and true for others.
|
|
43
|
+
* @see cliMain.setDefaults()
|
|
44
|
+
*/
|
|
45
|
+
loader?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* opt this command's `report` output into paging (like git's log/diff).
|
|
48
|
+
* when true, and stdout is an interactive human terminal, the output is piped through a pager
|
|
49
|
+
* (`less` by default). non-interactive contexts (piped output, CI, ai-agents, bit-cli-server)
|
|
50
|
+
* always get the full output at once. users can override with --pager / --no-pager.
|
|
51
|
+
* the default is false.
|
|
52
|
+
*/
|
|
53
|
+
pager?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Array of command options where each element is a tuple.
|
|
56
|
+
* ['flag alias', 'flag name', 'flag description']
|
|
57
|
+
* for example:
|
|
58
|
+
* ['j', 'json', 'output json format']
|
|
59
|
+
*/
|
|
60
|
+
options: CommandOptions;
|
|
61
|
+
/**
|
|
62
|
+
* arguments are defined in the "name" property, and that's where the source of truth is.
|
|
63
|
+
* this prop is optional and provides a way to describe the args. later, it'll support more fields, such as defaultValue.
|
|
64
|
+
* if this is set, it'll be shown in the command help under "Arguments" section.
|
|
65
|
+
*/
|
|
66
|
+
arguments?: CommandArg[];
|
|
67
|
+
/**
|
|
68
|
+
* sub commands for example:
|
|
69
|
+
* bit capsule list to list active capsules.
|
|
70
|
+
*/
|
|
71
|
+
commands?: Command[];
|
|
72
|
+
/**
|
|
73
|
+
* interact with a remote, e.g. "export" push to a remote
|
|
74
|
+
* for now, the only difference is that they get a "token" flag to authenticate anonymously.
|
|
75
|
+
*/
|
|
76
|
+
remoteOp?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* if true, it indicates that it doesn't need the workspace to work and can be executed outside a
|
|
79
|
+
* workspace
|
|
80
|
+
*/
|
|
81
|
+
skipWorkspace?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* optionally, give some examples how to use the command.
|
|
84
|
+
*/
|
|
85
|
+
examples?: Example[];
|
|
86
|
+
/**
|
|
87
|
+
* whether to load aspects set in workspace.jsonc before running the command.
|
|
88
|
+
* default is true.
|
|
89
|
+
*/
|
|
90
|
+
loadAspects?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* do not set this. it is being set once the command run.
|
|
93
|
+
* the values are those followed `--` in the command line. (e.g. `bit import -- --no-optional`)
|
|
94
|
+
*/
|
|
95
|
+
_packageManagerArgs?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Command handler which prints the return value to the console and exits.
|
|
98
|
+
* If the command has both, `render` and `report`, this one will be called when process.isTTY is false.
|
|
99
|
+
* @param args - arguments object as defined in name.
|
|
100
|
+
* @param flags - command flags as described in options.
|
|
101
|
+
* @return - Report object. The Report.data is printed to the stdout as is.
|
|
102
|
+
* Optionally include Report.details for expanded output accessible via `bit details` after the command completes.
|
|
103
|
+
*/
|
|
104
|
+
report?(args: CLIArgs, flags: Flags): Promise<string | Report>;
|
|
105
|
+
/**
|
|
106
|
+
* Command handler which never exits the process
|
|
107
|
+
* @param args - arguments object as defined in name.
|
|
108
|
+
* @param flags - command flags as described in options.
|
|
109
|
+
*/
|
|
110
|
+
wait?(args: CLIArgs, flags: Flags): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Optional handler to provide a raw result of the command.
|
|
113
|
+
* Will be go called if '-j'/'--json' option is provided by user.
|
|
114
|
+
* @param args - arguments object as defined in name.
|
|
115
|
+
* @param flags - command flags as described in options.
|
|
116
|
+
* @return a GenericObject to be rendered to string (by json.stringify) in the console.
|
|
117
|
+
*/
|
|
118
|
+
json?(args: CLIArgs, flags: Flags): Promise<GenericObject>;
|
|
119
|
+
}
|
|
120
|
+
export type Flags = {
|
|
121
|
+
[flagName: string]: string | boolean | undefined | any;
|
|
122
|
+
};
|
|
123
|
+
export type CLIArgs = Array<string[] | string>;
|
|
124
|
+
export type GenericObject = {
|
|
125
|
+
[k: string]: any;
|
|
126
|
+
};
|
|
127
|
+
export type Report = {
|
|
128
|
+
data: string;
|
|
129
|
+
code: number;
|
|
130
|
+
/**
|
|
131
|
+
* Optional expanded output persisted to disk and viewable via `bit details`.
|
|
132
|
+
* Use this for verbose information (e.g. auto-tagged dependents) that would clutter
|
|
133
|
+
* the default output but is useful after a one-shot command has already completed.
|
|
134
|
+
*/
|
|
135
|
+
details?: string;
|
|
136
|
+
};
|
|
137
|
+
export type CommandArg = {
|
|
138
|
+
name: string;
|
|
139
|
+
description?: string;
|
|
140
|
+
};
|
|
141
|
+
export type Example = {
|
|
142
|
+
cmd: string;
|
|
143
|
+
description: string;
|
|
144
|
+
};
|
|
145
|
+
export {};
|
package/dist/command.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["command.ts"],"sourcesContent":["import type { Group } from './command-groups';\n\ntype CommandOption = [string, string, string];\nexport type CommandOptions = Array<CommandOption>;\n\nexport interface Command {\n /**\n * Name of command with arguments:\n * <> for mandatory arguments.\n * [] for optional arguments.\n * e.g. 'add <path>'\n */\n name: string;\n\n /**\n * command alias (for example: 't' for 'tag')\n */\n alias?: string;\n\n /**\n * The description of the command. Being used in the commands summery (`bit --help`) and the help (e.g. `bit create --help`).\n * should be short and precise. not more than one line. (use extendedDescription for more info).\n */\n description: string;\n\n /**\n * The extended description of the command. Will be seen in only in the command help, just after the description.\n */\n extendedDescription?: string;\n\n /**\n * url to a doc page explaining the command. shown in the command help just after the extendedDescription.\n * if a relative url is entered, the base url will be retrieved from `teambit.community/community` aspect.\n */\n helpUrl?: string;\n\n /**\n * allow grouping of commands to hint summery renderer\n * Places in default automatic help\n */\n group?: Group | string;\n\n /**\n * should a command be exposed to the user (by bit help).\n * e.g. experimental or plumbing commands should be hidden.\n */\n private?: boolean;\n\n /**\n * should turn on Loader.\n * the default is false for internal-commands and true for others.\n * @see cliMain.setDefaults()\n */\n loader?: boolean;\n\n /**\n * opt this command's `report` output into paging (like git's log/diff).\n * when true, and stdout is an interactive human terminal, the output is piped through a pager\n * (`less` by default). non-interactive contexts (piped output, CI, ai-agents, bit-cli-server)\n * always get the full output at once. users can override with --pager / --no-pager.\n * the default is false.\n */\n pager?: boolean;\n\n /**\n * Array of command options where each element is a tuple.\n * ['flag alias', 'flag name', 'flag description']\n * for example:\n * ['j', 'json', 'output json format']\n */\n options: CommandOptions;\n\n /**\n * arguments are defined in the \"name\" property, and that's where the source of truth is.\n * this prop is optional and provides a way to describe the args. later, it'll support more fields, such as defaultValue.\n * if this is set, it'll be shown in the command help under \"Arguments\" section.\n */\n arguments?: CommandArg[];\n\n /**\n * sub commands for example:\n * bit capsule list to list active capsules.\n */\n commands?: Command[];\n\n /**\n * interact with a remote, e.g. \"export\" push to a remote\n * for now, the only difference is that they get a \"token\" flag to authenticate anonymously.\n */\n remoteOp?: boolean;\n\n /**\n * if true, it indicates that it doesn't need the workspace to work and can be executed outside a\n * workspace\n */\n skipWorkspace?: boolean;\n\n /**\n * optionally, give some examples how to use the command.\n */\n examples?: Example[];\n\n /**\n * whether to load aspects set in workspace.jsonc before running the command.\n * default is true.\n */\n loadAspects?: boolean;\n\n /**\n * do not set this. it is being set once the command run.\n * the values are those followed `--` in the command line. (e.g. `bit import -- --no-optional`)\n */\n _packageManagerArgs?: string[];\n\n /**\n * Command handler which prints the return value to the console and exits.\n * If the command has both, `render` and `report`, this one will be called when process.isTTY is false.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return - Report object. The Report.data is printed to the stdout as is.\n * Optionally include Report.details for expanded output accessible via `bit details` after the command completes.\n */\n report?(args: CLIArgs, flags: Flags): Promise<string | Report>;\n\n /**\n * Command handler which never exits the process\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n */\n wait?(args: CLIArgs, flags: Flags): Promise<void>;\n\n /**\n * Optional handler to provide a raw result of the command.\n * Will be go called if '-j'/'--json' option is provided by user.\n * @param args - arguments object as defined in name.\n * @param flags - command flags as described in options.\n * @return a GenericObject to be rendered to string (by json.stringify) in the console.\n */\n json?(args: CLIArgs, flags: Flags): Promise<GenericObject>;\n}\nexport type Flags = { [flagName: string]: string | boolean | undefined | any };\nexport type CLIArgs = Array<string[] | string>;\nexport type GenericObject = { [k: string]: any };\nexport type Report = {\n data: string;\n code: number;\n /**\n * Optional expanded output persisted to disk and viewable via `bit details`.\n * Use this for verbose information (e.g. auto-tagged dependents) that would clutter\n * the default output but is useful after a one-shot command has already completed.\n */\n details?: string;\n};\nexport type CommandArg = { name: string; description?: string };\nexport type Example = { cmd: string; description: string };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CompletionCmd = 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 CompletionCmd {
|
|
11
|
+
constructor() {
|
|
12
|
+
_defineProperty(this, "name", 'completion');
|
|
13
|
+
_defineProperty(this, "description", 'enable bash/zsh-completion shortcuts for commands and options');
|
|
14
|
+
_defineProperty(this, "alias", '');
|
|
15
|
+
_defineProperty(this, "group", 'system');
|
|
16
|
+
_defineProperty(this, "options", []);
|
|
17
|
+
_defineProperty(this, "private", true);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CompletionCmd = CompletionCmd;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=completion.cmd.js.map
|