@gooddata/app-toolkit 9.6.0-alpha.12 → 9.6.0-alpha.14
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/esm/__version.d.ts +1 -1
- package/esm/__version.js +1 -1
- package/esm/_base/inputHandling/validators.d.ts +39 -0
- package/esm/_base/inputHandling/validators.d.ts.map +1 -0
- package/esm/_base/inputHandling/validators.js +93 -0
- package/esm/_base/inputHandling/validators.js.map +1 -0
- package/esm/_base/terminal/clear.d.ts +3 -0
- package/esm/_base/terminal/clear.d.ts.map +1 -0
- package/esm/_base/terminal/clear.js +13 -0
- package/esm/_base/terminal/clear.js.map +1 -0
- package/esm/_base/terminal/loggers.d.ts +24 -0
- package/esm/_base/terminal/loggers.d.ts.map +1 -0
- package/esm/_base/terminal/loggers.js +35 -0
- package/esm/_base/terminal/loggers.js.map +1 -0
- package/esm/_base/terminal/prompts.d.ts +9 -0
- package/esm/_base/terminal/prompts.d.ts.map +1 -0
- package/esm/_base/terminal/prompts.js +49 -0
- package/esm/_base/terminal/prompts.js.map +1 -0
- package/esm/_base/types.d.ts +40 -0
- package/esm/_base/types.d.ts.map +1 -0
- package/esm/_base/types.js +24 -0
- package/esm/_base/types.js.map +1 -0
- package/esm/_base/utils.d.ts +31 -0
- package/esm/_base/utils.d.ts.map +1 -0
- package/esm/_base/utils.js +78 -0
- package/esm/_base/utils.js.map +1 -0
- package/esm/_base/workspaceTargetConfig.d.ts +16 -0
- package/esm/_base/workspaceTargetConfig.d.ts.map +1 -0
- package/esm/_base/workspaceTargetConfig.js +12 -0
- package/esm/_base/workspaceTargetConfig.js.map +1 -0
- package/esm/index.d.ts +3 -0
- package/esm/initCmd/actionConfig.d.ts +21 -0
- package/esm/initCmd/actionConfig.d.ts.map +1 -0
- package/esm/initCmd/actionConfig.js +56 -0
- package/esm/initCmd/actionConfig.js.map +1 -0
- package/esm/initCmd/index.d.ts +3 -0
- package/esm/initCmd/index.d.ts.map +1 -0
- package/esm/initCmd/index.js +131 -0
- package/esm/initCmd/index.js.map +1 -0
- package/esm/initCmd/replaceInFiles.d.ts +13 -0
- package/esm/initCmd/replaceInFiles.d.ts.map +1 -0
- package/esm/initCmd/replaceInFiles.js +36 -0
- package/esm/initCmd/replaceInFiles.js.map +1 -0
- package/esm/react-app-template.d.ts +3 -0
- package/esm/react-app-template.d.ts.map +1 -0
- package/esm/react-app-template.js +12 -0
- package/esm/react-app-template.js.map +1 -0
- package/esm/react-app-template.js.tgz +0 -0
- package/esm/react-app-template.ts.tgz +0 -0
- package/package.json +4 -4
package/esm/__version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "9.6.0-alpha.
|
|
1
|
+
export declare const LIB_VERSION = "9.6.0-alpha.13";
|
|
2
2
|
export declare const LIB_DESCRIPTION = "CLI with useful tools for creating and maintaining GoodData web applications.";
|
|
3
3
|
export declare const LIB_NAME = "@gooddata/app-toolkit";
|
|
4
4
|
//# sourceMappingURL=__version.d.ts.map
|
package/esm/__version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// (C) 2021 GoodData Corporation
|
|
2
2
|
// DO NOT CHANGE THIS FILE, IT IS RE-GENERATED ON EVERY BUILD
|
|
3
|
-
export const LIB_VERSION = "9.6.0-alpha.
|
|
3
|
+
export const LIB_VERSION = "9.6.0-alpha.13";
|
|
4
4
|
export const LIB_DESCRIPTION = "CLI with useful tools for creating and maintaining GoodData web applications.";
|
|
5
5
|
export const LIB_NAME = "@gooddata/app-toolkit";
|
|
6
6
|
//# sourceMappingURL=__version.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type InputValidator<T = string> = (value: T) => boolean | string;
|
|
2
|
+
export type AsyncInputValidator = (value: string) => Promise<boolean | string>;
|
|
3
|
+
/**
|
|
4
|
+
* Validates that application name matches required regex.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applicationNameValidator(value: string): boolean | string;
|
|
7
|
+
/**
|
|
8
|
+
* Validates that value is either 'js' or 'ts'.
|
|
9
|
+
*/
|
|
10
|
+
export declare function languageValidator(value: string): boolean | string;
|
|
11
|
+
/**
|
|
12
|
+
* Validates that the value is supported template.
|
|
13
|
+
*/
|
|
14
|
+
export declare function templateValidator(value: string): boolean | string;
|
|
15
|
+
/**
|
|
16
|
+
* Validates that value is either 'npm' or 'yarn'.
|
|
17
|
+
*/
|
|
18
|
+
export declare function packageManagerValidator(value: string): boolean | string;
|
|
19
|
+
/**
|
|
20
|
+
* Triggers validation of value for particular input, using the provided validator. If the validation
|
|
21
|
+
* succeeds (validator returns true), then this function just returns.
|
|
22
|
+
*
|
|
23
|
+
* Otherwise the function throws an {@link InputValidationError}.
|
|
24
|
+
*
|
|
25
|
+
* @param inputName - name of input that is being validated - this is purely metadata, passed over to the exception
|
|
26
|
+
* so that whoever gets hold of it can determine what exactly failed validation.
|
|
27
|
+
* @param value - value to validate; this will be sent to the validator function & in case of failure will also
|
|
28
|
+
* appear in the exception
|
|
29
|
+
* @param validator - validator to use, this is function matching the contract set by the inquirer library
|
|
30
|
+
*/
|
|
31
|
+
export declare function validOrDie(inputName: string, value: string, validator: InputValidator): void;
|
|
32
|
+
/**
|
|
33
|
+
* This is same as {@link validOrDie} except that the validator function returns Promise of the validation
|
|
34
|
+
* result.
|
|
35
|
+
*
|
|
36
|
+
* See {@link validOrDie} for more detail.
|
|
37
|
+
*/
|
|
38
|
+
export declare function asyncValidOrDie(inputName: string, value: string, validator: AsyncInputValidator): Promise<void>;
|
|
39
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/_base/inputHandling/validators.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;AAM/E;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAgBxE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAMjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAMjE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAMvE;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,IAAI,CAU5F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,mBAAmB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// (C) 2007-2022 GoodData Corporation
|
|
2
|
+
import validateNpmPackageName from "validate-npm-package-name";
|
|
3
|
+
import isEmpty from "lodash/isEmpty.js";
|
|
4
|
+
import capitalize from "lodash/capitalize.js";
|
|
5
|
+
import { InputValidationError } from "../types.js";
|
|
6
|
+
//
|
|
7
|
+
// Simple validators compatible with inquirer API
|
|
8
|
+
//
|
|
9
|
+
/**
|
|
10
|
+
* Validates that application name matches required regex.
|
|
11
|
+
*/
|
|
12
|
+
export function applicationNameValidator(value) {
|
|
13
|
+
if (isEmpty(value) || (value && isEmpty(value.trim()))) {
|
|
14
|
+
return "Please enter non-empty application name.";
|
|
15
|
+
}
|
|
16
|
+
const result = validateNpmPackageName(value);
|
|
17
|
+
if (result.errors?.length) {
|
|
18
|
+
return `Invalid application name. ${result.errors
|
|
19
|
+
.map((e) => {
|
|
20
|
+
return `${capitalize(e)}.`;
|
|
21
|
+
})
|
|
22
|
+
.join(" ")}`;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates that value is either 'js' or 'ts'.
|
|
28
|
+
*/
|
|
29
|
+
export function languageValidator(value) {
|
|
30
|
+
if (value === "js" || value === "ts") {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return "Invalid language. Specify 'ts' for TypeScript or 'js' for JavaScript.";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates that the value is supported template.
|
|
37
|
+
*/
|
|
38
|
+
export function templateValidator(value) {
|
|
39
|
+
if (value === "react-app") {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return "Invalid template. Specify a supported template. (e.g. react-app)";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates that value is either 'npm' or 'yarn'.
|
|
46
|
+
*/
|
|
47
|
+
export function packageManagerValidator(value) {
|
|
48
|
+
if (value === "npm" || value === "yarn") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return "Invalid package manager. Specify 'npm' or 'yarn'.";
|
|
52
|
+
}
|
|
53
|
+
//
|
|
54
|
+
// Functions to trigger validation outside of inquirer.
|
|
55
|
+
//
|
|
56
|
+
/**
|
|
57
|
+
* Triggers validation of value for particular input, using the provided validator. If the validation
|
|
58
|
+
* succeeds (validator returns true), then this function just returns.
|
|
59
|
+
*
|
|
60
|
+
* Otherwise the function throws an {@link InputValidationError}.
|
|
61
|
+
*
|
|
62
|
+
* @param inputName - name of input that is being validated - this is purely metadata, passed over to the exception
|
|
63
|
+
* so that whoever gets hold of it can determine what exactly failed validation.
|
|
64
|
+
* @param value - value to validate; this will be sent to the validator function & in case of failure will also
|
|
65
|
+
* appear in the exception
|
|
66
|
+
* @param validator - validator to use, this is function matching the contract set by the inquirer library
|
|
67
|
+
*/
|
|
68
|
+
export function validOrDie(inputName, value, validator) {
|
|
69
|
+
const result = validator(value);
|
|
70
|
+
if (typeof result === "string") {
|
|
71
|
+
throw new InputValidationError(inputName, value, result);
|
|
72
|
+
}
|
|
73
|
+
if (!result) {
|
|
74
|
+
throw new InputValidationError(inputName, value, `Invalid value provided: ${value}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* This is same as {@link validOrDie} except that the validator function returns Promise of the validation
|
|
79
|
+
* result.
|
|
80
|
+
*
|
|
81
|
+
* See {@link validOrDie} for more detail.
|
|
82
|
+
*/
|
|
83
|
+
export function asyncValidOrDie(inputName, value, validator) {
|
|
84
|
+
return validator(value).then((result) => {
|
|
85
|
+
if (typeof result === "string") {
|
|
86
|
+
throw new InputValidationError(inputName, value, result);
|
|
87
|
+
}
|
|
88
|
+
if (!result) {
|
|
89
|
+
throw new InputValidationError(inputName, value, `Invalid value provided: ${value}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/_base/inputHandling/validators.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKnD,EAAE;AACF,iDAAiD;AACjD,EAAE;AAEF;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAa;IAClD,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE;QACpD,OAAO,0CAA0C,CAAC;KACrD;I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E,2BAA2B,KAAK,EAAE,CAAC,CAAC;KACxF;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC3B,SAAiB,EACjB,KAAa,EACb,SAA8B;IAE9B,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,MAAM,IAAI,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,2BAA2B,KAAK,EAAE,CAAC,CAAC;SACxF;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../../src/_base/terminal/clear.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,GAAG,GAAE,OAAc,GAAG,IAAI,CAKvD;AAED,wBAAgB,SAAS,IAAI,IAAI,CAGhC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// (C) 2007-2022 GoodData Corporation
|
|
2
|
+
import * as readline from "readline";
|
|
3
|
+
export function clearTerminal(clr = true) {
|
|
4
|
+
if (clr) {
|
|
5
|
+
process.stdout.write("\x1b[2J\x1b[H");
|
|
6
|
+
}
|
|
7
|
+
process.stdout.write("\x1b[2K\x1b[G");
|
|
8
|
+
}
|
|
9
|
+
export function clearLine() {
|
|
10
|
+
readline.clearLine(process.stdout, 0);
|
|
11
|
+
readline.cursorTo(process.stdout, 0);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../src/_base/terminal/clear.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,MAAM,UAAU,aAAa,CAAC,MAAe,IAAI;IAC7C,IAAI,GAAG,EAAE;QACL,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;KACzC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,SAAS;IACrB,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log an info message. Use these to communicate what the tool done, what is about to do, give additional
|
|
3
|
+
* explanation and so on.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare function logInfo(message: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Log a warning. Use these to communicate that either something seems amiss (but the tool can continue) or
|
|
9
|
+
* to communicate info that may be surprising (good example is --dry-run mode. end the dry run with warning
|
|
10
|
+
* because user may forget/miss that she has --dry-run on CLI and may be surprised that nothing actually
|
|
11
|
+
* happens)
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare function logWarn(message: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Log message communicating success. Use scarcely, typically at the end of command processing. Success message
|
|
17
|
+
* may include summary info & details about the great success that just occurred. Also emojis.
|
|
18
|
+
*/
|
|
19
|
+
export declare function logSuccess(message: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log an error. Use for validation errors and runtime errors.
|
|
22
|
+
*/
|
|
23
|
+
export declare function logError(message: string): void;
|
|
24
|
+
//# sourceMappingURL=loggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggers.d.ts","sourceRoot":"","sources":["../../../src/_base/terminal/loggers.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// (C) 2007-2022 GoodData Corporation
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
/**
|
|
5
|
+
* Log an info message. Use these to communicate what the tool done, what is about to do, give additional
|
|
6
|
+
* explanation and so on.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export function logInfo(message) {
|
|
10
|
+
console.log(chalk `{blue.bold 🛈} ${message}`);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Log a warning. Use these to communicate that either something seems amiss (but the tool can continue) or
|
|
14
|
+
* to communicate info that may be surprising (good example is --dry-run mode. end the dry run with warning
|
|
15
|
+
* because user may forget/miss that she has --dry-run on CLI and may be surprised that nothing actually
|
|
16
|
+
* happens)
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export function logWarn(message) {
|
|
20
|
+
console.log(chalk `{blue.yellow ⚠} ${message}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Log message communicating success. Use scarcely, typically at the end of command processing. Success message
|
|
24
|
+
* may include summary info & details about the great success that just occurred. Also emojis.
|
|
25
|
+
*/
|
|
26
|
+
export function logSuccess(message) {
|
|
27
|
+
console.log(chalk `{white.bold.bgGreen ✔} ${message}`);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Log an error. Use for validation errors and runtime errors.
|
|
31
|
+
*/
|
|
32
|
+
export function logError(message) {
|
|
33
|
+
console.log(chalk `{white.bold.bgRed ✘} ${message}`);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=loggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../src/_base/terminal/loggers.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,mBAAmB,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,0BAA0B,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA,wBAAwB,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TargetAppLanguage, AppTemplate } from "../types.js";
|
|
2
|
+
export type WorkspaceChoices = {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function promptName(object?: string): Promise<string>;
|
|
7
|
+
export declare function promptLanguage(): Promise<TargetAppLanguage>;
|
|
8
|
+
export declare function promptTemplate(): Promise<AppTemplate>;
|
|
9
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/_base/terminal/prompts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,UAAU,CAAC,MAAM,GAAE,MAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAUhF;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAmBjE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAe3D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// (C) 2007-2022 GoodData Corporation
|
|
2
|
+
import pkg from "inquirer";
|
|
3
|
+
const { prompt } = pkg;
|
|
4
|
+
import { applicationNameValidator } from "../inputHandling/validators.js";
|
|
5
|
+
export async function promptName(object = "application") {
|
|
6
|
+
const question = {
|
|
7
|
+
message: `Enter ${object} name:`,
|
|
8
|
+
name: "name",
|
|
9
|
+
type: "input",
|
|
10
|
+
validate: applicationNameValidator,
|
|
11
|
+
};
|
|
12
|
+
const response = await prompt(question);
|
|
13
|
+
return response.name;
|
|
14
|
+
}
|
|
15
|
+
export async function promptLanguage() {
|
|
16
|
+
const question = {
|
|
17
|
+
message: "Select programming language that you want to use in your application:",
|
|
18
|
+
name: "language",
|
|
19
|
+
type: "list",
|
|
20
|
+
choices: [
|
|
21
|
+
{
|
|
22
|
+
name: "TypeScript",
|
|
23
|
+
value: "ts",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "JavaScript",
|
|
27
|
+
value: "js",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
const response = await prompt(question);
|
|
32
|
+
return response.language;
|
|
33
|
+
}
|
|
34
|
+
export async function promptTemplate() {
|
|
35
|
+
const question = {
|
|
36
|
+
message: "Select template that you want to use for your project:",
|
|
37
|
+
name: "template",
|
|
38
|
+
type: "list",
|
|
39
|
+
choices: [
|
|
40
|
+
{
|
|
41
|
+
name: "React Application",
|
|
42
|
+
value: "react-app",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
const response = await prompt(question);
|
|
47
|
+
return response.template;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/_base/terminal/prompts.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,GAAyB,MAAM,UAAU,CAAC;AACjD,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAQ1E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAiB,aAAa;IAC3D,MAAM,QAAQ,GAAqB;QAC/B,OAAO,EAAE,SAAS,MAAM,QAAQ;QAChC,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,wBAAwB;KACrC,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAChC,MAAM,QAAQ,GAAqB;QAC/B,OAAO,EAAE,uEAAuE;QAChF,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE;YACL;gBACI,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,IAAI;aACd;SACJ;KACJ,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAChC,MAAM,QAAQ,GAAqB;QAC/B,OAAO,EAAE,wDAAwD;QACjE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE;YACL;gBACI,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,WAAW;aACrB;SACJ;KACJ,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OptionValues } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Program & command level options are grabbed from the commander and sent together to the action.
|
|
4
|
+
*/
|
|
5
|
+
export type ActionOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Program-level options. These are the top level options defined directly using `program.option(...)`
|
|
8
|
+
*/
|
|
9
|
+
programOpts: OptionValues;
|
|
10
|
+
/**
|
|
11
|
+
* Command-level options. These are options defined via `program.command(..).option(..)`
|
|
12
|
+
*/
|
|
13
|
+
commandOpts: OptionValues;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Supported languages to use in application projects bootstrapped by the CLI.
|
|
17
|
+
*/
|
|
18
|
+
export type TargetAppLanguage = "ts" | "js";
|
|
19
|
+
/**
|
|
20
|
+
* Supported package managers that the tool can use to auto-install dependencies for the boostrapped projects.
|
|
21
|
+
*/
|
|
22
|
+
export type SupportedPackageManager = "npm" | "yarn";
|
|
23
|
+
/**
|
|
24
|
+
* Supported templates that can be bootstrapped by the CLI.
|
|
25
|
+
*/
|
|
26
|
+
export type AppTemplate = "react-app";
|
|
27
|
+
/**
|
|
28
|
+
* This error is thrown when input validation fails.
|
|
29
|
+
*/
|
|
30
|
+
export declare class InputValidationError extends Error {
|
|
31
|
+
readonly inputName: string;
|
|
32
|
+
readonly value: string;
|
|
33
|
+
readonly type = "IVE";
|
|
34
|
+
constructor(inputName: string, value: string, message: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type guard testing whether object is a type of {@link InputValidationError}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isInputValidationError(obj: unknown): obj is InputValidationError;
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/_base/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;IAE1B;;OAEG;IACH,WAAW,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,MAAM,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC;AAEtC;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAGR,SAAS,EAAE,MAAM;aAAkB,KAAK,EAAE,MAAM;IAFnF,SAAgB,IAAI,SAAS;gBAEM,SAAS,EAAE,MAAM,EAAkB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMvG;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,oBAAoB,CAEhF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// (C) 2021-2022 GoodData Corporation
|
|
2
|
+
import isEmpty from "lodash/isEmpty.js";
|
|
3
|
+
/**
|
|
4
|
+
* This error is thrown when input validation fails.
|
|
5
|
+
*/
|
|
6
|
+
export class InputValidationError extends Error {
|
|
7
|
+
inputName;
|
|
8
|
+
value;
|
|
9
|
+
type = "IVE";
|
|
10
|
+
constructor(inputName, value, message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.inputName = inputName;
|
|
13
|
+
this.value = value;
|
|
14
|
+
// restore prototype chain
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type guard testing whether object is a type of {@link InputValidationError}.
|
|
20
|
+
*/
|
|
21
|
+
export function isInputValidationError(obj) {
|
|
22
|
+
return !isEmpty(obj) && obj.type === "IVE";
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/_base/types.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAGrC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAgCxC;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAGR;IAAmC;IAFtD,IAAI,GAAG,KAAK,CAAC;IAE7B,YAAmC,SAAiB,EAAkB,KAAa,EAAE,OAAe;QAChG,KAAK,CAAC,OAAO,CAAC,CAAC;QADgB,cAAS,GAAT,SAAS,CAAQ;QAAkB,UAAK,GAAL,KAAK,CAAQ;QAG/E,0BAA0B;QAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAY;IAC/C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAK,GAA4B,CAAC,IAAI,KAAK,KAAK,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare function toJsonString(obj: any): string;
|
|
2
|
+
export declare function writeAsJsonSync(file: string, obj: object): void;
|
|
3
|
+
export declare function readJsonSync(file: string): any;
|
|
4
|
+
/**
|
|
5
|
+
* Reads package.json file if it exists in current dir. Otherwise returns empty object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readPackageJsonIfExists(): Record<string, any>;
|
|
8
|
+
/**
|
|
9
|
+
* Safely joins two path parts together.
|
|
10
|
+
*
|
|
11
|
+
* Path on windows will contain backslashes which can cause problems with Globby. This function makes sure
|
|
12
|
+
* only forward slashes are used so that Globby and node fs works properly on all platforms.
|
|
13
|
+
*
|
|
14
|
+
* @param initialPath - the first part
|
|
15
|
+
* @param relativePath - the second part
|
|
16
|
+
* @returns joined path
|
|
17
|
+
*/
|
|
18
|
+
export declare function safeJoin(initialPath: string, relativePath: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts application name to directory name for the application. This will ensure that if the application name
|
|
21
|
+
* contains organization (`@something/application`) then only the `application` will be used.
|
|
22
|
+
*/
|
|
23
|
+
export declare function convertToApplicationDirectory(name: string): string;
|
|
24
|
+
export declare function extractRootCause(error: any): any;
|
|
25
|
+
/**
|
|
26
|
+
* This function will attempt to categorize the provided error and print something meaningful into the console.
|
|
27
|
+
*
|
|
28
|
+
* @param error - error message to report on
|
|
29
|
+
*/
|
|
30
|
+
export declare function genericErrorReporter(error: any): void;
|
|
31
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/_base/utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAI7C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAE9C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAM7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAMhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAoBrD"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// (C) 2021-2022 GoodData Corporation
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import { isInputValidationError } from "./types.js";
|
|
5
|
+
import { logError } from "./terminal/loggers.js";
|
|
6
|
+
import { isNotAuthenticated } from "@gooddata/sdk-backend-spi";
|
|
7
|
+
export function toJsonString(obj) {
|
|
8
|
+
// note: using json-stable-stringify is likely not a good idea in this project:
|
|
9
|
+
// the toolkit works with package.json files; stable stringify will reshuffle contents of package.json
|
|
10
|
+
return JSON.stringify(obj, null, 4);
|
|
11
|
+
}
|
|
12
|
+
export function writeAsJsonSync(file, obj) {
|
|
13
|
+
fse.writeFileSync(file, toJsonString(obj), { encoding: "utf-8" });
|
|
14
|
+
}
|
|
15
|
+
export function readJsonSync(file) {
|
|
16
|
+
return JSON.parse(fse.readFileSync(file, { encoding: "utf-8" }));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads package.json file if it exists in current dir. Otherwise returns empty object.
|
|
20
|
+
*/
|
|
21
|
+
export function readPackageJsonIfExists() {
|
|
22
|
+
if (fse.existsSync("package.json")) {
|
|
23
|
+
return readJsonSync("package.json");
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Safely joins two path parts together.
|
|
29
|
+
*
|
|
30
|
+
* Path on windows will contain backslashes which can cause problems with Globby. This function makes sure
|
|
31
|
+
* only forward slashes are used so that Globby and node fs works properly on all platforms.
|
|
32
|
+
*
|
|
33
|
+
* @param initialPath - the first part
|
|
34
|
+
* @param relativePath - the second part
|
|
35
|
+
* @returns joined path
|
|
36
|
+
*/
|
|
37
|
+
export function safeJoin(initialPath, relativePath) {
|
|
38
|
+
return path.posix.join(initialPath, relativePath).replace(/\\/g, "/");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Converts application name to directory name for the application. This will ensure that if the application name
|
|
42
|
+
* contains organization (`@something/application`) then only the `application` will be used.
|
|
43
|
+
*/
|
|
44
|
+
export function convertToApplicationDirectory(name) {
|
|
45
|
+
const split = name.split("/");
|
|
46
|
+
return split.length > 1 ? split[1] : name;
|
|
47
|
+
}
|
|
48
|
+
export function extractRootCause(error) {
|
|
49
|
+
if (error.cause === undefined || error.cause === null) {
|
|
50
|
+
return error;
|
|
51
|
+
}
|
|
52
|
+
return extractRootCause(error.cause);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This function will attempt to categorize the provided error and print something meaningful into the console.
|
|
56
|
+
*
|
|
57
|
+
* @param error - error message to report on
|
|
58
|
+
*/
|
|
59
|
+
export function genericErrorReporter(error) {
|
|
60
|
+
if (isInputValidationError(error)) {
|
|
61
|
+
logError(error.message);
|
|
62
|
+
}
|
|
63
|
+
else if (isNotAuthenticated(error)) {
|
|
64
|
+
logError("Authentication to backend has failed. Please ensure your environment is setup with correct credentials.");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const e = extractRootCause(error);
|
|
68
|
+
if (e.message?.search(/.*(certificate|self-signed).*/) > -1) {
|
|
69
|
+
logError("Server does not have valid certificate. The login has failed. " +
|
|
70
|
+
"If you trust the server, you can use the --accept-untrusted-ssl option " +
|
|
71
|
+
"to turn off certificate validation.");
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
logError(`An unexpected error has occurred: ${e.stack}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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IAAY;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAU;IACvC,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE;QACnD,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAU;IAC3C,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE;QAC/B,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC3B;SAAM,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CACJ,yGAAyG,CAC5G,CAAC;KACL;SAAM;QACH,MAAM,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAElC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC,EAAE;YACzD,QAAQ,CACJ,gEAAgE;gBAC5D,yEAAyE;gBACzE,qCAAqC,CAC5C,CAAC;SACL;aAAM;YACH,QAAQ,CAAC,qCAAqC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;SAC5D;KACJ;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ActionOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Config for commands that target a workspace.
|
|
4
|
+
*/
|
|
5
|
+
export type WorkspaceTargetConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* For completeness includes package.json of the current project. May be an empty object in case CLI
|
|
8
|
+
* is invoked from directory that does not contain package.json
|
|
9
|
+
*/
|
|
10
|
+
packageJson: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates common config for commands that target a workspace.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createWorkspaceTargetConfig(_options: ActionOptions): Promise<WorkspaceTargetConfig>;
|
|
16
|
+
//# sourceMappingURL=workspaceTargetConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaceTargetConfig.d.ts","sourceRoot":"","sources":["../../src/_base/workspaceTargetConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAMzG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// (C) 2021-2022 GoodData Corporation
|
|
2
|
+
import { readPackageJsonIfExists } from "./utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates common config for commands that target a workspace.
|
|
5
|
+
*/
|
|
6
|
+
export async function createWorkspaceTargetConfig(_options) {
|
|
7
|
+
const packageJson = readPackageJsonIfExists();
|
|
8
|
+
return {
|
|
9
|
+
packageJson,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=workspaceTargetConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaceTargetConfig.js","sourceRoot":"","sources":["../../src/_base/workspaceTargetConfig.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAIrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAarD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,QAAuB;IACrE,MAAM,WAAW,GAAG,uBAAuB,EAAE,CAAC;IAE9C,OAAO;QACH,WAAW;KACd,CAAC;AACN,CAAC"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ActionOptions, AppTemplate, SupportedPackageManager, TargetAppLanguage } from "../_base/types.js";
|
|
2
|
+
export type InitCmdActionConfig = {
|
|
3
|
+
name: string;
|
|
4
|
+
language: TargetAppLanguage;
|
|
5
|
+
packageManager: SupportedPackageManager;
|
|
6
|
+
targetDir: string | undefined;
|
|
7
|
+
skipInstall: boolean;
|
|
8
|
+
template: AppTemplate;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* This function will obtain configuration for the application init command. It will do so from the argument
|
|
12
|
+
* and option values passed via CLI and in case vital input is missing by using interactive prompts.
|
|
13
|
+
*
|
|
14
|
+
* The function will first verify all the available options and only then start prompting the user - this
|
|
15
|
+
* is intentional as the CLI should fail fast and not at some arbitrary point after user prompting.
|
|
16
|
+
*
|
|
17
|
+
* @param applicationName - application name (if any) as passed by the user, undefined means no application name on CLI
|
|
18
|
+
* @param options - program & command level options provided by the user via CLI
|
|
19
|
+
*/
|
|
20
|
+
export declare function getInitCmdActionConfig(applicationName: string | undefined, options: ActionOptions): Promise<InitCmdActionConfig>;
|
|
21
|
+
//# sourceMappingURL=actionConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionConfig.d.ts","sourceRoot":"","sources":["../../src/initCmd/actionConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkD3G,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,EAAE,uBAAuB,CAAC;IACxC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CACxC,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,aAAa,GACvB,OAAO,CAAC,mBAAmB,CAAC,CAqB9B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { applicationNameValidator, languageValidator, packageManagerValidator, templateValidator, validOrDie, } from "../_base/inputHandling/validators.js";
|
|
2
|
+
import { promptLanguage, promptName, promptTemplate } from "../_base/terminal/prompts.js";
|
|
3
|
+
function getLanguageFromOptions(options) {
|
|
4
|
+
const { language } = options.commandOpts;
|
|
5
|
+
if (!language) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
validOrDie("language", language, languageValidator);
|
|
9
|
+
return language;
|
|
10
|
+
}
|
|
11
|
+
function getPackageManagerFromOptions(options) {
|
|
12
|
+
const { packageManager } = options.commandOpts;
|
|
13
|
+
if (!packageManager) {
|
|
14
|
+
return "npm";
|
|
15
|
+
}
|
|
16
|
+
validOrDie("packageManager", packageManager, packageManagerValidator);
|
|
17
|
+
return packageManager;
|
|
18
|
+
}
|
|
19
|
+
function getTemplateFromOptions(options) {
|
|
20
|
+
const { template } = options.commandOpts;
|
|
21
|
+
if (!template) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
validOrDie("template", template, templateValidator);
|
|
25
|
+
return template;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This function will obtain configuration for the application init command. It will do so from the argument
|
|
29
|
+
* and option values passed via CLI and in case vital input is missing by using interactive prompts.
|
|
30
|
+
*
|
|
31
|
+
* The function will first verify all the available options and only then start prompting the user - this
|
|
32
|
+
* is intentional as the CLI should fail fast and not at some arbitrary point after user prompting.
|
|
33
|
+
*
|
|
34
|
+
* @param applicationName - application name (if any) as passed by the user, undefined means no application name on CLI
|
|
35
|
+
* @param options - program & command level options provided by the user via CLI
|
|
36
|
+
*/
|
|
37
|
+
export async function getInitCmdActionConfig(applicationName, options) {
|
|
38
|
+
if (applicationName) {
|
|
39
|
+
validOrDie("app-name", applicationName, applicationNameValidator);
|
|
40
|
+
}
|
|
41
|
+
const languageFromOptions = getLanguageFromOptions(options);
|
|
42
|
+
const packageManagerFromOptions = getPackageManagerFromOptions(options);
|
|
43
|
+
const templateFromOptions = getTemplateFromOptions(options);
|
|
44
|
+
const name = applicationName ?? (await promptName());
|
|
45
|
+
const template = templateFromOptions ?? (await promptTemplate());
|
|
46
|
+
const language = languageFromOptions ?? (await promptLanguage());
|
|
47
|
+
return {
|
|
48
|
+
name,
|
|
49
|
+
language,
|
|
50
|
+
packageManager: packageManagerFromOptions,
|
|
51
|
+
targetDir: options.commandOpts.targetDir,
|
|
52
|
+
skipInstall: options.commandOpts.skipInstall ?? false,
|
|
53
|
+
template,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=actionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionConfig.js","sourceRoot":"","sources":["../../src/initCmd/actionConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,GACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE1F,SAAS,sBAAsB,CAAC,OAAsB;IAClD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAEzC,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,SAAS,CAAC;KACpB;IAED,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAEpD,OAAO,QAA6B,CAAC;AACzC,CAAC;AAED,SAAS,4BAA4B,CAAC,OAAsB;IACxD,MAAM,EAAE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CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initCmd/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAkC,MAAM,mBAAmB,CAAC;AA+IlF,wBAAsB,aAAa,CAC/B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,aAAa,GACvB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { logError, logInfo, logSuccess, logWarn } from "../_base/terminal/loggers.js";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import tar from "tar";
|
|
5
|
+
import { getReactAppTemplateArchive } from "../react-app-template.js";
|
|
6
|
+
import { convertToApplicationDirectory, genericErrorReporter, readJsonSync, writeAsJsonSync, } from "../_base/utils.js";
|
|
7
|
+
import { getInitCmdActionConfig } from "./actionConfig.js";
|
|
8
|
+
import { replaceInFiles } from "./replaceInFiles.js";
|
|
9
|
+
import { sync as spawnSync } from "cross-spawn";
|
|
10
|
+
const archiveNameFunctionByTemplate = {
|
|
11
|
+
"react-app": getReactAppTemplateArchive,
|
|
12
|
+
};
|
|
13
|
+
function unpackProject(target, language, template) {
|
|
14
|
+
const archiveNameFunction = archiveNameFunctionByTemplate[template];
|
|
15
|
+
return fse.mkdirp(target).then((_) => {
|
|
16
|
+
return tar.x({
|
|
17
|
+
file: archiveNameFunction(language),
|
|
18
|
+
strip: 1,
|
|
19
|
+
cwd: target,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The original package.json can be tweaked now. The application name will be used for package name.
|
|
25
|
+
*
|
|
26
|
+
* @param target - target directory where the application template was expanded
|
|
27
|
+
* @param config - config for the initialization action
|
|
28
|
+
*/
|
|
29
|
+
function modifyPackageJson(target, config) {
|
|
30
|
+
const { name } = config;
|
|
31
|
+
const packageJsonFile = path.resolve(target, "package.json");
|
|
32
|
+
const packageJson = readJsonSync(packageJsonFile);
|
|
33
|
+
packageJson.name = name;
|
|
34
|
+
writeAsJsonSync(packageJsonFile, packageJson);
|
|
35
|
+
}
|
|
36
|
+
function performReplacementsInFiles(dir, config) {
|
|
37
|
+
const { language, packageManager } = config;
|
|
38
|
+
const replacements = {
|
|
39
|
+
"README.md": [
|
|
40
|
+
{
|
|
41
|
+
regex: /\{\{packageManager\}\}/g,
|
|
42
|
+
value: packageManager,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
regex: /\{\{language\}\}/g,
|
|
46
|
+
value: language,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
"src/App.tsx": [
|
|
50
|
+
{
|
|
51
|
+
regex: /\[\[language\]\]/g,
|
|
52
|
+
value: language,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"src/App.jsx": [
|
|
56
|
+
{
|
|
57
|
+
regex: /\[\[language\]\]/g,
|
|
58
|
+
value: language,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
return replaceInFiles(dir, replacements);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Prepares a new project for the application, according to the configuration obtained from CLI and/or by
|
|
66
|
+
* prompting the user.
|
|
67
|
+
*
|
|
68
|
+
* The responsibility of this function is to create target directory, unpack the contents of the
|
|
69
|
+
* appropriate application template archive and then 'massage' the unpacked files and directories:
|
|
70
|
+
*
|
|
71
|
+
* - package json has to be modified
|
|
72
|
+
* - string replacements need to happen in the different files to reflect the renaming
|
|
73
|
+
*
|
|
74
|
+
* @param target - target directory to create application in
|
|
75
|
+
* @param config - config for the initialization action
|
|
76
|
+
*/
|
|
77
|
+
async function prepareProject(target, config) {
|
|
78
|
+
const { language, template } = config;
|
|
79
|
+
await unpackProject(target, language, template);
|
|
80
|
+
modifyPackageJson(target, config);
|
|
81
|
+
await performReplacementsInFiles(target, config);
|
|
82
|
+
}
|
|
83
|
+
function runInstall(target, config) {
|
|
84
|
+
const { skipInstall, packageManager } = config;
|
|
85
|
+
const isNpm = packageManager === "npm";
|
|
86
|
+
if (skipInstall) {
|
|
87
|
+
logWarn(`Skipping installation of application project dependencies. Make sure to run '${packageManager} install' in the application directory before you start developing.`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const args = ["install"];
|
|
92
|
+
if (isNpm) {
|
|
93
|
+
args.push("--legacy-peer-deps");
|
|
94
|
+
logInfo("Command will run with '--legacy-peer-deps' flag.");
|
|
95
|
+
}
|
|
96
|
+
const result = spawnSync(packageManager, args, {
|
|
97
|
+
cwd: target,
|
|
98
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
99
|
+
});
|
|
100
|
+
if (result.status !== 0) {
|
|
101
|
+
logWarn(`New project was created but the installation of dependencies has failed. Troubleshoot the problem in '${target}' and retry '${packageManager} install'.`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
logError(`An internal error has occurred while attempting to install project dependencies: ${e.message}`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export async function initCmdAction(applicationName, options) {
|
|
112
|
+
try {
|
|
113
|
+
const config = await getInitCmdActionConfig(applicationName, options);
|
|
114
|
+
const { name, targetDir } = config;
|
|
115
|
+
const target = targetDir
|
|
116
|
+
? targetDir
|
|
117
|
+
: path.resolve(process.cwd(), convertToApplicationDirectory(name));
|
|
118
|
+
if (fse.existsSync(target)) {
|
|
119
|
+
logError(`Directory for your new application already exists: ${target}. Either use a different application name or use --target-dir and specify a different directory.`);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
await prepareProject(target, config);
|
|
123
|
+
runInstall(target, config);
|
|
124
|
+
logSuccess(`A new project for your application is ready in: ${target}. Check out the package.json and fill in author and description if possible.`);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
genericErrorReporter(e);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initCmd/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EACH,6BAA6B,EAC7B,oBAAoB,EACpB,YAAY,EACZ,eAAe,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAuB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAuB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,6BAA6B,GAC/B;IACI,WAAW,EAAE,0BAA0B;CAC1C,CAAC;AAEN,SAAS,aAAa,CAAC,MAAc,EAAE,QAA2B,EAAE,QAAqB;IACrF,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IAEpE,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QACjC,OAAO,GAAG,CAAC,CAAC,CAAC;YACT,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC;YACnC,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,MAAM;SACd,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,SAAS,iB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,CACJ,sDAAsD,MAAM,kGAAkG,CACjK,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAErC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAE3B,UAAU,CACN,mDAAmD,MAAM,8EAA8E,CAC1I,CAAC;KACL;IAAC,OAAO,CAAC,EAAE;QACR,oBAAoB,CAAC,CAAC,CAAC,CAAC;QAExB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACnB;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fse from "fs-extra";
|
|
2
|
+
type ReadFileFn = typeof fse.readFile;
|
|
3
|
+
type WriteFileFn = typeof fse.writeFile;
|
|
4
|
+
export type RegexReplacement = {
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
value: string;
|
|
7
|
+
apply?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export interface FileReplacementSpec extends Record<string, RegexReplacement[] | FileReplacementSpec> {
|
|
10
|
+
}
|
|
11
|
+
export declare function replaceInFiles(initialPath: string, spec: FileReplacementSpec, readFile?: ReadFileFn, writeFile?: WriteFileFn): Promise<void>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=replaceInFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceInFiles.d.ts","sourceRoot":"","sources":["../../src/initCmd/replaceInFiles.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,UAAU,CAAC;AAK3B,KAAK,UAAU,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;AACtC,KAAK,WAAW,GAAG,OAAO,GAAG,CAAC,SAAS,CAAC;AA8CxC,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAGF,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,CAAC;CAAG;AAExG,wBAAsB,cAAc,CAChC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,mBAAmB,EACzB,QAAQ,GAAE,UAAyB,EACnC,SAAS,GAAE,WAA2B,GACvC,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// (C) 2021-2023 GoodData Corporation
|
|
2
|
+
import fse from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import flatMap from "lodash/flatMap.js";
|
|
5
|
+
import entries from "lodash/entries.js";
|
|
6
|
+
function collectFileReplacements(currentPath, spec) {
|
|
7
|
+
return flatMap(entries(spec), ([key, value]) => {
|
|
8
|
+
const nextPath = path.join(currentPath, key);
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return [{ file: nextPath, replacements: value }];
|
|
11
|
+
}
|
|
12
|
+
return collectFileReplacements(nextPath, value);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function createFileProcessor(readFile, writeFile) {
|
|
16
|
+
return async ({ file, replacements }) => {
|
|
17
|
+
let contents;
|
|
18
|
+
try {
|
|
19
|
+
contents = await readFile(file, { encoding: "utf8", flag: "r" });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// ENOENT is fine, allow defining replacements for files that may not exist
|
|
23
|
+
if (e.code === "ENOENT")
|
|
24
|
+
return;
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
const replaced = replacements.reduce((acc, { regex, value, apply }) => (apply ?? true ? acc.replace(regex, value) : acc), contents);
|
|
28
|
+
return writeFile(file, replaced, { encoding: "utf8", flag: "w" });
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export async function replaceInFiles(initialPath, spec, readFile = fse.readFile, writeFile = fse.writeFile) {
|
|
32
|
+
const fileReplacements = collectFileReplacements(initialPath, spec);
|
|
33
|
+
const processor = createFileProcessor(readFile, writeFile);
|
|
34
|
+
await Promise.all(fileReplacements.map(processor));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=replaceInFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceInFiles.js","sourceRoot":"","sources":["../../src/initCmd/replaceInFiles.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAYxC,SAAS,uBAAuB,CAAC,WAAmB,EAAE,IAAyB;IAC3E,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAE7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;SACpD;QAED,OAAO,uBAAuB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAoB,EAAE,SAAsB;IACrE,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE;QACpC,IAAI,QAAQ,CAAC;QACb,IAAI;YACA,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;SACpE;QAAC,OAAO,CAAM,EAAE;YACb,2EAA2E;YAC3E,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO;YAEhC,MAAM,CAAC,CAAC;SACX;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EACnF,QAAQ,CACX,CAAC;QAEF,OAAO,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;AACN,CAAC;AAeD,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,WAAmB,EACnB,IAAyB,EACzB,WAAuB,GAAG,CAAC,QAAQ,EACnC,YAAyB,GAAG,CAAC,SAAS;IAEtC,MAAM,gBAAgB,GAAuB,uBAAuB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACxF,MAAM,SAAS,GAA6B,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAErF,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-app-template.d.ts","sourceRoot":"","sources":["../src/react-app-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAE9E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { fileURLToPath } from "url";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = path.dirname(__filename);
|
|
5
|
+
/*
|
|
6
|
+
* This file is intentionally named and located in the root to reflect the location of the archives
|
|
7
|
+
* that contain the template project.
|
|
8
|
+
*/
|
|
9
|
+
export function getReactAppTemplateArchive(language) {
|
|
10
|
+
return path.join(__dirname, `react-app-template.${language}.tgz`);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=react-app-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-app-template.js","sourceRoot":"","sources":["../src/react-app-template.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C;;;GAGG;AAEH,MAAM,UAAU,0BAA0B,CAAC,QAA2B;IAClE,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,QAAQ,MAAM,CAAC,CAAC;AACtE,CAAC"}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/app-toolkit",
|
|
3
|
-
"version": "9.6.0-alpha.
|
|
3
|
+
"version": "9.6.0-alpha.14",
|
|
4
4
|
"author": "GoodData",
|
|
5
5
|
"description": "CLI with useful tools for creating and maintaining GoodData web applications.",
|
|
6
6
|
"repository": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"tar": "^6.1.11",
|
|
45
45
|
"tslib": "^2.5.0",
|
|
46
46
|
"validate-npm-package-name": "^5.0.0",
|
|
47
|
-
"@gooddata/sdk-backend-spi": "9.6.0-alpha.
|
|
48
|
-
"@gooddata/sdk-backend-tiger": "9.6.0-alpha.
|
|
49
|
-
"@gooddata/sdk-model": "9.6.0-alpha.
|
|
47
|
+
"@gooddata/sdk-backend-spi": "9.6.0-alpha.14",
|
|
48
|
+
"@gooddata/sdk-backend-tiger": "9.6.0-alpha.14",
|
|
49
|
+
"@gooddata/sdk-model": "9.6.0-alpha.14"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@gooddata/eslint-config": "^4.1.0",
|