@raisenow/tamaro-cli 1.0.6 → 1.0.10
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/.eslintignore +1 -0
- package/.eslintrc.js +0 -5
- package/.gitignore +2 -1
- package/.nvmrc +1 -1
- package/.prettierignore +1 -0
- package/dist/cli.js +474 -126
- package/dist/webpack.config.js +96 -57
- package/package.json +53 -55
- package/readme.html +55 -0
- package/readme.md +227 -0
- package/src/cli.ts +100 -17
- package/src/commands/build.ts +97 -0
- package/src/commands/deploy-email-config.ts +107 -0
- package/src/commands/deploy.ts +151 -0
- package/src/commands/dev.ts +61 -0
- package/src/commands/list-deployed.ts +102 -0
- package/src/commands/serve.ts +29 -0
- package/src/lib/aws.ts +119 -0
- package/src/lib/helpers.ts +104 -27
- package/src/webpack.config.ts +34 -5
- package/src/assets/rnw-logo.png +0 -0
- package/src/commands/build/index.ts +0 -43
- package/src/commands/deploy/index.ts +0 -25
- package/src/commands/dev/index.ts +0 -32
- package/src/commands/serve/index.ts +0 -12
package/dist/cli.js
CHANGED
|
@@ -6,24 +6,24 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
|
-
var __reExport = (target, module2, desc) => {
|
|
9
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
10
10
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
11
11
|
for (let key of __getOwnPropNames(module2))
|
|
12
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
12
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
13
13
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
14
14
|
}
|
|
15
15
|
return target;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default",
|
|
17
|
+
var __toESM = (module2, isNodeMode) => {
|
|
18
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
// src/cli.ts
|
|
22
|
-
var import_commander =
|
|
22
|
+
var import_commander = require("commander");
|
|
23
23
|
|
|
24
24
|
// package.json
|
|
25
25
|
var name = "@raisenow/tamaro-cli";
|
|
26
|
-
var version = "1.0.
|
|
26
|
+
var version = "1.0.10";
|
|
27
27
|
var author = {
|
|
28
28
|
name: "RaiseNow",
|
|
29
29
|
email: "development@raisenow.com"
|
|
@@ -34,94 +34,92 @@ var scripts = {
|
|
|
34
34
|
start: "npm run dev",
|
|
35
35
|
dev: "npm run build -- --watch --ignore-watch .idea",
|
|
36
36
|
build: "tsup src/cli.ts src/webpack.config.ts --format cjs",
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
docs: "npx -y http-server . --cors -o /readme.html",
|
|
38
|
+
lint: "eslint . --fix && prettier --write ."
|
|
39
39
|
};
|
|
40
40
|
var bin = "dist/cli.js";
|
|
41
41
|
var engines = {
|
|
42
|
-
node: ">=
|
|
42
|
+
node: ">=16",
|
|
43
43
|
npm: ">=8"
|
|
44
44
|
};
|
|
45
45
|
var dependencies = {
|
|
46
|
-
"@babel/cli": "^7.
|
|
47
|
-
"@babel/core": "^7.
|
|
48
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
46
|
+
"@babel/cli": "^7.17.0",
|
|
47
|
+
"@babel/core": "^7.17.0",
|
|
48
|
+
"@babel/plugin-proposal-decorators": "^7.17.0",
|
|
49
49
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
50
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
51
|
-
"@babel/preset-env": "^7.
|
|
52
|
-
"@babel/preset-react": "^7.
|
|
53
|
-
"@babel/preset-typescript": "^7.
|
|
54
|
-
"@babel/runtime-corejs3": "^7.
|
|
55
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
56
|
-
"@statoscope/webpack-plugin": "^5.
|
|
57
|
-
"@svgr/webpack": "^
|
|
50
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
51
|
+
"@babel/preset-env": "^7.16.11",
|
|
52
|
+
"@babel/preset-react": "^7.16.7",
|
|
53
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
54
|
+
"@babel/runtime-corejs3": "^7.17.0",
|
|
55
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
|
|
56
|
+
"@statoscope/webpack-plugin": "^5.20.1",
|
|
57
|
+
"@svgr/webpack": "^6.2.1",
|
|
58
58
|
"@types/columnify": "^1.5.1",
|
|
59
|
-
"@types/
|
|
60
|
-
"@types/css-
|
|
61
|
-
"@types/
|
|
62
|
-
"@types/
|
|
63
|
-
"@types/node": "^16.11.6",
|
|
64
|
-
"@types/node-notifier": "^8.0.1",
|
|
59
|
+
"@types/lodash": "^4.14.178",
|
|
60
|
+
"@types/mini-css-extract-plugin": "^2.5.1",
|
|
61
|
+
"@types/node": "^17.0.16",
|
|
62
|
+
"@types/node-notifier": "^8.0.2",
|
|
65
63
|
"@types/resolve-bin": "^0.4.1",
|
|
66
64
|
"@types/webpack-config-utils": "^2.3.1",
|
|
67
|
-
"@
|
|
68
|
-
"@typescript-eslint/
|
|
69
|
-
|
|
70
|
-
autoprefixer: "^10.3.7",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
66
|
+
"@typescript-eslint/parser": "^5.11.0",
|
|
67
|
+
autoprefixer: "^10.4.2",
|
|
71
68
|
"babel-loader": "^8.2.3",
|
|
72
69
|
"babel-plugin-lodash": "^3.3.4",
|
|
73
70
|
boxen: "^5.1.2",
|
|
74
71
|
chalk: "^4.1.2",
|
|
75
72
|
"clean-webpack-plugin": "^4.0.0",
|
|
76
|
-
columnify: "^1.
|
|
77
|
-
commander: "^
|
|
78
|
-
"copy-webpack-plugin": "^
|
|
79
|
-
"core-js": "^3.
|
|
80
|
-
"css-loader": "^6.
|
|
81
|
-
"css-minimizer-webpack-plugin": "^3.
|
|
73
|
+
columnify: "^1.6.0",
|
|
74
|
+
commander: "^9.0.0",
|
|
75
|
+
"copy-webpack-plugin": "^10.2.4",
|
|
76
|
+
"core-js": "^3.21.0",
|
|
77
|
+
"css-loader": "^6.6.0",
|
|
78
|
+
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
82
79
|
"current-script-polyfill": "^1.0.0",
|
|
83
|
-
dotenv: "^
|
|
84
|
-
"dotenv-expand": "^
|
|
80
|
+
dotenv: "^16.0.0",
|
|
81
|
+
"dotenv-expand": "^8.0.1",
|
|
85
82
|
"element-closest": "^3.0.2",
|
|
86
83
|
"escape-string-regexp": "^4.0.0",
|
|
87
|
-
eslint: "^8.
|
|
84
|
+
eslint: "^8.8.0",
|
|
88
85
|
"eslint-config-prettier": "^8.3.0",
|
|
89
86
|
"eslint-plugin-node": "^11.1.0",
|
|
90
87
|
"eslint-plugin-prettier": "^4.0.0",
|
|
91
|
-
"eslint-plugin-promise": "^
|
|
88
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
92
89
|
"eslint-webpack-plugin": "^3.1.0",
|
|
93
90
|
execa: "^5.1.1",
|
|
94
91
|
"file-loader": "^6.2.0",
|
|
95
|
-
"fork-ts-checker-webpack-plugin": "^
|
|
92
|
+
"fork-ts-checker-webpack-plugin": "^7.1.1",
|
|
96
93
|
glob: "^7.2.0",
|
|
97
|
-
"html-loader": "^3.
|
|
94
|
+
"html-loader": "^3.1.0",
|
|
98
95
|
"html-webpack-plugin": "^5.5.0",
|
|
99
96
|
"json-loader": "^0.5.7",
|
|
100
97
|
lodash: "^4.17.21",
|
|
101
|
-
"mini-css-extract-plugin": "^2.
|
|
102
|
-
"node-notifier": "^10.0.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
98
|
+
"mini-css-extract-plugin": "^2.5.3",
|
|
99
|
+
"node-notifier": "^10.0.1",
|
|
100
|
+
open: "^8.4.0",
|
|
101
|
+
portfinder: "^1.0.28",
|
|
102
|
+
postcss: "^8.4.6",
|
|
103
|
+
"postcss-custom-properties": "^12.1.4",
|
|
104
|
+
"postcss-loader": "^6.2.1",
|
|
105
|
+
prettier: "^2.5.1",
|
|
106
|
+
"react-refresh": "^0.11.0",
|
|
108
107
|
"resolve-bin": "^1.0.0",
|
|
109
|
-
"resolve-url-loader": "^
|
|
110
|
-
sass: "^1.
|
|
111
|
-
"sass-loader": "^12.
|
|
112
|
-
"source-map-loader": "^3.0.
|
|
108
|
+
"resolve-url-loader": "^5.0.0",
|
|
109
|
+
sass: "^1.49.7",
|
|
110
|
+
"sass-loader": "^12.4.0",
|
|
111
|
+
"source-map-loader": "^3.0.1",
|
|
113
112
|
"strip-indent": "^3.0.0",
|
|
114
113
|
"style-loader": "^3.3.1",
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
typescript: "^4.4.4",
|
|
114
|
+
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
115
|
+
tsup: "^5.11.13",
|
|
116
|
+
typescript: "^4.5.5",
|
|
119
117
|
unfetch: "^4.2.0",
|
|
120
118
|
"url-loader": "^4.1.1",
|
|
121
|
-
webpack: "^5.
|
|
122
|
-
"webpack-cli": "^4.9.
|
|
119
|
+
webpack: "^5.68.0",
|
|
120
|
+
"webpack-cli": "^4.9.2",
|
|
123
121
|
"webpack-config-utils": "^2.3.1",
|
|
124
|
-
"webpack-dev-server": "^4.4
|
|
122
|
+
"webpack-dev-server": "^4.7.4",
|
|
125
123
|
"yaml-loader": "^0.6.0"
|
|
126
124
|
};
|
|
127
125
|
var package_default = {
|
|
@@ -135,25 +133,21 @@ var package_default = {
|
|
|
135
133
|
dependencies
|
|
136
134
|
};
|
|
137
135
|
|
|
138
|
-
// src/commands/dev/index.ts
|
|
139
|
-
var import_execa = __toModule(require("execa"));
|
|
140
|
-
|
|
141
136
|
// src/lib/helpers.ts
|
|
142
|
-
var import_path =
|
|
143
|
-
var import_fs =
|
|
144
|
-
var import_chalk =
|
|
145
|
-
var import_node_notifier =
|
|
146
|
-
var import_webpack_config_utils =
|
|
147
|
-
var import_columnify =
|
|
148
|
-
var import_boxen =
|
|
149
|
-
var import_dotenv_expand =
|
|
150
|
-
var import_dotenv =
|
|
151
|
-
var
|
|
152
|
-
var
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
];
|
|
137
|
+
var import_path = require("path");
|
|
138
|
+
var import_fs = require("fs");
|
|
139
|
+
var import_chalk = __toESM(require("chalk"));
|
|
140
|
+
var import_node_notifier = __toESM(require("node-notifier"));
|
|
141
|
+
var import_webpack_config_utils = require("webpack-config-utils");
|
|
142
|
+
var import_columnify = __toESM(require("columnify"));
|
|
143
|
+
var import_boxen = __toESM(require("boxen"));
|
|
144
|
+
var import_dotenv_expand = require("dotenv-expand");
|
|
145
|
+
var import_dotenv = require("dotenv");
|
|
146
|
+
var import_open = __toESM(require("open"));
|
|
147
|
+
var import_strip_indent = __toESM(require("strip-indent"));
|
|
148
|
+
var import_execa = require("execa");
|
|
149
|
+
var TAMARO_CORE_PACKAGE_NAMES = ["@raisenow/tamaro-core"];
|
|
150
|
+
var TAMARO_CONFIGURATIONS_PACKAGE_NAMES = ["@raisenow/tamaro-configurations"];
|
|
157
151
|
var getIfCoreFns = () => {
|
|
158
152
|
const corePkgPath = resolveApp("package.json");
|
|
159
153
|
const configsPkgPath = resolveApp("../../package.json");
|
|
@@ -169,12 +163,12 @@ var getIfCoreFns = () => {
|
|
|
169
163
|
return (0, import_webpack_config_utils.getIfUtils)({ core: false }, ["core"]);
|
|
170
164
|
}
|
|
171
165
|
}
|
|
172
|
-
|
|
166
|
+
logError((0, import_strip_indent.default)(` You must run "npx @raisenow/tamaro-cli" commands from:
|
|
173
167
|
1. Root of "${import_chalk.default.bold(TAMARO_CORE_PACKAGE_NAMES[0])}" package folder.
|
|
174
168
|
2. Root of particular customer configuration folder of "${import_chalk.default.bold(TAMARO_CONFIGURATIONS_PACKAGE_NAMES[0])}" package.
|
|
175
169
|
You are currently in "${import_chalk.default.bold((0, import_fs.realpathSync)(process.cwd()))}".
|
|
176
|
-
`))
|
|
177
|
-
process.exit(
|
|
170
|
+
`));
|
|
171
|
+
process.exit(1);
|
|
178
172
|
};
|
|
179
173
|
var moduleFileExtensions = ["ts", "tsx", "js", "jsx"];
|
|
180
174
|
var extensions = moduleFileExtensions.map((v) => `.${v}`);
|
|
@@ -209,77 +203,418 @@ var getPaths = (ifCore) => {
|
|
|
209
203
|
appTailwindConfig: void 0
|
|
210
204
|
});
|
|
211
205
|
};
|
|
212
|
-
var
|
|
213
|
-
console.log(
|
|
206
|
+
var logTitle = (title) => {
|
|
207
|
+
console.log(`
|
|
208
|
+
${import_chalk.default.bold(title)}`);
|
|
209
|
+
};
|
|
210
|
+
var logError = (message) => {
|
|
211
|
+
if (message) {
|
|
212
|
+
console.log(import_chalk.default.red(message));
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var fail = (message) => {
|
|
216
|
+
logError(message);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
};
|
|
219
|
+
var logCommand = (command) => {
|
|
220
|
+
console.log(import_chalk.default.dim((0, import_strip_indent.default)(command)));
|
|
221
|
+
};
|
|
222
|
+
var prepareCommand = (command) => {
|
|
223
|
+
return command.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
|
|
224
|
+
};
|
|
225
|
+
var runCommandSync = (command, options) => {
|
|
226
|
+
return (0, import_execa.commandSync)(prepareCommand(command), options);
|
|
227
|
+
};
|
|
228
|
+
var logDataTable = (vars, title) => {
|
|
229
|
+
logTable((0, import_columnify.default)(vars, { showHeaders: false }), title);
|
|
230
|
+
};
|
|
231
|
+
var logTable = (text, title) => {
|
|
232
|
+
let out = "";
|
|
233
|
+
const boxTitle = title ? import_chalk.default.bold(`${title}`) : void 0;
|
|
234
|
+
if (boxTitle) {
|
|
235
|
+
out += `${boxTitle}
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
out += text;
|
|
239
|
+
console.log((0, import_boxen.default)(out, {
|
|
240
|
+
margin: 0,
|
|
241
|
+
padding: {
|
|
242
|
+
top: 0,
|
|
243
|
+
right: 1,
|
|
244
|
+
bottom: 0,
|
|
245
|
+
left: 1
|
|
246
|
+
},
|
|
247
|
+
borderColor: "green"
|
|
248
|
+
}));
|
|
214
249
|
};
|
|
215
250
|
var notify = (args) => {
|
|
216
|
-
const { title, message } = args;
|
|
217
|
-
|
|
251
|
+
const { title, message, target } = args;
|
|
252
|
+
import_node_notifier.default.notify({
|
|
218
253
|
title,
|
|
219
254
|
message,
|
|
220
|
-
contentImage:
|
|
221
|
-
sound: "Funk"
|
|
255
|
+
contentImage: "https://assets.raisenow.io/favicon.png",
|
|
256
|
+
sound: "Funk",
|
|
257
|
+
timeout: 30
|
|
222
258
|
});
|
|
259
|
+
if (target) {
|
|
260
|
+
import_node_notifier.default.on("click", () => {
|
|
261
|
+
(0, import_open.default)(target);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
223
264
|
};
|
|
224
265
|
|
|
225
|
-
// src/commands/dev
|
|
226
|
-
var import_resolve_bin =
|
|
227
|
-
var prepareDevFlags = (options) => {
|
|
228
|
-
const { localCore } = options;
|
|
229
|
-
let flags = [];
|
|
230
|
-
flags = localCore ? [...flags, "--env localCore"] : flags;
|
|
231
|
-
return flags.join(" ");
|
|
232
|
-
};
|
|
266
|
+
// src/commands/dev.ts
|
|
267
|
+
var import_resolve_bin = __toESM(require("resolve-bin"));
|
|
233
268
|
var dev = async (options) => {
|
|
234
|
-
|
|
269
|
+
assertOptionsValid(options);
|
|
270
|
+
const flags = prepareFlags(options);
|
|
271
|
+
const { ifCore } = getIfCoreFns();
|
|
272
|
+
const title = ifCore("Running dev web-server for Tamaro Core \u2026", "Running dev web-server for customer configuration \u2026");
|
|
235
273
|
const wpBin = import_resolve_bin.default.sync("webpack");
|
|
236
274
|
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
237
|
-
const cmd =
|
|
275
|
+
const cmd = `
|
|
276
|
+
${wpBin} serve
|
|
277
|
+
--config ${wpConfig}
|
|
278
|
+
${flags}
|
|
279
|
+
`;
|
|
280
|
+
logTitle(title);
|
|
238
281
|
logCommand(cmd);
|
|
239
|
-
(
|
|
282
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
240
283
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
284
|
+
var assertOptionsValid = (options) => {
|
|
285
|
+
const { localCore } = options;
|
|
286
|
+
const { ifCore } = getIfCoreFns();
|
|
287
|
+
if (ifCore() && localCore) {
|
|
288
|
+
fail('Flag "--local-core" is redundant if running in Tamaro Core context.');
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var prepareFlags = (options) => {
|
|
292
|
+
const { localCore } = options;
|
|
247
293
|
let flags = [];
|
|
248
294
|
flags = localCore ? [...flags, "--env localCore"] : flags;
|
|
249
|
-
flags = analyze ? [...flags, "--env analyze"] : flags;
|
|
250
295
|
return flags.join(" ");
|
|
251
296
|
};
|
|
297
|
+
|
|
298
|
+
// src/commands/build.ts
|
|
299
|
+
var import_resolve_bin2 = __toESM(require("resolve-bin"));
|
|
300
|
+
|
|
301
|
+
// src/lib/aws.ts
|
|
302
|
+
var import_execa2 = require("execa");
|
|
303
|
+
var import_strip_indent2 = __toESM(require("strip-indent"));
|
|
304
|
+
var DEFAULT_AWS_PROFILE = "payments-prod-cs-deployer";
|
|
305
|
+
var runAwsCommandSync = (command, options) => {
|
|
306
|
+
authenticate();
|
|
307
|
+
return (0, import_execa2.commandSync)(prepareCommand(command), options);
|
|
308
|
+
};
|
|
309
|
+
var authenticate = () => {
|
|
310
|
+
if (isSetEnv()) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
checkIdentity();
|
|
315
|
+
} catch (error) {
|
|
316
|
+
login();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
var isSetEnv = () => {
|
|
320
|
+
return !!(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
|
|
321
|
+
};
|
|
322
|
+
var assertProfileValid = (profile) => {
|
|
323
|
+
if (isSetEnv()) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const profiles = getAvailableProfiles();
|
|
327
|
+
if (!profiles.includes(profile)) {
|
|
328
|
+
console.log(`Using AWS profile: \u201C${profile}\u201D`);
|
|
329
|
+
let message;
|
|
330
|
+
if (profiles.length === 0) {
|
|
331
|
+
message = (0, import_strip_indent2.default)(`
|
|
332
|
+
No AWS profiles found.
|
|
333
|
+
`);
|
|
334
|
+
} else {
|
|
335
|
+
message = (0, import_strip_indent2.default)(`
|
|
336
|
+
AWS profile \u201C${profile}\u201D has not been found.
|
|
337
|
+
Available profiles are: ${profiles.map((v) => `\u201C${v}\u201D`).join(", ")}.
|
|
338
|
+
`);
|
|
339
|
+
}
|
|
340
|
+
message += (0, import_strip_indent2.default)(`
|
|
341
|
+
Run \u201Caws configure sso\u201D to set up SSO-enabled profile.
|
|
342
|
+
Check the wiki for more information:
|
|
343
|
+
https://raisenow.atlassian.net/wiki/x/lIrWvg
|
|
344
|
+
`);
|
|
345
|
+
fail(message);
|
|
346
|
+
}
|
|
347
|
+
process.env.AWS_PROFILE = profile;
|
|
348
|
+
};
|
|
349
|
+
var getAvailableProfiles = () => {
|
|
350
|
+
const { stdout } = (0, import_execa2.commandSync)("aws configure list-profiles");
|
|
351
|
+
return stdout.split("\n");
|
|
352
|
+
};
|
|
353
|
+
var checkIdentity = () => {
|
|
354
|
+
(0, import_execa2.commandSync)("aws sts get-caller-identity");
|
|
355
|
+
};
|
|
356
|
+
var login = () => {
|
|
357
|
+
try {
|
|
358
|
+
(0, import_execa2.commandSync)("aws sso login", { stdio: "inherit" });
|
|
359
|
+
console.log("");
|
|
360
|
+
} catch (error) {
|
|
361
|
+
fail("Login failed");
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// src/commands/deploy.ts
|
|
366
|
+
var import_fs2 = require("fs");
|
|
367
|
+
var import_strip_indent3 = __toESM(require("strip-indent"));
|
|
368
|
+
var AWS_S3_BUCKET = "tamaro.raisenow.com";
|
|
369
|
+
var CORE_CONFIG_NAME = "tamaro-core";
|
|
370
|
+
var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
|
|
371
|
+
var DEFAULT_TAG = "latest";
|
|
372
|
+
var deploy = async (options) => {
|
|
373
|
+
const { ifCore } = getIfCoreFns();
|
|
374
|
+
const paths = getPaths(ifCore);
|
|
375
|
+
assertOptionsValid2(options);
|
|
376
|
+
assertDistPathExists(paths.appDist);
|
|
377
|
+
const { tag } = options;
|
|
378
|
+
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
379
|
+
const deployUrl = `s3://${AWS_S3_BUCKET}/${configName}/${tag}`;
|
|
380
|
+
const entryFilename = ifCore("index.js", "widget.js");
|
|
381
|
+
const cmdSyncAll = `
|
|
382
|
+
aws s3 sync ${paths.appDist} ${deployUrl}
|
|
383
|
+
--acl public-read
|
|
384
|
+
--size-only
|
|
385
|
+
--exclude ${paths.appDist}/${entryFilename}
|
|
386
|
+
--cache-control max-age=31536000
|
|
387
|
+
`;
|
|
388
|
+
logTitle("Deploying to AWS S3 \u2026");
|
|
389
|
+
logCommand(cmdSyncAll);
|
|
390
|
+
try {
|
|
391
|
+
runAwsCommandSync(cmdSyncAll, { stdout: "inherit" });
|
|
392
|
+
} catch (error) {
|
|
393
|
+
fail(error.stderr);
|
|
394
|
+
}
|
|
395
|
+
const cmdCpEntry = `
|
|
396
|
+
aws s3 cp ${paths.appDist}/${entryFilename} ${deployUrl}/${entryFilename}
|
|
397
|
+
--acl public-read
|
|
398
|
+
--cache-control max-age=64800
|
|
399
|
+
`;
|
|
400
|
+
logCommand(cmdCpEntry);
|
|
401
|
+
try {
|
|
402
|
+
runAwsCommandSync(cmdCpEntry, { stdout: "inherit" });
|
|
403
|
+
} catch (error) {
|
|
404
|
+
fail(error.stderr);
|
|
405
|
+
}
|
|
406
|
+
const cmdInvalidateCache = `
|
|
407
|
+
aws cloudfront create-invalidation
|
|
408
|
+
--distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID}
|
|
409
|
+
--paths /${configName}/${tag}/*
|
|
410
|
+
`;
|
|
411
|
+
logTitle("Invalidating edge cache \u2026");
|
|
412
|
+
logCommand(cmdInvalidateCache);
|
|
413
|
+
try {
|
|
414
|
+
runAwsCommandSync(cmdInvalidateCache);
|
|
415
|
+
} catch (error) {
|
|
416
|
+
fail(error.stderr);
|
|
417
|
+
}
|
|
418
|
+
const demoPage = `https://${AWS_S3_BUCKET}/${configName}/${tag}/index.html`;
|
|
419
|
+
const entryPoint = `https://${AWS_S3_BUCKET}/${configName}/${tag}/${entryFilename}`;
|
|
420
|
+
logDataTable({
|
|
421
|
+
"Demo page:": demoPage,
|
|
422
|
+
"Entry point:": entryPoint
|
|
423
|
+
}, `Bundle for \u201C${configName}\u201D is deployed with tag \u201C${tag}\u201D`);
|
|
424
|
+
notify({
|
|
425
|
+
title: "deploy",
|
|
426
|
+
message: (0, import_strip_indent3.default)(`
|
|
427
|
+
Bundle for \u201C${configName}\u201D is deployed with tag \u201C${tag}\u201D.
|
|
428
|
+
Demo page: ${demoPage}
|
|
429
|
+
`),
|
|
430
|
+
target: demoPage
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
var assertOptionsValid2 = (options) => {
|
|
434
|
+
const { tag, profile } = options;
|
|
435
|
+
assertTagValid(tag);
|
|
436
|
+
assertProfileValid(profile);
|
|
437
|
+
};
|
|
438
|
+
var assertDistPathExists = (distPath) => {
|
|
439
|
+
if (!(0, import_fs2.existsSync)(distPath)) {
|
|
440
|
+
fail(`
|
|
441
|
+
Dist folder does not exists.
|
|
442
|
+
Make sure you have built the bundle before trying to deploy it.
|
|
443
|
+
`);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var assertTagValid = (tag) => {
|
|
447
|
+
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
448
|
+
if (!regex.test(tag)) {
|
|
449
|
+
fail(`Flag "--tag" has forbidden format. Allowed format: ${regex}.`);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// src/commands/build.ts
|
|
252
454
|
var build = async (options) => {
|
|
253
|
-
|
|
455
|
+
assertOptionsValid3(options);
|
|
456
|
+
const flags = prepareFlags2(options);
|
|
457
|
+
const { ifCore } = getIfCoreFns();
|
|
458
|
+
const paths = getPaths(ifCore);
|
|
459
|
+
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
460
|
+
const title = ifCore("Building optimised (minified) bundle of Tamaro Core \u2026", `Building optimised (minified) bundle of \u201C${configName}\u201D customer configuration \u2026`);
|
|
254
461
|
const wpBin = import_resolve_bin2.default.sync("webpack");
|
|
255
462
|
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
256
|
-
const cmd =
|
|
463
|
+
const cmd = `
|
|
464
|
+
${wpBin}
|
|
465
|
+
--config ${wpConfig}
|
|
466
|
+
--env min
|
|
467
|
+
${flags}
|
|
468
|
+
`;
|
|
469
|
+
logTitle(title);
|
|
257
470
|
logCommand(cmd);
|
|
258
|
-
(
|
|
471
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
472
|
+
logDataTable({ "Path:": paths.appDist }, `Bundle for \u201C${configName}\u201D customer configuration is done.`);
|
|
259
473
|
notify({
|
|
260
|
-
title:
|
|
261
|
-
message:
|
|
474
|
+
title: "build",
|
|
475
|
+
message: `Bundle for \u201C${configName}\u201D customer configuration is done.`
|
|
262
476
|
});
|
|
263
477
|
};
|
|
478
|
+
var assertOptionsValid3 = (options) => {
|
|
479
|
+
const { localCore, deploy: deploy2, profile } = options;
|
|
480
|
+
const { ifCore } = getIfCoreFns();
|
|
481
|
+
if (ifCore() && localCore) {
|
|
482
|
+
fail('Flag "--local-core" is redundant if running in Tamaro Core context.');
|
|
483
|
+
}
|
|
484
|
+
if (localCore && deploy2) {
|
|
485
|
+
fail('Flags "--local-core" and "--deploy" must not be used together.');
|
|
486
|
+
}
|
|
487
|
+
assertProfileValid(profile);
|
|
488
|
+
};
|
|
489
|
+
var prepareFlags2 = (options) => {
|
|
490
|
+
const { localCore, analyze } = options;
|
|
491
|
+
let flags = [];
|
|
492
|
+
flags = localCore ? [...flags, "--env localCore"] : flags;
|
|
493
|
+
flags = analyze ? [...flags, "--env analyze"] : flags;
|
|
494
|
+
return flags.join(" ");
|
|
495
|
+
};
|
|
264
496
|
|
|
265
|
-
// src/commands/
|
|
266
|
-
var
|
|
267
|
-
var
|
|
497
|
+
// src/commands/serve.ts
|
|
498
|
+
var import_portfinder = require("portfinder");
|
|
499
|
+
var DEFAULT_PORT = 1234;
|
|
500
|
+
var serve = async () => {
|
|
268
501
|
const { ifCore } = getIfCoreFns();
|
|
269
502
|
const paths = getPaths(ifCore);
|
|
270
|
-
const
|
|
503
|
+
const port = await (0, import_portfinder.getPortPromise)({ port: DEFAULT_PORT });
|
|
504
|
+
const cmd = `
|
|
505
|
+
npx -y http-server ${paths.appDist}
|
|
506
|
+
--cors
|
|
507
|
+
--port ${port}
|
|
508
|
+
`;
|
|
509
|
+
logTitle(`Running web-server for pre-built bundle \u2026`);
|
|
271
510
|
logCommand(cmd);
|
|
272
|
-
(
|
|
511
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
273
512
|
};
|
|
274
513
|
|
|
275
|
-
// src/commands/
|
|
276
|
-
var
|
|
277
|
-
|
|
514
|
+
// src/commands/list-deployed.ts
|
|
515
|
+
var listDeployed = async (options) => {
|
|
516
|
+
assertOptionsValid4(options);
|
|
517
|
+
const { config } = options;
|
|
518
|
+
const { ifCore } = getIfCoreFns();
|
|
519
|
+
const configName = config != null ? config : ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
520
|
+
const title = !config && ifCore() ? `Listing deployments of Tamaro Core \u2026` : `Listing deployments of \u201C${configName}\u201D customer configuration \u2026`;
|
|
521
|
+
const deployUrl = `s3://${AWS_S3_BUCKET}/${configName}/`;
|
|
522
|
+
const cmd = `aws s3 ls ${deployUrl}`;
|
|
523
|
+
let out = "";
|
|
524
|
+
logTitle(title);
|
|
525
|
+
logCommand(cmd);
|
|
526
|
+
try {
|
|
527
|
+
const result = runAwsCommandSync(cmd);
|
|
528
|
+
out = result.stdout;
|
|
529
|
+
} catch (error) {
|
|
530
|
+
out = error.stdout;
|
|
531
|
+
if (error.stderr) {
|
|
532
|
+
fail(error.stderr);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const lines = out.split("\n");
|
|
536
|
+
const tags = parseTags(lines);
|
|
537
|
+
let text = "";
|
|
538
|
+
if (tags.length === 0) {
|
|
539
|
+
text = "No deployments found.";
|
|
540
|
+
} else {
|
|
541
|
+
text = tags.map((tag, idx) => {
|
|
542
|
+
return `${idx + 1}. https://${AWS_S3_BUCKET}/${configName}/${tag}/index.html`;
|
|
543
|
+
}).join("\n");
|
|
544
|
+
}
|
|
545
|
+
logTable(text);
|
|
546
|
+
};
|
|
547
|
+
var assertOptionsValid4 = (options) => {
|
|
548
|
+
const { config, profile } = options;
|
|
549
|
+
assertConfigValid(config);
|
|
550
|
+
assertProfileValid(profile);
|
|
551
|
+
};
|
|
552
|
+
var assertConfigValid = (config) => {
|
|
553
|
+
if (!config) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
557
|
+
if (!regex.test(config)) {
|
|
558
|
+
fail(`Flag "--config" has forbidden format. Allowed format: ${regex}.`);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
var parseTags = (lines) => {
|
|
562
|
+
const regex = /^\s*PRE\s*/;
|
|
563
|
+
return lines.filter((line) => regex.test(line)).map((line) => line.replace(regex, "").replace(/\/$/, ""));
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/commands/deploy-email-config.ts
|
|
567
|
+
var import_fs3 = require("fs");
|
|
568
|
+
var DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET = "rnw-email-service";
|
|
569
|
+
var deployEmailConfig = async (options) => {
|
|
278
570
|
const { ifCore } = getIfCoreFns();
|
|
279
571
|
const paths = getPaths(ifCore);
|
|
280
|
-
const
|
|
572
|
+
const emailConfigPath = `${paths.app}/email-config`;
|
|
573
|
+
assertOptionsValid5(options);
|
|
574
|
+
assertEmailConfigPathExists(emailConfigPath);
|
|
575
|
+
assertIsNotCore();
|
|
576
|
+
const { bucket } = options;
|
|
577
|
+
const configName = getWidgetUuid();
|
|
578
|
+
const deployUrl = `s3://${bucket}/${configName}`;
|
|
579
|
+
const cmd = `
|
|
580
|
+
aws s3 sync ${emailConfigPath} ${deployUrl}
|
|
581
|
+
--delete
|
|
582
|
+
--exact-timestamps
|
|
583
|
+
`;
|
|
584
|
+
logTitle(`Deploying email configuration for \u201C${configName}\u201D customer configuration to AWS S3 \u2026`);
|
|
281
585
|
logCommand(cmd);
|
|
282
|
-
|
|
586
|
+
try {
|
|
587
|
+
runAwsCommandSync(cmd, { stdout: "inherit" });
|
|
588
|
+
} catch (error) {
|
|
589
|
+
fail(error.stderr);
|
|
590
|
+
}
|
|
591
|
+
logDataTable({ "Deploy URL:": deployUrl }, `Email configuration for \u201C${configName}\u201D customer configuration is deployed.`);
|
|
592
|
+
notify({
|
|
593
|
+
title: `deploy-email-config`,
|
|
594
|
+
message: `Email configuration for \u201C${configName}\u201D customer configuration is deployed.`
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
var assertOptionsValid5 = (options) => {
|
|
598
|
+
const { bucket, profile } = options;
|
|
599
|
+
assertBucketValid(bucket);
|
|
600
|
+
assertProfileValid(profile);
|
|
601
|
+
};
|
|
602
|
+
var assertEmailConfigPathExists = (distPath) => {
|
|
603
|
+
if (!(0, import_fs3.existsSync)(distPath)) {
|
|
604
|
+
fail("Email config folder does not exists. Nothing to deploy.");
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
var assertBucketValid = (tag) => {
|
|
608
|
+
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
609
|
+
if (!regex.test(tag)) {
|
|
610
|
+
fail(`Flag "--bucket" has forbidden format. Allowed format: ${regex}.`);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
var assertIsNotCore = () => {
|
|
614
|
+
const { ifCore } = getIfCoreFns();
|
|
615
|
+
if (ifCore()) {
|
|
616
|
+
fail("You cannot deploy widget email configuration for Tamaro Core.");
|
|
617
|
+
}
|
|
283
618
|
};
|
|
284
619
|
|
|
285
620
|
// src/cli.ts
|
|
@@ -287,13 +622,13 @@ process.on("unhandledRejection", (error) => {
|
|
|
287
622
|
throw error;
|
|
288
623
|
});
|
|
289
624
|
process.on("SIGINT", () => {
|
|
290
|
-
process.exit(
|
|
625
|
+
process.exit(1);
|
|
291
626
|
});
|
|
292
627
|
var cli = (0, import_commander.createCommand)().name(package_default.name).version(package_default.version, "-v, --version");
|
|
293
|
-
cli.command("dev").description("Run
|
|
628
|
+
cli.command("dev").description("Run the local development server for Tamaro Core or a particular customer configuration").option("--local-core", "Load Tamaro Core from localhost instead of the CDN", false).action(async (options) => {
|
|
294
629
|
await dev(options);
|
|
295
630
|
});
|
|
296
|
-
cli.command("build").description("Build Tamaro Core or customer configuration
|
|
631
|
+
cli.command("build").description("Build an optimised (minified) bundle of Tamaro Core or a customer configuration").option("--local-core", "Load Tamaro Core from localhost instead of the CDN", false).option("--analyze", 'Generate bundle statistics to "reports" folder', false).option("--deploy", "Deploy Tamaro Core or a customer configuration bundle to AWS S3", false).option("--serve", "Run the generated bundle with a local web server", false).option("--tag <tag>", "Tag which should be used for the deployment of the bundle", DEFAULT_TAG).option("--profile <profile>", "AWS profile which should be used for the deployment of the bundle", DEFAULT_AWS_PROFILE).action(async (options) => {
|
|
297
632
|
await build(options);
|
|
298
633
|
if (options.deploy) {
|
|
299
634
|
await deploy(options);
|
|
@@ -302,12 +637,25 @@ cli.command("build").description("Build Tamaro Core or customer configuration fo
|
|
|
302
637
|
await serve();
|
|
303
638
|
}
|
|
304
639
|
});
|
|
305
|
-
cli.command("deploy").description("Deploy Tamaro Core or customer configuration to AWS").option("--
|
|
640
|
+
cli.command("deploy").description("Deploy a pre-built Tamaro Core or customer configuration bundle to AWS S3").option("--tag <tag>", "Tag which should be used for the deployment of the bundle", DEFAULT_TAG).option("--profile <profile>", "AWS profile which should be used for the deployment of the bundle", DEFAULT_AWS_PROFILE).action(async (options) => {
|
|
306
641
|
await deploy(options);
|
|
307
642
|
});
|
|
308
|
-
cli.command("serve").description("Run web
|
|
643
|
+
cli.command("serve").description("Run a local web server for pre-built bundle").action(async () => {
|
|
309
644
|
await serve();
|
|
310
645
|
});
|
|
646
|
+
cli.command("list-deployed").description("List deployments of Tamaro Core or a particular customer configuration").option("--config <config>", "Configuration name (default: current customer configuration)").option("--profile <profile>", "AWS profile which should be used for fetching deployments", DEFAULT_AWS_PROFILE).action(async (options) => {
|
|
647
|
+
await listDeployed(options);
|
|
648
|
+
});
|
|
649
|
+
cli.command("deploy-email-config").description("Deploy a widget\u2019s email configuration to AWS S3").option("--bucket <bucket>", "AWS S3 bucket where it should be deployed", DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET).option("--profile <profile>", "AWS profile which should be used for the deployment of email configuration", DEFAULT_AWS_PROFILE).action(async (options) => {
|
|
650
|
+
await deployEmailConfig(options);
|
|
651
|
+
});
|
|
311
652
|
(async () => {
|
|
312
|
-
|
|
653
|
+
try {
|
|
654
|
+
await cli.parseAsync(process.argv);
|
|
655
|
+
} catch (error) {
|
|
656
|
+
if (error.signal === "SIGINT" && error.signalDescription) {
|
|
657
|
+
logError(`
|
|
658
|
+
${error.signalDescription}`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
313
661
|
})();
|