zcatalyst-cli 1.13.2 → 1.14.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 (162) hide show
  1. package/docs/client-utils.toml +6 -1
  2. package/docs/commands/ds/import.toml +5 -0
  3. package/docs/fn-utils/lib/python.toml +4 -0
  4. package/docs/init/dependencies/python/ensure-python.toml +12 -0
  5. package/docs/init/dependencies/python/pip-install.toml +4 -0
  6. package/docs/serve/index.toml +5 -0
  7. package/lib/authentication/login.js +2 -1
  8. package/lib/cli_table/index.js +26 -2
  9. package/lib/cli_table/src/cell.js +359 -267
  10. package/lib/cli_table/src/layout-manager.js +231 -209
  11. package/lib/cli_table/src/table.js +76 -60
  12. package/lib/cli_table/src/utils.js +259 -224
  13. package/lib/client-utils.js +18 -4
  14. package/lib/command_needs/rc.js +57 -8
  15. package/lib/commands/config/delete.js +23 -0
  16. package/lib/commands/config/get.js +23 -0
  17. package/lib/commands/config/list.js +23 -0
  18. package/lib/commands/config/set.js +29 -0
  19. package/lib/commands/console/cache.js +31 -1
  20. package/lib/commands/console/queue.js +31 -1
  21. package/lib/commands/console/zcql.js +27 -1
  22. package/lib/commands/ds/export.js +2 -2
  23. package/lib/commands/ds/import.js +25 -5
  24. package/lib/commands/ds/status.js +2 -2
  25. package/lib/commands/iac/export.js +1 -1
  26. package/lib/commands/iac/import.js +1 -1
  27. package/lib/commands/iac/pack.js +16 -5
  28. package/lib/commands/iac/status.js +1 -1
  29. package/lib/commands/index.js +4 -0
  30. package/lib/commands/project/list.js +1 -1
  31. package/lib/commands/project/use.js +1 -1
  32. package/lib/deploy/features/client.js +2 -2
  33. package/lib/deploy/features/functions/index.js +13 -3
  34. package/lib/deploy/features/functions/languages/index.js +19 -2
  35. package/lib/endpoints/index.js +12 -5
  36. package/lib/endpoints/lib/env.js +5 -2
  37. package/lib/endpoints/lib/functions.js +30 -0
  38. package/lib/endpoints/lib/org.js +35 -0
  39. package/lib/endpoints/lib/project.js +7 -3
  40. package/lib/express_middlewares/unknownReqProxy.js +4 -1
  41. package/lib/fn-utils/index.js +2 -0
  42. package/lib/fn-utils/lib/common.js +68 -7
  43. package/lib/fn-utils/lib/integ.js +15 -11
  44. package/lib/fn-utils/lib/java.js +7 -3
  45. package/lib/fn-utils/lib/python.js +121 -0
  46. package/lib/fn-watcher.js +10 -2
  47. package/lib/index.js +2 -1
  48. package/lib/init/dependencies/python/ensure-python.js +151 -0
  49. package/lib/init/dependencies/python/pip-install.js +175 -0
  50. package/lib/init/features/functions/index.js +50 -29
  51. package/lib/init/features/functions/languages/index.js +3 -1
  52. package/lib/init/features/functions/languages/python.js +115 -0
  53. package/lib/init/features/index.js +2 -2
  54. package/lib/init/features/project.js +26 -6
  55. package/lib/init/util/project.js +2 -2
  56. package/lib/internal/api.js +2 -0
  57. package/lib/internal/command.js +1 -1
  58. package/lib/internal/rc.js +2 -0
  59. package/lib/port-resolver.js +4 -3
  60. package/lib/prompt/types/file-path.js +1 -1
  61. package/lib/pull/features/functions/index.js +35 -2
  62. package/lib/pull/features/functions/languages.js +8 -1
  63. package/lib/readLineUtils.js +37 -1
  64. package/lib/readline/features/cache.js +175 -1
  65. package/lib/readline/features/index.js +7 -1
  66. package/lib/readline/features/queue.js +209 -1
  67. package/lib/readline/features/zcql.js +237 -1
  68. package/lib/readline/index.js +30 -1
  69. package/lib/serve/index.js +48 -7
  70. package/lib/serve/server/index.js +118 -44
  71. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  72. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  73. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  74. package/lib/serve/server/lib/master.js +18 -5
  75. package/lib/serve/server/lib/node.mjs +41 -0
  76. package/lib/serve/server/lib/web_client/index.js +7 -3
  77. package/lib/serve/server/lib/web_client/server.js +31 -15
  78. package/lib/shell/dependencies/http-functions.js +57 -21
  79. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +1 -2
  80. package/lib/shell/dependencies/invoker/bio/node.mjs +127 -0
  81. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  82. package/lib/shell/dependencies/invoker/cron/node.mjs +87 -0
  83. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +3 -3
  84. package/lib/shell/dependencies/invoker/event/node.mjs +84 -0
  85. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +1 -1
  86. package/lib/shell/dependencies/invoker/integ/node.mjs +88 -0
  87. package/lib/shell/dependencies/local-function.js +74 -22
  88. package/lib/shell/index.js +11 -2
  89. package/lib/shell/prepare/index.js +21 -0
  90. package/lib/shell/prepare/languages/index.js +8 -2
  91. package/lib/shell/prepare/languages/java.js +39 -2
  92. package/lib/shell/prepare/languages/node.js +21 -2
  93. package/lib/shell/prepare/languages/python.js +65 -0
  94. package/lib/throbber/index.js +3 -1
  95. package/lib/userConfig.js +48 -0
  96. package/lib/util_modules/constants/index.js +3 -1
  97. package/lib/util_modules/constants/lib/apig-rules.js +8 -0
  98. package/lib/util_modules/constants/lib/cliq-handlers.js +17 -1
  99. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  100. package/lib/util_modules/constants/lib/default.js +2 -2
  101. package/lib/util_modules/constants/lib/env-path.js +12 -0
  102. package/lib/util_modules/constants/lib/file-names.js +4 -1
  103. package/lib/util_modules/constants/lib/folder-names.js +3 -1
  104. package/lib/util_modules/constants/lib/placeholders.js +6 -1
  105. package/lib/util_modules/constants/lib/runtime.js +2 -1
  106. package/lib/util_modules/constants/lib/scopes.js +1 -0
  107. package/lib/util_modules/constants/lib/template.js +9 -0
  108. package/lib/util_modules/constants/lib/urls.js +2 -6
  109. package/lib/util_modules/context-help.js +2 -0
  110. package/lib/util_modules/fs/lib/async.js +35 -11
  111. package/lib/util_modules/project.js +20 -1
  112. package/package.json +2 -1
  113. package/templates/init/functions/java/aio/catalyst-config.json +3 -2
  114. package/templates/init/functions/java/bio/catalyst-config.json +3 -2
  115. package/templates/init/functions/java/cron/catalyst-config.json +3 -2
  116. package/templates/init/functions/java/event/catalyst-config.json +3 -2
  117. package/templates/init/functions/java/integ/cliq/catalyst-config.json +1 -0
  118. package/templates/init/functions/node/aio/catalyst-config.json +3 -2
  119. package/templates/init/functions/node/bio/catalyst-config.json +3 -2
  120. package/templates/init/functions/node/cron/catalyst-config.json +3 -2
  121. package/templates/init/functions/node/event/catalyst-config.json +3 -2
  122. package/templates/init/functions/node/integ/cliq/catalyst-config.json +1 -0
  123. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -2
  124. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +1 -2
  125. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +1 -1
  126. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +1 -1
  127. package/templates/init/functions/node/integ/cliq/handlers/installation-validator.js +1 -1
  128. package/templates/init/functions/node/integ/cliq/handlers/message-action-handler.js +1 -1
  129. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
  130. package/templates/init/functions/node/integ/cliq/sample.js +4 -4
  131. package/templates/init/functions/python/aio/catalyst-config.json +11 -0
  132. package/templates/init/functions/python/aio/requirements.txt +1 -0
  133. package/templates/init/functions/python/aio/sample.py +26 -0
  134. package/templates/init/functions/python/bio/catalyst-config.json +11 -0
  135. package/templates/init/functions/python/bio/requirements.txt +1 -0
  136. package/templates/init/functions/python/bio/sample.py +6 -0
  137. package/templates/init/functions/python/cron/catalyst-config.json +11 -0
  138. package/templates/init/functions/python/cron/requirements.txt +1 -0
  139. package/templates/init/functions/python/cron/sample.py +18 -0
  140. package/templates/init/functions/python/event/catalyst-config.json +11 -0
  141. package/templates/init/functions/python/event/requirements.txt +1 -0
  142. package/templates/init/functions/python/event/sample.py +21 -0
  143. package/templates/init/functions/python/integ/cliq/catalyst-config.json +11 -0
  144. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +174 -0
  145. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +102 -0
  146. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +409 -0
  147. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +12 -0
  148. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +16 -0
  149. package/templates/init/functions/python/integ/cliq/handlers/message_action_handler.py +18 -0
  150. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +269 -0
  151. package/templates/init/functions/python/integ/cliq/requirements.txt +1 -0
  152. package/templates/init/functions/python/integ/cliq/sample.py +21 -0
  153. package/lib/serve/server/lib/node.js +0 -62
  154. package/lib/shell/dependencies/invoker/bio/node.js +0 -80
  155. package/lib/shell/dependencies/invoker/cron/node.js +0 -54
  156. package/lib/shell/dependencies/invoker/event/node.js +0 -56
  157. package/lib/shell/dependencies/invoker/integ/node.js +0 -79
  158. package/templates/.DS_Store +0 -0
  159. package/templates/init/.DS_Store +0 -0
  160. package/templates/init/client/.DS_Store +0 -0
  161. package/templates/init/client/react/.DS_Store +0 -0
  162. package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
