zcatalyst-cli 1.26.1 → 1.27.0

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 (155) hide show
  1. package/README.md +1 -0
  2. package/lib/appsail-utils.d.ts +1 -1
  3. package/lib/appsail-utils.js +170 -129
  4. package/lib/authentication/credential.d.ts +2 -1
  5. package/lib/authentication/credential.js +20 -3
  6. package/lib/authentication/crypt.d.ts +7 -3
  7. package/lib/authentication/crypt.js +87 -16
  8. package/lib/authentication/index.js +1 -0
  9. package/lib/authentication/key-manager.d.ts +7 -0
  10. package/lib/authentication/key-manager.js +62 -0
  11. package/lib/authentication/login.js +20 -20
  12. package/lib/bin/catalyst.js +1 -15
  13. package/lib/client.d.ts +3 -1
  14. package/lib/client.js +16 -5
  15. package/lib/command_needs/rc.js +13 -3
  16. package/lib/commands/appsail/add.js +10 -0
  17. package/lib/commands/client/delete.js +18 -6
  18. package/lib/commands/client/setup.js +7 -0
  19. package/lib/commands/deploy/index.js +3 -3
  20. package/lib/commands/deploy/slate.js +65 -4
  21. package/lib/commands/functions/add.js +7 -0
  22. package/lib/commands/functions/delete.js +22 -4
  23. package/lib/commands/functions/execute.js +39 -71
  24. package/lib/commands/functions/setup.js +13 -0
  25. package/lib/commands/functions/shell.js +15 -1
  26. package/lib/commands/iac/import.js +2 -2
  27. package/lib/commands/init.js +34 -20
  28. package/lib/commands/login.js +1 -0
  29. package/lib/commands/pull.js +22 -1
  30. package/lib/commands/serve.js +2 -1
  31. package/lib/commands/slate/create.js +7 -4
  32. package/lib/commands/slate/link.js +11 -5
  33. package/lib/commands/slate/unlink.js +7 -0
  34. package/lib/commands/zest/generate/index.js +28 -35
  35. package/lib/deploy/features/appsail/index.js +2 -1
  36. package/lib/deploy/features/slate.d.ts +3 -1
  37. package/lib/deploy/features/slate.js +204 -5
  38. package/lib/docs/client-utils.toml +0 -5
  39. package/lib/docs/command_needs/rc.toml +9 -1
  40. package/lib/docs/commands/client/delete.toml +4 -0
  41. package/lib/docs/commands/deploy/slate.toml +3 -0
  42. package/lib/docs/commands/functions/delete.toml +10 -0
  43. package/lib/docs/commands/functions/execute.toml +1 -16
  44. package/lib/docs/commands/functions/setup.toml +3 -0
  45. package/lib/docs/commands/functions/shell.toml +8 -0
  46. package/lib/docs/commands/init.toml +3 -0
  47. package/lib/docs/commands/pull.toml +6 -0
  48. package/lib/docs/commands/slate/unlink.toml +6 -0
  49. package/lib/docs/execute/command-utils.toml +14 -0
  50. package/lib/docs/execute/execute-input-resolver.toml +37 -0
  51. package/lib/docs/init/features/project.toml +20 -0
  52. package/lib/docs/init/util/client.toml +4 -0
  53. package/lib/docs/prompt/index.toml +15 -0
  54. package/lib/docs/pull/features/apig.toml +6 -0
  55. package/lib/docs/pull/features/client.toml +20 -0
  56. package/lib/docs/pull/features/functions/index.toml +24 -0
  57. package/lib/endpoints/lib/slate.d.ts +14 -1
  58. package/lib/endpoints/lib/slate.js +35 -0
  59. package/lib/error/context-help.js +1 -1
  60. package/lib/error/index.js +9 -13
  61. package/lib/execute/command-utils.d.ts +5 -0
  62. package/lib/execute/command-utils.js +86 -0
  63. package/lib/execute/execute-input-resolver.d.ts +29 -0
  64. package/lib/execute/execute-input-resolver.js +207 -0
  65. package/lib/execute/index.d.ts +4 -1
  66. package/lib/execute/index.js +3 -2
  67. package/lib/fn-utils/lib/integ.js +22 -17
  68. package/lib/index.js +1 -0
  69. package/lib/init/dependencies/package-json.js +11 -7
  70. package/lib/init/features/appsail/index.js +75 -26
  71. package/lib/init/features/appsail/prompt-fields.d.ts +43 -0
  72. package/lib/init/features/appsail/prompt-fields.js +55 -0
  73. package/lib/init/features/appsail/utils/custom-runtime.d.ts +3 -0
  74. package/lib/init/features/appsail/utils/custom-runtime.js +161 -0
  75. package/lib/init/features/appsail/{utils.d.ts → utils/index.d.ts} +2 -2
  76. package/lib/init/features/appsail/utils/index.js +170 -0
  77. package/lib/init/features/client/index.js +4 -3
  78. package/lib/init/features/client/initializers/angular.js +3 -2
  79. package/lib/init/features/client/initializers/react.js +4 -3
  80. package/lib/init/features/client/prompt-fields.d.ts +37 -0
  81. package/lib/init/features/client/prompt-fields.js +48 -0
  82. package/lib/init/features/functions/index.js +37 -8
  83. package/lib/init/features/functions/languages/java.js +42 -7
  84. package/lib/init/features/functions/languages/node.js +42 -10
  85. package/lib/init/features/functions/languages/python.js +42 -7
  86. package/lib/init/features/functions/prompt-fields.d.ts +25 -0
  87. package/lib/init/features/functions/prompt-fields.js +34 -0
  88. package/lib/init/features/project.js +41 -6
  89. package/lib/init/features/slate/index.js +2 -0
  90. package/lib/init/features/slate/prompt-fields.d.ts +31 -0
  91. package/lib/init/features/slate/prompt-fields.js +41 -0
  92. package/lib/init/index.js +2 -1
  93. package/lib/init/util/client.js +11 -8
  94. package/lib/init/util/common.d.ts +2 -0
  95. package/lib/init/util/common.js +33 -3
  96. package/lib/init/util/prompt-fields.d.ts +7 -0
  97. package/lib/init/util/prompt-fields.js +13 -0
  98. package/lib/internal/command.d.ts +3 -0
  99. package/lib/internal/command.js +26 -3
  100. package/lib/migration/global/1.27.0.d.ts +2 -0
  101. package/lib/migration/global/1.27.0.js +39 -0
  102. package/lib/prompt/choice.d.ts +2 -0
  103. package/lib/prompt/choice.js +24 -0
  104. package/lib/prompt/cli-option-key.d.ts +1 -0
  105. package/lib/prompt/cli-option-key.js +10 -0
  106. package/lib/prompt/index.d.ts +6 -22
  107. package/lib/prompt/index.js +264 -67
  108. package/lib/prompt/overwrite-prompt.d.ts +11 -0
  109. package/lib/prompt/overwrite-prompt.js +16 -0
  110. package/lib/prompt/question-factory.d.ts +34 -0
  111. package/lib/prompt/question-factory.js +41 -0
  112. package/lib/prompt/register-fields.d.ts +24 -0
  113. package/lib/prompt/register-fields.js +37 -0
  114. package/lib/pull/features/apig.js +57 -6
  115. package/lib/pull/features/client.js +107 -24
  116. package/lib/pull/features/functions/index.js +100 -4
  117. package/lib/pull/index.js +1 -1
  118. package/lib/pull/utils.d.ts +13 -0
  119. package/lib/pull/utils.js +20 -0
  120. package/lib/repl-server.d.ts +4 -0
  121. package/lib/repl-server.js +9 -0
  122. package/lib/serve/features/appsail.js +2 -45
  123. package/lib/serve/server/lib/master/index.js +3 -3
  124. package/lib/serve/server/lib/slate/static-server.js +2 -2
  125. package/lib/serve/server/lib/web_client/server.js +2 -2
  126. package/lib/shell/format-functions.d.ts +4 -0
  127. package/lib/shell/format-functions.js +59 -0
  128. package/lib/shell/index.js +18 -0
  129. package/lib/util_modules/config/lib/appsail.d.ts +3 -2
  130. package/lib/util_modules/config/lib/appsail.js +21 -5
  131. package/lib/util_modules/config/lib/slate.d.ts +19 -0
  132. package/lib/util_modules/config-store.d.ts +1 -0
  133. package/lib/util_modules/config-store.js +29 -10
  134. package/lib/util_modules/constants/index.d.ts +0 -1
  135. package/lib/util_modules/constants/index.js +1 -3
  136. package/lib/util_modules/constants/lib/urls.d.ts +2 -0
  137. package/lib/util_modules/constants/lib/urls.js +4 -0
  138. package/lib/util_modules/dc.d.ts +6 -1
  139. package/lib/util_modules/dc.js +21 -8
  140. package/lib/util_modules/env.d.ts +3 -0
  141. package/lib/util_modules/env.js +41 -0
  142. package/lib/util_modules/fs/lib/sync.d.ts +1 -0
  143. package/lib/util_modules/fs/lib/sync.js +19 -0
  144. package/lib/util_modules/logger/utils.d.ts +1 -0
  145. package/lib/util_modules/logger/utils.js +5 -1
  146. package/lib/util_modules/option.d.ts +1 -0
  147. package/lib/util_modules/option.js +8 -0
  148. package/lib/util_modules/{server.js → server/index.js} +3 -3
  149. package/lib/util_modules/server/needed-scopes.d.ts +1 -0
  150. package/lib/util_modules/{constants/lib → server}/needed-scopes.js +7 -7
  151. package/package.json +3 -2
  152. package/lib/init/features/appsail/utils.js +0 -273
  153. package/lib/util_modules/constants/lib/needed-scopes.d.ts +0 -4
  154. /package/lib/docs/{dc.toml → util_modules/dc.toml} +0 -0
  155. /package/lib/util_modules/{server.d.ts → server/index.d.ts} +0 -0
