@gooddata/app-toolkit 9.6.0-alpha.5 → 9.6.0-alpha.7

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.
Files changed (46) hide show
  1. package/esm/__version.d.ts +4 -0
  2. package/esm/__version.d.ts.map +1 -0
  3. package/esm/__version.js +6 -0
  4. package/esm/__version.js.map +1 -0
  5. package/esm/index.js +2 -2
  6. package/esm/index.js.map +1 -1
  7. package/esm/react-app-template.js.tgz +0 -0
  8. package/esm/react-app-template.ts.tgz +0 -0
  9. package/package.json +6 -8
  10. package/esm/_base/inputHandling/validators.d.ts +0 -39
  11. package/esm/_base/inputHandling/validators.d.ts.map +0 -1
  12. package/esm/_base/inputHandling/validators.js +0 -94
  13. package/esm/_base/inputHandling/validators.js.map +0 -1
  14. package/esm/_base/terminal/loggers.d.ts +0 -24
  15. package/esm/_base/terminal/loggers.d.ts.map +0 -1
  16. package/esm/_base/terminal/loggers.js +0 -35
  17. package/esm/_base/terminal/loggers.js.map +0 -1
  18. package/esm/_base/terminal/prompts.d.ts +0 -9
  19. package/esm/_base/terminal/prompts.d.ts.map +0 -1
  20. package/esm/_base/terminal/prompts.js +0 -49
  21. package/esm/_base/terminal/prompts.js.map +0 -1
  22. package/esm/_base/types.d.ts +0 -40
  23. package/esm/_base/types.d.ts.map +0 -1
  24. package/esm/_base/types.js +0 -22
  25. package/esm/_base/types.js.map +0 -1
  26. package/esm/_base/utils.d.ts +0 -31
  27. package/esm/_base/utils.d.ts.map +0 -1
  28. package/esm/_base/utils.js +0 -79
  29. package/esm/_base/utils.js.map +0 -1
  30. package/esm/index.d.ts +0 -3
  31. package/esm/initCmd/actionConfig.d.ts +0 -21
  32. package/esm/initCmd/actionConfig.d.ts.map +0 -1
  33. package/esm/initCmd/actionConfig.js +0 -57
  34. package/esm/initCmd/actionConfig.js.map +0 -1
  35. package/esm/initCmd/index.d.ts +0 -3
  36. package/esm/initCmd/index.d.ts.map +0 -1
  37. package/esm/initCmd/index.js +0 -131
  38. package/esm/initCmd/index.js.map +0 -1
  39. package/esm/initCmd/replaceInFiles.d.ts +0 -13
  40. package/esm/initCmd/replaceInFiles.d.ts.map +0 -1
  41. package/esm/initCmd/replaceInFiles.js +0 -36
  42. package/esm/initCmd/replaceInFiles.js.map +0 -1
  43. package/esm/react-app-template.d.ts +0 -3
  44. package/esm/react-app-template.d.ts.map +0 -1
  45. package/esm/react-app-template.js +0 -12
  46. package/esm/react-app-template.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ export declare const LIB_VERSION = "9.6.0-alpha.7";
2
+ export declare const LIB_DESCRIPTION = "CLI with useful tools for creating and maintaining GoodData web applications.";
3
+ export declare const LIB_NAME = "@gooddata/app-toolkit";
4
+ //# sourceMappingURL=__version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__version.d.ts","sourceRoot":"","sources":["../src/__version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,eAAO,MAAM,eAAe,kFACuD,CAAC;AAEpF,eAAO,MAAM,QAAQ,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // (C) 2021 GoodData Corporation
2
+ // DO NOT CHANGE THIS FILE, IT IS RE-GENERATED ON EVERY BUILD
3
+ export const LIB_VERSION = "9.6.0-alpha.7";
4
+ export const LIB_DESCRIPTION = "CLI with useful tools for creating and maintaining GoodData web applications.";
5
+ export const LIB_NAME = "@gooddata/app-toolkit";
6
+ //# sourceMappingURL=__version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__version.js","sourceRoot":"","sources":["../src/__version.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GACxB,+EAA+E,CAAC;AAEpF,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAC"}
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  // (C) 2021-2022 GoodData Corporation
3
3
  import { program } from "commander";