@@ -1 +1,209 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // var _ = require('lodash');
4
+ // var clc = require('cli-color');
5
+ // var readline = require('readline');
6
+
7
+ // var queueAPI = require('../../endpoints').queue;
8
+ // var logger = require('../../logger');
9
+ // var utils = require('../../utils');
10
+ // var readlineUtil = require('../../readLineUtils');
11
+
12
+ // var outputStream = process.stdout;
13
+ // var inputStream = process.stdin;
14
+
15
+ // var consumerTimeout;
16
+
17
+ // var listAllQueue = function(projectId, resolve) {
18
+ // return queueAPI
19
+ // .list(projectId)
20
+ // .then(function(data) {
21
+ // _.forEach(data, function(topic, index) {
22
+ // logger.info(
23
+ // index + 1 + '. ' + clc.bold(topic.queue_name) + ' ( ' + topic.id + ' )'
24
+ // );
25
+ // });
26
+ // return resolve(true);
27
+ // })
28
+ // .catch(function(err) {
29
+ // logger.debug('There was an error processing the request.' + err);
30
+ // logger.info(clc.redBright("couldn't fetch queue details"));
31
+ // return resolve(true);
32
+ // });
33
+ // };
34
+
35
+ // var produceToQueue = function(projectId, queueId, obj, resolve) {
36
+ // return queueAPI
37
+ // .produce(projectId, queueId, obj)
38
+ // .then(function() {
39
+ // // console.log(data);
40
+ // return resolve(false);
41
+ // })
42
+ // .catch(function(err) {
43
+ // logger.debug('There was an error processing the request.' + err);
44
+ // logger.info(clc.redBright("couldn't produce to queue. Please check the queue id."));
45
+ // return resolve(false);
46
+ // });
47
+ // };
48
+
49
+ // var startConsumerTimeout = function(projectId, queueId, delayInMillis) {
50
+ // consumerTimeout = setInterval(function() {
51
+ // return queueAPI
52
+ // .consume(projectId, queueId)
53
+ // .then(function(data) {
54
+ // if (data) {
55
+ // console.log(data[0].value);
56
+ // }
57
+ // })
58
+ // .catch(function(err) {
59
+ // logger.debug('There was an error processing the request.' + err);
60
+ // // clearInterval(consumerTimeout);
61
+ // });
62
+ // }, delayInMillis);
63
+ // };
64
+
65
+ // module.exports = function(options) {
66
+ // var state = 0;
67
+ // var queue = '';
68
+ // var consumerAlive = false;
69
+ // var producerAlive = false;
70
+
71
+ // return new Promise(function(resolve) {
72
+ // var prompt = clc.cyanBright('queue > ');
73
+ // var prevPrompt = prompt;
74
+
75
+ // function completer(line) {
76
+ // var completions = 'list use start-producer start-consumer'.split(' ');
77
+ // var hits = completions.filter(function(c) {
78
+ // c.startsWith(line);
79
+ // });
80
+ // // show all completions if none found
81
+ // return [hits.length ? hits : completions, line];
82
+ // }
83
+ // var rl = readline.createInterface({
84
+ // input: inputStream,
85
+ // output: outputStream,
86
+ // prompt: prompt,
87
+ // completer: completer
88
+ // });
89
+
90
+ // rl.on('line', function(line) {
91
+ // var originalLine = line.trim();
92
+ // var lineArr = readlineUtil.splitLineIntoArray(originalLine);
93
+ // return new Promise(function(resolve) {
94
+ // if (producerAlive) {
95
+ // if (originalLine === '') {
96
+ // readlineUtil.displayHelp('cannot produce a empty msg to queue.');
97
+ // return resolve(true);
98
+ // }
99
+ // var obj = {};
100
+ // obj.value = line;
101
+ // return produceToQueue(options.project, queue, obj, resolve);
102
+ // }
103
+ // if (consumerAlive) {
104
+ // return resolve(false);
105
+ // }
106
+ // switch (true) {
107
+ // case /^exit/i.test(originalLine):
108
+ // case /\\q/i.test(originalLine):
109
+ // rl.close();
110
+ // break;
111
+ // case /^list/i.test(originalLine):
112
+ // if (lineArr.length === 1) {
113
+ // return listAllQueue(options.project, resolve);
114
+ // } else {
115
+ // readlineUtil.displayHelp('use of additional params not permitted.');
116
+ // return resolve(true);
117
+ // }
118
+ // case /^use/i.test(originalLine):
119
+ // var queueID = lineArr[lineArr.length - 1];
120
+ // if (lineArr.length === 2 && /^[0-9]*$/gm.test(queueID)) {
121
+ // queue = queueID;
122
+ // state = 1;
123
+ // prevPrompt = prompt;
124
+ // prompt = clc.cyanBright('queue:' + queue + ' > ');
125
+ // rl.setPrompt(prompt);
126
+ // return resolve(true);
127
+ // } else {
128
+ // readlineUtil.displayHelp('Queue ID not valid.');
129
+ // return resolve(true);
130
+ // }
131
+ // case /^start-consumer/i.test(line):
132
+ // if (state === 0) {
133
+ // utils.logWarning(
134
+ // 'You must select a queue first. Try ' + clc.bold('use <queueId>'),
135
+ // 'info'
136
+ // );
137
+ // return resolve(true);
138
+ // } else if (lineArr.length === 1) {
139
+ // consumerAlive = true;
140
+ // prevPrompt = prompt;
141
+ // prompt = '';
142
+ // rl.setPrompt(prompt);
143
+ // startConsumerTimeout(options.project, queue, 5000);
144
+ // return resolve(false);
145
+ // } else {
146
+ // readlineUtil.displayHelp('use of additional params not permitted.');
147
+ // return resolve(true);
148
+ // }
149
+ // case /^start-producer/i.test(line):
150
+ // if (state === 0) {
151
+ // utils.logWarning(
152
+ // 'You must select a queue first. Try ' + clc.bold('use <queueId>'),
153
+ // 'info'
154
+ // );
155
+ // return resolve(true);
156
+ // } else if (lineArr.length === 1) {
157
+ // producerAlive = true;
158
+ // prevPrompt = prompt;
159
+ // prompt = '';
160
+ // rl.setPrompt(prompt);
161
+ // return resolve(false);
162
+ // } else {
163
+ // readlineUtil.displayHelp('use of additional params not permitted.');
164
+ // return resolve(true);
165
+ // }
166
+ // case /^help/i.test(originalLine):
167
+ // case /^\\h/i.test(originalLine):
168
+ // utils.logBullet(
169
+ // 'Available commands :\t ' +
170
+ // clc.bold('list, use, start-producer, start-consumer, exit')
171
+ // );
172
+ // return resolve(true);
173
+ // default:
174
+ // logger.info(
175
+ // `We might have heard '${clc.bold(
176
+ // line.trim()
177
+ // )}'\n which is an unknown command!! Use '${clc.bold(
178
+ // 'help'
179
+ // )}' for the list of commands you can use.`
180
+ // );
181
+ // return resolve(true);
182
+ // }
183
+ // }).then(function(showPrompt) {
184
+ // if (showPrompt) {
185
+ // rl.prompt();
186
+ // }
187
+ // });
188
+ // }).on('close', function() {
189
+ // logger.info('Have a great day!');
190
+ // return resolve();
191
+ // });
192
+
193
+ // rl.on('SIGINT', function() {
194
+ // if (!producerAlive && !consumerAlive) {
195
+ // rl.close();
196
+ // } else {
197
+ // producerAlive = producerAlive ? !producerAlive : producerAlive;
198
+ // consumerAlive = consumerAlive ? !consumerAlive : consumerAlive;
199
+ // if (consumerTimeout) {
200
+ // clearInterval(consumerTimeout);
201
+ // }
202
+ // prompt = prevPrompt;
203
+ // rl.setPrompt(prompt);
204
+ // rl.prompt();
205
+ // }
206
+ // });
207
+ // rl.prompt();
208
+ // });
209
+ // };
@@ -1 +1,237 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // var _ = require('lodash');
4
+ // var clc = require('cli-color');
5
+ // var readline = require('readline');
6
+ // var Table = require('cli-table');
7
+
8
+ // var zcqlAPI = require('../../endpoints').zcql;
9
+ // var dataStoreAPI = require('../../endpoints').datastore;
10
+ // var logger = require('../../logger');
11
+
12
+ // var outputStream = process.stdout;
13
+ // var inputStream = process.stdin;
14
+
15
+ // module.exports = function(options) {
16
+ // return new Promise(function(resolve) {
17
+ // function getHeadTable(headArr) {
18
+ // headArr = headArr || [];
19
+ // return new Table({
20
+ // head: headArr,
21
+ // chars: {
22
+ // top: ' ',
23
+ // 'top-mid': '',
24
+ // 'top-left': '',
25
+ // 'top-right': '',
26
+ // bottom: '-',
27
+ // 'bottom-mid': '+',
28
+ // 'bottom-left': ' ',
29
+ // 'bottom-right': ' ',
30
+ // left: ' ',
31
+ // 'left-mid': ' ',
32
+ // mid: '',
33
+ // 'mid-mid': '',
34
+ // right: '',
35
+ // 'right-mid': '',
36
+ // middle: '|'
37
+ // },
38
+ // style: {
39
+ // head: ['yellow']
40
+ // }
41
+ // });
42
+ // }
43
+
44
+ // function getRowTable() {
45
+ // return new Table({
46
+ // chars: {
47
+ // top: ' ',
48
+ // 'top-mid': '',
49
+ // 'top-left': '',
50
+ // 'top-right': '',
51
+ // bottom: ' ',
52
+ // 'bottom-mid': '',
53
+ // 'bottom-left': '',
54
+ // 'bottom-right': '',
55
+ // left: ' ',
56
+ // 'left-mid': '',
57
+ // mid: ' ',
58
+ // 'mid-mid': '',
59
+ // right: ' ',
60
+ // 'right-mid': '',
61
+ // middle: '|'
62
+ // }
63
+ // });
64
+ // }
65
+
66
+ // function parseHrtimeToSeconds(hrtime) {
67
+ // var seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
68
+ // return seconds;
69
+ // }
70
+
71
+ // function completer(line) {
72
+ // var completions = 'show select'.split(' ');
73
+ // var hits = completions.filter(function(c) {
74
+ // c.startsWith(line);
75
+ // });
76
+ // // show all completions if none found
77
+ // return [hits.length ? hits : completions, line];
78
+ // }
79
+ // var prompt = clc.cyanBright('query > ');
80
+ // var rl = readline.createInterface({
81
+ // input: inputStream,
82
+ // output: outputStream,
83
+ // prompt: prompt,
84
+ // completer: completer
85
+ // });
86
+
87
+ // rl.prompt();
88
+
89
+ // rl.on('line', function(line) {
90
+ // var originalLine = line.trim();
91
+ // return new Promise(function(resolve) {
92
+ // switch (true) {
93
+ // case /^exit/i.test(originalLine):
94
+ // case /\\q/i.test(originalLine):
95
+ // rl.close();
96
+ // break;
97
+ // case /^show tables$/i.test(originalLine):
98
+ // case /^show tables;$/i.test(originalLine):
99
+ // var startShowTime = process.hrtime();
100
+ // var totalTableRows = 0;
101
+ // return dataStoreAPI
102
+ // .getAllTables(options.project)
103
+ // .then(function(data) {
104
+ // var elapsedSeconds = parseHrtimeToSeconds(
105
+ // process.hrtime(startShowTime)
106
+ // );
107
+ // var table = getHeadTable(['Tables_in_' + options.project]);
108
+ // // style override
109
+ // table.options.chars = {
110
+ // top: '-',
111
+ // 'top-left': '+',
112
+ // 'top-right': '+',
113
+ // bottom: '-',
114
+ // 'bottom-left': '+',
115
+ // 'bottom-right': '+',
116
+ // left: '|',
117
+ // 'left-mid': '|',
118
+ // mid: '-',
119
+ // 'mid-mid': '+',
120
+ // right: '|',
121
+ // 'right-mid': '|',
122
+ // middle: '|'
123
+ // };
124
+ // data.forEach(function(tableDetails) {
125
+ // var row = [tableDetails.table_name];
126
+ // table.push(row);
127
+ // totalTableRows++;
128
+ // });
129
+ // if (totalTableRows > 0) {
130
+ // console.log(table.toString());
131
+ // console.log(
132
+ // totalTableRows +
133
+ // ' rows in set (' +
134
+ // elapsedSeconds +
135
+ // 'sec)\n'
136
+ // );
137
+ // } else {
138
+ // console.log('Empty set (' + elapsedSeconds + 'sec)\n');
139
+ // }
140
+ // return resolve();
141
+ // })
142
+ // .catch(function(err) {
143
+ // logger.debug('There was an error processing the request.' + err);
144
+ // logger.info(clc.redBright("couldn't fetch any details"));
145
+ // return resolve();
146
+ // });
147
+ // case /^select/i.test(originalLine):
148
+ // var startTime = process.hrtime();
149
+ // var totalRows = 0;
150
+ // var containsJoin =
151
+ // _.words(originalLine).indexOf('join') >= 0 ||
152
+ // _.words(originalLine).indexOf('JOIN') >= 0;
153
+ // return zcqlAPI
154
+ // .query(options.project, originalLine.replace(';', ''))
155
+ // .then(function(data) {
156
+ // var elapsedSeconds = parseHrtimeToSeconds(
157
+ // process.hrtime(startTime)
158
+ // );
159
+ // var globalMaxWidthArr = [];
160
+ // var globalHeadArr = [];
161
+ // var headTable = getHeadTable();
162
+ // var rowTable = getRowTable();
163
+ // data.forEach(function(rowDetails) {
164
+ // var row = [];
165
+ // _.keysIn(rowDetails).forEach(function(tableKeys) {
166
+ // var maxWidthArr = [];
167
+ // var tableHead = [];
168
+ // var tableDetails = _.get(rowDetails, tableKeys);
169
+ // _.forIn(tableDetails, function(value, key) {
170
+ // //null handling
171
+ // value = (value || '') + '';
172
+ // var headerName = key;
173
+ // if (containsJoin) {
174
+ // headerName = tableKeys + '.' + key;
175
+ // }
176
+ // tableHead.push(headerName);
177
+ // maxWidthArr.push(
178
+ // headerName.length + 2 > value.length + 2
179
+ // ? headerName.length + 2
180
+ // : value.length + 2
181
+ // );
182
+ // row.push(value);
183
+ // });
184
+ // globalMaxWidthArr =
185
+ // globalMaxWidthArr.length > 0
186
+ // ? globalMaxWidthArr
187
+ // : maxWidthArr;
188
+ // maxWidthArr.forEach(function(maxLen, index) {
189
+ // globalMaxWidthArr[index] =
190
+ // maxLen > globalMaxWidthArr[index]
191
+ // ? maxLen
192
+ // : globalMaxWidthArr[index];
193
+ // });
194
+ // globalHeadArr = _.union(globalHeadArr, tableHead);
195
+ // });
196
+ // rowTable.push(row);
197
+ // totalRows++;
198
+ // });
199
+ // if (totalRows > 0) {
200
+ // var colAlignmentArr = new Array(globalMaxWidthArr.length);
201
+ // colAlignmentArr.fill('middle');
202
+ // headTable.options.head = globalHeadArr;
203
+ // headTable.options.colAligns = colAlignmentArr;
204
+ // headTable.options.colWidths = globalMaxWidthArr;
205
+ // rowTable.options.colAligns = colAlignmentArr;
206
+ // rowTable.options.colWidths = globalMaxWidthArr;
207
+ // console.log(headTable.toString() + '\n' + rowTable.toString());
208
+ // console.log(
209
+ // totalRows + ' rows in set (' + elapsedSeconds + 'sec)\n'
210
+ // );
211
+ // } else {
212
+ // console.log('Empty set (' + elapsedSeconds + 'sec)\n');
213
+ // }
214
+ // return resolve();
215
+ // })
216
+ // .catch(function(err) {
217
+ // logger.debug('There was an error processing the request.' + err);
218
+ // logger.info(clc.redBright("couldn't fetch any details"));
219
+ // return resolve();
220
+ // });
221
+ // default:
222
+ // logger.info(
223
+ // `We might have heard '${clc.bold(
224
+ // line.trim()
225
+ // )}'\n which is an unknown command!! Try a SQL Query instead.`
226
+ // );
227
+ // return resolve();
228
+ // }
229
+ // }).then(function() {
230
+ // rl.prompt();
231
+ // });
232
+ // }).on('close', function() {
233
+ // logger.info('Have a great day!');
234
+ // return resolve();
235
+ // });
236
+ // });
237
+ // };
@@ -1 +1,30 @@
1
- "use strict";
1
+ // 'use strict';
2
+
3
+ // var _ = require('lodash');
4
+ // var clc = require('cli-color');
5
+
6
+ // var logger = require('../logger');
7
+ // var utils = require('../utils');
8
+
9
+ // var features = require('./features');
10
+
11
+ // var replServer = function(setup, options) {
12
+ // var feature = setup.repl.feature;
13
+ // if (feature) {
14
+ // if (!features[feature]) {
15
+ // return utils.reject(
16
+ // clc.bold(feature) +
17
+ // ' is not a valid feature. Must be one of ' +
18
+ // _.without(_.keys(features)).join(',')
19
+ // );
20
+ // }
21
+ // logger.info();
22
+ // logger.info(
23
+ // clc.bold(clc.white('===> Your personalized ') + _.capitalize(feature) + ' console')
24
+ // );
25
+ // return features[feature](options);
26
+ // }
27
+ // return Promise.resolve();
28
+ // };
29
+
30
+ // module.exports = replServer;
@@ -35,6 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
+ const ansi_colors_1 = require("ansi-colors");
38
39
  const path_1 = require("path");