@@ -0,0 +1,43 @@
1
+ export declare const appsailAddPromptFields: import("../../../prompt/register-fields").PromptFieldsRegistry<readonly [{
2
+ readonly name: "name";
3
+ readonly cliOption: {
4
+ readonly option: "--name <name>";
5
+ readonly description: "appsail service name";
6
+ };
7
+ }, {
8
+ readonly name: "source";
9
+ readonly cliOption: {
10
+ readonly option: "--source <source>";
11
+ readonly description: "absolute path to appsail source directory or docker image url or docker archive url";
12
+ };
13
+ }, {
14
+ readonly name: "overwrite";
15
+ readonly cliOption: {
16
+ readonly option: "--overwrite-config";
17
+ readonly description: "overwrite existing app-config.json when present, applicable for catalyst runtime";
18
+ };
19
+ }, {
20
+ readonly name: "buildPath";
21
+ readonly cliOption: {
22
+ readonly option: "--build <path>";
23
+ readonly description: "appsail build path relative to source, applicable for catalyst runtime";
24
+ };
25
+ }, {
26
+ readonly name: "platform";
27
+ readonly cliOption: {
28
+ readonly option: "--platform <platform>";
29
+ readonly description: "appsail java platform <javase|war>";
30
+ };
31
+ }, {
32
+ readonly name: "command";
33
+ readonly cliOption: {
34
+ readonly option: "--command <command>";
35
+ readonly description: "startup command for appsail";
36
+ };
37
+ }, {
38
+ readonly name: "port";
39
+ readonly cliOption: {
40
+ readonly option: "--port <httpPort>";
41
+ readonly description: "http port for appsail, applicable only for custom runtime";
42
+ };
43
+ }]>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appsailAddPromptFields = void 0;
4
+ const register_fields_1 = require("../../../prompt/register-fields");
5
+ exports.appsailAddPromptFields = (0, register_fields_1.definePromptFields)([
6
+ {
7
+ name: 'name',
8
+ cliOption: {
9
+ option: '--name <name>',
10
+ description: 'appsail service name'
11
+ }
12
+ },
13
+ {
14
+ name: 'source',
15
+ cliOption: {
16
+ option: '--source <source>',
17
+ description: 'absolute path to appsail source directory or docker image url or docker archive url'
18
+ }
19
+ },
20
+ {
21
+ name: 'overwrite',
22
+ cliOption: {
23
+ option: '--overwrite-config',
24
+ description: 'overwrite existing app-config.json when present, applicable for catalyst runtime'
25
+ }
26
+ },
27
+ {
28
+ name: 'buildPath',
29
+ cliOption: {
30
+ option: '--build <path>',
31
+ description: 'appsail build path relative to source, applicable for catalyst runtime'
32
+ }
33
+ },
34
+ {
35
+ name: 'platform',
36
+ cliOption: {
37
+ option: '--platform <platform>',
38
+ description: 'appsail java platform <javase|war>'
39
+ }
40
+ },
41
+ {
42
+ name: 'command',
43
+ cliOption: {
44
+ option: '--command <command>',
45
+ description: 'startup command for appsail'
46
+ }
47
+ },
48
+ {
49
+ name: 'port',
50
+ cliOption: {
51
+ option: '--port <httpPort>',
52
+ description: 'http port for appsail, applicable only for custom runtime'
53
+ }
54
+ }
55
+ ]);
@@ -0,0 +1,3 @@
1
+ export declare function getContainerImageTag(): Promise<string>;
2
+ export declare function resolveCustomAppSailSourceFromOption(sourceInput: string): Promise<string>;
3
+ export declare function getCustomAppSailSource(sourceInput?: string): Promise<string>;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getContainerImageTag = getContainerImageTag;
16
+ exports.resolveCustomAppSailSourceFromOption = resolveCustomAppSailSourceFromOption;
17
+ exports.getCustomAppSailSource = getCustomAppSailSource;
18
+ const image_1 = require("@zcatalyst/container-plugin/out/endpoints/image");
19
+ const container_1 = require("../../../../util_modules/container");
20
+ const js_1 = require("../../../../util_modules/js");
21
+ const ansi_colors_1 = require("ansi-colors");
22
+ const prompt_1 = __importDefault(require("../../../../prompt"));
23
+ const error_1 = __importDefault(require("../../../../error"));
24
+ const project_1 = require("../../../../util_modules/project");
25
+ const path_1 = require("path");
26
+ const fs_1 = require("../../../../util_modules/fs");
27
+ function getContainerImageTag() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ yield (0, container_1.isSocketAccessible)();
30
+ const images = (yield (0, image_1.getAllLocalImages)()).reduce((_images, img) => {
31
+ var _a;
32
+ (_a = img.RepoTags) === null || _a === void 0 ? void 0 : _a.forEach((tag) => _images.push({ imgName: tag, id: img.Id }));
33
+ return _images;
34
+ }, []);
35
+ const searchImages = (filter) => {
36
+ const filteredImages = [];
37
+ images.forEach((img) => {
38
+ var _a;
39
+ if (filter === '' ||
40
+ img.id.includes(filter) ||
41
+ ((_a = img.imgName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(filter.toLowerCase()))) {
42
+ filteredImages.push({
43
+ name: `${img.imgName} ${(0, ansi_colors_1.dim)(img.id.substring(7, 17))}`,
44
+ value: img.imgName || img.id
45
+ });
46
+ return;
47
+ }
48
+ });
49
+ return filteredImages;
50
+ };
51
+ yield prompt_1.default.register('search-box');
52
+ const image = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please search and select the image to link:', {
53
+ type: 'search-box',
54
+ boxType: 'list',
55
+ searchable: true,
56
+ pageSize: 10,
57
+ highlight: true,
58
+ notFoundMsg: 'No Images found!',
59
+ searchMsg: 'Searching images...',
60
+ source(_answersSoFar, input) {
61
+ input || (input = '');
62
+ return Promise.resolve(searchImages(input));
63
+ },
64
+ validate: (ansArr) => {
65
+ if (js_1.JS.isEmpty(ansArr)) {
66
+ return 'Must select an Image';
67
+ }
68
+ return true;
69
+ }
70
+ }));
71
+ return `docker://${image.name}`;
72
+ });
73
+ }
74
+ function resolveCustomAppSailSourceFromOption(sourceInput) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const source = sourceInput.trim();
77
+ if (!source) {
78
+ throw new error_1.default('AppSail source cannot be empty for custom runtime.', {
79
+ exit: 2
80
+ });
81
+ }
82
+ const isDockerArchiveProtocol = source.startsWith('docker-archive://');
83
+ const isDockerImageProtocol = source.startsWith('docker://');
84
+ if (isDockerImageProtocol) {
85
+ const imageName = source.slice('docker://'.length).trim();
86
+ if (!imageName) {
87
+ throw new error_1.default('Invalid docker image source. Use format docker://<image[:tag]>.', { exit: 2 });
88
+ }
89
+ return source;
90
+ }
91
+ const archivePathOrImage = isDockerArchiveProtocol
92
+ ? source.slice('docker-archive://'.length)
93
+ : source;
94
+ const archivePathCandidate = (0, path_1.isAbsolute)(archivePathOrImage)
95
+ ? archivePathOrImage
96
+ : (0, project_1.resolveProjectPath)(archivePathOrImage);
97
+ const isArchiveLike = archivePathOrImage.endsWith('.tar');
98
+ if (isDockerArchiveProtocol || isArchiveLike) {
99
+ if (!(yield fs_1.ASYNC.fileExists(archivePathCandidate))) {
100
+ throw new error_1.default('Provided docker archive path does not exist.', {
101
+ exit: 2
102
+ });
103
+ }
104
+ if (!archivePathCandidate.endsWith('.tar')) {
105
+ throw new error_1.default('Provided file is not a valid docker archive. Please provide a .tar file.', { exit: 2 });
106
+ }
107
+ const normalized = (0, path_1.relative)((0, project_1.getProjectRoot)(), archivePathCandidate);
108
+ return `docker-archive://${normalized}`;
109
+ }
110
+ return `docker://${source}`;
111
+ });
112
+ }
113
+ function getCustomAppSailSource(sourceInput) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ if (sourceInput !== undefined) {
116
+ return resolveCustomAppSailSourceFromOption(sourceInput);
117
+ }
118
+ const dockerProtocol = yield prompt_1.default.ask(prompt_1.default.question('type', 'Please choose one of the supported protocols:', {
119
+ type: 'list',
120
+ choices: [
121
+ prompt_1.default.choice(`Docker image ${(0, ansi_colors_1.italic)('(docker://)')}`, {
122
+ value: 'image',
123
+ short: 'Docker image'
124
+ }),
125
+ prompt_1.default.choice(`Docker archive ${(0, ansi_colors_1.italic)('(docker-archive://)')}`, {
126
+ value: 'docker-archive',
127
+ short: 'Docker archive'
128
+ })
129
+ ]
130
+ }));
131
+ switch (dockerProtocol.type) {
132
+ case 'image': {
133
+ return getContainerImageTag();
134
+ }
135
+ case 'docker-archive': {
136
+ const archivePath = yield prompt_1.default.ask(prompt_1.default.question('archive', 'Please provide the path to the docker archive file: ', {
137
+ type: 'input',
138
+ validate: (pth) => __awaiter(this, void 0, void 0, function* () {
139
+ if (!(0, path_1.isAbsolute)(pth)) {
140
+ return 'Please provide an absolute path';
141
+ }
142
+ if (!(yield fs_1.ASYNC.fileExists(pth))) {
143
+ return 'Provided path does not exists';
144
+ }
145
+ if (!pth.endsWith('.tar')) {
146
+ return 'Provided file is not a valid docker archive. Please provide a .tar file';
147
+ }
148
+ return true;
149
+ })
150
+ }));
151
+ const path = (0, path_1.relative)((0, project_1.getProjectRoot)(), archivePath.archive);
152
+ return `docker-archive://${path}`;
153
+ }
154
+ default: {
155
+ throw new error_1.default('Unsupported protocol selected for AppSail source', {
156
+ exit: 2
157
+ });
158
+ }
159
+ }
160
+ });
161
+ }
@@ -12,5 +12,5 @@ export type _TAppSailInitConfig = {
12
12
  };
