dceky 1.0.0-beta.6 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +93 -0
- package/README.md +41 -0
- package/cypress/e2e/profile-test.cy.ts +10 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/e2e.ts +17 -0
- package/cypress.config.ts +9 -0
- package/docs/GlobalsAndProfiles.md +23 -0
- package/lib/setup/addToGitIgnore.d.ts +6 -0
- package/lib/setup/addToGitIgnore.js +47 -0
- package/lib/setup/addToGitIgnore.js.map +1 -0
- package/lib/setup/checkRequiredFiles.d.ts +6 -0
- package/lib/setup/checkRequiredFiles.js +59 -0
- package/lib/setup/checkRequiredFiles.js.map +1 -0
- package/lib/setup/genCommandImportFile.d.ts +7 -0
- package/lib/setup/genCommandImportFile.js +67 -0
- package/lib/setup/genCommandImportFile.js.map +1 -0
- package/lib/setup/genDynamicConfigFile.d.ts +5 -0
- package/lib/setup/genDynamicConfigFile.js +29 -0
- package/lib/setup/genDynamicConfigFile.js.map +1 -0
- package/lib/setup/helpers/getRootPath.d.ts +7 -0
- package/lib/setup/helpers/getRootPath.js +17 -0
- package/lib/setup/helpers/getRootPath.js.map +1 -0
- package/lib/setup/index.d.ts +1 -0
- package/lib/setup/index.js +16 -0
- package/lib/setup/index.js.map +1 -0
- package/lib/setup/setupCypressDependencies.d.ts +6 -0
- package/lib/setup/setupCypressDependencies.js +40 -0
- package/lib/setup/setupCypressDependencies.js.map +1 -0
- package/lib/src/commands/assertDoesNotHaveClass.d.ts +20 -0
- package/lib/src/commands/assertDoesNotHaveClass.js +17 -0
- package/lib/src/commands/assertDoesNotHaveClass.js.map +1 -0
- package/lib/src/commands/assertHasClass.d.ts +20 -0
- package/lib/src/commands/assertHasClass.js +17 -0
- package/lib/src/commands/assertHasClass.js.map +1 -0
- package/lib/src/commands/assertNumElements.d.ts +19 -0
- package/lib/src/commands/assertNumElements.js +17 -0
- package/lib/src/commands/assertNumElements.js.map +1 -0
- package/lib/src/commands/extractDataFromClass.d.ts +18 -0
- package/lib/src/commands/extractDataFromClass.js +25 -0
- package/lib/src/commands/extractDataFromClass.js.map +1 -0
- package/lib/src/commands/extractDataFromClassByContents.d.ts +19 -0
- package/lib/src/commands/extractDataFromClassByContents.js +26 -0
- package/lib/src/commands/extractDataFromClassByContents.js.map +1 -0
- package/lib/src/commands/getJSON.d.ts +16 -0
- package/lib/src/commands/getJSON.js +21 -0
- package/lib/src/commands/getJSON.js.map +1 -0
- package/lib/src/commands/getNumElements.d.ts +15 -0
- package/lib/src/commands/getNumElements.js +19 -0
- package/lib/src/commands/getNumElements.js.map +1 -0
- package/lib/src/commands/handleHarvardKey.d.ts +15 -0
- package/lib/src/commands/handleHarvardKey.js +53 -0
- package/lib/src/commands/handleHarvardKey.js.map +1 -0
- package/lib/src/commands/launchAs.d.ts +25 -0
- package/lib/src/commands/launchAs.js +66 -0
- package/lib/src/commands/launchAs.js.map +1 -0
- package/lib/src/commands/launchLTIUsingToken.d.ts +21 -0
- package/lib/src/commands/launchLTIUsingToken.js +68 -0
- package/lib/src/commands/launchLTIUsingToken.js.map +1 -0
- package/lib/src/commands/navigateToHref.d.ts +15 -0
- package/lib/src/commands/navigateToHref.js +35 -0
- package/lib/src/commands/navigateToHref.js.map +1 -0
- package/lib/src/commands/runScript.d.ts +15 -0
- package/lib/src/commands/runScript.js +20 -0
- package/lib/src/commands/runScript.js.map +1 -0
- package/lib/src/commands/typeInto.d.ts +24 -0
- package/lib/src/commands/typeInto.js +41 -0
- package/lib/src/commands/typeInto.js.map +1 -0
- package/lib/src/commands/visitCanvasGETEndpoint.d.ts +20 -0
- package/lib/src/commands/visitCanvasGETEndpoint.js +26 -0
- package/lib/src/commands/visitCanvasGETEndpoint.js.map +1 -0
- package/lib/src/commands/waitForElementVisible.d.ts +16 -0
- package/lib/src/commands/waitForElementVisible.js +19 -0
- package/lib/src/commands/waitForElementVisible.js.map +1 -0
- package/lib/src/genConfiguration/helpers/getRootPath.d.ts +7 -0
- package/lib/src/genConfiguration/helpers/getRootPath.js +17 -0
- package/lib/src/genConfiguration/helpers/getRootPath.js.map +1 -0
- package/lib/src/genConfiguration/helpers/resolveDependents.d.ts +13 -0
- package/lib/src/genConfiguration/helpers/resolveDependents.js +50 -0
- package/lib/src/genConfiguration/helpers/resolveDependents.js.map +1 -0
- package/lib/src/genConfiguration/helpers/splitEnv.d.ts +10 -0
- package/lib/src/genConfiguration/helpers/splitEnv.js +27 -0
- package/lib/src/genConfiguration/helpers/splitEnv.js.map +1 -0
- package/{src/genConfiguration.ts → lib/src/genConfiguration/index.d.ts} +3 -6
- package/lib/src/genConfiguration/index.js +89 -0
- package/lib/src/genConfiguration/index.js.map +1 -0
- package/lib/src/genConfiguration/types/DependentValue.d.ts +11 -0
- package/lib/src/genConfiguration/types/DependentValue.js +3 -0
- package/lib/src/genConfiguration/types/DependentValue.js.map +1 -0
- package/lib/src/genConfiguration/types/GlobalsOrProfile.d.ts +9 -0
- package/lib/src/genConfiguration/types/GlobalsOrProfile.js +3 -0
- package/lib/src/genConfiguration/types/GlobalsOrProfile.js.map +1 -0
- package/lib/src/genConfiguration/types/SplitEnv.d.ts +13 -0
- package/lib/src/genConfiguration/types/SplitEnv.js +3 -0
- package/lib/src/genConfiguration/types/SplitEnv.js.map +1 -0
- package/lib/{index.d.ts → src/index.d.ts} +1 -1
- package/lib/{index.js → src/index.js} +6 -3
- package/lib/src/index.js.map +1 -0
- package/lib/src/init.d.ts +6 -0
- package/lib/src/init.js +45 -0
- package/lib/src/init.js.map +1 -0
- package/lib/start/constants/AVAILABLE_BROWSERS.d.ts +9 -0
- package/lib/start/constants/AVAILABLE_BROWSERS.js +27 -0
- package/lib/start/constants/AVAILABLE_BROWSERS.js.map +1 -0
- package/lib/start/helpers/exec.d.ts +8 -0
- package/lib/start/helpers/exec.js +18 -0
- package/lib/start/helpers/exec.js.map +1 -0
- package/lib/start/helpers/extractArgValue.d.ts +10 -0
- package/lib/start/helpers/extractArgValue.js +39 -0
- package/lib/start/helpers/extractArgValue.js.map +1 -0
- package/lib/start/helpers/findProfilesByNames.d.ts +16 -0
- package/lib/start/helpers/findProfilesByNames.js +35 -0
- package/lib/start/helpers/findProfilesByNames.js.map +1 -0
- package/lib/start/helpers/getRootPath.d.ts +7 -0
- package/lib/start/helpers/getRootPath.js +17 -0
- package/lib/start/helpers/getRootPath.js.map +1 -0
- package/lib/start/helpers/parseCommaSeparated.d.ts +8 -0
- package/lib/start/helpers/parseCommaSeparated.js +23 -0
- package/lib/start/helpers/parseCommaSeparated.js.map +1 -0
- package/lib/start/helpers/print.d.ts +38 -0
- package/lib/start/helpers/print.js +145 -0
- package/lib/start/helpers/print.js.map +1 -0
- package/lib/start/helpers/prompt.d.ts +8 -0
- package/lib/start/helpers/prompt.js +25 -0
- package/lib/start/helpers/prompt.js.map +1 -0
- package/lib/start/helpers/showChooser.d.ts +21 -0
- package/lib/start/helpers/showChooser.js +116 -0
- package/lib/start/helpers/showChooser.js.map +1 -0
- package/lib/start/helpers/validateBrowsers.d.ts +8 -0
- package/lib/start/helpers/validateBrowsers.js +36 -0
- package/lib/start/helpers/validateBrowsers.js.map +1 -0
- package/lib/start/index.d.ts +7 -0
- package/lib/start/index.js +140 -0
- package/lib/start/index.js.map +1 -0
- package/lib/start/types/ChooserOption.d.ts +10 -0
- package/lib/start/types/ChooserOption.js +3 -0
- package/lib/start/types/ChooserOption.js.map +1 -0
- package/package.json +28 -8
- package/setup/addToGitIgnore.ts +48 -0
- package/setup/checkRequiredFiles.ts +63 -0
- package/setup/genCommandImportFile.ts +76 -0
- package/setup/genDynamicConfigFile.ts +29 -0
- package/setup/helpers/getRootPath.ts +13 -0
- package/setup/index.ts +11 -0
- package/setup/setupCypressDependencies.ts +38 -0
- package/src/commands/assertDoesNotHaveClass.ts +51 -0
- package/src/commands/assertHasClass.ts +51 -0
- package/src/commands/assertNumElements.ts +50 -0
- package/src/commands/extractDataFromClass.ts +52 -0
- package/src/commands/extractDataFromClassByContents.ts +55 -0
- package/src/commands/getJSON.ts +45 -0
- package/src/commands/getNumElements.ts +45 -0
- package/src/commands/handleHarvardKey.ts +91 -0
- package/src/commands/launchAs.ts +120 -0
- package/src/commands/launchLTIUsingToken.ts +115 -0
- package/src/commands/navigateToHref.ts +60 -0
- package/src/commands/runScript.ts +44 -0
- package/src/commands/typeInto.ts +88 -0
- package/src/commands/visitCanvasGETEndpoint.ts +61 -0
- package/src/commands/waitForElementVisible.ts +49 -0
- package/src/genConfiguration/helpers/getRootPath.ts +13 -0
- package/src/genConfiguration/helpers/resolveDependents.ts +46 -0
- package/src/genConfiguration/helpers/splitEnv.ts +30 -0
- package/src/genConfiguration/index.ts +95 -0
- package/src/genConfiguration/types/DependentValue.ts +14 -0
- package/src/genConfiguration/types/GlobalsOrProfile.ts +12 -0
- package/src/genConfiguration/types/SplitEnv.ts +18 -0
- package/src/index.ts +7 -4
- package/src/init.ts +36 -17
- package/start/constants/AVAILABLE_BROWSERS.ts +28 -0
- package/start/helpers/exec.ts +17 -0
- package/start/helpers/extractArgValue.ts +42 -0
- package/start/helpers/findProfilesByNames.ts +39 -0
- package/start/helpers/getRootPath.ts +13 -0
- package/start/helpers/parseCommaSeparated.ts +23 -0
- package/start/helpers/print.ts +155 -0
- package/start/helpers/prompt.ts +23 -0
- package/start/helpers/showChooser.ts +140 -0
- package/start/helpers/validateBrowsers.ts +35 -0
- package/start/index.ts +164 -0
- package/start/types/ChooserOption.ts +11 -0
- package/tsconfig.json +3 -4
- package/.eslintrc.json +0 -58
- package/lib/genConfiguration.d.ts +0 -8
- package/lib/genConfiguration.js +0 -13
- package/lib/genConfiguration.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/init.d.ts +0 -13
- package/lib/init.js +0 -10
- package/lib/init.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Available browsers for Cypress tests
|
|
5
|
+
* @author Yuen Ler Chow
|
|
6
|
+
*/
|
|
7
|
+
var AVAILABLE_BROWSERS = [
|
|
8
|
+
{
|
|
9
|
+
name: 'chrome',
|
|
10
|
+
tag: 'C',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'firefox',
|
|
14
|
+
tag: 'F',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'edge',
|
|
18
|
+
tag: 'E',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'safari',
|
|
22
|
+
tag: 'S',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
// Export only the browser names in lowercase
|
|
26
|
+
exports.default = AVAILABLE_BROWSERS;
|
|
27
|
+
//# sourceMappingURL=AVAILABLE_BROWSERS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AVAILABLE_BROWSERS.js","sourceRoot":"","sources":["../../../start/constants/AVAILABLE_BROWSERS.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAM,kBAAkB,GAGlB;IACJ;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,GAAG;KACT;IACD;QACE,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;KACT;IACD;QACE,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,GAAG;KACT;IACD;QACE,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,GAAG;KACT;CACF,CAAC;AAEF,6CAA6C;AAC7C,kBAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute a command
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param command the command to execute
|
|
5
|
+
* @param printToStdOut if true, print to standard out instead of returning
|
|
6
|
+
*/
|
|
7
|
+
declare const exec: (command: string, printToStdOut?: boolean) => string;
|
|
8
|
+
export default exec;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var child_process_1 = require("child_process");
|
|
4
|
+
/**
|
|
5
|
+
* Execute a command
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
* @param command the command to execute
|
|
8
|
+
* @param printToStdOut if true, print to standard out instead of returning
|
|
9
|
+
*/
|
|
10
|
+
var exec = function (command, printToStdOut) {
|
|
11
|
+
if (printToStdOut) {
|
|
12
|
+
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
return (0, child_process_1.execSync)(command).toString();
|
|
16
|
+
};
|
|
17
|
+
exports.default = exec;
|
|
18
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../start/helpers/exec.ts"],"names":[],"mappings":";;AAAA,+CAAyC;AAEzC;;;;;GAKG;AACH,IAAM,IAAI,GAAG,UAAC,OAAe,EAAE,aAAuB;IACpD,IAAI,aAAa,EAAE,CAAC;QAClB,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAA,wBAAQ,EAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract CLI argument value or check if flag exists
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
* @author Yuen Ler Chow
|
|
5
|
+
* @param args array of CLI arguments
|
|
6
|
+
* @param argName the argument name to look for (e.g., '--profile' or '--headless')
|
|
7
|
+
* @returns the argument value if found, empty string if flag exists without value, undefined otherwise
|
|
8
|
+
*/
|
|
9
|
+
declare const extractArgValue: (args: string[], argName: string) => string | undefined;
|
|
10
|
+
export default extractArgValue;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Extract CLI argument value or check if flag exists
|
|
5
|
+
* @author Gardenia Liu
|
|
6
|
+
* @author Yuen Ler Chow
|
|
7
|
+
* @param args array of CLI arguments
|
|
8
|
+
* @param argName the argument name to look for (e.g., '--profile' or '--headless')
|
|
9
|
+
* @returns the argument value if found, empty string if flag exists without value, undefined otherwise
|
|
10
|
+
*/
|
|
11
|
+
var extractArgValue = function (args, argName) {
|
|
12
|
+
var matchedValue;
|
|
13
|
+
args.some(function (rawArg, index) {
|
|
14
|
+
var normalizedArg = rawArg.toLowerCase();
|
|
15
|
+
// Case 1: flag and value combined, e.g. "--profile=stage"
|
|
16
|
+
if (normalizedArg.startsWith("".concat(argName, "="))) {
|
|
17
|
+
var _a = rawArg.split('='), value = _a[1];
|
|
18
|
+
matchedValue = value;
|
|
19
|
+
return true; // stop scanning
|
|
20
|
+
}
|
|
21
|
+
// Case 2: flag by itself, possibly followed by a separate value
|
|
22
|
+
if (normalizedArg === argName) {
|
|
23
|
+
var nextArg = args[index + 1];
|
|
24
|
+
// If the next token exists and isn't another flag, treat it as the value
|
|
25
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
26
|
+
matchedValue = nextArg;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Flag exists but no value given (boolean-style flag) (e.g. "--headless")
|
|
30
|
+
matchedValue = '';
|
|
31
|
+
}
|
|
32
|
+
return true; // stop scanning
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
return matchedValue;
|
|
37
|
+
};
|
|
38
|
+
exports.default = extractArgValue;
|
|
39
|
+
//# sourceMappingURL=extractArgValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractArgValue.js","sourceRoot":"","sources":["../../../start/helpers/extractArgValue.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,eAAe,GAAG,UAAC,IAAc,EAAE,OAAe;IACtD,IAAI,YAAgC,CAAC;IACrC,IAAI,CAAC,IAAI,CAAC,UAAC,MAAM,EAAE,KAAK;QACtB,IAAM,aAAa,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAE3C,0DAA0D;QAC1D,IAAI,aAAa,CAAC,UAAU,CAAC,UAAG,OAAO,MAAG,CAAC,EAAE,CAAC;YACtC,IAAA,KAAY,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAA1B,KAAK,QAAqB,CAAC;YACpC,YAAY,GAAG,KAAK,CAAC;YACrB,OAAO,IAAI,CAAC,CAAC,gBAAgB;QAC/B,CAAC;QAED,gEAAgE;QAChE,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAC9B,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAEhC,yEAAyE;YACzE,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzC,YAAY,GAAG,OAAO,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,0EAA0E;gBAC1E,YAAY,GAAG,EAAE,CAAC;YACpB,CAAC;YAED,OAAO,IAAI,CAAC,CAAC,gBAAgB;QAC/B,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find profiles by names
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
* @author Yuen Ler Chow
|
|
5
|
+
* @param names array of profile names to find
|
|
6
|
+
* @param profiles array of available profiles
|
|
7
|
+
* @returns array of found profiles
|
|
8
|
+
*/
|
|
9
|
+
declare const findProfilesByNames: (names: string[], profiles: Array<{
|
|
10
|
+
file: string;
|
|
11
|
+
profileName: string;
|
|
12
|
+
}>) => Array<{
|
|
13
|
+
file: string;
|
|
14
|
+
profileName: string;
|
|
15
|
+
}>;
|
|
16
|
+
export default findProfilesByNames;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Find profiles by names
|
|
5
|
+
* @author Gardenia Liu
|
|
6
|
+
* @author Yuen Ler Chow
|
|
7
|
+
* @param names array of profile names to find
|
|
8
|
+
* @param profiles array of available profiles
|
|
9
|
+
* @returns array of found profiles
|
|
10
|
+
*/
|
|
11
|
+
var findProfilesByNames = function (names, profiles) {
|
|
12
|
+
var found = [];
|
|
13
|
+
var notFound = [];
|
|
14
|
+
names.forEach(function (name) {
|
|
15
|
+
var target = name.toLowerCase();
|
|
16
|
+
// Find matching profile (case-insensitive)
|
|
17
|
+
var match = profiles.find(function (p) {
|
|
18
|
+
return p.profileName.toLowerCase() === target;
|
|
19
|
+
});
|
|
20
|
+
if (match) {
|
|
21
|
+
found.push(match);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
notFound.push(name);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (notFound.length > 0) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.error("Profile(s) not found: ".concat(notFound.join(', '), ". Available profiles: ").concat(profiles.map(function (p) { return p.profileName; }).join(', ')));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
return found;
|
|
33
|
+
};
|
|
34
|
+
exports.default = findProfilesByNames;
|
|
35
|
+
//# sourceMappingURL=findProfilesByNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findProfilesByNames.js","sourceRoot":"","sources":["../../../start/helpers/findProfilesByNames.ts"],"names":[],"mappings":";;AAAA;;;;;;;GAOG;AACH,IAAM,mBAAmB,GAAG,UAC1B,KAAe,EACf,QAAsD;IAEtD,IAAM,KAAK,GAAiD,EAAE,CAAC;IAC/D,IAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI;QACjB,IAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAElC,2CAA2C;QAC3C,IAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAC,CAAC;YAC5B,OAAO,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QAChD,CAAC,CAAC,CAAC;QACH,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,gCAAyB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAyB,QAAQ,CAAC,GAAG,CAAC,UAAC,CAAC,IAAO,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAC,CAAC;QAChJ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var path_1 = __importDefault(require("path"));
|
|
7
|
+
/**
|
|
8
|
+
* Get the root path of the project
|
|
9
|
+
* @author Yuen Ler Chow
|
|
10
|
+
* @returns the root path of the project
|
|
11
|
+
*/
|
|
12
|
+
var getRootPath = function () {
|
|
13
|
+
var root = path_1.default.join(__dirname, '../../../../');
|
|
14
|
+
return root;
|
|
15
|
+
};
|
|
16
|
+
exports.default = getRootPath;
|
|
17
|
+
//# sourceMappingURL=getRootPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRootPath.js","sourceRoot":"","sources":["../../../start/helpers/getRootPath.ts"],"names":[],"mappings":";;;;;AAAA,8CAAwB;AAExB;;;;GAIG;AACH,IAAM,WAAW,GAAG;IAClB,IAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse comma-separated values into an array
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
* @param commaSeparatedString the comma-separated string to parse
|
|
5
|
+
* @returns array of trimmed, non-empty values
|
|
6
|
+
*/
|
|
7
|
+
declare const parseCommaSeparated: (commaSeparatedString?: string) => string[];
|
|
8
|
+
export default parseCommaSeparated;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Parse comma-separated values into an array
|
|
5
|
+
* @author Yuen Ler Chow
|
|
6
|
+
* @param commaSeparatedString the comma-separated string to parse
|
|
7
|
+
* @returns array of trimmed, non-empty values
|
|
8
|
+
*/
|
|
9
|
+
var parseCommaSeparated = function (commaSeparatedString) {
|
|
10
|
+
if (!commaSeparatedString) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
return (commaSeparatedString
|
|
14
|
+
.split(',')
|
|
15
|
+
.map(function (value) {
|
|
16
|
+
return value.trim();
|
|
17
|
+
})
|
|
18
|
+
.filter(function (value) {
|
|
19
|
+
return value.length > 0;
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
exports.default = parseCommaSeparated;
|
|
23
|
+
//# sourceMappingURL=parseCommaSeparated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseCommaSeparated.js","sourceRoot":"","sources":["../../../start/helpers/parseCommaSeparated.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,IAAM,mBAAmB,GAAG,UAAC,oBAA6B;IACxD,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CACL,oBAAoB;SACjB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,UAAC,KAAK;QACT,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC;SACD,MAAM,CAAC,UAAC,KAAK;QACZ,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare const print: {
|
|
2
|
+
/**
|
|
3
|
+
* Print a title
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param str text to print
|
|
6
|
+
*/
|
|
7
|
+
title: (str: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Print a sub title (subheading)
|
|
10
|
+
* @author Gabe Abrams
|
|
11
|
+
* @param str text to print
|
|
12
|
+
*/
|
|
13
|
+
subtitle: (str: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Print centered text
|
|
16
|
+
* @author Gabe Abrams
|
|
17
|
+
* @param str text to print
|
|
18
|
+
*/
|
|
19
|
+
centered: (str: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Print a fatal error message
|
|
22
|
+
* @author Gabe Abrams
|
|
23
|
+
* @param err error message
|
|
24
|
+
*/
|
|
25
|
+
fatalError: (err: string) => never;
|
|
26
|
+
/**
|
|
27
|
+
* Save a copy of the prompt instance
|
|
28
|
+
* @author Gabe Abrams
|
|
29
|
+
* @param promptInstance instance of prompt-sync
|
|
30
|
+
*/
|
|
31
|
+
savePrompt: (promptInstance: any) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Ask the user to press enter before continuing
|
|
34
|
+
* @author Gabe Abrams
|
|
35
|
+
*/
|
|
36
|
+
enterToContinue: () => void;
|
|
37
|
+
};
|
|
38
|
+
export default print;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/**
|
|
5
|
+
* Get the left buffer for a centered message
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
* @param message message to print
|
|
8
|
+
* @param padding amount of padding to add
|
|
9
|
+
* @returns number of chars in the buffer
|
|
10
|
+
*/
|
|
11
|
+
var leftBuffer = function (message, padding) {
|
|
12
|
+
return (Math.floor(process.stdout.columns / 2) - padding - Math.ceil(message.length / 2));
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Get the right buffer for a centered message
|
|
16
|
+
* @author Gabe Abrams
|
|
17
|
+
* @param message message to print
|
|
18
|
+
* @param padding amount of padding to add
|
|
19
|
+
* @returns number of chars in the buffer
|
|
20
|
+
*/
|
|
21
|
+
var rightBuffer = function (message, padding) {
|
|
22
|
+
return (Math.ceil(process.stdout.columns / 2) - padding - Math.floor(message.length / 2));
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Surround text with a border and spaces
|
|
26
|
+
* @author Gabe Abrams
|
|
27
|
+
* @param str text to print
|
|
28
|
+
* @param border single character to use as a border
|
|
29
|
+
* @returns text to print
|
|
30
|
+
*/
|
|
31
|
+
var surroundWithBuffer = function (str, border) {
|
|
32
|
+
return (border
|
|
33
|
+
+ ' '.repeat(leftBuffer(str, border.length))
|
|
34
|
+
+ str
|
|
35
|
+
+ ' '.repeat(rightBuffer(str, border.length))
|
|
36
|
+
+ border);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Surround text with a character as the buffer
|
|
40
|
+
* @author Gabe Abrams
|
|
41
|
+
* @param str text to print
|
|
42
|
+
* @param char character to place as the buffer
|
|
43
|
+
* @returns text to print
|
|
44
|
+
*/
|
|
45
|
+
var surroundWithChars = function (str, char) {
|
|
46
|
+
if (str.length > process.stdout.columns) {
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
if (str.length === process.stdout.columns - 1) {
|
|
50
|
+
return char + str;
|
|
51
|
+
}
|
|
52
|
+
if (str.length === process.stdout.columns - 2) {
|
|
53
|
+
return char + str + char;
|
|
54
|
+
}
|
|
55
|
+
return (char.repeat(leftBuffer(str, 1))
|
|
56
|
+
+ ' '
|
|
57
|
+
+ str
|
|
58
|
+
+ ' '
|
|
59
|
+
+ char.repeat(rightBuffer(str, 1)));
|
|
60
|
+
};
|
|
61
|
+
// Prompt instance
|
|
62
|
+
var cachedPrompt;
|
|
63
|
+
var print = {
|
|
64
|
+
/**
|
|
65
|
+
* Print a title
|
|
66
|
+
* @author Gabe Abrams
|
|
67
|
+
* @param str text to print
|
|
68
|
+
*/
|
|
69
|
+
title: function (str) {
|
|
70
|
+
if (str.length > process.stdout.columns) {
|
|
71
|
+
return console.log(str);
|
|
72
|
+
}
|
|
73
|
+
console.log('\u2554' + '\u2550'.repeat(process.stdout.columns - 2) + '\u2557');
|
|
74
|
+
console.log(surroundWithBuffer(str, '\u2551'));
|
|
75
|
+
console.log('\u255A' + '\u2550'.repeat(process.stdout.columns - 2) + '\u255D');
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Print a sub title (subheading)
|
|
79
|
+
* @author Gabe Abrams
|
|
80
|
+
* @param str text to print
|
|
81
|
+
*/
|
|
82
|
+
subtitle: function (str) {
|
|
83
|
+
if (str.length > process.stdout.columns) {
|
|
84
|
+
return console.log(str);
|
|
85
|
+
}
|
|
86
|
+
console.log(surroundWithChars(str, '\u257C'));
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Print centered text
|
|
90
|
+
* @author Gabe Abrams
|
|
91
|
+
* @param str text to print
|
|
92
|
+
*/
|
|
93
|
+
centered: function (str) {
|
|
94
|
+
var lines = [];
|
|
95
|
+
var index = 0;
|
|
96
|
+
while (index < str.length) {
|
|
97
|
+
lines.push(str.substring(index, Math.min(index + process.stdout.columns, str.length)));
|
|
98
|
+
index += process.stdout.columns;
|
|
99
|
+
}
|
|
100
|
+
lines.forEach(function (line, lineIndex) {
|
|
101
|
+
if (lineIndex !== lines.length - 1) {
|
|
102
|
+
// No need to center: fills whole line
|
|
103
|
+
console.log(line);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// This line needs to be centered
|
|
107
|
+
console.log(surroundWithChars(line, ' '));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Print a fatal error message
|
|
113
|
+
* @author Gabe Abrams
|
|
114
|
+
* @param err error message
|
|
115
|
+
*/
|
|
116
|
+
fatalError: function (err) {
|
|
117
|
+
console.log('\n');
|
|
118
|
+
var errLine1 = err.substring(0, process.stdout.columns - 6);
|
|
119
|
+
var errLine2 = err.substring(process.stdout.columns - 6);
|
|
120
|
+
console.log('\u2554' + '\u2550'.repeat(3) + '\u2557 ');
|
|
121
|
+
console.log("\u2551 ! \u2551 ".concat(errLine1));
|
|
122
|
+
console.log('\u255A' + '\u2550'.repeat(3) + '\u255D ' + errLine2);
|
|
123
|
+
process.exit(0);
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Save a copy of the prompt instance
|
|
127
|
+
* @author Gabe Abrams
|
|
128
|
+
* @param promptInstance instance of prompt-sync
|
|
129
|
+
*/
|
|
130
|
+
savePrompt: function (promptInstance) {
|
|
131
|
+
cachedPrompt = promptInstance;
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Ask the user to press enter before continuing
|
|
135
|
+
* @author Gabe Abrams
|
|
136
|
+
*/
|
|
137
|
+
enterToContinue: function () {
|
|
138
|
+
var res = cachedPrompt(surroundWithChars('enter to continue, ctrl+c to quit', '\u257C'), true);
|
|
139
|
+
if (res === null) {
|
|
140
|
+
process.exit(0);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
exports.default = print;
|
|
145
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../../start/helpers/print.ts"],"names":[],"mappings":";AAAA,+BAA+B;;AAE/B;;;;;;GAMG;AACH,IAAM,UAAU,GAAG,UAAC,OAAe,EAAE,OAAe;IAClD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,IAAM,WAAW,GAAG,UAAC,OAAe,EAAE,OAAe;IACnD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,IAAM,kBAAkB,GAAG,UAAC,GAAW,EAAE,MAAc;IACrD,OAAO,CACL,MAAM;UACJ,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;UAC1C,GA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,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD;;;;OAIG;IACH,UAAU,EAAE,UAAC,GAAW;QACtB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,IAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC3D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,0BAAmB,QAAQ,CAAE,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACH,UAAU,EAAE,UAAC,cAAmB;QAC9B,YAAY,GAAG,cAAc,CAAC;IAChC,CAAC;IACD;;;OAGG;IACH,eAAe,EAAE;QACf,IAAM,GAAG,GAAG,YAAY,CACtB,iBAAiB,CAAC,mCAAmC,EAAE,QAAQ,CAAC,EAChE,IAAI,CACL,CAAC;QACF,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var prompt_sync_1 = __importDefault(require("prompt-sync"));
|
|
7
|
+
var print_1 = __importDefault(require("./print"));
|
|
8
|
+
var promptSync = (0, prompt_sync_1.default)();
|
|
9
|
+
/**
|
|
10
|
+
* Ask the user a question
|
|
11
|
+
* @param title title of the question
|
|
12
|
+
* @param notRequired true if question is not required
|
|
13
|
+
* @returns response
|
|
14
|
+
*/
|
|
15
|
+
var prompt = function (title, notRequired) {
|
|
16
|
+
var val = promptSync(title);
|
|
17
|
+
if (val === null || (!notRequired && !val)) {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
return val;
|
|
21
|
+
};
|
|
22
|
+
// Save the prompt for use later
|
|
23
|
+
print_1.default.savePrompt(prompt);
|
|
24
|
+
exports.default = prompt;
|
|
25
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../start/helpers/prompt.ts"],"names":[],"mappings":";;;;;AAAA,4DAAqC;AACrC,kDAA4B;AAE5B,IAAM,UAAU,GAAG,IAAA,qBAAU,GAAE,CAAC;AAEhC;;;;;GAKG;AACH,IAAM,MAAM,GAAG,UAAC,KAAa,EAAE,WAAqB;IAClD,IAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,gCAAgC;AAChC,eAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAEzB,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ChooserOption from '../types/ChooserOption';
|
|
2
|
+
/**
|
|
3
|
+
* Show a chooser between many options
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @author Yuen Ler Chow
|
|
6
|
+
* @param opts object of arguments
|
|
7
|
+
* @param opts.question the question to ask
|
|
8
|
+
* @param opts.options list of options to choose from
|
|
9
|
+
* @param opts.title main title to show above the choices
|
|
10
|
+
* @param opts.dontClear if true, don't clear the console before
|
|
11
|
+
* @param opts.allowMulti if true, allow multiple selections (comma-separated)
|
|
12
|
+
* @returns array of chosen option(s)
|
|
13
|
+
*/
|
|
14
|
+
declare const showChooser: (opts: {
|
|
15
|
+
question: string;
|
|
16
|
+
options: ChooserOption[];
|
|
17
|
+
title?: string;
|
|
18
|
+
dontClear?: boolean;
|
|
19
|
+
allowMulti?: boolean;
|
|
20
|
+
}) => ChooserOption[];
|
|
21
|
+
export default showChooser;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/* eslint-disable no-console */
|
|
18
|
+
var clear_1 = __importDefault(require("clear"));
|
|
19
|
+
// Import shared helpers
|
|
20
|
+
var print_1 = __importDefault(require("./print"));
|
|
21
|
+
var prompt_1 = __importDefault(require("./prompt"));
|
|
22
|
+
var parseCommaSeparated_1 = __importDefault(require("./parseCommaSeparated"));
|
|
23
|
+
/**
|
|
24
|
+
* Show a chooser between many options
|
|
25
|
+
* @author Gabe Abrams
|
|
26
|
+
* @author Yuen Ler Chow
|
|
27
|
+
* @param opts object of arguments
|
|
28
|
+
* @param opts.question the question to ask
|
|
29
|
+
* @param opts.options list of options to choose from
|
|
30
|
+
* @param opts.title main title to show above the choices
|
|
31
|
+
* @param opts.dontClear if true, don't clear the console before
|
|
32
|
+
* @param opts.allowMulti if true, allow multiple selections (comma-separated)
|
|
33
|
+
* @returns array of chosen option(s)
|
|
34
|
+
*/
|
|
35
|
+
var showChooser = function (opts) {
|
|
36
|
+
var question = opts.question, options = opts.options, title = opts.title, dontClear = opts.dontClear, _a = opts.allowMulti, allowMulti = _a === void 0 ? false : _a;
|
|
37
|
+
// Helper to re-display the chooser after an invalid selection
|
|
38
|
+
var retryWithMessage = function (message) {
|
|
39
|
+
(0, clear_1.default)();
|
|
40
|
+
print_1.default.title('Invalid Choice');
|
|
41
|
+
console.log(message);
|
|
42
|
+
console.log('');
|
|
43
|
+
print_1.default.enterToContinue();
|
|
44
|
+
return showChooser({
|
|
45
|
+
question: question,
|
|
46
|
+
options: options,
|
|
47
|
+
title: title,
|
|
48
|
+
dontClear: dontClear,
|
|
49
|
+
allowMulti: allowMulti,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
// Print the header
|
|
53
|
+
if (!dontClear) {
|
|
54
|
+
(0, clear_1.default)();
|
|
55
|
+
}
|
|
56
|
+
if (title) {
|
|
57
|
+
print_1.default.title(title);
|
|
58
|
+
console.log('');
|
|
59
|
+
}
|
|
60
|
+
print_1.default.subtitle(question);
|
|
61
|
+
// Make sure all options have tags
|
|
62
|
+
var nextNumber = 1;
|
|
63
|
+
var optionsWithTags = options.map(function (option) {
|
|
64
|
+
// Get/generate a tag
|
|
65
|
+
var tag = option.tag;
|
|
66
|
+
if (!tag) {
|
|
67
|
+
tag = String(nextNumber);
|
|
68
|
+
nextNumber += 1;
|
|
69
|
+
}
|
|
70
|
+
// Return complete option
|
|
71
|
+
return __assign(__assign({}, option), { tag: tag });
|
|
72
|
+
});
|
|
73
|
+
// Print options
|
|
74
|
+
optionsWithTags.forEach(function (option) {
|
|
75
|
+
console.log("".concat(option.tag, " - ").concat(option.description));
|
|
76
|
+
});
|
|
77
|
+
// Ask user to choose
|
|
78
|
+
var response = (0, prompt_1.default)('> ').trim();
|
|
79
|
+
// Always parse as comma-separated (treat all inputs with multi-select logic)
|
|
80
|
+
var selectedTags = (0, parseCommaSeparated_1.default)(response);
|
|
81
|
+
// Fail fast if multi-select is not allowed but multiple selections were made
|
|
82
|
+
if (!allowMulti && selectedTags.length > 1) {
|
|
83
|
+
return retryWithMessage('Multiple selections are not allowed. Please select only one option.');
|
|
84
|
+
}
|
|
85
|
+
// Find matching options
|
|
86
|
+
var selected = [];
|
|
87
|
+
var invalidTags = [];
|
|
88
|
+
selectedTags.forEach(function (tag) {
|
|
89
|
+
var lowerTag = tag.toLowerCase();
|
|
90
|
+
var found = false;
|
|
91
|
+
optionsWithTags.forEach(function (opt, idx) {
|
|
92
|
+
if (opt.tag.toLowerCase() === lowerTag) {
|
|
93
|
+
selected.push({
|
|
94
|
+
description: opt.description,
|
|
95
|
+
tag: opt.tag,
|
|
96
|
+
index: idx,
|
|
97
|
+
});
|
|
98
|
+
found = true;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
if (!found) {
|
|
102
|
+
invalidTags.push(tag);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
// Handle invalid tags
|
|
106
|
+
if (invalidTags.length > 0) {
|
|
107
|
+
return retryWithMessage("The following selections are not valid: ".concat(invalidTags.join(', ')));
|
|
108
|
+
}
|
|
109
|
+
// Handle no selections
|
|
110
|
+
if (selected.length === 0) {
|
|
111
|
+
return retryWithMessage('No valid selections made.');
|
|
112
|
+
}
|
|
113
|
+
return selected;
|
|
114
|
+
};
|
|
115
|
+
exports.default = showChooser;
|
|
116
|
+
//# sourceMappingURL=showChooser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AG;iBACX,CAAC,CAAC;gBACH,KAAK,GAAG,IAAI,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,sBAAsB;IACtB,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,gBAAgB,CACrB,kDAA2C,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CACpE,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate browsers (supports multiple)
|
|
3
|
+
* @author Yuen Ler Chow
|
|
4
|
+
* @param browserNames array of browser names to validate
|
|
5
|
+
* @returns array of valid browser names (lowercased)
|
|
6
|
+
*/
|
|
7
|
+
declare const validateBrowsers: (browserNames: string[]) => string[];
|
|
8
|
+
export default validateBrowsers;
|