39
40
  const client_utils_1 = require("../client-utils");
40
41
  const error_1 = __importDefault(require("../error"));
@@ -44,6 +45,7 @@ const port_resolver_1 = __importDefault(require("../port-resolver"));
44
45
  const runtime_store_1 = __importDefault(require("../runtime-store"));
45
46
  const http_functions_1 = __importDefault(require("../shell/dependencies/http-functions"));
46
47
  const constants_1 = require("../util_modules/constants");
48
+ const runtime_1 = __importDefault(require("../util_modules/constants/lib/runtime"));
47
49
  const fs_1 = require("../util_modules/fs");
48
50
  const logger_1 = require("../util_modules/logger");
49
51
  const option_1 = require("../util_modules/option");
@@ -53,6 +55,25 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
53
55
  const serveTargets = runtime_store_1.default.get('context.targets', []);
54
56
  const advancedServer = new server_1.default();
55
57
  const basicFnServer = new http_functions_1.default({ primary: false });
58
+ const projectRoot = runtime_store_1.default.get('project.root');
59
+ const buildFolder = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build);
60
+ if (yield fs_1.ASYNC.isPathExists(buildFolder)) {
61
+ try {
62
+ (0, logger_1.debug)('Build folder already exists, staring cleanup');
63
+ yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
64
+ recursive: true
65
+ });
66
+ yield fs_1.ASYNC.deleteDir(buildFolder);
67
+ }
68
+ catch (err) {
69
+ throw new error_1.default('Error running pre cleanup', {
70
+ original: err,
71
+ exit: 1,
72
+ errorId: 'SERVE-2',
73
+ arg: [(0, ansi_colors_1.bold)(constants_1.FOLDERNAME.build), ansi_colors_1.italic.red(buildFolder)]
74
+ });
75
+ }
76
+ }
56
77
  try {
57
78
  const masterPort = yield port_resolver_1.default.getPort('master', 'http', 'master', false);
58
79
  runtime_store_1.default.set('context.port.http.master', masterPort);
@@ -62,7 +83,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
62
83
  if (watchOpt) {
63
84
  yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? (0, fn_watcher_1.default)(target) : undefined); })));