13
13
  export declare function getAppSailZip(): Promise<_TAppSailInitConfig>;
14
14
  export declare function getAppSailName(): Promise<string>;
15
- export declare function getContainerImageTag(): Promise<string>;
16
- export declare function getCustomAppSailSource(): Promise<string>;
15
+ export declare function detectRuntimeFromSourceOption(sourceInput?: string): 'custom' | 'catalyst' | undefined;
16
+ export declare function resolveCatalystSourceFromOption(sourceInput: string): Promise<string>;
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getAppSailZip = getAppSailZip;
16
+ exports.getAppSailName = getAppSailName;
17
+ exports.detectRuntimeFromSourceOption = detectRuntimeFromSourceOption;
18
+ exports.resolveCatalystSourceFromOption = resolveCatalystSourceFromOption;
19
+ const ansi_colors_1 = require("ansi-colors");
20
+ const path_1 = require("path");
21
+ const archiver_1 = __importDefault(require("../../../../archiver"));
22
+ const endpoints_1 = require("../../../../endpoints");
23
+ const error_1 = __importDefault(require("../../../../error"));
24
+ const prompt_1 = __importDefault(require("../../../../prompt"));
25
+ const config_1 = require("../../../../util_modules/config");
26
+ const appsail_1 = require("../../../../util_modules/config/lib/appsail");
27
+ const constants_1 = require("../../../../util_modules/constants");
28
+ const fs_1 = require("../../../../util_modules/fs");
29
+ const logger_1 = require("../../../../util_modules/logger");
30
+ const project_1 = require("../../../../util_modules/project");
31
+ const prompt_fields_1 = require("../prompt-fields");
32
+ function getAppSailZip() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const _gitHubAPI = yield (0, endpoints_1.gitHubAPI)();
35
+ const gitRepo = yield prompt_1.default.ask(prompt_1.default.question('repo', 'Please choose from the list of recommended projects to get started', {
36
+ type: 'list',
37
+ choices: [
38
+ prompt_1.default.choice(`appsail-nodejs - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-nodejs')}`, {
39
+ value: {
40
+ api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
41
+ command: 'node index.js',
42
+ source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
43
+ build: './',
44
+ stack: {
45
+ runtime: 'node16',
46
+ lang: 'node'
47
+ },
48
+ scripts: {
49
+ preserve: 'npm install',
50
+ predeploy: 'npm install'
51
+ },
52
+ memory: 256
53
+ },
54
+ short: 'appsail-nodejs'
55
+ }),
56
+ prompt_1.default.choice(`appsail-java - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-java')}`, {
57
+ value: {
58
+ api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
59
+ command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
60
+ source: (0, project_1.resolveProjectPath)('appsail-java'),
61
+ build: (0, path_1.join)('target', 'demo-0.0.1-SNAPSHOT.jar'),
62
+ stack: {
63
+ runtime: 'java8',
64
+ lang: 'java'
65
+ },
66
+ scripts: {
67
+ preserve: './mvnw clean install',
68
+ predeploy: './mvnw clean install'
69
+ },
70
+ memory: 512,
71
+ platform: 'javase'
72
+ },
73
+ short: 'appsail-java'
74
+ }),
75
+ prompt_1.default.choice(`appsail-python - ${(0, ansi_colors_1.underline)('https://github.com/catalystbyzoho/appsail-python')}`, {
76
+ value: {
77
+ api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
78
+ command: 'python3 app.py',
79
+ source: (0, project_1.resolveProjectPath)('appsail-python'),
80
+ build: './',
81
+ stack: {
82
+ runtime: 'python_3_9',
83
+ lang: 'python'
84
+ },
85
+ scripts: {
86
+ preserve: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade',
87
+ predeploy: 'python3 -m pip install -r ./requirements.txt -t ./ --upgrade'
88
+ },
89
+ memory: 256
90
+ },
91
+ short: 'appsail-python'
92
+ })
93
+ ]
94
+ }));
95
+ (0, logger_1.info)();
96
+ (0, logger_1.info)((0, ansi_colors_1.white)('=>') + ' Downloading code');
97
+ const code = (yield gitRepo.repo.api());
98
+ const repoDir = gitRepo.repo.source;
99
+ yield fs_1.ASYNC.ensureDir(repoDir);
100
+ const zip = new archiver_1.default();
101
+ zip.load(code);
102
+ zip.extract(repoDir, '/', {
103
+ isFolder: true,
104
+ ignoreLevel: 1
105
+ });
106
+ yield zip.finalize();
107
+ (0, logger_1.success)(`Successfully downloaded the code to ${ansi_colors_1.bold.green(gitRepo.repo.source)}`);
108
+ return {
109
+ source: gitRepo.repo.source,
110
+ build: gitRepo.repo.build,
111
+ stack: gitRepo.repo.stack,
112
+ command: gitRepo.repo.command,
113
+ scripts: gitRepo.repo.scripts,
114
+ memory: gitRepo.repo.memory,
115
+ platform: gitRepo.repo.platform
116
+ };
117
+ });
118
+ }
119
+ function getAppSailName() {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const existingSails = config_1.appSailConfig.raw() || [];
122
+ const appName = yield prompt_1.default.ask(prompt_1.default.question(prompt_fields_1.appsailAddPromptFields.get('name'), 'Please provide the name for your AppSail: ', {
123
+ type: 'input',
124
+ default: 'AppSail',
125
+ validate: (name) => {
126
+ const exists = existingSails.findIndex((appSail) => appSail.name === name) !== -1
127
+ ? 'AppSail already exists'
128
+ : true;
129
+ const match = name.match(constants_1.REGEX.appsail.name)
130
+ ? true
131
+ : 'Invalid AppSail name: Name must contain only alphanumeric and hyphen';
132
+ return typeof exists === 'string'
133
+ ? exists
134
+ : typeof match === 'string'
135
+ ? match
136
+ : true;
137
+ }
138
+ }));
139
+ return appName.name;
140
+ });
141
+ }
142
+ function detectRuntimeFromSourceOption(sourceInput) {
143
+ if (sourceInput === undefined) {
144
+ return undefined;
145
+ }
146
+ const source = sourceInput.trim();
147
+ if (!source) {
148
+ return undefined;
149
+ }
150
+ if ((0, appsail_1.isCustomAppSailSource)(source)) {
151
+ return 'custom';
152
+ }
153
+ return 'catalyst';
154
+ }
155
+ function resolveCatalystSourceFromOption(sourceInput) {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ const source = sourceInput.trim();
158
+ if (!(0, path_1.isAbsolute)(source)) {
159
+ throw new error_1.default('Please provide an absolute path for AppSail source directory.', {
160
+ exit: 2
161
+ });
162
+ }
163
+ if (!(yield fs_1.ASYNC.dirExists(source))) {
164
+ throw new error_1.default('Provided AppSail source directory does not exist.', {
165
+ exit: 2
166
+ });
167
+ }
168
+ return source;
169
+ });
170
+ }
@@ -47,16 +47,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  const index_js_1 = __importDefault(require("../../../prompt/index.js"));
49
49
  const index_js_2 = require("../../../util_modules/constants/index.js");