4
- import pkg from "../package.json" assert { type: "json" };
5
4
  import { initCmdAction } from "./initCmd/index.js";
6
- program.name(pkg.name).description(pkg.description).version(pkg.version);
5
+ import { LIB_NAME, LIB_DESCRIPTION, LIB_VERSION } from "./__version.js";
6
+ program.name(LIB_NAME).description(LIB_DESCRIPTION).version(LIB_VERSION);
7
7
  export const initCmd = program
8
8
  .command("init")
9
9
  .description("initializes a new GoodData application.")
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,qCAAqC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO;KACzB,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,yCAAyC,CAAC;KACtD,QAAQ,CACL,YAAY,EACZ,sEAAsE;IAClE,qGAAqG,CAC5G;KACA,MAAM,CACH,uBAAuB,EACvB,gFAAgF,CACnF;KACA,MAAM,CAAC,qCAAqC,EAAE,mDAAmD,EAAE,KAAK,CAAC;KACzG,MAAM,CAAC,uBAAuB,EAAE,qCAAqC,EAAE,WAAW,CAAC;KACnF,MAAM,CACH,qBAAqB,EACrB,qDAAqD;IACjD,2FAA2F;IAC3F,qFAAqF,CAC5F;KACA,MAAM,CAAC,gBAAgB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KA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,EAAE,OAAO,CAAC,IAAI,EAAE;KAC9B,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,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.5",
3
+ "version": "9.6.0-alpha.7",
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.5",
48
- "@gooddata/sdk-backend-tiger": "9.6.0-alpha.5",
49
- "@gooddata/sdk-model": "9.6.0-alpha.5"
47
+ "@gooddata/sdk-backend-spi": "9.6.0-alpha.7",
48
+ "@gooddata/sdk-model": "9.6.0-alpha.7",
49
+ "@gooddata/sdk-backend-tiger": "9.6.0-alpha.7"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@gooddata/eslint-config": "^4.1.0",
@@ -54,7 +54,7 @@
54
54
  "@types/cross-spawn": "^6.0.2",
55
55
  "@types/fs-extra": "^9.0.13",
56
56
  "@types/inquirer": "^8.2.6",
57
- "@types/lodash": "^4.14.158",
57
+ "@types/lodash": "^4.14.202",
58
58
  "@types/node": "^18.17.6",
59
59
  "@types/tar": "^6.1.0",
60
60
  "@typescript-eslint/eslint-plugin": "^5.57.1",
@@ -77,10 +77,8 @@
77
77
  "vitest": "1.0.4"
78
78
  },