64
85
  }
65
- const funtionTargets = rawTargets.filter((target) => {
86
+ const functionTargets = rawTargets.filter((target) => {
87
+ var _a;
66
88
  if (!target.valid) {
67
89
  (0, logger_1.warning)('skipping serve of function [' +
68
90
  target.name +
@@ -73,6 +95,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
73
95
  if (target.type === constants_1.FN_TYPE.advanced) {
74
96
  advancedServer.add('server', target);
75
97
  }
98
+ if (target.type === constants_1.FN_TYPE.basic &&
99
+ ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python))) {
100
+ advancedServer.add('functions', target);
101
+ }
76
102
  return target.valid;
77
103
  });
78
104
  if (serveTargets.includes('client')) {
@@ -88,13 +114,14 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
88
114
  serveTargets.splice(serveTargets.indexOf('client'), 1);
89
115
  }
90
116
  }
91
- if (serveTargets.includes('functions') && funtionTargets.length === 0) {
117
+ const isFunctionsServed = serveTargets.includes('functions');
118
+ if (isFunctionsServed && functionTargets.length === 0) {
92
119
  (0, logger_1.labeled)('functions', 'No targets are ready to be served in local').WARN();
93
120
  serveTargets.splice(serveTargets.indexOf('functions'), 1);
94
121
  runtime_store_1.default.set('context.targets', serveTargets);
95
122
  }
96
- if (serveTargets.includes('functions')) {
97
- runtime_store_1.default.set('context.functions.targets', funtionTargets);
123
+ if (isFunctionsServed) {
124
+ runtime_store_1.default.set('context.functions.targets', functionTargets);
98
125
  }
99
126
  if (serveTargets.length === 0 ||
100
127
  (serveTargets.length === 1 && serveTargets[0] === 'apig')) {
@@ -102,14 +129,24 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
102
129
  }
103
130
  const basicFn = runtime_store_1.default
104
131
  .get('context.functions.targets', [])
105
- .find((target) => target.type === constants_1.FN_TYPE.basic && target.valid);
132
+ .find((target) => {
133
+ var _a;
134
+ return target.type === constants_1.FN_TYPE.basic &&
135
+ !((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python)) &&
136
+ target.valid;
137
+ });
106
138
  if (basicFn) {
107
139
  yield basicFnServer.start();
108
140
  }
109
141
  yield advancedServer.start();
110
142
  yield advancedServer.wait();
143
+ isFunctionsServed &&
144
+ (yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
145
+ checkPath: false,
146
+ recursive: true
147
+ }).catch((err) => (0, logger_1.debug)('Error modifying the permissions: ', err)));
111
148
  yield Promise.all([
112
- fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
149
+ fs_1.ASYNC.deleteDir(buildFolder).catch(),
113
150
  advancedServer ? advancedServer.stop() : undefined,
114
151
  basicFnServer ? basicFnServer.stop() : undefined
115
152
  ]);
@@ -129,8 +166,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
129
166
  (0, logger_1.success)('Shutdown complete');
130
167
  }
131
168
  catch (e) {
169
+ (0, logger_1.debug)('Error serving the resources: ', e);
170
+ yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
171
+ recursive: true
172
+ }).catch((err) => (0, logger_1.debug)('Error modifying the permissions: ', err));
132
173
  yield Promise.all([
133
- fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
174
+ fs_1.ASYNC.deleteDir(buildFolder).catch(),
134
175
  advancedServer ? advancedServer.stop() : undefined,
135
176
  basicFnServer ? basicFnServer.stop() : undefined
136
177
  ]);