50
+ const prompt_fields_js_1 = require("./prompt-fields.js");
50
51
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
51
- const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
52
+ const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question(prompt_fields_js_1.clientPromptFields.get('clientType'), 'Choose the type of client to initialise: ', {
52
53
  type: 'list',
53
54
  choices: index_js_2.PLUGIN.client.map((plugin) => {
54
55
  return index_js_1.default.choice(plugin + ' web app', {
55
- id: plugin.toUpperCase(),
56
+ id: plugin.toLowerCase(),
56
57
  value: plugin.toLowerCase(),
57
58
  short: plugin.toUpperCase()
58
59
  });
59
60
  })
60
61
  }));
61
- return (yield Promise.resolve(`${'./initializers/' + clientInitAnswer.clientFlavour}`).then(s => __importStar(require(s)))).default();
62
+ return (yield Promise.resolve(`${'./initializers/' + clientInitAnswer.clientType}`).then(s => __importStar(require(s)))).default();
62
63
  });
@@ -59,16 +59,17 @@ const path_1 = require("path");
59
59
  const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
60
60
  const index_js_1 = __importDefault(require("../../../../error/index.js"));
61
61
  const index_js_2 = __importDefault(require("../../../../prompt/index.js"));
62
+ const prompt_fields_1 = require("../prompt-fields");
62
63
  const { angular } = plugin_js_1.default;