79
79
  "scripts": {
80
- "clean": "rm -rf ci dist esm build coverage *.log",
81
- "dev": "tsc -p tsconfig.dev.json --watch",
80
+ "clean": "rm -rf ci dist esm build coverage *.log tsconfig.tsbuildinfo",
82
81
  "build": "bash scripts/build.sh",
83
- "build-esm": "tsc -p tsconfig.build.json",
84
82
  "test": "vitest watch --passWithNoTests",
85
83
  "test-once": "vitest run --passWithNoTests",
86
84
  "test-ci": "vitest run --reporter=junit --outputFile=./ci/results/test-results.xml --passWithNoTests",
@@ -1,39 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,94 +0,0 @@
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
- var _a;
14
- if (isEmpty(value) || (value && isEmpty(value.trim()))) {
15
- return "Please enter non-empty application name.";
16
- }
17
- const result = validateNpmPackageName(value);
18
- if ((_a = result.errors) === null || _a === void 0 ? void 0 : _a.length) {
19
- return `Invalid application name. ${result.errors
20
- .map((e) => {
21
- return `${capitalize(e)}.`;
22
- })
23
- .join(" ")}`;
24
- }
25
- return true;
26
- }
27
- /**
28
- * Validates that value is either 'js' or 'ts'.
29
- */
30
- export function languageValidator(value) {
31
- if (value === "js" || value === "ts") {
32
- return true;
33
- }
34
- return "Invalid language. Specify 'ts' for TypeScript or 'js' for JavaScript.";
35
- }
36
- /**
37
- * Validates that the value is supported template.
38
- */
39
- export function templateValidator(value) {
40
- if (value === "react-app") {
41
- return true;
42
- }
43
- return "Invalid template. Specify a supported template. (e.g. react-app)";
44
- }
45
- /**
46
- * Validates that value is either 'npm' or 'yarn'.
47
- */
48
- export function packageManagerValidator(value) {
49
- if (value === "npm" || value === "yarn") {
50
- return true;
51
- }
52
- return "Invalid package manager. Specify 'npm' or 'yarn'.";
53
- }
54
- //
55
- // Functions to trigger validation outside of inquirer.
56
- //
57
- /**
58
- * Triggers validation of value for particular input, using the provided validator. If the validation
59
- * succeeds (validator returns true), then this function just returns.
60
- *
61
- * Otherwise the function throws an {@link InputValidationError}.
62
- *
63
- * @param inputName - name of input that is being validated - this is purely metadata, passed over to the exception
64
- * so that whoever gets hold of it can determine what exactly failed validation.
65
- * @param value - value to validate; this will be sent to the validator function & in case of failure will also
66
- * appear in the exception
67
- * @param validator - validator to use, this is function matching the contract set by the inquirer library
68
- */
69
- export function validOrDie(inputName, value, validator) {
70
- const result = validator(value);
71
- if (typeof result === "string") {
72
- throw new InputValidationError(inputName, value, result);
73
- }
74
- if (!result) {
75
- throw new InputValidationError(inputName, value, `Invalid value provided: ${value}`);
76
- }
77
- }
78
- /**
79
- * This is same as {@link validOrDie} except that the validator function returns Promise of the validation
80
- * result.
81
- *
82
- * See {@link validOrDie} for more detail.
83
- */
84
- export function asyncValidOrDie(inputName, value, validator) {
85
- return validator(value).then((result) => {
86
- if (typeof result === "string") {
87
- throw new InputValidationError(inputName, value, result);
88
- }
89
- if (!result) {
90
- throw new InputValidationError(inputName, value, `Invalid value provided: ${value}`);
91
- }
92
- });
93
- }
94
- //# sourceMappingURL=validators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/_base/inputHandling/validators.ts"],"names":[],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AI,CAAC;KACf;IAED,OAAO,mDAAmD,CAAC;AAC/D,CAAC;AAED,EAAE;AACF,uDAAuD;AACvD,EAAE;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,KAAa,EAAE,SAAyB;IAClF,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAEhC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;KAC5D;IAED,IAAI,CAAC,MAAM,EAAE;QACT,MAAM,IAAI,oBAAoB,CAAC,SAAS,EAAE,KAAK,EAAE,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"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,35 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,49 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,22 +0,0 @@
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
- constructor(inputName, value, message) {
8
- super(message);
9
- this.inputName = inputName;
10
- this.value = value;
11
- this.type = "IVE";
12
- // restore prototype chain
13
- Object.setPrototypeOf(this, new.target.prototype);
14
- }
15
- }
16
- /**
17
- * Type guard testing whether object is a type of {@link InputValidationError}.
18
- */
19
- export function isInputValidationError(obj) {
20
- return !isEmpty(obj) && obj.type === "IVE";
21
- }
22
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
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;IAG3C,YAAmC,SAAiB,EAAkB,KAAa,EAAE,OAAe;QAChG,KAAK,CAAC,OAAO,CAAC,CAAC;QADgB,cAAS,GAAT,SAAS,CAAQ;QAAkB,UAAK,GAAL,KAAK,CAAQ;QAFnE,SAAI,GAAG,KAAK,CAAC;QAKzB,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"}
@@ -1,31 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,79 +0,0 @@
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
- var _a;
61
- if (isInputValidationError(error)) {
62
- logError(error.message);
63
- }
64
- else if (isNotAuthenticated(error)) {
65
- logError("Authentication to backend has failed. Please ensure your environment is setup with correct credentials.");
66
- }
67
- else {
68
- const e = extractRootCause(error);
69
- if (((_a = e.message) === null || _a === void 0 ? void 0 : _a.search(/.*(certificate|self-signed).*/)) > -1) {
70
- logError("Server does not have valid certificate. The login has failed. " +
71
- "If you trust the server, you can use the --accept-untrusted-ssl option " +
72
- "to turn off certificate validation.");
73
- }
74
- else {
75
- logError(`An unexpected error has occurred: ${e.stack}`);
76
- }
77
- }
78
- }
79
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/_base/utils.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,UAAU,YAAY,CAAC,GAAQ;IACjC,+EAA+E;IAC/E,sGAAsG;IACtG,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,GAAW;IACrD,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACnC,IAAI,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,E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AAC;SACL;aAAM;YACH,QAAQ,CAAC,qCAAqC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;SAC5D;KACJ;AACL,CAAC"}
package/esm/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare const initCmd: import("commander").Command;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,21 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,57 +0,0 @@
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
- var _a;
39
- if (applicationName) {
40
- validOrDie("app-name", applicationName, applicationNameValidator);
41
- }
42
- const languageFromOptions = getLanguageFromOptions(options);
43
- const packageManagerFromOptions = getPackageManagerFromOptions(options);
44
- const templateFromOptions = getTemplateFromOptions(options);
45
- const name = applicationName !== null && applicationName !== void 0 ? applicationName : (await promptName());
46
- const template = templateFromOptions !== null && templateFromOptions !== void 0 ? templateFromOptions : (await promptTemplate());
47
- const language = languageFromOptions !== null && languageFromOptions !== void 0 ? languageFromOptions : (await promptLanguage());
48
- return {
49
- name,
50
- language,
51
- packageManager: packageManagerFromOptions,
52
- targetDir: options.commandOpts.targetDir,
53
- skipInstall: (_a = options.commandOpts.skipInstall) !== null && _a !== void 0 ? _a : false,
54
- template,
55
- };
56
- }
57
- //# sourceMappingURL=actionConfig.js.map
@@ -1 +0,0 @@
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,cAAc,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAE/C,IAAI,CAAC,cAAc,EAAE;QACjB,OAAO,KAAK,CAAC;KAChB;IAED,UAAU,CAAC,gBAAgB,EAAE,cAAc,EAAE,uBAAuB,CAAC,CAAC;IAEtE,OAAO,cAAyC,CAAC;AACrD,CAAC;AAED,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,QAAuB,CAAC;AACnC,CAAC;AAeD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,eAAmC,EACnC,OAAsB;;IAEtB,IAAI,eAAe,EAAE;QACjB,UAAU,CAAC,UAAU,EAAE,eAAe,EAAE,wBAAwB,CAAC,CAAC;KACrE;IAED,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,yBAAyB,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAE5D,MAAM,IAAI,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,CAAC,MAAM,cAAc,EAAE,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,CAAC,MAAM,cAAc,EAAE,CAAC,CAAC;IAEjE,OAAO;QACH,IAAI;QACJ,QAAQ;QACR,cAAc,EAAE,yBAAyB;QACzC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS;QACxC,WAAW,EAAE,MAAA,OAAO,CAAC,WAAW,CAAC,WAAW,mCAAI,KAAK;QACrD,QAAQ;KACX,CAAC;AACN,CAAC"}
@@ -1,3 +0,0 @@
1
- import { ActionOptions } from "../_base/types.js";
2
- export declare function initCmdAction(applicationName: string | undefined, options: ActionOptions): Promise<void>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,131 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,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AE,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"}
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
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 !== null && apply !== void 0 ? 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
@@ -1 +0,0 @@
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,G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,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"}
@@ -1,3 +0,0 @@
1
- import { TargetAppLanguage } from "./_base/types.js";
2
- export declare function getReactAppTemplateArchive(language: TargetAppLanguage): string;
3
- //# sourceMappingURL=react-app-template.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}