@raisenow/tamaro-cli 1.0.14 → 1.0.15
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/dist/{chunk-IBQ4UW3S.js → chunk-BWJBN44Y.js} +5 -5
- package/dist/cli.js +38 -37
- package/dist/webpack.config.js +1 -1
- package/package.json +13 -13
- package/src/commands/build.ts +3 -3
- package/src/commands/deploy-email-config.ts +6 -6
- package/src/commands/deploy.ts +12 -9
- package/src/commands/dev.ts +3 -3
- package/src/commands/list-deployed.ts +3 -3
- package/src/commands/serve.ts +2 -2
- package/src/lib/aws.ts +3 -3
- package/src/lib/command.ts +2 -2
- package/src/lib/env.ts +3 -3
|
@@ -136,9 +136,9 @@ import stripIndent3 from "strip-indent";
|
|
|
136
136
|
|
|
137
137
|
// src/lib/command.ts
|
|
138
138
|
import { execaCommandSync } from "execa";
|
|
139
|
-
var
|
|
139
|
+
var halt = (message, exitCode = 1) => {
|
|
140
140
|
logError(message);
|
|
141
|
-
process.exit(
|
|
141
|
+
process.exit(exitCode);
|
|
142
142
|
};
|
|
143
143
|
var prepareCommand = (cmd) => {
|
|
144
144
|
return cmd.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
|
|
@@ -216,10 +216,10 @@ var assertEnvValid = (env) => {
|
|
|
216
216
|
}
|
|
217
217
|
if (envs.length !== 0) {
|
|
218
218
|
if (!env) {
|
|
219
|
-
|
|
219
|
+
halt("Flag \u201C--env\u201D is required.");
|
|
220
220
|
}
|
|
221
221
|
if (!envs.includes(env)) {
|
|
222
|
-
|
|
222
|
+
halt(stripIndent3(`
|
|
223
223
|
Flag \u201C--env\u201D has wrong value.
|
|
224
224
|
Available values are: ${envs.map((v) => `\u201C${v}\u201D`).join(", ")}.
|
|
225
225
|
`));
|
|
@@ -244,7 +244,7 @@ export {
|
|
|
244
244
|
getPaths,
|
|
245
245
|
getRelativePaths,
|
|
246
246
|
getIfCoreFns,
|
|
247
|
-
|
|
247
|
+
halt,
|
|
248
248
|
runCommandSync,
|
|
249
249
|
getEnvVars,
|
|
250
250
|
assertEnvValid
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
assertEnvValid,
|
|
4
|
-
fail,
|
|
5
4
|
getIfCoreFns,
|
|
6
5
|
getPaths,
|
|
7
6
|
getWidgetUuid,
|
|
7
|
+
halt,
|
|
8
8
|
logCommand,
|
|
9
9
|
logDataTable,
|
|
10
10
|
logError,
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
resolveBin,
|
|
13
13
|
resolveOwn,
|
|
14
14
|
runCommandSync
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BWJBN44Y.js";
|
|
16
16
|
|
|
17
17
|
// src/cli.ts
|
|
18
18
|
import { createCommand } from "commander";
|
|
19
19
|
|
|
20
20
|
// package.json
|
|
21
21
|
var name = "@raisenow/tamaro-cli";
|
|
22
|
-
var version = "1.0.
|
|
22
|
+
var version = "1.0.15";
|
|
23
23
|
var author = {
|
|
24
24
|
name: "RaiseNow",
|
|
25
25
|
email: "development@raisenow.com"
|
|
@@ -51,35 +51,35 @@ var dependencies = {
|
|
|
51
51
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
|
52
52
|
"@statoscope/webpack-plugin": "^5.20.1",
|
|
53
53
|
"@types/columnify": "^1.5.1",
|
|
54
|
-
"@types/lodash": "^4.14.
|
|
55
|
-
"@types/node": "^17.0.
|
|
54
|
+
"@types/lodash": "^4.14.182",
|
|
55
|
+
"@types/node": "^17.0.26",
|
|
56
56
|
"@types/node-notifier": "^8.0.2",
|
|
57
57
|
"@types/resolve-bin": "^0.4.1",
|
|
58
58
|
"@types/webpack-config-utils": "^2.3.1",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
60
|
-
"@typescript-eslint/parser": "^5.
|
|
61
|
-
autoprefixer: "^10.4.
|
|
62
|
-
"babel-loader": "^8.2.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
60
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
61
|
+
autoprefixer: "^10.4.5",
|
|
62
|
+
"babel-loader": "^8.2.5",
|
|
63
63
|
"babel-plugin-lodash": "^3.3.4",
|
|
64
64
|
chalk: "^5.0.1",
|
|
65
65
|
"clean-webpack-plugin": "^4.0.0",
|
|
66
66
|
columnify: "^1.6.0",
|
|
67
|
-
commander: "^9.
|
|
67
|
+
commander: "^9.2.0",
|
|
68
68
|
"copy-webpack-plugin": "^10.2.4",
|
|
69
|
-
"core-js": "^3.
|
|
69
|
+
"core-js": "^3.22.2",
|
|
70
70
|
"css-loader": "^6.7.1",
|
|
71
71
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
72
72
|
dotenv: "^16.0.0",
|
|
73
73
|
"dotenv-expand": "^8.0.3",
|
|
74
74
|
"escape-string-regexp": "^5.0.0",
|
|
75
|
-
eslint: "^8.
|
|
75
|
+
eslint: "^8.14.0",
|
|
76
76
|
"eslint-config-prettier": "^8.5.0",
|
|
77
77
|
"eslint-plugin-node": "^11.1.0",
|
|
78
78
|
"eslint-plugin-promise": "^6.0.0",
|
|
79
79
|
"eslint-webpack-plugin": "^3.1.1",
|
|
80
80
|
execa: "^6.1.0",
|
|
81
81
|
"file-loader": "^6.2.0",
|
|
82
|
-
"fork-ts-checker-webpack-plugin": "^7.2.
|
|
82
|
+
"fork-ts-checker-webpack-plugin": "^7.2.7",
|
|
83
83
|
glob: "^8.0.1",
|
|
84
84
|
"html-loader": "^3.1.0",
|
|
85
85
|
"html-webpack-plugin": "^5.5.0",
|
|
@@ -94,13 +94,13 @@ var dependencies = {
|
|
|
94
94
|
prettier: "^2.6.2",
|
|
95
95
|
"react-refresh": "^0.12.0",
|
|
96
96
|
"resolve-url-loader": "^5.0.0",
|
|
97
|
-
sass: "^1.50.
|
|
97
|
+
sass: "^1.50.1",
|
|
98
98
|
"sass-loader": "^12.6.0",
|
|
99
99
|
"source-map-loader": "^3.0.1",
|
|
100
100
|
"strip-indent": "^4.0.0",
|
|
101
101
|
"style-loader": "^3.3.1",
|
|
102
102
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
103
|
-
tsup: "^5.12.
|
|
103
|
+
tsup: "^5.12.6",
|
|
104
104
|
typescript: "^4.6.3",
|
|
105
105
|
"url-loader": "^4.1.1",
|
|
106
106
|
webpack: "^5.72.0",
|
|
@@ -151,10 +151,10 @@ var assertOptionsValid = (options) => {
|
|
|
151
151
|
const { localCore, port, env } = options;
|
|
152
152
|
const { ifCore } = getIfCoreFns();
|
|
153
153
|
if (ifCore() && localCore) {
|
|
154
|
-
|
|
154
|
+
halt("Flag \u201C--local-core\u201D is redundant if running in Tamaro Core context.");
|
|
155
155
|
}
|
|
156
156
|
if (isNaN(Number(port))) {
|
|
157
|
-
|
|
157
|
+
halt("Flag \u201C--port\u201D should be a number.");
|
|
158
158
|
}
|
|
159
159
|
assertEnvValid(env);
|
|
160
160
|
};
|
|
@@ -211,7 +211,7 @@ var assertProfileValid = (profile) => {
|
|
|
211
211
|
Check the wiki for more information:
|
|
212
212
|
https://raisenow.atlassian.net/wiki/x/lIrWvg
|
|
213
213
|
`);
|
|
214
|
-
|
|
214
|
+
halt(message);
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
var getAvailableProfiles = () => {
|
|
@@ -228,7 +228,7 @@ var login = (options) => {
|
|
|
228
228
|
execaCommandSync(`aws sso login ${flags}`, { stdio: "inherit" });
|
|
229
229
|
console.log("");
|
|
230
230
|
} catch (error) {
|
|
231
|
-
|
|
231
|
+
halt("Login failed.");
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
var prepareFlags2 = (flags, options) => {
|
|
@@ -286,10 +286,10 @@ var assertOptionsValid2 = (options) => {
|
|
|
286
286
|
const { localCore, deploy: deploy2, profile, env } = options;
|
|
287
287
|
const { ifCore } = getIfCoreFns();
|
|
288
288
|
if (ifCore() && localCore) {
|
|
289
|
-
|
|
289
|
+
halt("Flag \u201C--local-core\u201D is redundant if running in Tamaro Core context.");
|
|
290
290
|
}
|
|
291
291
|
if (localCore && deploy2) {
|
|
292
|
-
|
|
292
|
+
halt("Flags \u201C--local-core\u201D and \u201C--deploy\u201D must not be used together.");
|
|
293
293
|
}
|
|
294
294
|
assertProfileValid(profile);
|
|
295
295
|
assertEnvValid(env);
|
|
@@ -307,6 +307,7 @@ var prepareFlags3 = (flags, options) => {
|
|
|
307
307
|
|
|
308
308
|
// src/commands/deploy.ts
|
|
309
309
|
import { existsSync } from "fs";
|
|
310
|
+
import stripIndent3 from "strip-indent";
|
|
310
311
|
var deploy = async (options) => {
|
|
311
312
|
const { ifCore } = getIfCoreFns();
|
|
312
313
|
const paths = getPaths(ifCore);
|
|
@@ -330,7 +331,7 @@ var deploy = async (options) => {
|
|
|
330
331
|
try {
|
|
331
332
|
withAwsAuthenticate(() => runCommandSync(cmdSyncAll, { stdout: "inherit" }), options);
|
|
332
333
|
} catch (error) {
|
|
333
|
-
|
|
334
|
+
halt(error.stderr);
|
|
334
335
|
}
|
|
335
336
|
const cmdCpEntry = `
|
|
336
337
|
aws s3 cp ${paths.appDist}/${entryFilename} ${deployUrl}/${entryFilename}
|
|
@@ -343,7 +344,7 @@ var deploy = async (options) => {
|
|
|
343
344
|
try {
|
|
344
345
|
withAwsAuthenticate(() => runCommandSync(cmdCpEntry, { stdout: "inherit" }), options);
|
|
345
346
|
} catch (error) {
|
|
346
|
-
|
|
347
|
+
halt(error.stderr);
|
|
347
348
|
}
|
|
348
349
|
const cmdInvalidateCache = `
|
|
349
350
|
aws cloudfront create-invalidation
|
|
@@ -356,7 +357,7 @@ var deploy = async (options) => {
|
|
|
356
357
|
try {
|
|
357
358
|
withAwsAuthenticate(() => runCommandSync(cmdInvalidateCache), options);
|
|
358
359
|
} catch (error) {
|
|
359
|
-
|
|
360
|
+
halt(error.stderr);
|
|
360
361
|
}
|
|
361
362
|
const demoPage = `https://${AWS_S3_BUCKET}/${configName}/${tag}/index.html`;
|
|
362
363
|
const entryPoint = `https://${AWS_S3_BUCKET}/${configName}/${tag}/${entryFilename}`;
|
|
@@ -384,16 +385,16 @@ var assertOptionsValid3 = (options) => {
|
|
|
384
385
|
};
|
|
385
386
|
var assertDistPathExists = (distPath) => {
|
|
386
387
|
if (!existsSync(distPath)) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
halt(stripIndent3(`
|
|
389
|
+
Dist folder does not exists.
|
|
390
|
+
Make sure you have built the bundle before trying to deploy it.
|
|
391
|
+
`));
|
|
391
392
|
}
|
|
392
393
|
};
|
|
393
394
|
var assertTagValid = (tag) => {
|
|
394
395
|
const regex = /^[a-zA-Z0-9-_.]+$/;
|
|
395
396
|
if (!regex.test(tag)) {
|
|
396
|
-
|
|
397
|
+
halt(`Flag \u201C--tag\u201D has forbidden format. Allowed format: ${regex}.`);
|
|
397
398
|
}
|
|
398
399
|
};
|
|
399
400
|
var prepareFlags4 = (flags, options) => {
|
|
@@ -419,7 +420,7 @@ var serve = async (options) => {
|
|
|
419
420
|
var assertOptionsValid4 = (options) => {
|
|
420
421
|
const { port } = options;
|
|
421
422
|
if (isNaN(Number(port))) {
|
|
422
|
-
|
|
423
|
+
halt('Flag "--port" should be a number.');
|
|
423
424
|
}
|
|
424
425
|
};
|
|
425
426
|
var prepareFlags5 = async (flags, options) => {
|
|
@@ -448,7 +449,7 @@ var listDeployed = async (options) => {
|
|
|
448
449
|
} catch (error) {
|
|
449
450
|
out = error.stdout;
|
|
450
451
|
if (error.stderr) {
|
|
451
|
-
|
|
452
|
+
halt(error.stderr);
|
|
452
453
|
}
|
|
453
454
|
}
|
|
454
455
|
const lines = out.split("\n");
|
|
@@ -475,7 +476,7 @@ var assertConfigValid = (config) => {
|
|
|
475
476
|
}
|
|
476
477
|
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
477
478
|
if (!regex.test(config)) {
|
|
478
|
-
|
|
479
|
+
halt(`Flag \u201C--config\u201D has forbidden format. Allowed format: ${regex}.`);
|
|
479
480
|
}
|
|
480
481
|
};
|
|
481
482
|
var prepareFlags6 = (flags, options) => {
|
|
@@ -493,8 +494,8 @@ var deployEmailConfig = async (options) => {
|
|
|
493
494
|
const paths = getPaths(ifCore);
|
|
494
495
|
const emailConfigPath = `${paths.app}/email-config`;
|
|
495
496
|
assertOptionsValid6(options);
|
|
496
|
-
assertEmailConfigPathExists(emailConfigPath);
|
|
497
497
|
assertIsNotCore();
|
|
498
|
+
assertEmailConfigPathExists(emailConfigPath);
|
|
498
499
|
const flags = prepareFlags7([], options).join(" ");
|
|
499
500
|
const { bucket } = options;
|
|
500
501
|
const configName = getWidgetUuid();
|
|
@@ -510,7 +511,7 @@ var deployEmailConfig = async (options) => {
|
|
|
510
511
|
try {
|
|
511
512
|
withAwsAuthenticate(() => runCommandSync(cmd, { stdout: "inherit" }), options);
|
|
512
513
|
} catch (error) {
|
|
513
|
-
|
|
514
|
+
halt(error.stderr);
|
|
514
515
|
}
|
|
515
516
|
logTitle(`Email configuration for \u201C${configName}\u201D customer configuration is deployed.`);
|
|
516
517
|
logDataTable({ "Deploy URL:": deployUrl });
|
|
@@ -528,19 +529,19 @@ var assertOptionsValid6 = (options) => {
|
|
|
528
529
|
};
|
|
529
530
|
var assertEmailConfigPathExists = (distPath) => {
|
|
530
531
|
if (!existsSync2(distPath)) {
|
|
531
|
-
|
|
532
|
+
halt("Email config folder does not exists. Nothing to deploy.", 0);
|
|
532
533
|
}
|
|
533
534
|
};
|
|
534
535
|
var assertBucketValid = (tag) => {
|
|
535
536
|
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
536
537
|
if (!regex.test(tag)) {
|
|
537
|
-
|
|
538
|
+
halt(`Flag \u201C--bucket\u201D has forbidden format. Allowed format: ${regex}.`);
|
|
538
539
|
}
|
|
539
540
|
};
|
|
540
541
|
var assertIsNotCore = () => {
|
|
541
542
|
const { ifCore } = getIfCoreFns();
|
|
542
543
|
if (ifCore()) {
|
|
543
|
-
|
|
544
|
+
halt("You cannot deploy widget email configuration for Tamaro Core.");
|
|
544
545
|
}
|
|
545
546
|
};
|
|
546
547
|
var prepareFlags7 = (flags, options) => {
|
package/dist/webpack.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raisenow/tamaro-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "RaiseNow",
|
|
6
6
|
"email": "development@raisenow.com"
|
|
@@ -32,35 +32,35 @@
|
|
|
32
32
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
|
33
33
|
"@statoscope/webpack-plugin": "^5.20.1",
|
|
34
34
|
"@types/columnify": "^1.5.1",
|
|
35
|
-
"@types/lodash": "^4.14.
|
|
36
|
-
"@types/node": "^17.0.
|
|
35
|
+
"@types/lodash": "^4.14.182",
|
|
36
|
+
"@types/node": "^17.0.26",
|
|
37
37
|
"@types/node-notifier": "^8.0.2",
|
|
38
38
|
"@types/resolve-bin": "^0.4.1",
|
|
39
39
|
"@types/webpack-config-utils": "^2.3.1",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
42
|
-
"autoprefixer": "^10.4.
|
|
43
|
-
"babel-loader": "^8.2.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
41
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
42
|
+
"autoprefixer": "^10.4.5",
|
|
43
|
+
"babel-loader": "^8.2.5",
|
|
44
44
|
"babel-plugin-lodash": "^3.3.4",
|
|
45
45
|
"chalk": "^5.0.1",
|
|
46
46
|
"clean-webpack-plugin": "^4.0.0",
|
|
47
47
|
"columnify": "^1.6.0",
|
|
48
|
-
"commander": "^9.
|
|
48
|
+
"commander": "^9.2.0",
|
|
49
49
|
"copy-webpack-plugin": "^10.2.4",
|
|
50
|
-
"core-js": "^3.
|
|
50
|
+
"core-js": "^3.22.2",
|
|
51
51
|
"css-loader": "^6.7.1",
|
|
52
52
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
53
53
|
"dotenv": "^16.0.0",
|
|
54
54
|
"dotenv-expand": "^8.0.3",
|
|
55
55
|
"escape-string-regexp": "^5.0.0",
|
|
56
|
-
"eslint": "^8.
|
|
56
|
+
"eslint": "^8.14.0",
|
|
57
57
|
"eslint-config-prettier": "^8.5.0",
|
|
58
58
|
"eslint-plugin-node": "^11.1.0",
|
|
59
59
|
"eslint-plugin-promise": "^6.0.0",
|
|
60
60
|
"eslint-webpack-plugin": "^3.1.1",
|
|
61
61
|
"execa": "^6.1.0",
|
|
62
62
|
"file-loader": "^6.2.0",
|
|
63
|
-
"fork-ts-checker-webpack-plugin": "^7.2.
|
|
63
|
+
"fork-ts-checker-webpack-plugin": "^7.2.7",
|
|
64
64
|
"glob": "^8.0.1",
|
|
65
65
|
"html-loader": "^3.1.0",
|
|
66
66
|
"html-webpack-plugin": "^5.5.0",
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"prettier": "^2.6.2",
|
|
76
76
|
"react-refresh": "^0.12.0",
|
|
77
77
|
"resolve-url-loader": "^5.0.0",
|
|
78
|
-
"sass": "^1.50.
|
|
78
|
+
"sass": "^1.50.1",
|
|
79
79
|
"sass-loader": "^12.6.0",
|
|
80
80
|
"source-map-loader": "^3.0.1",
|
|
81
81
|
"strip-indent": "^4.0.0",
|
|
82
82
|
"style-loader": "^3.3.1",
|
|
83
83
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
84
|
-
"tsup": "^5.12.
|
|
84
|
+
"tsup": "^5.12.6",
|
|
85
85
|
"typescript": "^4.6.3",
|
|
86
86
|
"url-loader": "^4.1.1",
|
|
87
87
|
"webpack": "^5.72.0",
|
package/src/commands/build.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {assertEnvValid} from 'lib/env'
|
|
11
11
|
import {logCommand, logTitle} from 'lib/logging'
|
|
12
12
|
import {notify} from 'lib/notifier'
|
|
13
|
-
import {
|
|
13
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
14
14
|
import {DeployOptions} from 'commands/deploy'
|
|
15
15
|
|
|
16
16
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -74,11 +74,11 @@ const assertOptionsValid = (options: BuildOptions & DeployOptions) => {
|
|
|
74
74
|
const {ifCore} = getIfCoreFns()
|
|
75
75
|
|
|
76
76
|
if (ifCore() && localCore) {
|
|
77
|
-
|
|
77
|
+
halt('Flag “--local-core” is redundant if running in Tamaro Core context.')
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (localCore && deploy) {
|
|
81
|
-
|
|
81
|
+
halt('Flags “--local-core” and “--deploy” must not be used together.')
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
assertProfileValid(profile)
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {logCommand, logDataTable, logTitle} from 'lib/logging'
|
|
9
9
|
import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
|
|
10
10
|
import {notify} from 'lib/notifier'
|
|
11
|
-
import {
|
|
11
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
12
12
|
|
|
13
13
|
///////////////////////////////////////////////////////////////////////////////
|
|
14
14
|
|
|
@@ -26,8 +26,8 @@ export const deployEmailConfig = async (
|
|
|
26
26
|
const emailConfigPath = `${paths.app}/email-config`
|
|
27
27
|
|
|
28
28
|
assertOptionsValid(options)
|
|
29
|
-
assertEmailConfigPathExists(emailConfigPath)
|
|
30
29
|
assertIsNotCore()
|
|
30
|
+
assertEmailConfigPathExists(emailConfigPath)
|
|
31
31
|
|
|
32
32
|
const flags = prepareFlags([], options).join(' ')
|
|
33
33
|
const {bucket} = options
|
|
@@ -48,7 +48,7 @@ export const deployEmailConfig = async (
|
|
|
48
48
|
try {
|
|
49
49
|
withAwsAuthenticate(() => runCommandSync(cmd, {stdout: 'inherit'}), options)
|
|
50
50
|
} catch (error: any) {
|
|
51
|
-
|
|
51
|
+
halt(error.stderr)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -81,7 +81,7 @@ const assertOptionsValid = (options: DeployEmailConfigOptions) => {
|
|
|
81
81
|
|
|
82
82
|
const assertEmailConfigPathExists = (distPath: string) => {
|
|
83
83
|
if (!existsSync(distPath)) {
|
|
84
|
-
|
|
84
|
+
halt('Email config folder does not exists. Nothing to deploy.', 0)
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ const assertBucketValid = (tag: string) => {
|
|
|
91
91
|
const regex = /^[a-zA-Z0-9-_]+$/
|
|
92
92
|
|
|
93
93
|
if (!regex.test(tag)) {
|
|
94
|
-
|
|
94
|
+
halt(`Flag “--bucket” has forbidden format. Allowed format: ${regex}.`)
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -101,7 +101,7 @@ const assertIsNotCore = () => {
|
|
|
101
101
|
const {ifCore} = getIfCoreFns()
|
|
102
102
|
|
|
103
103
|
if (ifCore()) {
|
|
104
|
-
|
|
104
|
+
halt('You cannot deploy widget email configuration for Tamaro Core.')
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
package/src/commands/deploy.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {existsSync} from 'fs'
|
|
2
|
+
import stripIndent from 'strip-indent'
|
|
2
3
|
import {
|
|
3
4
|
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
4
5
|
AWS_S3_BUCKET,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
|
|
14
15
|
import {logCommand, logDataTable, logTitle} from 'lib/logging'
|
|
15
16
|
import {notify} from 'lib/notifier'
|
|
16
|
-
import {
|
|
17
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
17
18
|
|
|
18
19
|
///////////////////////////////////////////////////////////////////////////////
|
|
19
20
|
|
|
@@ -57,7 +58,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
|
|
|
57
58
|
options,
|
|
58
59
|
)
|
|
59
60
|
} catch (error: any) {
|
|
60
|
-
|
|
61
|
+
halt(error.stderr)
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -79,7 +80,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
|
|
|
79
80
|
options,
|
|
80
81
|
)
|
|
81
82
|
} catch (error: any) {
|
|
82
|
-
|
|
83
|
+
halt(error.stderr)
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -99,7 +100,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
|
|
|
99
100
|
// ignore output
|
|
100
101
|
withAwsAuthenticate(() => runCommandSync(cmdInvalidateCache), options)
|
|
101
102
|
} catch (error: any) {
|
|
102
|
-
|
|
103
|
+
halt(error.stderr)
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -140,10 +141,12 @@ const assertOptionsValid = (options: DeployOptions) => {
|
|
|
140
141
|
|
|
141
142
|
const assertDistPathExists = (distPath: string) => {
|
|
142
143
|
if (!existsSync(distPath)) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
halt(
|
|
145
|
+
stripIndent(`
|
|
146
|
+
Dist folder does not exists.
|
|
147
|
+
Make sure you have built the bundle before trying to deploy it.
|
|
148
|
+
`),
|
|
149
|
+
)
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
|
|
@@ -153,7 +156,7 @@ const assertTagValid = (tag: string) => {
|
|
|
153
156
|
const regex = /^[a-zA-Z0-9-_.]+$/
|
|
154
157
|
|
|
155
158
|
if (!regex.test(tag)) {
|
|
156
|
-
|
|
159
|
+
halt(`Flag “--tag” has forbidden format. Allowed format: ${regex}.`)
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
|
package/src/commands/dev.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {getPortPromise} from 'portfinder'
|
|
2
2
|
import {getIfCoreFns, resolveBin, resolveOwn} from 'lib/resolve'
|
|
3
3
|
import {logCommand, logTitle} from 'lib/logging'
|
|
4
|
-
import {
|
|
4
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
5
5
|
import {assertEnvValid} from 'lib/env'
|
|
6
6
|
|
|
7
7
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -43,11 +43,11 @@ const assertOptionsValid = (options: DevOptions) => {
|
|
|
43
43
|
const {ifCore} = getIfCoreFns()
|
|
44
44
|
|
|
45
45
|
if (ifCore() && localCore) {
|
|
46
|
-
|
|
46
|
+
halt('Flag “--local-core” is redundant if running in Tamaro Core context.')
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (isNaN(Number(port))) {
|
|
50
|
-
|
|
50
|
+
halt('Flag “--port” should be a number.')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
assertEnvValid(env)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from 'lib/aws'
|
|
8
8
|
import {getIfCoreFns, getWidgetUuid} from 'lib/resolve'
|
|
9
9
|
import {logCommand, logTitle} from 'lib/logging'
|
|
10
|
-
import {
|
|
10
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
11
11
|
|
|
12
12
|
///////////////////////////////////////////////////////////////////////////////
|
|
13
13
|
|
|
@@ -47,7 +47,7 @@ export const listDeployed = async (
|
|
|
47
47
|
out = error.stdout
|
|
48
48
|
|
|
49
49
|
if (error.stderr) {
|
|
50
|
-
|
|
50
|
+
halt(error.stderr)
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -88,7 +88,7 @@ const assertConfigValid = (config: string | undefined) => {
|
|
|
88
88
|
const regex = /^[a-zA-Z0-9-_]+$/
|
|
89
89
|
|
|
90
90
|
if (!regex.test(config)) {
|
|
91
|
-
|
|
91
|
+
halt(`Flag “--config” has forbidden format. Allowed format: ${regex}.`)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
package/src/commands/serve.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {getPortPromise} from 'portfinder'
|
|
2
2
|
import {getIfCoreFns, getPaths} from 'lib/resolve'
|
|
3
3
|
import {logCommand, logTitle} from 'lib/logging'
|
|
4
|
-
import {
|
|
4
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
5
5
|
|
|
6
6
|
///////////////////////////////////////////////////////////////////////////////
|
|
7
7
|
|
|
@@ -34,7 +34,7 @@ const assertOptionsValid = (options: ServeOptions) => {
|
|
|
34
34
|
const {port} = options
|
|
35
35
|
|
|
36
36
|
if (isNaN(Number(port))) {
|
|
37
|
-
|
|
37
|
+
halt('Flag "--port" should be a number.')
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
package/src/lib/aws.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {execaCommandSync} from 'execa'
|
|
2
2
|
import stripIndent from 'strip-indent'
|
|
3
|
-
import {
|
|
3
|
+
import {halt} from 'lib/command'
|
|
4
4
|
|
|
5
5
|
///////////////////////////////////////////////////////////////////////////////
|
|
6
6
|
|
|
@@ -74,7 +74,7 @@ export const assertProfileValid = (profile: string) => {
|
|
|
74
74
|
https://raisenow.atlassian.net/wiki/x/lIrWvg
|
|
75
75
|
`)
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
halt(message)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -107,7 +107,7 @@ const login = (options: AwsOptions) => {
|
|
|
107
107
|
execaCommandSync(`aws sso login ${flags}`, {stdio: 'inherit'})
|
|
108
108
|
console.log('')
|
|
109
109
|
} catch (error) {
|
|
110
|
-
|
|
110
|
+
halt('Login failed.')
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
package/src/lib/command.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {logError} from 'lib/logging'
|
|
|
3
3
|
|
|
4
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const halt = (message?: string, exitCode = 1) => {
|
|
7
7
|
logError(message)
|
|
8
|
-
process.exit(
|
|
8
|
+
process.exit(exitCode)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
///////////////////////////////////////////////////////////////////////////////
|
package/src/lib/env.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {expand as dotenvExpand} from 'dotenv-expand'
|
|
|
6
6
|
import {config as dotenvConfig} from 'dotenv'
|
|
7
7
|
import stripIndent from 'strip-indent'
|
|
8
8
|
import {getIfCoreFns, getPaths, getWidgetUuid, resolveApp} from 'lib/resolve'
|
|
9
|
-
import {
|
|
9
|
+
import {halt} from 'lib/command'
|
|
10
10
|
|
|
11
11
|
///////////////////////////////////////////////////////////////////////////////
|
|
12
12
|
|
|
@@ -129,11 +129,11 @@ export const assertEnvValid = (env: string) => {
|
|
|
129
129
|
|
|
130
130
|
if (envs.length !== 0) {
|
|
131
131
|
if (!env) {
|
|
132
|
-
|
|
132
|
+
halt('Flag “--env” is required.')
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
if (!envs.includes(env)) {
|
|
136
|
-
|
|
136
|
+
halt(
|
|
137
137
|
stripIndent(`
|
|
138
138
|
Flag “--env” has wrong value.
|
|
139
139
|
Available values are: ${envs.map((v) => `“${v}”`).join(', ')}.
|