63
64
  const { client } = placeholders_js_1.default;
64
65
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
65
66
  const clientName = yield (0, client_js_1.clientNamePrompt)('Please provide a name for your Angular App:', 'angular-app');
66
67
  const clientDirPath = (0, project_js_1.resolveProjectPath)(folder_names_js_1.default.client);
67
68
  yield (0, client_js_1.directoryOverridePrompt)(clientDirPath);
68
- const angularQuestions = yield index_js_2.default.ask(index_js_2.default.question('routing', 'Would you like to add Angular routing?', {
69
+ const angularQuestions = yield index_js_2.default.ask(index_js_2.default.question(prompt_fields_1.clientPromptFields.get('routing'), 'Would you like to add Angular routing?', {
69
70
  type: 'confirm',
70
71
  defaultAns: false
71
- }), index_js_2.default.question('stylesheet', 'Which stylesheet format would you like to use?', {
72
+ }), index_js_2.default.question(prompt_fields_1.clientPromptFields.get('stylesheet'), 'Which stylesheet format would you like to use?', {
72
73
  type: 'list',
73
74
  choices: [
74
75
  index_js_2.default.choice('CSS', { id: 'CSS', value: 'css', short: 'CSS' }),
@@ -52,6 +52,7 @@ const ASYNC = __importStar(require("../../../../util_modules/fs/lib/async.js"));
52
52
  const path_1 = require("path");
53
53
  const os_1 = require("os");
54
54
  const index_js_1 = __importDefault(require("../../../../prompt/index.js"));
55
+ const prompt_fields_1 = require("../prompt-fields");
55
56
  const client_js_1 = require("../../../util/client.js");
56
57
  const plugin_js_1 = __importDefault(require("../../../../util_modules/constants/lib/plugin.js"));
57
58
  const template_js_1 = __importDefault(require("../../../../util_modules/constants/lib/template.js"));
@@ -60,11 +61,11 @@ const index_js_2 = __importDefault(require("../../../../error/index.js"));
60
61
  const { react } = plugin_js_1.default;
61
62
  const { client } = placeholders_js_1.default;
62
63
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
63
- const flavourPrompt = yield index_js_1.default.ask(index_js_1.default.question('flavour', `Choose an option to create the React App:`, {
64
+ const flavourPrompt = yield index_js_1.default.ask(index_js_1.default.question(prompt_fields_1.clientPromptFields.get('js-ts'), `Choose an option to create the React App:`, {
64
65
  type: 'list',
65
66
  choices: [
66
- index_js_1.default.choice('JavaScript', { value: 'js', short: 'JavaScript' }),
67
- index_js_1.default.choice('TypeScript', { value: 'ts', short: 'TypeScript' })
67
+ index_js_1.default.choice('JavaScript', { id: 'js', value: 'js', short: 'JavaScript' }),
68
+ index_js_1.default.choice('TypeScript', { id: 'ts', value: 'ts', short: 'TypeScript' })
68
69
  ]
69
70
  }));
70
71
  const clientName = yield (0, client_js_1.clientNamePrompt)('Please provide a name for your React App:', 'react-app');
@@ -0,0 +1,37 @@
1
+ export declare const clientPromptFields: import("../../../prompt/register-fields").PromptFieldsRegistry<readonly [{
2
+ readonly name: "clientType";
3
+ readonly cliOption: {
4
+ readonly option: "--type <type>";
5
+ readonly description: "client type to initialize: react, angular, basic";
6
+ };
7
+ }, {
8
+ readonly name: "name";
9
+ readonly cliOption: {
10
+ readonly option: "--name <name>";
11
+ readonly description: "client application name";
12
+ };
13
+ }, {
14
+ readonly name: "js-ts";
15
+ readonly cliOption: {
16
+ readonly option: "--flavour <flavour>";
17
+ readonly description: "React variant: js or ts - (FOR REACT ONLY)";
18
+ };
19
+ }, {
20
+ readonly name: "routing";
21
+ readonly cliOption: {
22
+ readonly option: "--routing";
23
+ readonly description: "enable Angular routing - (FOR ANGULAR ONLY)";
24
+ };
25
+ }, {
26
+ readonly name: "stylesheet";
27
+ readonly cliOption: {
28
+ readonly option: "--stylesheet <format>";
29
+ readonly description: "Angular stylesheet format: css, scss, sass, less - (FOR ANGULAR ONLY)";
30
+ };
31
+ }, {
32
+ readonly name: "overwrite";
33
+ readonly cliOption: {
34
+ readonly option: "--overwrite";
35
+ readonly description: "overwrite the web client source directory if already present";
36
+ };
37
+ }]>;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clientPromptFields = void 0;
4
+ const register_fields_1 = require("../../../prompt/register-fields");
5
+ exports.clientPromptFields = (0, register_fields_1.definePromptFields)([
6
+ {
7
+ name: 'clientType',
8
+ cliOption: {
9
+ option: '--type <type>',
10
+ description: 'client type to initialize: react, angular, basic'
11
+ }
12
+ },
13
+ {
14
+ name: 'name',
15
+ cliOption: {
16
+ option: '--name <name>',
17
+ description: 'client application name'
18
+ }
19
+ },
20
+ {
21
+ name: 'js-ts',
22
+ cliOption: {
23
+ option: '--flavour <flavour>',
24
+ description: 'React variant: js or ts - (FOR REACT ONLY)'
25
+ }
26
+ },
27
+ {
28
+ name: 'routing',
29
+ cliOption: {
30
+ option: '--routing',
31
+ description: 'enable Angular routing - (FOR ANGULAR ONLY)'
32
+ }
33
+ },
34
+ {
35
+ name: 'stylesheet',
36
+ cliOption: {
37
+ option: '--stylesheet <format>',
38
+ description: 'Angular stylesheet format: css, scss, sass, less - (FOR ANGULAR ONLY)'
39
+ }
40
+ },
41
+ {
42
+ name: 'overwrite',
43
+ cliOption: {
44
+ option: '--overwrite',
45
+ description: 'overwrite the web client source directory if already present'
46
+ }
47
+ }
48
+ ]);