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.
- package/docs/client-utils.toml +6 -1
- package/docs/commands/ds/import.toml +5 -0
- package/docs/fn-utils/lib/python.toml +4 -0
- package/docs/init/dependencies/python/ensure-python.toml +12 -0
- package/docs/init/dependencies/python/pip-install.toml +4 -0
- package/docs/serve/index.toml +5 -0
- package/lib/authentication/login.js +2 -1
- package/lib/cli_table/index.js +26 -2
- package/lib/cli_table/src/cell.js +359 -267
- package/lib/cli_table/src/layout-manager.js +231 -209
- package/lib/cli_table/src/table.js +76 -60
- package/lib/cli_table/src/utils.js +259 -224
- package/lib/client-utils.js +18 -4
- package/lib/command_needs/rc.js +57 -8
- package/lib/commands/config/delete.js +23 -0
- package/lib/commands/config/get.js +23 -0
- package/lib/commands/config/list.js +23 -0
- package/lib/commands/config/set.js +29 -0
- package/lib/commands/console/cache.js +31 -1
- package/lib/commands/console/queue.js +31 -1
- package/lib/commands/console/zcql.js +27 -1
- package/lib/commands/ds/export.js +2 -2
- package/lib/commands/ds/import.js +25 -5
- package/lib/commands/ds/status.js +2 -2
- package/lib/commands/iac/export.js +1 -1
- package/lib/commands/iac/import.js +1 -1
- package/lib/commands/iac/pack.js +16 -5
- package/lib/commands/iac/status.js +1 -1
- package/lib/commands/index.js +4 -0
- package/lib/commands/project/list.js +1 -1
- package/lib/commands/project/use.js +1 -1
- package/lib/deploy/features/client.js +2 -2
- package/lib/deploy/features/functions/index.js +13 -3
- package/lib/deploy/features/functions/languages/index.js +19 -2
- package/lib/endpoints/index.js +12 -5
- package/lib/endpoints/lib/env.js +5 -2
- package/lib/endpoints/lib/functions.js +30 -0
- package/lib/endpoints/lib/org.js +35 -0
- package/lib/endpoints/lib/project.js +7 -3
- package/lib/express_middlewares/unknownReqProxy.js +4 -1
- package/lib/fn-utils/index.js +2 -0
- package/lib/fn-utils/lib/common.js +68 -7
- package/lib/fn-utils/lib/integ.js +15 -11
- package/lib/fn-utils/lib/java.js +7 -3
- package/lib/fn-utils/lib/python.js +121 -0
- package/lib/fn-watcher.js +10 -2
- package/lib/index.js +2 -1
- package/lib/init/dependencies/python/ensure-python.js +151 -0
- package/lib/init/dependencies/python/pip-install.js +175 -0
- package/lib/init/features/functions/index.js +50 -29
- package/lib/init/features/functions/languages/index.js +3 -1
- package/lib/init/features/functions/languages/python.js +115 -0
- package/lib/init/features/index.js +2 -2
- package/lib/init/features/project.js +26 -6
- package/lib/init/util/project.js +2 -2
- package/lib/internal/api.js +2 -0
- package/lib/internal/command.js +1 -1
- package/lib/internal/rc.js +2 -0
- package/lib/port-resolver.js +4 -3
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/pull/features/functions/index.js +35 -2
- package/lib/pull/features/functions/languages.js +8 -1
- package/lib/readLineUtils.js +37 -1
- package/lib/readline/features/cache.js +175 -1
- package/lib/readline/features/index.js +7 -1
- package/lib/readline/features/queue.js +209 -1
- package/lib/readline/features/zcql.js +237 -1
- package/lib/readline/index.js +30 -1
- package/lib/serve/index.js +48 -7
- package/lib/serve/server/index.js +118 -44
- package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/master.js +18 -5
- package/lib/serve/server/lib/node.mjs +41 -0
- package/lib/serve/server/lib/web_client/index.js +7 -3
- package/lib/serve/server/lib/web_client/server.js +31 -15
- package/lib/shell/dependencies/http-functions.js +57 -21
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +1 -2
- package/lib/shell/dependencies/invoker/bio/node.mjs +127 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/cron/node.mjs +87 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +3 -3
- package/lib/shell/dependencies/invoker/event/node.mjs +84 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/integ/node.mjs +88 -0
- package/lib/shell/dependencies/local-function.js +74 -22
- package/lib/shell/index.js +11 -2
- package/lib/shell/prepare/index.js +21 -0
- package/lib/shell/prepare/languages/index.js +8 -2
- package/lib/shell/prepare/languages/java.js +39 -2
- package/lib/shell/prepare/languages/node.js +21 -2
- package/lib/shell/prepare/languages/python.js +65 -0
- package/lib/throbber/index.js +3 -1
- package/lib/userConfig.js +48 -0
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/apig-rules.js +8 -0
- package/lib/util_modules/constants/lib/cliq-handlers.js +17 -1
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +2 -2
- package/lib/util_modules/constants/lib/env-path.js +12 -0
- package/lib/util_modules/constants/lib/file-names.js +4 -1
- package/lib/util_modules/constants/lib/folder-names.js +3 -1
- package/lib/util_modules/constants/lib/placeholders.js +6 -1
- package/lib/util_modules/constants/lib/runtime.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +1 -0
- package/lib/util_modules/constants/lib/template.js +9 -0
- package/lib/util_modules/constants/lib/urls.js +2 -6
- package/lib/util_modules/context-help.js +2 -0
- package/lib/util_modules/fs/lib/async.js +35 -11
- package/lib/util_modules/project.js +20 -1
- package/package.json +2 -1
- package/templates/init/functions/java/aio/catalyst-config.json +3 -2
- package/templates/init/functions/java/bio/catalyst-config.json +3 -2
- package/templates/init/functions/java/cron/catalyst-config.json +3 -2
- package/templates/init/functions/java/event/catalyst-config.json +3 -2
- package/templates/init/functions/java/integ/cliq/catalyst-config.json +1 -0
- package/templates/init/functions/node/aio/catalyst-config.json +3 -2
- package/templates/init/functions/node/bio/catalyst-config.json +3 -2
- package/templates/init/functions/node/cron/catalyst-config.json +3 -2
- package/templates/init/functions/node/event/catalyst-config.json +3 -2
- package/templates/init/functions/node/integ/cliq/catalyst-config.json +1 -0
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +2 -2
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +1 -2
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/installation-validator.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/message-action-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
- package/templates/init/functions/node/integ/cliq/sample.js +4 -4
- package/templates/init/functions/python/aio/catalyst-config.json +11 -0
- package/templates/init/functions/python/aio/requirements.txt +1 -0
- package/templates/init/functions/python/aio/sample.py +26 -0
- package/templates/init/functions/python/bio/catalyst-config.json +11 -0
- package/templates/init/functions/python/bio/requirements.txt +1 -0
- package/templates/init/functions/python/bio/sample.py +6 -0
- package/templates/init/functions/python/cron/catalyst-config.json +11 -0
- package/templates/init/functions/python/cron/requirements.txt +1 -0
- package/templates/init/functions/python/cron/sample.py +18 -0
- package/templates/init/functions/python/event/catalyst-config.json +11 -0
- package/templates/init/functions/python/event/requirements.txt +1 -0
- package/templates/init/functions/python/event/sample.py +21 -0
- package/templates/init/functions/python/integ/cliq/catalyst-config.json +11 -0
- package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +174 -0
- package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +102 -0
- package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +409 -0
- package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +12 -0
- package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +16 -0
- package/templates/init/functions/python/integ/cliq/handlers/message_action_handler.py +18 -0
- package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +269 -0
- package/templates/init/functions/python/integ/cliq/requirements.txt +1 -0
- package/templates/init/functions/python/integ/cliq/sample.py +21 -0
- package/lib/serve/server/lib/node.js +0 -62
- package/lib/shell/dependencies/invoker/bio/node.js +0 -80
- package/lib/shell/dependencies/invoker/cron/node.js +0 -54
- package/lib/shell/dependencies/invoker/event/node.js +0 -56
- package/lib/shell/dependencies/invoker/integ/node.js +0 -79
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
|
@@ -1,267 +1,302 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
const stringWidth = require('string-width');
|
|
2
|
+
|
|
3
3
|
function codeRegex(capture) {
|
|
4
|
-
|
|
4
|
+
return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g;
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
function strlen(str) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const code = codeRegex();
|
|
9
|
+
const stripped = ('' + str).replace(code, '');
|
|
10
|
+
const split = stripped.split('\n');
|
|
11
|
+
return split.reduce((memo, s) => {
|
|
12
|
+
return stringWidth(s) > memo ? stringWidth(s) : memo;
|
|
13
|
+
}, 0);
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
function repeat(str, times) {
|
|
15
|
-
|
|
17
|
+
return Array(times + 1).join(str);
|
|
16
18
|
}
|
|
19
|
+
|
|
17
20
|
function pad(str, len, pad, dir) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const length = strlen(str);
|
|
22
|
+
if (len + 1 >= length) {
|
|
23
|
+
const padlen = len - length;
|
|
24
|
+
switch (dir) {
|
|
25
|
+
case 'right': {
|
|
26
|
+
str = repeat(pad, padlen) + str;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case 'center': {
|
|
30
|
+
const right = Math.ceil(padlen / 2);
|
|
31
|
+
const left = padlen - right;
|
|
32
|
+
str = repeat(pad, left) + str + repeat(pad, right);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
default: {
|
|
36
|
+
str = str + repeat(pad, padlen);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return str;
|
|
39
42
|
}
|
|
43
|
+
|
|
40
44
|
const codeCache = {};
|
|
45
|
+
|
|
41
46
|
function addToCodeCache(name, on, off) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
on = '\u001b[' + on + 'm';
|
|
48
|
+
off = '\u001b[' + off + 'm';
|
|
49
|
+
codeCache[on] = { set: name, to: true };
|
|
50
|
+
codeCache[off] = { set: name, to: false };
|
|
51
|
+
codeCache[name] = { on: on, off: off };
|
|
47
52
|
}
|
|
53
|
+
|
|
54
|
+
// https://github.com/Marak/colors.js/blob/master/lib/styles.js
|
|
48
55
|
addToCodeCache('bold', 1, 22);
|
|
49
56
|
addToCodeCache('italics', 3, 23);
|
|
50
57
|
addToCodeCache('underline', 4, 24);
|
|
51
58
|
addToCodeCache('inverse', 7, 27);
|
|
52
59
|
addToCodeCache('strikethrough', 9, 29);
|
|
60
|
+
|
|
53
61
|
function updateState(state, controlChars) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
const controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0;
|
|
63
|
+
if ((controlCode >= 30 && controlCode <= 39) || (controlCode >= 90 && controlCode <= 97)) {
|
|
64
|
+
state.lastForegroundAdded = controlChars[0];
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if ((controlCode >= 40 && controlCode <= 49) || (controlCode >= 100 && controlCode <= 107)) {
|
|
68
|
+
state.lastBackgroundAdded = controlChars[0];
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (controlCode === 0) {
|
|
72
|
+
for (const i in state) {
|
|
73
|
+
/* istanbul ignore else */
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(state, i)) {
|
|
75
|
+
delete state[i];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const info = codeCache[controlChars[0]];
|
|
81
|
+
if (info) {
|
|
82
|
+
state[info.set] = info.to;
|
|
83
|
+
}
|
|
75
84
|
}
|
|
85
|
+
|
|
76
86
|
function readState(line) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
const code = codeRegex(true);
|
|
88
|
+
let controlChars = code.exec(line);
|
|
89
|
+
const state = {};
|
|
90
|
+
while (controlChars !== null) {
|
|
91
|
+
updateState(state, controlChars);
|
|
92
|
+
controlChars = code.exec(line);
|
|
93
|
+
}
|
|
94
|
+
return state;
|
|
85
95
|
}
|
|
96
|
+
|
|
86
97
|
function unwindState(state, ret) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
const lastBackgroundAdded = state.lastBackgroundAdded;
|
|
99
|
+
const lastForegroundAdded = state.lastForegroundAdded;
|
|
100
|
+
|
|
101
|
+
delete state.lastBackgroundAdded;
|
|
102
|
+
delete state.lastForegroundAdded;
|
|
103
|
+
|
|
104
|
+
Object.keys(state).forEach((key) => {
|
|
105
|
+
if (state[key]) {
|
|
106
|
+
ret += codeCache[key].off;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') {
|
|
111
|
+
ret += '\u001b[49m';
|
|
112
|
+
}
|
|
113
|
+
if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') {
|
|
114
|
+
ret += '\u001b[39m';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return ret;
|
|
103
118
|
}
|
|
119
|
+
|
|
104
120
|
function rewindState(state, ret) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
const lastBackgroundAdded = state.lastBackgroundAdded;
|
|
122
|
+
const lastForegroundAdded = state.lastForegroundAdded;
|
|
123
|
+
|
|
124
|
+
delete state.lastBackgroundAdded;
|
|
125
|
+
delete state.lastForegroundAdded;
|
|
126
|
+
|
|
127
|
+
Object.keys(state).forEach((key) => {
|
|
128
|
+
if (state[key]) {
|
|
129
|
+
ret = codeCache[key].on + ret;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') {
|
|
134
|
+
ret = lastBackgroundAdded + ret;
|
|
135
|
+
}
|
|
136
|
+
if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') {
|
|
137
|
+
ret = lastForegroundAdded + ret;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return ret;
|
|
121
141
|
}
|
|
142
|
+
|
|
122
143
|
function truncateWidth(str, desiredLength) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
if (str.length === strlen(str)) {
|
|
145
|
+
return str.substr(0, desiredLength);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
while (strlen(str) > desiredLength) {
|
|
149
|
+
str = str.slice(0, -1);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return str;
|
|
130
153
|
}
|
|
154
|
+
|
|
131
155
|
function truncateWidthWithAnsi(str, desiredLength) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
const code = codeRegex(true);
|
|
157
|
+
const split = str.split(codeRegex());
|
|
158
|
+
let splitIndex = 0;
|
|
159
|
+
let retLen = 0;
|
|
160
|
+
let ret = '';
|
|
161
|
+
let myArray;
|
|
162
|
+
const state = {};
|
|
163
|
+
|
|
164
|
+
while (retLen < desiredLength) {
|
|
165
|
+
myArray = code.exec(str);
|
|
166
|
+
let toAdd = split[splitIndex];
|
|
167
|
+
splitIndex++;
|
|
168
|
+
if (retLen + strlen(toAdd) > desiredLength) {
|
|
169
|
+
toAdd = truncateWidth(toAdd, desiredLength - retLen);
|
|
170
|
+
}
|
|
171
|
+
ret += toAdd;
|
|
172
|
+
retLen += strlen(toAdd);
|
|
173
|
+
|
|
174
|
+
if (retLen < desiredLength) {
|
|
175
|
+
if (!myArray) {
|
|
176
|
+
break;
|
|
177
|
+
} // full-width chars may cause a whitespace which cannot be filled
|
|
178
|
+
ret += myArray[0];
|
|
179
|
+
updateState(state, myArray);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return unwindState(state, ret);
|
|
157
184
|
}
|
|
185
|
+
|
|
158
186
|
function truncate(str, desiredLength, truncateChar) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
187
|
+
truncateChar = truncateChar || '…';
|
|
188
|
+
const lengthOfStr = strlen(str);
|
|
189
|
+
if (lengthOfStr <= desiredLength) {
|
|
190
|
+
return str;
|
|
191
|
+
}
|
|
192
|
+
desiredLength -= strlen(truncateChar);
|
|
193
|
+
|
|
194
|
+
const ret = truncateWidthWithAnsi(str, desiredLength);
|
|
195
|
+
|
|
196
|
+
return ret + truncateChar;
|
|
167
197
|
}
|
|
198
|
+
|
|
168
199
|
function defaultOptions() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
return {
|
|
201
|
+
chars: {
|
|
202
|
+
top: '─',
|
|
203
|
+
'top-mid': '┬',
|
|
204
|
+
'top-left': '┌',
|
|
205
|
+
'top-right': '┐',
|
|
206
|
+
bottom: '─',
|
|
207
|
+
'bottom-mid': '┴',
|
|
208
|
+
'bottom-left': '└',
|
|
209
|
+
'bottom-right': '┘',
|
|
210
|
+
left: '│',
|
|
211
|
+
'left-mid': '├',
|
|
212
|
+
mid: '─',
|
|
213
|
+
'mid-mid': '┼',
|
|
214
|
+
right: '│',
|
|
215
|
+
'right-mid': '┤',
|
|
216
|
+
middle: '│'
|
|
217
|
+
},
|
|
218
|
+
truncate: '…',
|
|
219
|
+
colWidths: [],
|
|
220
|
+
rowHeights: [],
|
|
221
|
+
colAligns: [],
|
|
222
|
+
rowAligns: [],
|
|
223
|
+
style: {
|
|
224
|
+
'padding-left': 1,
|
|
225
|
+
'padding-right': 1,
|
|
226
|
+
head: ['red'],
|
|
227
|
+
border: ['grey'],
|
|
228
|
+
compact: false
|
|
229
|
+
},
|
|
230
|
+
head: []
|
|
231
|
+
};
|
|
201
232
|
}
|
|
233
|
+
|
|
202
234
|
function mergeOptions(options, defaults) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
235
|
+
options = options || {};
|
|
236
|
+
defaults = defaults || defaultOptions();
|
|
237
|
+
const ret = Object.assign({}, defaults, options);
|
|
238
|
+
ret.chars = Object.assign({}, defaults.chars, options.chars);
|
|
239
|
+
ret.style = Object.assign({}, defaults.style, options.style);
|
|
240
|
+
return ret;
|
|
209
241
|
}
|
|
242
|
+
|
|
210
243
|
function wordWrap(maxLength, input) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return lines;
|
|
244
|
+
const lines = [];
|
|
245
|
+
const split = input.split(/(\s+)/g);
|
|
246
|
+
let line = [];
|
|
247
|
+
let lineLength = 0;
|
|
248
|
+
let whitespace;
|
|
249
|
+
for (let i = 0; i < split.length; i += 2) {
|
|
250
|
+
const word = split[i];
|
|
251
|
+
let newLength = lineLength + strlen(word);
|
|
252
|
+
if (lineLength > 0 && whitespace) {
|
|
253
|
+
newLength += whitespace.length;
|
|
254
|
+
}
|
|
255
|
+
if (newLength > maxLength) {
|
|
256
|
+
if (lineLength !== 0) {
|
|
257
|
+
lines.push(line.join(''));
|
|
258
|
+
}
|
|
259
|
+
line = [word];
|
|
260
|
+
lineLength = strlen(word);
|
|
261
|
+
} else {
|
|
262
|
+
line.push(whitespace || '', word);
|
|
263
|
+
lineLength = newLength;
|
|
264
|
+
}
|
|
265
|
+
whitespace = split[i + 1];
|
|
266
|
+
}
|
|
267
|
+
if (lineLength) {
|
|
268
|
+
lines.push(line.join(''));
|
|
269
|
+
}
|
|
270
|
+
return lines;
|
|
239
271
|
}
|
|
272
|
+
|
|
240
273
|
function multiLineWordWrap(maxLength, input) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
274
|
+
const output = [];
|
|
275
|
+
input = input.split('\n');
|
|
276
|
+
for (let i = 0; i < input.length; i++) {
|
|
277
|
+
output.push.apply(output, wordWrap(maxLength, input[i]));
|
|
278
|
+
}
|
|
279
|
+
return output;
|
|
247
280
|
}
|
|
281
|
+
|
|
248
282
|
function colorizeLines(input) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
283
|
+
let state = {};
|
|
284
|
+
const output = [];
|
|
285
|
+
for (let i = 0; i < input.length; i++) {
|
|
286
|
+
const line = rewindState(state, input[i]);
|
|
287
|
+
state = readState(line);
|
|
288
|
+
const temp = Object.assign({}, state);
|
|
289
|
+
output.push(unwindState(temp, line));
|
|
290
|
+
}
|
|
291
|
+
return output;
|
|
258
292
|
}
|
|
293
|
+
|
|
259
294
|
module.exports = {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
295
|
+
strlen: strlen,
|
|
296
|
+
repeat: repeat,
|
|
297
|
+
pad: pad,
|
|
298
|
+
truncate: truncate,
|
|
299
|
+
mergeOptions: mergeOptions,
|
|
300
|
+
wordWrap: multiLineWordWrap,
|
|
301
|
+
colorizeLines: colorizeLines
|
|
267
302
|
};
|
package/lib/client-utils.js
CHANGED
|
@@ -58,13 +58,25 @@ exports.clientUtils = {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
const name = js_1.JS.get(packageJson, 'name', null);
|
|
61
|
-
const homepage = js_1.JS.get(packageJson, 'homepage',
|
|
61
|
+
const homepage = js_1.JS.get(packageJson, 'homepage', 'index.html');
|
|
62
|
+
const notFoundPagePath = js_1.JS.get(packageJson, '404', '404.html');
|
|
63
|
+
if (homepage === notFoundPagePath) {
|
|
64
|
+
throw new error_1.default('404 page and homepage cannot be the same', {
|
|
65
|
+
exit: 1,
|
|
66
|
+
errorId: 'CLIENT-UTILS-7',
|
|
67
|
+
arg: [(0, ansi_colors_1.bold)('404'), (0, ansi_colors_1.bold)('HOME'), ansi_colors_1.italic.red(homepage)]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const notFoundPage = notFoundPagePath && (yield fs_1.ASYNC.fileExists((0, path_1.resolve)(sourceDir, notFoundPagePath)))
|
|
71
|
+
? (0, path_1.resolve)(sourceDir, notFoundPagePath)
|
|
72
|
+
: (yield fs_1.ASYNC.fileExists((0, path_1.join)(sourceDir, constants_1.FILENAME.client.notFoundPage))) &&
|
|
73
|
+
(0, path_1.join)(sourceDir, constants_1.FILENAME.client.notFoundPage);
|
|
62
74
|
const loginRedirect = runtime_store_1.default.get('context.client.login_redirect', packageJson.login_redirect);
|
|
63
|
-
if (js_1.JS.isNull(name)
|
|
75
|
+
if (js_1.JS.isNull(name)) {
|
|
64
76
|
throw new error_1.default(constants_1.FILENAME.client.package_json + ' file is corrupted.', {
|
|
65
77
|
exit: 1,
|
|
66
78
|
errorId: 'CLIENT-UTILS-4',
|
|
67
|
-
arg: [(0, ansi_colors_1.bold)(packageJsonFile), (0, ansi_colors_1.bold)('name')
|
|
79
|
+
arg: [(0, ansi_colors_1.bold)(packageJsonFile), (0, ansi_colors_1.bold)('name')]
|
|
68
80
|
});
|
|
69
81
|
}
|
|
70
82
|
runtime_store_1.default.set('context.client.name', name);
|
|
@@ -72,6 +84,7 @@ exports.clientUtils = {
|
|
|
72
84
|
runtime_store_1.default.set('context.client.source', sourceDir);
|
|
73
85
|
runtime_store_1.default.set('context.client.login_redirect', loginRedirect || homepage);
|
|
74
86
|
runtime_store_1.default.set('context.client.package_json', packageJsonFile);
|
|
87
|
+
runtime_store_1.default.set('context.client.notFoundPage', notFoundPage);
|
|
75
88
|
const validatePlugin = yield (0, plugin_loader_1.default)('client', 'validate').catch((err) => (0, logger_1.debug)(err));
|
|
76
89
|
if (typeof validatePlugin !== 'function') {
|
|
77
90
|
runtime_store_1.default.set('context.client.valid', true);
|
|
@@ -120,6 +133,7 @@ exports.clientUtils = {
|
|
|
120
133
|
let source = (0, project_1.resolveProjectPath)(config_1.clientConfig.source());
|
|
121
134
|
const buildPlugin = yield (0, plugin_loader_1.default)('client', 'build').catch((err) => (0, logger_1.debug)(err));
|
|
122
135
|
if (typeof buildPlugin === 'function') {
|
|
136
|
+
process.env.X_CATALYST_WEBAPP_PATH = source;
|
|
123
137
|
const logStreamPlugin = yield (0, plugin_loader_1.default)('client', 'logs').catch((err) => (0, logger_1.debug)(err));
|
|
124
138
|
let stream;
|
|
125
139
|
const streamLogFn = (chunk) => (0, logger_1.log)('info', chunk.toString(), true);
|
|
@@ -154,7 +168,7 @@ exports.clientUtils = {
|
|
|
154
168
|
}
|
|
155
169
|
}
|
|
156
170
|
const exclude = config_1.clientConfig.ignore(source);
|
|
157
|
-
const files = yield fs_1.ASYNC.walk(source, { exclude });
|
|
171
|
+
const files = yield fs_1.ASYNC.walk(source, { filter: { exclude, excludeDir: true } });
|
|
158
172
|
const zip = new archiver_1.default();
|
|
159
173
|
files.forEach((file) => {
|
|
160
174
|
zip.add(file.replace(source + path_1.sep, ''), fs_1.SYNC.getReadStream(file));
|