@raisenow/tamaro-cli 1.0.19 → 1.0.22
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/.nvmrc +1 -1
- package/README.md +22 -0
- package/dist/{chunk-6RQVBAWK.js → chunk-2HKMDCAH.js} +78 -31
- package/dist/cli.js +208 -74
- package/dist/webpack.config.js +64 -36
- package/package.json +30 -30
- package/src/cli.ts +15 -0
- package/src/commands/build.ts +12 -2
- package/src/commands/dev.ts +12 -2
- package/src/commands/serve.ts +20 -2
- package/src/lib/constants.ts +2 -0
- package/src/lib/env.ts +14 -2
- package/src/lib/https.ts +27 -0
- package/src/lib/resolve.ts +2 -0
- package/src/webpack.config.ts +12 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
4
|
+
AWS_S3_BUCKET,
|
|
5
|
+
CORE_CONFIG_NAME,
|
|
6
|
+
DEFAULT_AWS_PROFILE,
|
|
7
|
+
DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET,
|
|
8
|
+
DEFAULT_PORT,
|
|
9
|
+
DEFAULT_TAG,
|
|
10
|
+
HTTPS_CRT_FILE,
|
|
11
|
+
HTTPS_KEY_FILE,
|
|
3
12
|
assertEnvValid,
|
|
4
13
|
getIfCoreFns,
|
|
5
14
|
getPaths,
|
|
@@ -12,7 +21,7 @@ import {
|
|
|
12
21
|
resolveBin,
|
|
13
22
|
resolveOwn,
|
|
14
23
|
runCommandSync
|
|
15
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-2HKMDCAH.js";
|
|
16
25
|
|
|
17
26
|
// src/cli.ts
|
|
18
27
|
import { createCommand } from "commander";
|
|
@@ -20,7 +29,7 @@ import { createCommand } from "commander";
|
|
|
20
29
|
// package.json
|
|
21
30
|
var package_default = {
|
|
22
31
|
name: "@raisenow/tamaro-cli",
|
|
23
|
-
version: "1.0.
|
|
32
|
+
version: "1.0.22",
|
|
24
33
|
author: {
|
|
25
34
|
name: "RaiseNow",
|
|
26
35
|
email: "development@raisenow.com"
|
|
@@ -40,95 +49,112 @@ var package_default = {
|
|
|
40
49
|
npm: ">=8"
|
|
41
50
|
},
|
|
42
51
|
dependencies: {
|
|
43
|
-
"@babel/cli": "^7.18.
|
|
44
|
-
"@babel/core": "^7.
|
|
45
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
52
|
+
"@babel/cli": "^7.18.10",
|
|
53
|
+
"@babel/core": "^7.19.0",
|
|
54
|
+
"@babel/plugin-proposal-decorators": "^7.19.0",
|
|
46
55
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
47
|
-
"@babel/plugin-transform-runtime": "^7.18.
|
|
48
|
-
"@babel/preset-env": "^7.
|
|
56
|
+
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
57
|
+
"@babel/preset-env": "^7.19.0",
|
|
49
58
|
"@babel/preset-react": "^7.18.6",
|
|
50
59
|
"@babel/preset-typescript": "^7.18.6",
|
|
51
|
-
"@babel/runtime-corejs3": "^7.
|
|
60
|
+
"@babel/runtime-corejs3": "^7.19.0",
|
|
52
61
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
53
|
-
"@statoscope/webpack-plugin": "^5.
|
|
62
|
+
"@statoscope/webpack-plugin": "^5.24.0",
|
|
54
63
|
"@types/columnify": "^1.5.1",
|
|
55
|
-
"@types/lodash": "^4.14.
|
|
56
|
-
"@types/node": "^18.
|
|
64
|
+
"@types/lodash": "^4.14.184",
|
|
65
|
+
"@types/node": "^18.7.15",
|
|
57
66
|
"@types/node-notifier": "^8.0.2",
|
|
58
67
|
"@types/resolve-bin": "^0.4.1",
|
|
59
68
|
"@types/webpack-config-utils": "^2.3.1",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
61
|
-
"@typescript-eslint/parser": "^5.
|
|
62
|
-
autoprefixer: "^10.4.
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
70
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
71
|
+
autoprefixer: "^10.4.8",
|
|
63
72
|
"babel-loader": "^8.2.5",
|
|
64
73
|
"babel-plugin-istanbul": "^6.1.1",
|
|
65
74
|
"babel-plugin-lodash": "^3.3.4",
|
|
66
75
|
chalk: "^5.0.1",
|
|
67
76
|
"clean-webpack-plugin": "^4.0.0",
|
|
68
77
|
columnify: "^1.6.0",
|
|
69
|
-
commander: "^9.
|
|
78
|
+
commander: "^9.4.0",
|
|
70
79
|
"copy-webpack-plugin": "^11.0.0",
|
|
71
|
-
"core-js": "^3.
|
|
80
|
+
"core-js": "^3.25.0",
|
|
72
81
|
"css-loader": "^6.7.1",
|
|
73
82
|
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
74
|
-
dotenv: "^16.0.
|
|
75
|
-
"dotenv-expand": "^
|
|
83
|
+
dotenv: "^16.0.2",
|
|
84
|
+
"dotenv-expand": "^9.0.0",
|
|
76
85
|
"escape-string-regexp": "^5.0.0",
|
|
77
|
-
eslint: "^8.
|
|
86
|
+
eslint: "^8.23.0",
|
|
78
87
|
"eslint-config-prettier": "^8.5.0",
|
|
79
88
|
"eslint-plugin-node": "^11.1.0",
|
|
80
|
-
"eslint-plugin-promise": "^6.0.
|
|
89
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
81
90
|
"eslint-webpack-plugin": "^3.2.0",
|
|
82
91
|
execa: "^6.1.0",
|
|
83
92
|
"file-loader": "^6.2.0",
|
|
84
|
-
"fork-ts-checker-webpack-plugin": "^7.2.
|
|
93
|
+
"fork-ts-checker-webpack-plugin": "^7.2.13",
|
|
85
94
|
glob: "^8.0.3",
|
|
86
|
-
"html-loader": "^
|
|
95
|
+
"html-loader": "^4.1.0",
|
|
87
96
|
"html-webpack-plugin": "^5.5.0",
|
|
88
97
|
"json-loader": "^0.5.7",
|
|
89
98
|
lodash: "^4.17.21",
|
|
90
99
|
"mini-css-extract-plugin": "^2.6.1",
|
|
91
100
|
"node-notifier": "^10.0.1",
|
|
92
|
-
portfinder: "^1.0.
|
|
93
|
-
postcss: "^8.4.
|
|
101
|
+
portfinder: "^1.0.32",
|
|
102
|
+
postcss: "^8.4.16",
|
|
94
103
|
"postcss-custom-properties": "^12.1.7",
|
|
95
|
-
"postcss-loader": "^7.0.
|
|
104
|
+
"postcss-loader": "^7.0.1",
|
|
96
105
|
prettier: "^2.7.1",
|
|
97
106
|
"react-refresh": "^0.14.0",
|
|
98
107
|
"resolve-url-loader": "^5.0.0",
|
|
99
|
-
sass: "^1.
|
|
108
|
+
sass: "^1.54.8",
|
|
100
109
|
"sass-loader": "^13.0.2",
|
|
101
110
|
"source-map-loader": "^4.0.0",
|
|
102
111
|
"strip-indent": "^4.0.0",
|
|
103
112
|
"style-loader": "^3.3.1",
|
|
104
|
-
"tsconfig-paths-webpack-plugin": "^
|
|
105
|
-
tsup: "^6.
|
|
106
|
-
typescript: "^4.
|
|
113
|
+
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
114
|
+
tsup: "^6.2.3",
|
|
115
|
+
typescript: "^4.8.2",
|
|
107
116
|
"url-loader": "^4.1.1",
|
|
108
|
-
webpack: "^5.
|
|
117
|
+
webpack: "^5.74.0",
|
|
109
118
|
"webpack-cli": "^4.10.0",
|
|
110
119
|
"webpack-config-utils": "^2.3.1",
|
|
111
|
-
"webpack-dev-server": "^4.
|
|
120
|
+
"webpack-dev-server": "^4.10.1",
|
|
112
121
|
"yaml-loader": "^0.8.0"
|
|
113
122
|
}
|
|
114
123
|
};
|
|
115
124
|
|
|
116
|
-
// src/lib/constants.ts
|
|
117
|
-
var DEFAULT_TAG = "latest";
|
|
118
|
-
var DEFAULT_PORT = 1234;
|
|
119
|
-
var DEFAULT_AWS_PROFILE = "payments-prod-cs-deployer";
|
|
120
|
-
var DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET = "rnw-email-service";
|
|
121
|
-
var AWS_S3_BUCKET = "tamaro.raisenow.com";
|
|
122
|
-
var CORE_CONFIG_NAME = "tamaro-core";
|
|
123
|
-
var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
|
|
124
|
-
|
|
125
125
|
// src/commands/dev.ts
|
|
126
126
|
import { getPortPromise } from "portfinder";
|
|
127
|
+
|
|
128
|
+
// src/lib/https.ts
|
|
129
|
+
import { existsSync } from "fs";
|
|
130
|
+
import { resolve } from "path";
|
|
131
|
+
import stripIndent from "strip-indent";
|
|
132
|
+
var assertCrtExists = () => {
|
|
133
|
+
const { ifCore } = getIfCoreFns();
|
|
134
|
+
const paths = getPaths(ifCore);
|
|
135
|
+
const certFile = resolve(paths.root, HTTPS_CRT_FILE);
|
|
136
|
+
const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
|
|
137
|
+
if (existsSync(certFile) && existsSync(keyFile)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
halt(
|
|
141
|
+
stripIndent(`
|
|
142
|
+
Flag \u201C--https\u201D is used, but \u201C${HTTPS_CRT_FILE}\u201D and/or \u201C${HTTPS_KEY_FILE}\u201D files are not found.
|
|
143
|
+
You need to generate certificate first.
|
|
144
|
+
Check docs: https://unpkg.com/@raisenow/tamaro-cli/readme.html#/?id=use-transport-level-security-https
|
|
145
|
+
`)
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/commands/dev.ts
|
|
127
150
|
var dev = async (options) => {
|
|
128
151
|
assertOptionsValid(options);
|
|
129
152
|
const flags = (await prepareFlags([], options)).join(" ");
|
|
130
153
|
const { ifCore } = getIfCoreFns();
|
|
131
|
-
const title = ifCore(
|
|
154
|
+
const title = ifCore(
|
|
155
|
+
"Running dev web-server for Tamaro Core \u2026",
|
|
156
|
+
"Running dev web-server for customer configuration \u2026"
|
|
157
|
+
);
|
|
132
158
|
const wpBin = resolveBin("webpack");
|
|
133
159
|
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
134
160
|
const cmd = `
|
|
@@ -141,7 +167,7 @@ var dev = async (options) => {
|
|
|
141
167
|
runCommandSync(cmd, { stdio: "inherit" });
|
|
142
168
|
};
|
|
143
169
|
var assertOptionsValid = (options) => {
|
|
144
|
-
const { localCore, port, env } = options;
|
|
170
|
+
const { localCore, https, port, env } = options;
|
|
145
171
|
const { ifCore } = getIfCoreFns();
|
|
146
172
|
if (ifCore() && localCore) {
|
|
147
173
|
halt("Flag \u201C--local-core\u201D is redundant if running in Tamaro Core context.");
|
|
@@ -149,21 +175,27 @@ var assertOptionsValid = (options) => {
|
|
|
149
175
|
if (isNaN(Number(port))) {
|
|
150
176
|
halt("Flag \u201C--port\u201D should be a number.");
|
|
151
177
|
}
|
|
178
|
+
if (https) {
|
|
179
|
+
assertCrtExists();
|
|
180
|
+
}
|
|
152
181
|
assertEnvValid(env);
|
|
153
182
|
};
|
|
154
183
|
var prepareFlags = async (flags, options) => {
|
|
155
|
-
const { localCore, port: defaultPort } = options;
|
|
184
|
+
const { localCore, port: defaultPort, https } = options;
|
|
156
185
|
const port = await getPortPromise({ port: Number(defaultPort) });
|
|
157
186
|
if (localCore) {
|
|
158
187
|
flags.push("--env localCore");
|
|
159
188
|
}
|
|
160
189
|
flags.push(`--port ${port}`);
|
|
190
|
+
if (https) {
|
|
191
|
+
flags.push("--env https");
|
|
192
|
+
}
|
|
161
193
|
return flags;
|
|
162
194
|
};
|
|
163
195
|
|
|
164
196
|
// src/lib/aws.ts
|
|
165
197
|
import { execaCommandSync } from "execa";
|
|
166
|
-
import
|
|
198
|
+
import stripIndent2 from "strip-indent";
|
|
167
199
|
var withAwsAuthenticate = (fn, options) => {
|
|
168
200
|
awsAuthenticate(options);
|
|
169
201
|
return fn();
|
|
@@ -190,16 +222,16 @@ var assertProfileValid = (profile) => {
|
|
|
190
222
|
console.log(`Using AWS profile: \u201C${profile}\u201D`);
|
|
191
223
|
let message;
|
|
192
224
|
if (profiles.length === 0) {
|
|
193
|
-
message =
|
|
225
|
+
message = stripIndent2(`
|
|
194
226
|
No AWS profiles found.
|
|
195
227
|
`);
|
|
196
228
|
} else {
|
|
197
|
-
message =
|
|
229
|
+
message = stripIndent2(`
|
|
198
230
|
AWS profile \u201C${profile}\u201D has not been found.
|
|
199
231
|
Available profiles are: ${profiles.map((v) => `\u201C${v}\u201D`).join(", ")}.
|
|
200
232
|
`);
|
|
201
233
|
}
|
|
202
|
-
message +=
|
|
234
|
+
message += stripIndent2(`
|
|
203
235
|
Run \u201Caws configure sso\u201D to set up SSO-enabled profile.
|
|
204
236
|
Check the wiki for more information:
|
|
205
237
|
https://raisenow.atlassian.net/wiki/x/lIrWvg
|
|
@@ -234,12 +266,12 @@ var prepareFlags2 = (flags, options) => {
|
|
|
234
266
|
|
|
235
267
|
// src/lib/notifier.ts
|
|
236
268
|
import notifier from "node-notifier";
|
|
237
|
-
import
|
|
269
|
+
import stripIndent3 from "strip-indent";
|
|
238
270
|
var notify = (args) => {
|
|
239
271
|
const { title, message = "" } = args;
|
|
240
272
|
notifier.notify({
|
|
241
273
|
title,
|
|
242
|
-
message:
|
|
274
|
+
message: stripIndent3(message).trim(),
|
|
243
275
|
contentImage: "https://assets.raisenow.io/favicon.png",
|
|
244
276
|
sound: "Funk"
|
|
245
277
|
});
|
|
@@ -252,7 +284,10 @@ var build = async (options) => {
|
|
|
252
284
|
const { ifCore } = getIfCoreFns();
|
|
253
285
|
const paths = getPaths(ifCore);
|
|
254
286
|
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
255
|
-
const title = ifCore(
|
|
287
|
+
const title = ifCore(
|
|
288
|
+
"Building optimised (minified) bundle of Tamaro Core \u2026",
|
|
289
|
+
`Building optimised (minified) bundle of \u201C${configName}\u201D customer configuration \u2026`
|
|
290
|
+
);
|
|
256
291
|
const wpBin = resolveBin("webpack");
|
|
257
292
|
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
258
293
|
const cmd = `
|
|
@@ -276,7 +311,7 @@ Bundle for \u201C${configName}\u201D customer configuration is done.`);
|
|
|
276
311
|
});
|
|
277
312
|
};
|
|
278
313
|
var assertOptionsValid2 = (options) => {
|
|
279
|
-
const { localCore, deploy: deploy2, profile, env } = options;
|
|
314
|
+
const { localCore, https, deploy: deploy2, profile, env } = options;
|
|
280
315
|
const { ifCore } = getIfCoreFns();
|
|
281
316
|
if (ifCore() && localCore) {
|
|
282
317
|
halt("Flag \u201C--local-core\u201D is redundant if running in Tamaro Core context.");
|
|
@@ -284,23 +319,29 @@ var assertOptionsValid2 = (options) => {
|
|
|
284
319
|
if (localCore && deploy2) {
|
|
285
320
|
halt("Flags \u201C--local-core\u201D and \u201C--deploy\u201D must not be used together.");
|
|
286
321
|
}
|
|
322
|
+
if (https) {
|
|
323
|
+
assertCrtExists();
|
|
324
|
+
}
|
|
287
325
|
assertProfileValid(profile);
|
|
288
326
|
assertEnvValid(env);
|
|
289
327
|
};
|
|
290
328
|
var prepareFlags3 = (flags, options) => {
|
|
291
|
-
const { localCore, analyze } = options;
|
|
329
|
+
const { localCore, analyze, https } = options;
|
|
292
330
|
if (localCore) {
|
|
293
331
|
flags.push("--env localCore");
|
|
294
332
|
}
|
|
295
333
|
if (analyze) {
|
|
296
334
|
flags.push("--env analyze");
|
|
297
335
|
}
|
|
336
|
+
if (https) {
|
|
337
|
+
flags.push("--env https");
|
|
338
|
+
}
|
|
298
339
|
return flags;
|
|
299
340
|
};
|
|
300
341
|
|
|
301
342
|
// src/commands/deploy.ts
|
|
302
|
-
import { existsSync } from "fs";
|
|
303
|
-
import
|
|
343
|
+
import { existsSync as existsSync2 } from "fs";
|
|
344
|
+
import stripIndent4 from "strip-indent";
|
|
304
345
|
var deploy = async (options) => {
|
|
305
346
|
const { ifCore } = getIfCoreFns();
|
|
306
347
|
const paths = getPaths(ifCore);
|
|
@@ -321,7 +362,10 @@ var deploy = async (options) => {
|
|
|
321
362
|
logTitle("Deploying to AWS S3 \u2026");
|
|
322
363
|
logCommand(cmdSyncAll);
|
|
323
364
|
try {
|
|
324
|
-
withAwsAuthenticate(
|
|
365
|
+
withAwsAuthenticate(
|
|
366
|
+
() => runCommandSync(cmdSyncAll, { stdout: "inherit" }),
|
|
367
|
+
options
|
|
368
|
+
);
|
|
325
369
|
} catch (error) {
|
|
326
370
|
halt(error.stderr);
|
|
327
371
|
}
|
|
@@ -333,7 +377,10 @@ var deploy = async (options) => {
|
|
|
333
377
|
`;
|
|
334
378
|
logCommand(cmdCpEntry);
|
|
335
379
|
try {
|
|
336
|
-
withAwsAuthenticate(
|
|
380
|
+
withAwsAuthenticate(
|
|
381
|
+
() => runCommandSync(cmdCpEntry, { stdout: "inherit" }),
|
|
382
|
+
options
|
|
383
|
+
);
|
|
337
384
|
} catch (error) {
|
|
338
385
|
halt(error.stderr);
|
|
339
386
|
}
|
|
@@ -375,17 +422,21 @@ var assertOptionsValid3 = (options) => {
|
|
|
375
422
|
assertProfileValid(profile);
|
|
376
423
|
};
|
|
377
424
|
var assertDistPathExists = (distPath) => {
|
|
378
|
-
if (!
|
|
379
|
-
halt(
|
|
425
|
+
if (!existsSync2(distPath)) {
|
|
426
|
+
halt(
|
|
427
|
+
stripIndent4(`
|
|
380
428
|
Dist folder does not exists.
|
|
381
429
|
Make sure you have built the bundle before trying to deploy it.
|
|
382
|
-
`)
|
|
430
|
+
`)
|
|
431
|
+
);
|
|
383
432
|
}
|
|
384
433
|
};
|
|
385
434
|
var assertTagValid = (tag) => {
|
|
386
435
|
const regex = /^[a-zA-Z0-9-_.]+$/;
|
|
387
436
|
if (!regex.test(tag)) {
|
|
388
|
-
halt(
|
|
437
|
+
halt(
|
|
438
|
+
`Flag \u201C--tag\u201D has forbidden format. Allowed format: ${regex.toString()}.`
|
|
439
|
+
);
|
|
389
440
|
}
|
|
390
441
|
};
|
|
391
442
|
var prepareFlags4 = (flags, options) => {
|
|
@@ -393,6 +444,7 @@ var prepareFlags4 = (flags, options) => {
|
|
|
393
444
|
};
|
|
394
445
|
|
|
395
446
|
// src/commands/serve.ts
|
|
447
|
+
import { resolve as resolve2 } from "path";
|
|
396
448
|
import { getPortPromise as getPortPromise2 } from "portfinder";
|
|
397
449
|
var serve = async (options) => {
|
|
398
450
|
assertOptionsValid4(options);
|
|
@@ -409,15 +461,26 @@ var serve = async (options) => {
|
|
|
409
461
|
runCommandSync(cmd, { stdio: "inherit" });
|
|
410
462
|
};
|
|
411
463
|
var assertOptionsValid4 = (options) => {
|
|
412
|
-
const { port } = options;
|
|
464
|
+
const { port, https } = options;
|
|
413
465
|
if (isNaN(Number(port))) {
|
|
414
466
|
halt('Flag "--port" should be a number.');
|
|
415
467
|
}
|
|
468
|
+
if (https) {
|
|
469
|
+
assertCrtExists();
|
|
470
|
+
}
|
|
416
471
|
};
|
|
417
472
|
var prepareFlags5 = async (flags, options) => {
|
|
418
|
-
const { port: defaultPort } = options;
|
|
473
|
+
const { port: defaultPort, https } = options;
|
|
419
474
|
const port = await getPortPromise2({ port: Number(defaultPort) });
|
|
420
475
|
flags.push(`-p ${port}`);
|
|
476
|
+
if (https) {
|
|
477
|
+
const { ifCore } = getIfCoreFns();
|
|
478
|
+
const paths = getPaths(ifCore);
|
|
479
|
+
const certFile = resolve2(paths.root, HTTPS_CRT_FILE);
|
|
480
|
+
const keyFile = resolve2(paths.root, HTTPS_KEY_FILE);
|
|
481
|
+
flags.push(`--ssl-cert ${certFile}`);
|
|
482
|
+
flags.push(`--ssl-key ${keyFile}`);
|
|
483
|
+
}
|
|
421
484
|
return flags;
|
|
422
485
|
};
|
|
423
486
|
|
|
@@ -467,7 +530,9 @@ var assertConfigValid = (config) => {
|
|
|
467
530
|
}
|
|
468
531
|
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
469
532
|
if (!regex.test(config)) {
|
|
470
|
-
halt(
|
|
533
|
+
halt(
|
|
534
|
+
`Flag \u201C--config\u201D has forbidden format. Allowed format: ${regex.toString()}.`
|
|
535
|
+
);
|
|
471
536
|
}
|
|
472
537
|
};
|
|
473
538
|
var prepareFlags6 = (flags, options) => {
|
|
@@ -479,7 +544,7 @@ var parseTags = (lines) => {
|
|
|
479
544
|
};
|
|
480
545
|
|
|
481
546
|
// src/commands/deploy-email-config.ts
|
|
482
|
-
import { existsSync as
|
|
547
|
+
import { existsSync as existsSync3 } from "fs";
|
|
483
548
|
var deployEmailConfig = async (options) => {
|
|
484
549
|
const { ifCore } = getIfCoreFns();
|
|
485
550
|
const paths = getPaths(ifCore);
|
|
@@ -497,14 +562,18 @@ var deployEmailConfig = async (options) => {
|
|
|
497
562
|
--exact-timestamps
|
|
498
563
|
${flags}
|
|
499
564
|
`;
|
|
500
|
-
logTitle(
|
|
565
|
+
logTitle(
|
|
566
|
+
`Deploying email configuration for \u201C${configName}\u201D customer configuration to AWS S3 \u2026`
|
|
567
|
+
);
|
|
501
568
|
logCommand(cmd);
|
|
502
569
|
try {
|
|
503
570
|
withAwsAuthenticate(() => runCommandSync(cmd, { stdout: "inherit" }), options);
|
|
504
571
|
} catch (error) {
|
|
505
572
|
halt(error.stderr);
|
|
506
573
|
}
|
|
507
|
-
logTitle(
|
|
574
|
+
logTitle(
|
|
575
|
+
`Email configuration for \u201C${configName}\u201D customer configuration is deployed.`
|
|
576
|
+
);
|
|
508
577
|
logDataTable({ "Deploy URL:": deployUrl });
|
|
509
578
|
process.on("exit", () => {
|
|
510
579
|
notify({
|
|
@@ -519,14 +588,16 @@ var assertOptionsValid6 = (options) => {
|
|
|
519
588
|
assertProfileValid(profile);
|
|
520
589
|
};
|
|
521
590
|
var assertEmailConfigPathExists = (distPath) => {
|
|
522
|
-
if (!
|
|
591
|
+
if (!existsSync3(distPath)) {
|
|
523
592
|
halt("Email config folder does not exists. Nothing to deploy.", 0);
|
|
524
593
|
}
|
|
525
594
|
};
|
|
526
595
|
var assertBucketValid = (tag) => {
|
|
527
596
|
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
528
597
|
if (!regex.test(tag)) {
|
|
529
|
-
halt(
|
|
598
|
+
halt(
|
|
599
|
+
`Flag \u201C--bucket\u201D has forbidden format. Allowed format: ${regex.toString()}.`
|
|
600
|
+
);
|
|
530
601
|
}
|
|
531
602
|
};
|
|
532
603
|
var assertIsNotCore = () => {
|
|
@@ -547,10 +618,42 @@ process.on("SIGINT", () => {
|
|
|
547
618
|
process.exit(1);
|
|
548
619
|
});
|
|
549
620
|
var cli = createCommand().name(package_default.name).version(package_default.version, "-v, --version");
|
|
550
|
-
cli.command("dev").description(
|
|
621
|
+
cli.command("dev").description(
|
|
622
|
+
"Run the local development server for Tamaro Core or a particular customer configuration"
|
|
623
|
+
).option(
|
|
624
|
+
"--local-core",
|
|
625
|
+
"Load Tamaro Core from localhost:1234 instead of the CDN",
|
|
626
|
+
false
|
|
627
|
+
).option(
|
|
628
|
+
"--https",
|
|
629
|
+
"Let local web server serve Tamaro with SSL encryption",
|
|
630
|
+
false
|
|
631
|
+
).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").action(async (options) => {
|
|
551
632
|
await dev(options);
|
|
552
633
|
});
|
|
553
|
-
cli.command("build").description(
|
|
634
|
+
cli.command("build").description(
|
|
635
|
+
"Build an optimised (minified) bundle of Tamaro Core or a customer configuration"
|
|
636
|
+
).option(
|
|
637
|
+
"--local-core",
|
|
638
|
+
"Load Tamaro Core from localhost:1234 instead of the CDN",
|
|
639
|
+
false
|
|
640
|
+
).option("--analyze", 'Generate bundle statistics to "reports" folder', false).option("--serve", "Run the generated bundle with a local web server", false).option(
|
|
641
|
+
"--https",
|
|
642
|
+
"Let local web server serve Tamaro with SSL encryption",
|
|
643
|
+
false
|
|
644
|
+
).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option(
|
|
645
|
+
"--deploy",
|
|
646
|
+
"Deploy Tamaro Core or a customer configuration bundle to AWS S3",
|
|
647
|
+
false
|
|
648
|
+
).option(
|
|
649
|
+
"--tag <tag>",
|
|
650
|
+
"Tag which should be used for the deployment of the bundle",
|
|
651
|
+
DEFAULT_TAG
|
|
652
|
+
).option(
|
|
653
|
+
"--profile <profile>",
|
|
654
|
+
"AWS profile which should be used for the deployment of the bundle",
|
|
655
|
+
DEFAULT_AWS_PROFILE
|
|
656
|
+
).action(async (options) => {
|
|
554
657
|
await build(options);
|
|
555
658
|
if (options.serve) {
|
|
556
659
|
await serve(options);
|
|
@@ -559,16 +662,47 @@ cli.command("build").description("Build an optimised (minified) bundle of Tamaro
|
|
|
559
662
|
await deploy(options);
|
|
560
663
|
}
|
|
561
664
|
});
|
|
562
|
-
cli.command("serve").description("Run a local web server for pre-built bundle").option("--port <port>", "Web server port", `${DEFAULT_PORT}`).
|
|
665
|
+
cli.command("serve").description("Run a local web server for pre-built bundle").option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option(
|
|
666
|
+
"--https",
|
|
667
|
+
"Let local web server serve Tamaro with SSL encryption",
|
|
668
|
+
false
|
|
669
|
+
).action(async (options) => {
|
|
563
670
|
await serve(options);
|
|
564
671
|
});
|
|
565
|
-
cli.command("deploy").description(
|
|
672
|
+
cli.command("deploy").description(
|
|
673
|
+
"Deploy a pre-built Tamaro Core or customer configuration bundle to AWS S3"
|
|
674
|
+
).option(
|
|
675
|
+
"--tag <tag>",
|
|
676
|
+
"Tag which should be used for the deployment of the bundle",
|
|
677
|
+
DEFAULT_TAG
|
|
678
|
+
).option(
|
|
679
|
+
"--profile <profile>",
|
|
680
|
+
"AWS profile which should be used for the deployment of the bundle",
|
|
681
|
+
DEFAULT_AWS_PROFILE
|
|
682
|
+
).action(async (options) => {
|
|
566
683
|
await deploy(options);
|
|
567
684
|
});
|
|
568
|
-
cli.command("list-deployed").description(
|
|
685
|
+
cli.command("list-deployed").description(
|
|
686
|
+
"List deployments of Tamaro Core or a particular customer configuration"
|
|
687
|
+
).option(
|
|
688
|
+
"--config <config>",
|
|
689
|
+
"Configuration name (default: current customer configuration)"
|
|
690
|
+
).option(
|
|
691
|
+
"--profile <profile>",
|
|
692
|
+
"AWS profile which should be used for fetching deployments",
|
|
693
|
+
DEFAULT_AWS_PROFILE
|
|
694
|
+
).action(async (options) => {
|
|
569
695
|
await listDeployed(options);
|
|
570
696
|
});
|
|
571
|
-
cli.command("deploy-email-config").description("Deploy a widget\u2019s email configuration to AWS S3").option(
|
|
697
|
+
cli.command("deploy-email-config").description("Deploy a widget\u2019s email configuration to AWS S3").option(
|
|
698
|
+
"--bucket <bucket>",
|
|
699
|
+
"AWS S3 bucket where it should be deployed",
|
|
700
|
+
DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET
|
|
701
|
+
).option(
|
|
702
|
+
"--profile <profile>",
|
|
703
|
+
"AWS profile which should be used for the deployment of email configuration",
|
|
704
|
+
DEFAULT_AWS_PROFILE
|
|
705
|
+
).action(async (options) => {
|
|
572
706
|
await deployEmailConfig(options);
|
|
573
707
|
});
|
|
574
708
|
(async () => {
|