@raisenow/tamaro-cli 1.6.1 → 1.7.0-dev.1
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/.history/.eslintignore_20220609190420 +4 -0
- package/.history/.eslintignore_20230911190227 +6 -0
- package/.history/.eslintignore_20230911211247 +7 -0
- package/.history/.eslintignore_20230911211250 +7 -0
- package/.history/.eslintrc_20230911201601.js +49 -0
- package/.history/.eslintrc_20230911201643.js +49 -0
- package/.history/.eslintrc_20230911201735.js +49 -0
- package/.history/.eslintrc_20230911201913.js +64 -0
- package/.history/.eslintrc_20230911202002.js +62 -0
- package/.history/.eslintrc_20230911202138.js +133 -0
- package/.history/.eslintrc_20230911202140.js +133 -0
- package/.history/.eslintrc_20230911202145.js +133 -0
- package/.history/.eslintrc_20230911202147.js +133 -0
- package/.history/.eslintrc_20230911202406.js +133 -0
- package/.history/.eslintrc_20230911202447.js +133 -0
- package/.history/.eslintrc_20230911202453.js +133 -0
- package/.history/.eslintrc_20230911202511.js +133 -0
- package/.history/.eslintrc_20230911202527.js +133 -0
- package/.history/.eslintrc_20230911202639.js +125 -0
- package/.history/.eslintrc_20230911202721.js +149 -0
- package/.history/.eslintrc_20230911202746.js +149 -0
- package/.history/.eslintrc_20240423125702.cjs +148 -0
- package/.history/.gitignore_20220609190420 +14 -0
- package/.history/.gitignore_20230911185959 +4 -0
- package/.history/.gitignore_20230911190006 +4 -0
- package/.history/.gitignore_20230911190007 +4 -0
- package/.history/.nmprc_20241004144025 +0 -0
- package/.history/.nmprc_20241004144041 +1 -0
- package/.history/.npmrc_20241004144040 +1 -0
- package/.history/.npmrc_20241004144152 +1 -0
- package/.history/.npmrc_20241004145639 +2 -0
- package/.history/.npmrc_20241004145649 +1 -0
- package/.history/.nvmrc_20250729181039 +1 -0
- package/.history/.prettierignore_20220609190420 +5 -0
- package/.history/.prettierignore_20230911190242 +7 -0
- package/.history/.prettierignore_20230911190245 +7 -0
- package/.history/.prettierignore_20230911211301 +8 -0
- package/.history/CHANGELOG_20250729195139.md +28 -0
- package/.history/CHANGELOG_20250729195148.md +29 -0
- package/.history/CHANGELOG_20250729195156.md +28 -0
- package/.history/CHANGELOG_20250729195218.md +29 -0
- package/.history/CHANGELOG_20250729195223.md +27 -0
- package/.history/CHANGELOG_20250729195506.md +29 -0
- package/.history/CHANGELOG_20250729224404.md +30 -0
- package/.history/CHANGELOG_20250729224411.md +30 -0
- package/.history/CHANGELOG_20250730124538.md +41 -0
- package/.history/CHANGELOG_20250730124603.md +38 -0
- package/.history/CHANGELOG_20250730124627.md +36 -0
- package/.history/CHANGELOG_20250730124638.md +36 -0
- package/.history/CHANGELOG_20250730124640.md +36 -0
- package/.history/README_20230911145033.md +245 -0
- package/.history/README_20230911151749.md +245 -0
- package/.history/README_20230911151844.md +245 -0
- package/.history/README_20230911153040.md +245 -0
- package/.history/README_20230911202959.md +245 -0
- package/.history/bitbucket-pipelines_20250729111540.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210338.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210340.yml +46 -0
- package/.history/bitbucket-pipelines_20250729210342.yml +46 -0
- package/.history/bitbucket-pipelines_20250729222234.yml +47 -0
- package/.history/bitbucket-pipelines_20250729222554.yml +47 -0
- package/.history/bitbucket-pipelines_20250729222555.yml +47 -0
- package/.history/bitbucket-pipelines_20250729223022.yml +46 -0
- package/.history/bitbucket-pipelines_20250729223024.yml +46 -0
- package/.history/cli_20241005014539 +3 -0
- package/.history/cli_20241005014542 +3 -0
- package/.history/cli_20241005014848 +3 -0
- package/.history/dist/chunk-FICM3HUI_20230912183408.js +302 -0
- package/{dist/chunk-5D6F3T2J.js → .history/dist/chunk-FICM3HUI_20230912201610.js} +45 -98
- package/.history/package_20250729182417.json +111 -0
- package/.history/package_20250729182419.json +111 -0
- package/.history/package_20250729182618.json +110 -0
- package/.history/package_20250729182834.json +110 -0
- package/.history/package_20250729183032.json +110 -0
- package/.history/package_20250729183033.json +110 -0
- package/.history/package_20250729185750.json +110 -0
- package/.history/package_20250729185815.json +110 -0
- package/.history/package_20250729185846.json +110 -0
- package/.history/package_20250729185854.json +110 -0
- package/.history/package_20250729185943.json +110 -0
- package/.history/package_20250729190645.json +110 -0
- package/.history/package_20250729195934.json +110 -0
- package/.history/package_20250729200013.json +110 -0
- package/.history/package_20250729200056.json +110 -0
- package/.history/package_20250729200434.json +110 -0
- package/.history/package_20250729200808.json +110 -0
- package/.history/package_20250729200944.json +110 -0
- package/.history/package_20250729214420.json +114 -0
- package/.history/package_20250729223112.json +110 -0
- package/.history/package_20250729223127.json +110 -0
- package/.history/package_20250729223134.json +110 -0
- package/.history/package_20250730124647.json +114 -0
- package/.history/tsconfig_20241005001442.json +34 -0
- package/.history/tsconfig_20241005001500.json +34 -0
- package/.history/tsconfig_20241005001540.json +34 -0
- package/.history/tsconfig_20241005014429.json +42 -0
- package/.history/tsconfig_20241005014436.json +42 -0
- package/.history/tsconfig_20241005014439.json +38 -0
- package/.history/tsconfig_20241005014455.json +38 -0
- package/.history/tsconfig_20241005014521.json +38 -0
- package/.history/vitest.config_20250729214539.ts +0 -0
- package/.history/vitest.config_20250729214659.ts +24 -0
- package/.history/vitest.config_20250729214748.ts +21 -0
- package/.history/vitest.config_20250729214825.ts +21 -0
- package/.history/vitest.config_20250729214902.ts +21 -0
- package/.history/vitest.config_20250729222125.ts +20 -0
- package/.history/vitest.config_20250729222213.ts +20 -0
- package/.idea/codeStyles/Project.xml +131 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +17 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/tamaro-cli.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.nvmrc +1 -1
- package/bitbucket-pipelines.yml +1 -1
- package/dist/cli.js +754 -1160
- package/dist/env-C_Jkayak.js +261 -0
- package/dist/webpack.config.js +310 -441
- package/package.json +18 -22
- package/tsdown.config.ts +11 -0
package/dist/cli.js
CHANGED
|
@@ -1,442 +1,361 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
4
|
-
AWS_S3_BUCKET_TAMARO,
|
|
5
|
-
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD,
|
|
6
|
-
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
|
|
7
|
-
CORE_CONFIG_NAME,
|
|
8
|
-
DEFAULT_PORT,
|
|
9
|
-
DEFAULT_TAG,
|
|
10
|
-
HTTPS_CRT_FILE,
|
|
11
|
-
HTTPS_KEY_FILE,
|
|
12
|
-
applyEnv,
|
|
13
|
-
assertEnvValid,
|
|
14
|
-
getIfCoreFns,
|
|
15
|
-
getPaths,
|
|
16
|
-
getWidgetUuid,
|
|
17
|
-
halt,
|
|
18
|
-
logCommand,
|
|
19
|
-
logDataTable,
|
|
20
|
-
logError,
|
|
21
|
-
logSuccess,
|
|
22
|
-
logTitle,
|
|
23
|
-
promptConfirmation,
|
|
24
|
-
resolveBin,
|
|
25
|
-
resolveOwn,
|
|
26
|
-
runCommandSync
|
|
27
|
-
} from "./chunk-5D6F3T2J.js";
|
|
28
|
-
|
|
29
|
-
// src/cli.ts
|
|
2
|
+
import { C as promptConfirmation, D as logError, E as logDataTable, O as logSuccess, S as halt, T as logCommand, _ as getWidgetUuid, a as AWS_S3_BUCKET_TAMARO, c as CORE_CONFIG_NAME, d as HTTPS_CRT_FILE, f as HTTPS_KEY_FILE, h as getPaths, i as AWS_CLOUDFRONT_DISTRIBUTION_ID, k as logTitle, l as DEFAULT_PORT, m as getIfCoreFns, n as assertEnvValid, o as AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD, s as AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE, t as applyEnv, u as DEFAULT_TAG, w as runCommandSync, x as resolveOwn, y as resolveBin } from "./env-C_Jkayak.js";
|
|
30
3
|
import { createCommand } from "commander";
|
|
31
|
-
|
|
32
|
-
// src/commands/archive.ts
|
|
33
4
|
import { existsSync, mkdirSync, renameSync } from "fs";
|
|
34
5
|
import { basename, dirname, resolve } from "path";
|
|
35
|
-
|
|
36
|
-
// src/lib/aws.ts
|
|
37
6
|
import { execaCommandSync } from "execa";
|
|
38
7
|
import prompts from "prompts";
|
|
39
8
|
import stripIndent from "strip-indent";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
9
|
+
import notifier from "node-notifier";
|
|
10
|
+
import { globSync } from "glob";
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import Handlebars from "handlebars";
|
|
13
|
+
import helpers from "handlebars-helpers";
|
|
14
|
+
import { getPortPromise } from "portfinder";
|
|
15
|
+
|
|
16
|
+
//#region src/lib/aws.ts
|
|
17
|
+
const awsAuthenticate = (options) => {
|
|
18
|
+
if (options.ci)
|
|
19
|
+
/**
|
|
20
|
+
* Don't try to authenticate the user.
|
|
21
|
+
* This is done when CLI is running within an automated system like pipeline,
|
|
22
|
+
* In this case "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" are used instead of "AWS_PROFILE".
|
|
23
|
+
*/
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
checkIdentity(options);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
login(options);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const assertProfilesPresent = () => {
|
|
32
|
+
if (getAvailableProfiles().length === 0) halt(stripIndent(`
|
|
55
33
|
No AWS profiles found.
|
|
56
34
|
Run "aws configure sso" to set up SSO-enabled profile.
|
|
57
35
|
Check the wiki for more information:
|
|
58
36
|
https://raisenow.atlassian.net/wiki/x/lIrWvg
|
|
59
|
-
`)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
37
|
+
`));
|
|
38
|
+
};
|
|
39
|
+
const getAvailableProfiles = () => {
|
|
40
|
+
const { stdout } = execaCommandSync("aws configure list-profiles");
|
|
41
|
+
return stdout.split("\n");
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Returns caller identity data (output is ignored here).
|
|
45
|
+
* Fails in case of expired SSO session.
|
|
46
|
+
*/
|
|
47
|
+
const checkIdentity = (options) => {
|
|
48
|
+
execaCommandSync(`aws sts get-caller-identity ${prepareFlags$3(options)}`);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Opens SSO authentication page in the browser.
|
|
52
|
+
* Fails if user canceled authentication process.
|
|
53
|
+
*/
|
|
54
|
+
const login = (options) => {
|
|
55
|
+
const flags = prepareFlags$3(options);
|
|
56
|
+
try {
|
|
57
|
+
execaCommandSync(`aws sso login ${flags}`, { stdio: "inherit" });
|
|
58
|
+
console.log("");
|
|
59
|
+
} catch (error) {
|
|
60
|
+
halt("Login failed.");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const prepareFlags$3 = (options) => {
|
|
64
|
+
const flags = [];
|
|
65
|
+
const { profile } = options;
|
|
66
|
+
if (profile) flags.push(`--profile ${profile}`);
|
|
67
|
+
return flags.join(" ");
|
|
68
|
+
};
|
|
69
|
+
const assertProfileValid = (profile) => {
|
|
70
|
+
const profiles = getAvailableProfiles();
|
|
71
|
+
if (!profiles.includes(profile)) halt(stripIndent(`
|
|
93
72
|
AWS profile "${profile}" is not found.
|
|
94
73
|
Available profiles are: ${profiles.map((v) => `"${v}"`).join(", ")}.
|
|
95
|
-
`)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
{
|
|
111
|
-
onCancel: () => halt()
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
return profile;
|
|
74
|
+
`));
|
|
75
|
+
};
|
|
76
|
+
const promptProfile = async () => {
|
|
77
|
+
const { profile } = await prompts([{
|
|
78
|
+
type: "select",
|
|
79
|
+
name: "profile",
|
|
80
|
+
message: "Select AWS profile",
|
|
81
|
+
choices: getAvailableProfiles().filter((v) => !!v).map((v) => ({
|
|
82
|
+
title: v,
|
|
83
|
+
value: v
|
|
84
|
+
}))
|
|
85
|
+
}], { onCancel: () => halt() });
|
|
86
|
+
return profile;
|
|
115
87
|
};
|
|
116
88
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/lib/notifier.ts
|
|
91
|
+
const notify = (args) => {
|
|
92
|
+
const { title, message = "" } = args;
|
|
93
|
+
notifier.notify({
|
|
94
|
+
title,
|
|
95
|
+
message: stripIndent(message).trim(),
|
|
96
|
+
contentImage: "https://assets.raisenow.io/favicon.png",
|
|
97
|
+
sound: "Funk"
|
|
98
|
+
});
|
|
128
99
|
};
|
|
129
100
|
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
};
|
|
168
|
-
var assertIsNotCore = (ifCore) => {
|
|
169
|
-
if (ifCore()) {
|
|
170
|
-
halt("You cannot archive Tamaro Core.");
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
var assertIsNotArchived = () => {
|
|
174
|
-
const parentDirName = basename(dirname(process.cwd()));
|
|
175
|
-
if (parentDirName === "_archived") {
|
|
176
|
-
halt("This configuration is already archived.");
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
var assertArchiveTargetDoesNotExist = (archiveTarget) => {
|
|
180
|
-
if (existsSync(archiveTarget)) {
|
|
181
|
-
halt(
|
|
182
|
-
`Archive target already exists: ${archiveTarget}. Please remove it first.`
|
|
183
|
-
);
|
|
184
|
-
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/commands/archive.ts
|
|
103
|
+
const archive = (options) => {
|
|
104
|
+
const { ifCore } = getIfCoreFns();
|
|
105
|
+
assertIsNotCore$3(ifCore);
|
|
106
|
+
assertIsNotArchived();
|
|
107
|
+
const configName = getWidgetUuid();
|
|
108
|
+
const cwd = process.cwd();
|
|
109
|
+
const archiveDir = resolve(dirname(cwd), "_archived");
|
|
110
|
+
const archiveTarget = resolve(archiveDir, configName);
|
|
111
|
+
assertArchiveTargetDoesNotExist(archiveTarget);
|
|
112
|
+
assertOptionsValid$9(options);
|
|
113
|
+
if (options.dryrun) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
114
|
+
if (!options.dryrun) {
|
|
115
|
+
if (!existsSync(archiveDir)) mkdirSync(archiveDir, { recursive: true });
|
|
116
|
+
renameSync(cwd, archiveTarget);
|
|
117
|
+
} else logTitle(`Would move ${cwd} → ${archiveTarget}`);
|
|
118
|
+
logSuccess(`\n✅ "${configName}" has been archived and moved to ${archiveTarget}`);
|
|
119
|
+
process.on("exit", () => {
|
|
120
|
+
notify({
|
|
121
|
+
title: "archive",
|
|
122
|
+
message: `"${configName}" has been archived.`
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const assertOptionsValid$9 = (options) => {
|
|
127
|
+
const { profile } = options;
|
|
128
|
+
if (profile) assertProfileValid(profile);
|
|
129
|
+
};
|
|
130
|
+
const assertIsNotCore$3 = (ifCore) => {
|
|
131
|
+
if (ifCore()) halt("You cannot archive Tamaro Core.");
|
|
132
|
+
};
|
|
133
|
+
const assertIsNotArchived = () => {
|
|
134
|
+
if (basename(dirname(process.cwd())) === "_archived") halt("This configuration is already archived.");
|
|
135
|
+
};
|
|
136
|
+
const assertArchiveTargetDoesNotExist = (archiveTarget) => {
|
|
137
|
+
if (existsSync(archiveTarget)) halt(`Archive target already exists: ${archiveTarget}. Please remove it first.`);
|
|
185
138
|
};
|
|
186
139
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
var compileEmailTemplate = (template) => {
|
|
293
|
-
const compiled = Handlebars.compile(template);
|
|
294
|
-
compiled({});
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/lib/validators/validateEmailTemplates.ts
|
|
142
|
+
/**
|
|
143
|
+
* Register custom Handlebars helpers - the same, which are used in the Email Service.
|
|
144
|
+
* Make sure to update it if new helpers are added in the Email Service.
|
|
145
|
+
*/
|
|
146
|
+
helpers.comparison({ handlebars: Handlebars });
|
|
147
|
+
/**
|
|
148
|
+
* Recurse through the expected email templates folder and attempt to parse
|
|
149
|
+
* handlebars template to validate their syntax.
|
|
150
|
+
*/
|
|
151
|
+
const validateEmailTemplates = (templatePaths) => {
|
|
152
|
+
const errors = [];
|
|
153
|
+
for (const templatePath of templatePaths) try {
|
|
154
|
+
const template = fs.readFileSync(templatePath, "utf-8");
|
|
155
|
+
assureOnlySupportedHelpers(template);
|
|
156
|
+
compileEmailTemplate(template);
|
|
157
|
+
console.log(`${templatePath} is a valid email template`);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
errors.push(`${templatePath} is invalid`);
|
|
160
|
+
errors.push(e);
|
|
161
|
+
}
|
|
162
|
+
return errors;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Validate that only supported Handlebars helpers are used in the template.
|
|
166
|
+
* This function extracts helpers from the template AST and checks them
|
|
167
|
+
* against a predefined set of supported helpers.
|
|
168
|
+
*/
|
|
169
|
+
const assureOnlySupportedHelpers = (template) => {
|
|
170
|
+
/**
|
|
171
|
+
* Recursively extract helpers from the AST
|
|
172
|
+
*/
|
|
173
|
+
const extractHelpers = (ast) => {
|
|
174
|
+
const usedHelpers = /* @__PURE__ */ new Set();
|
|
175
|
+
const extractHelperName = (node) => {
|
|
176
|
+
if (node.path?.type === "PathExpression" && (node.params?.length > 0 || node.hash?.pairs?.length > 0)) return node.path?.original;
|
|
177
|
+
};
|
|
178
|
+
const visit = (node) => {
|
|
179
|
+
if (!node) return;
|
|
180
|
+
switch (node.type) {
|
|
181
|
+
case "MustacheStatement":
|
|
182
|
+
case "BlockStatement": {
|
|
183
|
+
const name = extractHelperName(node);
|
|
184
|
+
if (name) usedHelpers.add(name);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Recursively visit children of the AST node.
|
|
190
|
+
*/
|
|
191
|
+
for (const key in node) {
|
|
192
|
+
const value = node[key];
|
|
193
|
+
if (Array.isArray(value)) value.forEach(visit);
|
|
194
|
+
else if (value && typeof value === "object" && value.type) visit(value);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
visit(ast);
|
|
198
|
+
return usedHelpers;
|
|
199
|
+
};
|
|
200
|
+
const usedHelpers = extractHelpers(Handlebars.parse(template));
|
|
201
|
+
const supportedHelpers = new Set([
|
|
202
|
+
"if",
|
|
203
|
+
"unless",
|
|
204
|
+
"each",
|
|
205
|
+
"with",
|
|
206
|
+
"log",
|
|
207
|
+
"lookup",
|
|
208
|
+
"and",
|
|
209
|
+
"compare",
|
|
210
|
+
"contains",
|
|
211
|
+
"default",
|
|
212
|
+
"eq",
|
|
213
|
+
"gt",
|
|
214
|
+
"gte",
|
|
215
|
+
"has",
|
|
216
|
+
"isFalsey",
|
|
217
|
+
"isTruthy",
|
|
218
|
+
"ifEven",
|
|
219
|
+
"ifNth",
|
|
220
|
+
"ifOdd",
|
|
221
|
+
"is",
|
|
222
|
+
"isnt",
|
|
223
|
+
"lt",
|
|
224
|
+
"lte",
|
|
225
|
+
"neither",
|
|
226
|
+
"not",
|
|
227
|
+
"or",
|
|
228
|
+
"unlessEq",
|
|
229
|
+
"unlessGt",
|
|
230
|
+
"unlessLt",
|
|
231
|
+
"unlessGteq",
|
|
232
|
+
"unlessLteq"
|
|
233
|
+
]);
|
|
234
|
+
const unsupportedHelpers = Array.from(usedHelpers).filter((h) => !supportedHelpers.has(h));
|
|
235
|
+
if (unsupportedHelpers.length > 0) throw new Error(`Email template uses unsupported Handlebars helpers: ${unsupportedHelpers.join(", ")}`);
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Compile Email template and pass an empty context to validate syntax.
|
|
239
|
+
*/
|
|
240
|
+
const compileEmailTemplate = (template) => {
|
|
241
|
+
Handlebars.compile(template)({});
|
|
295
242
|
};
|
|
296
243
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/commands/validate.ts
|
|
246
|
+
/**
|
|
247
|
+
* Validates the current Tamaro configuration to avoid common errors.
|
|
248
|
+
*
|
|
249
|
+
* The command description is kept generic on purpose. We check for a number
|
|
250
|
+
* of mistakes observed when tamaro configurations are manually edited and
|
|
251
|
+
* deployed.
|
|
252
|
+
*/
|
|
253
|
+
const validate = async () => {
|
|
254
|
+
const errors = validateEmailTemplates(globSync("email-config/templates/**/*.hbs").sort());
|
|
255
|
+
if (errors.length) halt(errors.map((el) => el.toString()).join("\n"));
|
|
256
|
+
logTitle("Validated successfully");
|
|
306
257
|
};
|
|
307
258
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (existsSync2(certFile) && existsSync2(keyFile)) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
halt(
|
|
321
|
-
stripIndent3(`
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/lib/https.ts
|
|
261
|
+
const assertCrtExists = () => {
|
|
262
|
+
const { ifCore } = getIfCoreFns();
|
|
263
|
+
const paths = getPaths(ifCore);
|
|
264
|
+
const certFile = resolve(paths.root, HTTPS_CRT_FILE);
|
|
265
|
+
const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
|
|
266
|
+
if (existsSync(certFile) && existsSync(keyFile)) return;
|
|
267
|
+
halt(stripIndent(`
|
|
322
268
|
Flag "--https" is used, but "${HTTPS_CRT_FILE}" and/or "${HTTPS_KEY_FILE}" files are not found.
|
|
323
269
|
You need to generate certificate first.
|
|
324
270
|
Check docs: https://unpkg.com/@raisenow/tamaro-cli/readme.html#/?id=use-transport-level-security-https
|
|
325
|
-
`)
|
|
326
|
-
);
|
|
271
|
+
`));
|
|
327
272
|
};
|
|
328
273
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
349
|
-
const cmd = `
|
|
350
|
-
${wpBin}
|
|
351
|
-
--config ${wpConfig}
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/commands/build.ts
|
|
276
|
+
const build = async (options) => {
|
|
277
|
+
const { env } = options;
|
|
278
|
+
applyEnv(env);
|
|
279
|
+
if (options.deploy && !options.profile && !options.ci) {
|
|
280
|
+
assertProfilesPresent();
|
|
281
|
+
options.profile = await promptProfile();
|
|
282
|
+
}
|
|
283
|
+
assertOptionsValid$8(options);
|
|
284
|
+
await validate();
|
|
285
|
+
const flags = prepareFlags$2(options);
|
|
286
|
+
const { ifCore } = getIfCoreFns();
|
|
287
|
+
const paths = getPaths(ifCore);
|
|
288
|
+
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
289
|
+
const title = ifCore("Building optimised (minified) bundle of Tamaro Core …", `Building optimised (minified) bundle of "${configName}" customer configuration …`);
|
|
290
|
+
const cmd = `
|
|
291
|
+
${resolveBin("webpack")}
|
|
292
|
+
--config ${resolveOwn("dist/webpack.config.js")}
|
|
352
293
|
--env min
|
|
353
294
|
${flags}
|
|
354
295
|
`;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
};
|
|
386
|
-
var prepareFlags2 = (options) => {
|
|
387
|
-
const flags = [];
|
|
388
|
-
const { localCore, analyze, https, nolint } = options;
|
|
389
|
-
if (localCore) {
|
|
390
|
-
flags.push("--env localCore");
|
|
391
|
-
}
|
|
392
|
-
if (analyze) {
|
|
393
|
-
flags.push("--env analyze");
|
|
394
|
-
}
|
|
395
|
-
if (https) {
|
|
396
|
-
flags.push("--env https");
|
|
397
|
-
}
|
|
398
|
-
if (nolint) {
|
|
399
|
-
flags.push("--env nolint");
|
|
400
|
-
}
|
|
401
|
-
return flags.join(" ");
|
|
296
|
+
logTitle(title);
|
|
297
|
+
logCommand(cmd);
|
|
298
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
299
|
+
logTitle(`\nBundle for "${configName}" customer configuration is done.`);
|
|
300
|
+
console.log(`Path: ${paths.appDist}\n`);
|
|
301
|
+
process.on("exit", () => {
|
|
302
|
+
notify({
|
|
303
|
+
title: "build",
|
|
304
|
+
message: `Bundle for "${configName}" customer configuration is done.`
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
const assertOptionsValid$8 = (options) => {
|
|
309
|
+
const { localCore, https, deploy, env, profile } = options;
|
|
310
|
+
const { ifCore } = getIfCoreFns();
|
|
311
|
+
if (ifCore() && localCore) halt("Flag \"--local-core\" is redundant if running in Tamaro Core context.");
|
|
312
|
+
if (localCore && deploy) halt("Flags \"--local-core\" and \"--deploy\" must not be used together.");
|
|
313
|
+
if (https) assertCrtExists();
|
|
314
|
+
if (profile) assertProfileValid(profile);
|
|
315
|
+
assertEnvValid(env);
|
|
316
|
+
};
|
|
317
|
+
const prepareFlags$2 = (options) => {
|
|
318
|
+
const flags = [];
|
|
319
|
+
const { localCore, analyze, https, nolint, debug } = options;
|
|
320
|
+
if (localCore) flags.push("--env localCore");
|
|
321
|
+
if (analyze) flags.push("--env analyze");
|
|
322
|
+
if (https) flags.push("--env https");
|
|
323
|
+
if (nolint) flags.push("--env nolint");
|
|
324
|
+
if (debug) flags.push("--env debug");
|
|
325
|
+
return flags.join(" ");
|
|
402
326
|
};
|
|
403
327
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var assertTagValid = (tag) => {
|
|
410
|
-
const regex = /^[a-zA-Z0-9-_.]+$/;
|
|
411
|
-
if (!regex.test(tag)) {
|
|
412
|
-
halt(
|
|
413
|
-
`Flag "--tag" has forbidden format. Allowed format: ${regex.toString()}.`
|
|
414
|
-
);
|
|
415
|
-
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/lib/validators/assertTagValid.ts
|
|
330
|
+
const assertTagValid = (tag) => {
|
|
331
|
+
const regex = /^[a-zA-Z0-9-_.]+$/;
|
|
332
|
+
if (!regex.test(tag)) halt(`Flag "--tag" has forbidden format. Allowed format: ${regex.toString()}.`);
|
|
416
333
|
};
|
|
417
334
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/commands/deploy.ts
|
|
337
|
+
const deploy = async (options) => {
|
|
338
|
+
const { ifCore } = getIfCoreFns();
|
|
339
|
+
const paths = getPaths(ifCore);
|
|
340
|
+
assertDistPathExists(paths.appDist);
|
|
341
|
+
if (!options.profile && !options.ci) {
|
|
342
|
+
assertProfilesPresent();
|
|
343
|
+
options.profile = await promptProfile();
|
|
344
|
+
}
|
|
345
|
+
assertOptionsValid$7(options);
|
|
346
|
+
await validate();
|
|
347
|
+
awsAuthenticate(options);
|
|
348
|
+
const flags = prepareFlags$3(options);
|
|
349
|
+
const { tag, dryrun } = options;
|
|
350
|
+
const dryRunFlag = dryrun ? `--dryrun` : "";
|
|
351
|
+
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
352
|
+
const deployUrl = `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}`;
|
|
353
|
+
const entryFilename = ifCore("index.js", "widget.js");
|
|
354
|
+
if (dryRunFlag) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
355
|
+
/**
|
|
356
|
+
* Sync all files except entrypoint (without deleting old files)
|
|
357
|
+
*/
|
|
358
|
+
const cmdSyncAll = `
|
|
440
359
|
aws s3 sync ${paths.appDist} ${deployUrl}
|
|
441
360
|
--acl public-read
|
|
442
361
|
--exclude ${paths.appDist}/${entryFilename}
|
|
@@ -444,837 +363,512 @@ var deploy = async (options) => {
|
|
|
444
363
|
${flags}
|
|
445
364
|
${dryRunFlag}
|
|
446
365
|
`;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
366
|
+
logTitle("Deploying to AWS S3 …");
|
|
367
|
+
logCommand(cmdSyncAll);
|
|
368
|
+
try {
|
|
369
|
+
runCommandSync(cmdSyncAll, { stdout: "inherit" });
|
|
370
|
+
} catch (error) {
|
|
371
|
+
halt(error.stderr);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Copy entrypoint
|
|
375
|
+
*/
|
|
376
|
+
const cmdCpEntry = `
|
|
455
377
|
aws s3 cp ${paths.appDist}/${entryFilename} ${deployUrl}/${entryFilename}
|
|
456
378
|
--acl public-read
|
|
457
379
|
--cache-control max-age=64800
|
|
458
380
|
${flags}
|
|
459
381
|
${dryRunFlag}
|
|
460
382
|
`;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
383
|
+
logCommand(cmdCpEntry);
|
|
384
|
+
try {
|
|
385
|
+
runCommandSync(cmdCpEntry, { stdout: "inherit" });
|
|
386
|
+
} catch (error) {
|
|
387
|
+
halt(error.stderr);
|
|
388
|
+
}
|
|
389
|
+
if (!dryRunFlag) {
|
|
390
|
+
/**
|
|
391
|
+
* Invalidate cloudfront cache
|
|
392
|
+
*/
|
|
393
|
+
const cmdInvalidateCache = `
|
|
469
394
|
aws cloudfront create-invalidation
|
|
470
395
|
--distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID}
|
|
471
396
|
--paths /${configName}/${tag}/*
|
|
472
397
|
${flags}
|
|
473
398
|
`;
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
message: `
|
|
399
|
+
logTitle("\nInvalidating edge cache …");
|
|
400
|
+
logCommand(cmdInvalidateCache);
|
|
401
|
+
try {
|
|
402
|
+
runCommandSync(cmdInvalidateCache);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
halt(error.stderr);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const demoPage = `https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
|
|
408
|
+
const entryPoint = `https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/${entryFilename}`;
|
|
409
|
+
logTitle(`\nBundle for "${configName}" is deployed with tag "${tag}".`);
|
|
410
|
+
logDataTable({
|
|
411
|
+
"Demo page:": demoPage,
|
|
412
|
+
"Entry point:": entryPoint
|
|
413
|
+
});
|
|
414
|
+
process.on("exit", () => {
|
|
415
|
+
notify({
|
|
416
|
+
title: "deploy",
|
|
417
|
+
message: `
|
|
494
418
|
Bundle for "${configName}" is deployed with tag "${tag}".
|
|
495
419
|
Demo page: ${demoPage}
|
|
496
420
|
Entry point: ${entryPoint}
|
|
497
421
|
`
|
|
498
|
-
|
|
499
|
-
|
|
422
|
+
});
|
|
423
|
+
});
|
|
500
424
|
};
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
assertTagValid(tag);
|
|
425
|
+
const assertOptionsValid$7 = (options) => {
|
|
426
|
+
const { profile, tag } = options;
|
|
427
|
+
if (profile) assertProfileValid(profile);
|
|
428
|
+
assertTagValid(tag);
|
|
507
429
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
halt(
|
|
511
|
-
stripIndent4(`
|
|
430
|
+
const assertDistPathExists = (distPath) => {
|
|
431
|
+
if (!existsSync(distPath)) halt(stripIndent(`
|
|
512
432
|
Dist folder does not exists.
|
|
513
433
|
Make sure you have built the bundle before trying to deploy it.
|
|
514
|
-
`)
|
|
515
|
-
);
|
|
516
|
-
}
|
|
434
|
+
`));
|
|
517
435
|
};
|
|
518
436
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const configName = getWidgetUuid();
|
|
541
|
-
const deployUrl = `s3://${options.bucket}/${configName}`;
|
|
542
|
-
if (dryRunFlag) {
|
|
543
|
-
logTitle("\u{1F9EA} DRY RUN MODE - No actual changes will be made \u{1F9EA}");
|
|
544
|
-
}
|
|
545
|
-
const cmd = `
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/commands/deploy-email-config.ts
|
|
439
|
+
const deployEmailConfig = async (options) => {
|
|
440
|
+
const { ifCore } = getIfCoreFns();
|
|
441
|
+
const emailConfigPath = `${getPaths(ifCore).app}/email-config`;
|
|
442
|
+
assertIsNotCore$2();
|
|
443
|
+
assertEmailConfigPathExists(emailConfigPath);
|
|
444
|
+
if (!options.profile && !options.ci) {
|
|
445
|
+
assertProfilesPresent();
|
|
446
|
+
options.profile = await promptProfile();
|
|
447
|
+
}
|
|
448
|
+
if (!options.bucket) options.bucket = options.ci ? AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD : await promptBucketTamaroEmailConfig$1();
|
|
449
|
+
assertOptionsValid$6(options);
|
|
450
|
+
await validate();
|
|
451
|
+
awsAuthenticate(options);
|
|
452
|
+
const flags = prepareFlags$3(options);
|
|
453
|
+
const dryRunFlag = options.dryrun ? `--dryrun` : "";
|
|
454
|
+
const configName = getWidgetUuid();
|
|
455
|
+
const deployUrl = `s3://${options.bucket}/${configName}`;
|
|
456
|
+
if (dryRunFlag) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
457
|
+
const cmd = `
|
|
546
458
|
aws s3 sync ${emailConfigPath} ${deployUrl}
|
|
547
459
|
--delete
|
|
548
460
|
--exact-timestamps
|
|
549
461
|
${flags}
|
|
550
462
|
${dryRunFlag}
|
|
551
463
|
`;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
if (!buckets.includes(bucket)) {
|
|
598
|
-
halt("Invalid bucket name.");
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
var promptBucketTamaroEmailConfig = async () => {
|
|
602
|
-
const buckets = [
|
|
603
|
-
{ title: "stage", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE },
|
|
604
|
-
{ title: "prod", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD }
|
|
605
|
-
];
|
|
606
|
-
const { bucket } = await prompts2(
|
|
607
|
-
[
|
|
608
|
-
{
|
|
609
|
-
type: "select",
|
|
610
|
-
name: "bucket",
|
|
611
|
-
message: "Select environment",
|
|
612
|
-
choices: buckets
|
|
613
|
-
}
|
|
614
|
-
],
|
|
615
|
-
{
|
|
616
|
-
onCancel: () => halt()
|
|
617
|
-
}
|
|
618
|
-
);
|
|
619
|
-
return bucket;
|
|
464
|
+
logTitle(`Deploying email configuration for "${configName}" customer configuration to AWS S3 …`);
|
|
465
|
+
logCommand(cmd);
|
|
466
|
+
try {
|
|
467
|
+
runCommandSync(cmd, { stdout: "inherit" });
|
|
468
|
+
} catch (error) {
|
|
469
|
+
halt(error.stderr);
|
|
470
|
+
}
|
|
471
|
+
logTitle(`Email configuration for "${configName}" customer configuration is deployed.`);
|
|
472
|
+
logDataTable({ "Deploy URL:": deployUrl });
|
|
473
|
+
process.on("exit", () => {
|
|
474
|
+
notify({
|
|
475
|
+
title: "deploy-email-config",
|
|
476
|
+
message: `Email configuration for "${configName}" customer configuration is deployed.`
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
const assertOptionsValid$6 = (options) => {
|
|
481
|
+
const { profile, bucket } = options;
|
|
482
|
+
if (profile) assertProfileValid(profile);
|
|
483
|
+
if (bucket) assertBucketValid$1(bucket);
|
|
484
|
+
};
|
|
485
|
+
const assertEmailConfigPathExists = (distPath) => {
|
|
486
|
+
if (!existsSync(distPath)) halt("Email config folder does not exists. Nothing to deploy.");
|
|
487
|
+
};
|
|
488
|
+
const assertIsNotCore$2 = () => {
|
|
489
|
+
const { ifCore } = getIfCoreFns();
|
|
490
|
+
if (ifCore()) halt("You cannot deploy widget email configuration for Tamaro Core.");
|
|
491
|
+
};
|
|
492
|
+
const assertBucketValid$1 = (bucket) => {
|
|
493
|
+
if (![AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE, AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD].includes(bucket)) halt("Invalid bucket name.");
|
|
494
|
+
};
|
|
495
|
+
const promptBucketTamaroEmailConfig$1 = async () => {
|
|
496
|
+
const { bucket } = await prompts([{
|
|
497
|
+
type: "select",
|
|
498
|
+
name: "bucket",
|
|
499
|
+
message: "Select environment",
|
|
500
|
+
choices: [{
|
|
501
|
+
title: "stage",
|
|
502
|
+
value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
|
|
503
|
+
}, {
|
|
504
|
+
title: "prod",
|
|
505
|
+
value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
|
|
506
|
+
}]
|
|
507
|
+
}], { onCancel: () => halt() });
|
|
508
|
+
return bucket;
|
|
620
509
|
};
|
|
621
510
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
"
|
|
633
|
-
|
|
634
|
-
const wpBin = resolveBin("webpack");
|
|
635
|
-
const wpConfig = resolveOwn("dist/webpack.config.js");
|
|
636
|
-
const cmd = `
|
|
637
|
-
${wpBin} serve
|
|
638
|
-
--config ${wpConfig}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/commands/dev.ts
|
|
513
|
+
const dev = async (options) => {
|
|
514
|
+
const { env } = options;
|
|
515
|
+
applyEnv(env);
|
|
516
|
+
assertOptionsValid$5(options);
|
|
517
|
+
const flags = await prepareFlags$1(options);
|
|
518
|
+
const { ifCore } = getIfCoreFns();
|
|
519
|
+
const title = ifCore("Running dev web-server for Tamaro Core …", "Running dev web-server for customer configuration …");
|
|
520
|
+
const cmd = `
|
|
521
|
+
${resolveBin("webpack")} serve
|
|
522
|
+
--config ${resolveOwn("dist/webpack.config.js")}
|
|
639
523
|
${flags}
|
|
640
524
|
`;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (localCore) {
|
|
664
|
-
flags.push("--env localCore");
|
|
665
|
-
}
|
|
666
|
-
flags.push(`--port ${port}`);
|
|
667
|
-
if (https) {
|
|
668
|
-
flags.push("--env https");
|
|
669
|
-
}
|
|
670
|
-
if (nolint) {
|
|
671
|
-
flags.push("--env nolint");
|
|
672
|
-
}
|
|
673
|
-
return flags.join(" ");
|
|
525
|
+
logTitle(title);
|
|
526
|
+
logCommand(cmd);
|
|
527
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
528
|
+
};
|
|
529
|
+
const assertOptionsValid$5 = (options) => {
|
|
530
|
+
const { localCore, https, port, env } = options;
|
|
531
|
+
const { ifCore } = getIfCoreFns();
|
|
532
|
+
if (ifCore() && localCore) halt("Flag \"--local-core\" is redundant if running in Tamaro Core context.");
|
|
533
|
+
if (isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
|
|
534
|
+
if (https) assertCrtExists();
|
|
535
|
+
assertEnvValid(env);
|
|
536
|
+
};
|
|
537
|
+
const prepareFlags$1 = async (options) => {
|
|
538
|
+
const flags = [];
|
|
539
|
+
const { localCore, port: defaultPort, https, nolint, debug } = options;
|
|
540
|
+
const port = await getPortPromise({ port: Number(defaultPort) });
|
|
541
|
+
if (localCore) flags.push("--env localCore");
|
|
542
|
+
flags.push(`--port ${port}`);
|
|
543
|
+
if (https) flags.push("--env https");
|
|
544
|
+
if (nolint) flags.push("--env nolint");
|
|
545
|
+
if (debug) flags.push("--env debug");
|
|
546
|
+
return flags.join(" ");
|
|
674
547
|
};
|
|
675
548
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
var assertConfigValid = (config) => {
|
|
724
|
-
if (!config) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
728
|
-
if (!regex.test(config)) {
|
|
729
|
-
halt(
|
|
730
|
-
`Flag "--config" has forbidden format. Allowed format: ${regex.toString()}.`
|
|
731
|
-
);
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
var parseTags = (lines) => {
|
|
735
|
-
const regex = /^\s*PRE\s*/;
|
|
736
|
-
return lines.filter((line) => regex.test(line)).map((line) => line.replace(regex, "").replace(/\/$/, ""));
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/commands/list-deployed.ts
|
|
551
|
+
const listDeployed = async (options) => {
|
|
552
|
+
if (!options.profile && !options.ci) {
|
|
553
|
+
assertProfilesPresent();
|
|
554
|
+
options.profile = await promptProfile();
|
|
555
|
+
}
|
|
556
|
+
assertOptionsValid$4(options);
|
|
557
|
+
awsAuthenticate(options);
|
|
558
|
+
const flags = prepareFlags$3(options);
|
|
559
|
+
const { config } = options;
|
|
560
|
+
const { ifCore } = getIfCoreFns();
|
|
561
|
+
const configName = config ?? ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
562
|
+
const title = !config && ifCore() ? `Listing deployments of Tamaro Core …` : `Listing deployments of "${configName}" customer configuration …`;
|
|
563
|
+
const cmd = `aws s3 ls ${`s3://${AWS_S3_BUCKET_TAMARO}/${configName}/`} ${flags}`;
|
|
564
|
+
let out = "";
|
|
565
|
+
logTitle(title);
|
|
566
|
+
logCommand(cmd);
|
|
567
|
+
try {
|
|
568
|
+
out = runCommandSync(cmd).stdout;
|
|
569
|
+
} catch (error) {
|
|
570
|
+
out = error.stdout;
|
|
571
|
+
if (error.stderr) halt(error.stderr);
|
|
572
|
+
}
|
|
573
|
+
const tags = parseTags(out.split("\n"));
|
|
574
|
+
let text = "";
|
|
575
|
+
if (tags.length === 0) text = "No deployments found.";
|
|
576
|
+
else text = tags.map((tag, idx) => {
|
|
577
|
+
return `${idx + 1}. https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
|
|
578
|
+
}).join("\n");
|
|
579
|
+
console.log(`${text}\n`);
|
|
580
|
+
};
|
|
581
|
+
const assertOptionsValid$4 = (options) => {
|
|
582
|
+
const { config, profile } = options;
|
|
583
|
+
assertConfigValid(config);
|
|
584
|
+
if (profile) assertProfileValid(profile);
|
|
585
|
+
};
|
|
586
|
+
const assertConfigValid = (config) => {
|
|
587
|
+
if (!config) return;
|
|
588
|
+
const regex = /^[a-zA-Z0-9-_]+$/;
|
|
589
|
+
if (!regex.test(config)) halt(`Flag "--config" has forbidden format. Allowed format: ${regex.toString()}.`);
|
|
590
|
+
};
|
|
591
|
+
const parseTags = (lines) => {
|
|
592
|
+
const regex = /^\s*PRE\s*/;
|
|
593
|
+
return lines.filter((line) => regex.test(line)).map((line) => line.replace(regex, "").replace(/\/$/, ""));
|
|
737
594
|
};
|
|
738
595
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
const cmd = `
|
|
748
|
-
npx -y serve ${paths.appDist}
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/commands/serve.ts
|
|
598
|
+
const serve = async (options) => {
|
|
599
|
+
assertOptionsValid$3(options);
|
|
600
|
+
const flags = await prepareFlags(options);
|
|
601
|
+
const { ifCore } = getIfCoreFns();
|
|
602
|
+
const cmd = `
|
|
603
|
+
npx -y serve ${getPaths(ifCore).appDist}
|
|
749
604
|
--cors
|
|
750
605
|
${flags}
|
|
751
606
|
`;
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
flags.push(`--ssl-cert ${certFile}`);
|
|
776
|
-
flags.push(`--ssl-key ${keyFile}`);
|
|
777
|
-
}
|
|
778
|
-
return flags.join(" ");
|
|
607
|
+
logTitle(`Running web-server for pre-built bundle …`);
|
|
608
|
+
logCommand(cmd);
|
|
609
|
+
runCommandSync(cmd, { stdio: "inherit" });
|
|
610
|
+
};
|
|
611
|
+
const assertOptionsValid$3 = (options) => {
|
|
612
|
+
const { port, https } = options;
|
|
613
|
+
if (isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
|
|
614
|
+
if (https) assertCrtExists();
|
|
615
|
+
};
|
|
616
|
+
const prepareFlags = async (options) => {
|
|
617
|
+
const flags = [];
|
|
618
|
+
const { port: defaultPort, https } = options;
|
|
619
|
+
const port = await getPortPromise({ port: Number(defaultPort) });
|
|
620
|
+
flags.push(`-p ${port}`);
|
|
621
|
+
if (https) {
|
|
622
|
+
const { ifCore } = getIfCoreFns();
|
|
623
|
+
const paths = getPaths(ifCore);
|
|
624
|
+
const certFile = resolve(paths.root, HTTPS_CRT_FILE);
|
|
625
|
+
const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
|
|
626
|
+
flags.push(`--ssl-cert ${certFile}`);
|
|
627
|
+
flags.push(`--ssl-key ${keyFile}`);
|
|
628
|
+
}
|
|
629
|
+
return flags.join(" ");
|
|
779
630
|
};
|
|
780
631
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
};
|
|
818
|
-
var assertIsArchived = () => {
|
|
819
|
-
const parentDirName = basename2(dirname2(process.cwd()));
|
|
820
|
-
if (parentDirName !== "_archived") {
|
|
821
|
-
halt(
|
|
822
|
-
"This configuration is not archived. Only archived configurations can be unarchived."
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
var assertIsNotCore3 = (ifCore) => {
|
|
827
|
-
if (ifCore()) {
|
|
828
|
-
halt("You cannot unarchive Tamaro Core.");
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
|
-
var assertRestoreTargetDoesNotExist = (restoreTarget) => {
|
|
832
|
-
if (existsSync5(restoreTarget)) {
|
|
833
|
-
halt(
|
|
834
|
-
`Restore target already exists: ${restoreTarget}. Please remove it first.`
|
|
835
|
-
);
|
|
836
|
-
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/commands/unarchive.ts
|
|
634
|
+
const unarchive = (options) => {
|
|
635
|
+
const { ifCore } = getIfCoreFns({ allowArchived: true });
|
|
636
|
+
assertIsNotCore$1(ifCore);
|
|
637
|
+
assertIsArchived();
|
|
638
|
+
const configName = getWidgetUuid();
|
|
639
|
+
const cwd = process.cwd();
|
|
640
|
+
const restoreTarget = resolve(dirname(dirname(cwd)), configName);
|
|
641
|
+
assertRestoreTargetDoesNotExist(restoreTarget);
|
|
642
|
+
assertOptionsValid$2(options);
|
|
643
|
+
if (options.dryrun) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
644
|
+
if (!options.dryrun) {
|
|
645
|
+
renameSync(cwd, restoreTarget);
|
|
646
|
+
process.chdir(restoreTarget);
|
|
647
|
+
} else logTitle(`Would move ${cwd} → ${restoreTarget}`);
|
|
648
|
+
logTitle(`✅ "${configName}" has been unarchived and moved to ${restoreTarget}`);
|
|
649
|
+
process.on("exit", () => {
|
|
650
|
+
notify({
|
|
651
|
+
title: "unarchive",
|
|
652
|
+
message: `"${configName}" has been unarchived.`
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
const assertOptionsValid$2 = (options) => {
|
|
657
|
+
const { profile } = options;
|
|
658
|
+
if (profile) assertProfileValid(profile);
|
|
659
|
+
};
|
|
660
|
+
const assertIsArchived = () => {
|
|
661
|
+
if (basename(dirname(process.cwd())) !== "_archived") halt("This configuration is not archived. Only archived configurations can be unarchived.");
|
|
662
|
+
};
|
|
663
|
+
const assertIsNotCore$1 = (ifCore) => {
|
|
664
|
+
if (ifCore()) halt("You cannot unarchive Tamaro Core.");
|
|
665
|
+
};
|
|
666
|
+
const assertRestoreTargetDoesNotExist = (restoreTarget) => {
|
|
667
|
+
if (existsSync(restoreTarget)) halt(`Restore target already exists: ${restoreTarget}. Please remove it first.`);
|
|
837
668
|
};
|
|
838
669
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
`Are you sure you want to undeploy ${description}?`,
|
|
859
|
-
options.yes
|
|
860
|
-
);
|
|
861
|
-
const cmd = `
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/commands/undeploy.ts
|
|
672
|
+
const undeploy = async (options) => {
|
|
673
|
+
const { ifCore } = getIfCoreFns();
|
|
674
|
+
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
675
|
+
if (!options.profile && !options.ci) {
|
|
676
|
+
assertProfilesPresent();
|
|
677
|
+
options.profile = await promptProfile();
|
|
678
|
+
}
|
|
679
|
+
assertOptionsValid$1(options);
|
|
680
|
+
awsAuthenticate(options);
|
|
681
|
+
const flags = prepareFlags$3(options);
|
|
682
|
+
const { tag = DEFAULT_TAG, all, dryrun } = options;
|
|
683
|
+
const dryRunFlag = dryrun ? `--dryrun` : "";
|
|
684
|
+
const deployUrl = all ? `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/` : `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/`;
|
|
685
|
+
const description = all ? `all tags of "${configName}"` : `tag "${tag}" of "${configName}"`;
|
|
686
|
+
if (dryRunFlag) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
687
|
+
await promptConfirmation(`Are you sure you want to undeploy ${description}?`, options.yes);
|
|
688
|
+
const cmd = `
|
|
862
689
|
aws s3 rm ${deployUrl}
|
|
863
690
|
--recursive
|
|
864
691
|
${flags}
|
|
865
692
|
${dryRunFlag}
|
|
866
693
|
`;
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
const cmdInvalidateCache = `
|
|
694
|
+
logTitle(`Undeploying ${description} from AWS S3 …`);
|
|
695
|
+
logCommand(cmd);
|
|
696
|
+
try {
|
|
697
|
+
runCommandSync(cmd, { stdout: "inherit" });
|
|
698
|
+
} catch (error) {
|
|
699
|
+
halt(error.stderr);
|
|
700
|
+
}
|
|
701
|
+
if (!dryRunFlag) {
|
|
702
|
+
const cmdInvalidateCache = `
|
|
877
703
|
aws cloudfront create-invalidation
|
|
878
704
|
--distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID}
|
|
879
|
-
--paths ${
|
|
705
|
+
--paths ${all ? `/${configName}/*` : `/${configName}/${tag}/*`}
|
|
880
706
|
${flags}
|
|
881
707
|
`;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
halt("You cannot undeploy the default tag for Tamaro Core.");
|
|
908
|
-
}
|
|
909
|
-
if (profile) {
|
|
910
|
-
assertProfileValid(profile);
|
|
911
|
-
}
|
|
912
|
-
if (all && tag) {
|
|
913
|
-
halt('Flags "--tag" and "--all" must not be used together.');
|
|
914
|
-
}
|
|
915
|
-
if (!all && tag) {
|
|
916
|
-
assertTagValid(tag);
|
|
917
|
-
}
|
|
708
|
+
logTitle("\nInvalidating edge cache …");
|
|
709
|
+
logCommand(cmdInvalidateCache);
|
|
710
|
+
try {
|
|
711
|
+
runCommandSync(cmdInvalidateCache);
|
|
712
|
+
} catch (error) {
|
|
713
|
+
halt(error.stderr);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
logTitle(`\n${description} has been undeployed.`);
|
|
717
|
+
logDataTable({ "Removed URL:": deployUrl });
|
|
718
|
+
process.on("exit", () => {
|
|
719
|
+
notify({
|
|
720
|
+
title: "undeploy",
|
|
721
|
+
message: `${description} has been undeployed.`
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
const assertOptionsValid$1 = (options) => {
|
|
726
|
+
const { profile, tag, all } = options;
|
|
727
|
+
const { ifCore } = getIfCoreFns();
|
|
728
|
+
if (ifCore() && all) halt("Flag \"--all\" must not be used in Tamaro Core context.");
|
|
729
|
+
if (ifCore() && tag === DEFAULT_TAG) halt("You cannot undeploy the default tag for Tamaro Core.");
|
|
730
|
+
if (profile) assertProfileValid(profile);
|
|
731
|
+
if (all && tag) halt("Flags \"--tag\" and \"--all\" must not be used together.");
|
|
732
|
+
if (!all && tag) assertTagValid(tag);
|
|
918
733
|
};
|
|
919
734
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
assertOptionsValid10(options);
|
|
944
|
-
awsAuthenticate(options);
|
|
945
|
-
const flags = prepareFlags(options);
|
|
946
|
-
const dryRunFlag = options.dryrun ? `--dryrun` : "";
|
|
947
|
-
const configName = getWidgetUuid();
|
|
948
|
-
const deployUrl = `s3://${options.bucket}/${configName}/`;
|
|
949
|
-
await promptConfirmation(
|
|
950
|
-
`Are you sure you want to undeploy the email configuration for "${configName}" from "${options.bucket}"?`,
|
|
951
|
-
options.ci
|
|
952
|
-
);
|
|
953
|
-
if (dryRunFlag) {
|
|
954
|
-
logTitle("\u{1F9EA} DRY RUN MODE - No actual changes will be made \u{1F9EA}");
|
|
955
|
-
}
|
|
956
|
-
const cmd = `
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/commands/undeploy-email-config.ts
|
|
737
|
+
const undeployEmailConfig = async (options) => {
|
|
738
|
+
const { ifCore } = getIfCoreFns();
|
|
739
|
+
assertIsNotCore(ifCore);
|
|
740
|
+
if (!options.profile && !options.ci) {
|
|
741
|
+
assertProfilesPresent();
|
|
742
|
+
options.profile = await promptProfile();
|
|
743
|
+
}
|
|
744
|
+
if (options.ci) options.bucket = AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD;
|
|
745
|
+
if (!options.bucket) if (options.ci) options.bucket = AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD;
|
|
746
|
+
else if (options.prod) options.bucket = AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD;
|
|
747
|
+
else if (options.stage) options.bucket = AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE;
|
|
748
|
+
else options.bucket = await promptBucketTamaroEmailConfig();
|
|
749
|
+
assertOptionsValid(options);
|
|
750
|
+
awsAuthenticate(options);
|
|
751
|
+
const flags = prepareFlags$3(options);
|
|
752
|
+
const dryRunFlag = options.dryrun ? `--dryrun` : "";
|
|
753
|
+
const configName = getWidgetUuid();
|
|
754
|
+
const deployUrl = `s3://${options.bucket}/${configName}/`;
|
|
755
|
+
await promptConfirmation(`Are you sure you want to undeploy the email configuration for "${configName}" from "${options.bucket}"?`, options.ci);
|
|
756
|
+
if (dryRunFlag) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
|
|
757
|
+
const cmd = `
|
|
957
758
|
aws s3 rm ${deployUrl}
|
|
958
759
|
--recursive
|
|
959
760
|
${flags}
|
|
960
761
|
${dryRunFlag}
|
|
961
762
|
`;
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
};
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
var promptBucketTamaroEmailConfig2 = async () => {
|
|
1004
|
-
const buckets = [
|
|
1005
|
-
{ title: "stage", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE },
|
|
1006
|
-
{ title: "prod", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD }
|
|
1007
|
-
];
|
|
1008
|
-
const { bucket } = await prompts3(
|
|
1009
|
-
[
|
|
1010
|
-
{
|
|
1011
|
-
type: "select",
|
|
1012
|
-
name: "bucket",
|
|
1013
|
-
message: "Select environment",
|
|
1014
|
-
choices: buckets
|
|
1015
|
-
}
|
|
1016
|
-
],
|
|
1017
|
-
{
|
|
1018
|
-
onCancel: () => halt()
|
|
1019
|
-
}
|
|
1020
|
-
);
|
|
1021
|
-
return bucket;
|
|
763
|
+
logTitle(`Undeploying email configuration for "${configName}" from AWS S3 …`);
|
|
764
|
+
logCommand(cmd);
|
|
765
|
+
try {
|
|
766
|
+
runCommandSync(cmd, { stdout: "inherit" });
|
|
767
|
+
} catch (error) {
|
|
768
|
+
halt(error.stderr);
|
|
769
|
+
}
|
|
770
|
+
logTitle(`Email configuration for "${configName}" has been undeployed from "${options.bucket}".`);
|
|
771
|
+
logDataTable({ "Removed URL:": deployUrl });
|
|
772
|
+
process.on("exit", () => {
|
|
773
|
+
notify({
|
|
774
|
+
title: "undeploy-email-config",
|
|
775
|
+
message: `Email configuration for "${configName}" has been undeployed.`
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
const assertOptionsValid = (options) => {
|
|
780
|
+
const { profile, bucket } = options;
|
|
781
|
+
if (profile) assertProfileValid(profile);
|
|
782
|
+
if (bucket) assertBucketValid(bucket);
|
|
783
|
+
};
|
|
784
|
+
const assertIsNotCore = (ifCore) => {
|
|
785
|
+
if (ifCore()) halt("You cannot undeploy widget email configuration for Tamaro Core.");
|
|
786
|
+
};
|
|
787
|
+
const assertBucketValid = (bucket) => {
|
|
788
|
+
if (![AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE, AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD].includes(bucket)) halt("Invalid bucket name.");
|
|
789
|
+
};
|
|
790
|
+
const promptBucketTamaroEmailConfig = async () => {
|
|
791
|
+
const { bucket } = await prompts([{
|
|
792
|
+
type: "select",
|
|
793
|
+
name: "bucket",
|
|
794
|
+
message: "Select environment",
|
|
795
|
+
choices: [{
|
|
796
|
+
title: "stage",
|
|
797
|
+
value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
|
|
798
|
+
}, {
|
|
799
|
+
title: "prod",
|
|
800
|
+
value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
|
|
801
|
+
}]
|
|
802
|
+
}], { onCancel: () => halt() });
|
|
803
|
+
return bucket;
|
|
1022
804
|
};
|
|
1023
805
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
author: {
|
|
1029
|
-
name: "RaiseNow",
|
|
1030
|
-
email: "development@raisenow.com"
|
|
1031
|
-
},
|
|
1032
|
-
type: "module",
|
|
1033
|
-
bin: "dist/cli.js",
|
|
1034
|
-
packageManager: "pnpm@10.28.2",
|
|
1035
|
-
engines: {
|
|
1036
|
-
node: ">=22.22.0",
|
|
1037
|
-
pnpm: ">=10.28.2",
|
|
1038
|
-
npm: "please-use-pnpm",
|
|
1039
|
-
yarn: "please-use-pnpm"
|
|
1040
|
-
},
|
|
1041
|
-
scripts: {
|
|
1042
|
-
prepare: "pnpm build",
|
|
1043
|
-
typecheck: "tsc --noEmit",
|
|
1044
|
-
build: "tsup src/cli.ts src/webpack.config.ts --clean --shims --format esm",
|
|
1045
|
-
"build:watch": "pnpm build --watch --ignore-watch .history --ignore-watch .idea",
|
|
1046
|
-
dev: "pnpm build:watch",
|
|
1047
|
-
readme: "pnpx http-server . --cors -o /readme.html",
|
|
1048
|
-
lint: "DEBUG=eslint:cli-engine eslint .",
|
|
1049
|
-
"lint:fix": "DEBUG=eslint:cli-engine eslint --fix .",
|
|
1050
|
-
format: "prettier --write .",
|
|
1051
|
-
test: "vitest",
|
|
1052
|
-
"test:watch": "vitest --watch",
|
|
1053
|
-
"test:coverage": "vitest --coverage"
|
|
1054
|
-
},
|
|
1055
|
-
dependencies: {
|
|
1056
|
-
"@babel/cli": "^7.28.6",
|
|
1057
|
-
"@babel/core": "^7.29.0",
|
|
1058
|
-
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
1059
|
-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
1060
|
-
"@babel/plugin-transform-runtime": "^7.29.0",
|
|
1061
|
-
"@babel/preset-env": "^7.29.0",
|
|
1062
|
-
"@babel/preset-react": "^7.28.5",
|
|
1063
|
-
"@babel/preset-typescript": "^7.28.5",
|
|
1064
|
-
"@babel/runtime-corejs3": "^7.29.0",
|
|
1065
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
|
1066
|
-
"@statoscope/webpack-plugin": "^5.29.0",
|
|
1067
|
-
"@types/columnify": "^1.5.4",
|
|
1068
|
-
"@types/handlebars-helpers": "^0.5.6",
|
|
1069
|
-
"@types/lodash": "^4.17.23",
|
|
1070
|
-
"@types/node": "^22.19.8",
|
|
1071
|
-
"@types/node-notifier": "^8.0.5",
|
|
1072
|
-
"@types/prompts": "^2.4.9",
|
|
1073
|
-
"@types/resolve-bin": "^0.4.3",
|
|
1074
|
-
"@types/webpack-config-utils": "^2.3.4",
|
|
1075
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
1076
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
1077
|
-
autoprefixer: "^10.4.24",
|
|
1078
|
-
"babel-loader": "^10.0.0",
|
|
1079
|
-
"babel-plugin-istanbul": "^7.0.1",
|
|
1080
|
-
"babel-plugin-lodash": "^3.3.4",
|
|
1081
|
-
chalk: "^5.6.2",
|
|
1082
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
1083
|
-
columnify: "^1.6.0",
|
|
1084
|
-
commander: "^14.0.3",
|
|
1085
|
-
"copy-webpack-plugin": "^13.0.1",
|
|
1086
|
-
"core-js": "^3.48.0",
|
|
1087
|
-
"css-loader": "^7.1.3",
|
|
1088
|
-
"css-minimizer-webpack-plugin": "^7.0.4",
|
|
1089
|
-
dotenv: "^17.2.3",
|
|
1090
|
-
"escape-string-regexp": "^5.0.0",
|
|
1091
|
-
eslint: "^8.57.1",
|
|
1092
|
-
"eslint-config-prettier": "^10.1.8",
|
|
1093
|
-
"eslint-import-resolver-typescript": "^3.10.1",
|
|
1094
|
-
"eslint-plugin-deprecation": "^3.0.0",
|
|
1095
|
-
"eslint-plugin-import": "^2.32.0",
|
|
1096
|
-
"eslint-plugin-markdownlint": "^0.9.0",
|
|
1097
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
1098
|
-
"eslint-plugin-unused-imports": "^3.2.0",
|
|
1099
|
-
"eslint-plugin-yml": "^1.19.1",
|
|
1100
|
-
"eslint-webpack-plugin": "^5.0.2",
|
|
1101
|
-
execa: "^9.6.1",
|
|
1102
|
-
"file-loader": "^6.2.0",
|
|
1103
|
-
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
1104
|
-
glob: "^13.0.1",
|
|
1105
|
-
handlebars: "^4.7.8",
|
|
1106
|
-
"handlebars-helpers": "^0.10.0",
|
|
1107
|
-
"html-loader": "^5.1.0",
|
|
1108
|
-
"html-webpack-plugin": "^5.6.6",
|
|
1109
|
-
"json-loader": "^0.5.7",
|
|
1110
|
-
lodash: "^4.17.23",
|
|
1111
|
-
"mini-css-extract-plugin": "^2.10.0",
|
|
1112
|
-
"node-notifier": "^10.0.1",
|
|
1113
|
-
portfinder: "^1.0.38",
|
|
1114
|
-
postcss: "^8.5.6",
|
|
1115
|
-
"postcss-custom-properties": "^14.0.6",
|
|
1116
|
-
"postcss-import": "^16.1.1",
|
|
1117
|
-
"postcss-loader": "^8.2.0",
|
|
1118
|
-
"postcss-nested": "^7.0.2",
|
|
1119
|
-
prettier: "^3.8.1",
|
|
1120
|
-
prompts: "^2.4.2",
|
|
1121
|
-
"react-refresh": "^0.18.0",
|
|
1122
|
-
"resolve-url-loader": "^5.0.0",
|
|
1123
|
-
sass: "^1.97.3",
|
|
1124
|
-
"sass-loader": "^16.0.6",
|
|
1125
|
-
"strip-indent": "^4.1.1",
|
|
1126
|
-
"style-loader": "^4.0.0",
|
|
1127
|
-
"terser-webpack-plugin": "^5.3.16",
|
|
1128
|
-
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
1129
|
-
tsup: "^8.5.1",
|
|
1130
|
-
typescript: "^5.9.3",
|
|
1131
|
-
"url-loader": "^4.1.1",
|
|
1132
|
-
vitest: "^4.0.18",
|
|
1133
|
-
webpack: "^5.105.0",
|
|
1134
|
-
"webpack-cli": "^6.0.1",
|
|
1135
|
-
"webpack-config-utils": "^2.3.1",
|
|
1136
|
-
"webpack-dev-server": "^5.2.3",
|
|
1137
|
-
"yaml-loader": "^0.9.0"
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region package.json
|
|
808
|
+
var name = "@raisenow/tamaro-cli";
|
|
809
|
+
var version = "1.7.0-dev.1";
|
|
1140
810
|
|
|
1141
|
-
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/cli.ts
|
|
813
|
+
/**
|
|
814
|
+
* Makes the script crash on unhandled rejections instead of silently
|
|
815
|
+
* ignoring them. In the future, promise rejections that are not handled will
|
|
816
|
+
* terminate the Node.js process with a non-zero exit code.
|
|
817
|
+
*/
|
|
1142
818
|
process.on("unhandledRejection", (error) => {
|
|
1143
|
-
|
|
819
|
+
throw error;
|
|
1144
820
|
});
|
|
1145
821
|
process.on("SIGINT", () => {
|
|
1146
|
-
|
|
822
|
+
halt();
|
|
1147
823
|
});
|
|
1148
|
-
|
|
1149
|
-
cli.command("dev").description(
|
|
1150
|
-
|
|
1151
|
-
).option(
|
|
1152
|
-
"--local-core",
|
|
1153
|
-
"Load Tamaro Core from localhost:1234 instead of the CDN",
|
|
1154
|
-
false
|
|
1155
|
-
).option(
|
|
1156
|
-
"--https",
|
|
1157
|
-
"Let local web server serve Tamaro with SSL encryption",
|
|
1158
|
-
false
|
|
1159
|
-
).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option("--nolint", "Disable ESLint", false).action(async (options) => {
|
|
1160
|
-
await dev(options);
|
|
824
|
+
const cli = createCommand().name(name).version(version, "-v, --version");
|
|
825
|
+
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:1234 instead of the CDN", false).option("--https", "Let local web server serve Tamaro with SSL encryption", false).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option("--nolint", "Disable ESLint", false).option("--debug", "Enable debug mode", false).action(async (options) => {
|
|
826
|
+
await dev(options);
|
|
1161
827
|
});
|
|
1162
|
-
cli.command("build").description(
|
|
1163
|
-
|
|
1164
|
-
)
|
|
1165
|
-
|
|
1166
|
-
"Load Tamaro Core from localhost:1234 instead of the CDN",
|
|
1167
|
-
false
|
|
1168
|
-
).option("--analyze", 'Generate bundle statistics to "reports" folder', false).option("--serve", "Run the generated bundle with a local web server", false).option(
|
|
1169
|
-
"--https",
|
|
1170
|
-
"Let local web server serve Tamaro with SSL encryption",
|
|
1171
|
-
false
|
|
1172
|
-
).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
1173
|
-
"--deploy",
|
|
1174
|
-
"Deploy Tamaro Core or a customer configuration bundle to AWS S3",
|
|
1175
|
-
false
|
|
1176
|
-
).option(
|
|
1177
|
-
"--tag <tag>",
|
|
1178
|
-
"Tag which should be used for the deployment of the bundle",
|
|
1179
|
-
DEFAULT_TAG
|
|
1180
|
-
).option("--nolint", "Disable ESLint", false).action(async (options) => {
|
|
1181
|
-
await build(options);
|
|
1182
|
-
if (options.serve) {
|
|
1183
|
-
await serve(options);
|
|
1184
|
-
}
|
|
1185
|
-
if (options.deploy) {
|
|
1186
|
-
await deploy(options);
|
|
1187
|
-
}
|
|
828
|
+
cli.command("build").description("Build an optimised (minified) bundle of Tamaro Core or a customer configuration").option("--local-core", "Load Tamaro Core from localhost:1234 instead of the CDN", false).option("--analyze", "Generate bundle statistics to \"reports\" folder", false).option("--serve", "Run the generated bundle with a local web server", false).option("--https", "Let local web server serve Tamaro with SSL encryption", false).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--deploy", "Deploy Tamaro Core or a customer configuration bundle to AWS S3", false).option("--tag <tag>", "Tag which should be used for the deployment of the bundle", DEFAULT_TAG).option("--nolint", "Disable ESLint", false).option("--debug", "Enable debug mode", false).action(async (options) => {
|
|
829
|
+
await build(options);
|
|
830
|
+
if (options.serve) await serve(options);
|
|
831
|
+
if (options.deploy) await deploy(options);
|
|
1188
832
|
});
|
|
1189
|
-
cli.command("serve").description("Run a local web server for pre-built bundle").option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option(
|
|
1190
|
-
|
|
1191
|
-
"Let local web server serve Tamaro with SSL encryption",
|
|
1192
|
-
false
|
|
1193
|
-
).action(async (options) => {
|
|
1194
|
-
await serve(options);
|
|
833
|
+
cli.command("serve").description("Run a local web server for pre-built bundle").option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--https", "Let local web server serve Tamaro with SSL encryption", false).action(async (options) => {
|
|
834
|
+
await serve(options);
|
|
1195
835
|
});
|
|
1196
|
-
cli.command("deploy").description(
|
|
1197
|
-
|
|
1198
|
-
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
1199
|
-
"--tag <tag>",
|
|
1200
|
-
"Tag which should be used for the deployment of the bundle",
|
|
1201
|
-
DEFAULT_TAG
|
|
1202
|
-
).option(
|
|
1203
|
-
"--dryrun",
|
|
1204
|
-
"Displays the operations that would be performed without actually running them",
|
|
1205
|
-
false
|
|
1206
|
-
).action(async (options) => {
|
|
1207
|
-
await deploy(options);
|
|
836
|
+
cli.command("deploy").description("Deploy a pre-built Tamaro Core or customer configuration bundle to AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--tag <tag>", "Tag which should be used for the deployment of the bundle", DEFAULT_TAG).option("--dryrun", "Displays the operations that would be performed without actually running them", false).action(async (options) => {
|
|
837
|
+
await deploy(options);
|
|
1208
838
|
});
|
|
1209
|
-
cli.command("list-deployed").description(
|
|
1210
|
-
|
|
1211
|
-
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
1212
|
-
"--config <config>",
|
|
1213
|
-
"Configuration name (default: current customer configuration)"
|
|
1214
|
-
).action(async (options) => {
|
|
1215
|
-
await listDeployed(options);
|
|
839
|
+
cli.command("list-deployed").description("List deployments of Tamaro Core or a particular customer configuration").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--config <config>", "Configuration name (default: current customer configuration)").action(async (options) => {
|
|
840
|
+
await listDeployed(options);
|
|
1216
841
|
});
|
|
1217
|
-
cli.command("deploy-email-config").description("Deploy a widget's email configuration to AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--bucket <bucket>", "AWS bucket for email configs").option(
|
|
1218
|
-
|
|
1219
|
-
"Displays the operations that would be performed without actually running them",
|
|
1220
|
-
false
|
|
1221
|
-
).action(async (options) => {
|
|
1222
|
-
await deployEmailConfig(options);
|
|
842
|
+
cli.command("deploy-email-config").description("Deploy a widget's email configuration to AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--bucket <bucket>", "AWS bucket for email configs").option("--dryrun", "Displays the operations that would be performed without actually running them", false).action(async (options) => {
|
|
843
|
+
await deployEmailConfig(options);
|
|
1223
844
|
});
|
|
1224
|
-
cli.command("undeploy").description(
|
|
1225
|
-
|
|
1226
|
-
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--tag <tag>", "Tag which should be undeployed").option("--all", "Undeploy all tags", false).option(
|
|
1227
|
-
"--dryrun",
|
|
1228
|
-
"Displays the operations that would be performed without actually running them",
|
|
1229
|
-
false
|
|
1230
|
-
).action(async (options) => {
|
|
1231
|
-
await undeploy(options);
|
|
845
|
+
cli.command("undeploy").description("Undeploy a Tamaro Core or customer configuration bundle from AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--tag <tag>", "Tag which should be undeployed").option("--all", "Undeploy all tags", false).option("--dryrun", "Displays the operations that would be performed without actually running them", false).action(async (options) => {
|
|
846
|
+
await undeploy(options);
|
|
1232
847
|
});
|
|
1233
|
-
cli.command("undeploy-email-config").description("Undeploy a widget's email configuration from AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--bucket <bucket>", "AWS bucket for email configs").option(
|
|
1234
|
-
|
|
1235
|
-
"Undeploy from stage environment (alternative to --bucket)"
|
|
1236
|
-
).option("--prod", "Undeploy from prod environment (alternative to --bucket)").option(
|
|
1237
|
-
"--dryrun",
|
|
1238
|
-
"Displays the operations that would be performed without actually running them",
|
|
1239
|
-
false
|
|
1240
|
-
).action(async (options) => {
|
|
1241
|
-
await undeployEmailConfig(options);
|
|
848
|
+
cli.command("undeploy-email-config").description("Undeploy a widget's email configuration from AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--bucket <bucket>", "AWS bucket for email configs").option("--stage", "Undeploy from stage environment (alternative to --bucket)").option("--prod", "Undeploy from prod environment (alternative to --bucket)").option("--dryrun", "Displays the operations that would be performed without actually running them", false).action(async (options) => {
|
|
849
|
+
await undeployEmailConfig(options);
|
|
1242
850
|
});
|
|
1243
|
-
cli.command("archive").description(
|
|
1244
|
-
|
|
1245
|
-
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
1246
|
-
"--dryrun",
|
|
1247
|
-
"Displays the operations that would be performed without actually running them",
|
|
1248
|
-
false
|
|
1249
|
-
).action((options) => {
|
|
1250
|
-
archive(options);
|
|
851
|
+
cli.command("archive").description("Archive a customer configuration by moving it to the _archived folder").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--dryrun", "Displays the operations that would be performed without actually running them", false).action((options) => {
|
|
852
|
+
archive(options);
|
|
1251
853
|
});
|
|
1252
|
-
cli.command("unarchive").description(
|
|
1253
|
-
|
|
1254
|
-
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
1255
|
-
"--dryrun",
|
|
1256
|
-
"Displays the operations that would be performed without actually running them",
|
|
1257
|
-
false
|
|
1258
|
-
).action((options) => {
|
|
1259
|
-
unarchive(options);
|
|
854
|
+
cli.command("unarchive").description("Unarchive a customer configuration by restoring it from the _archived folder").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--dryrun", "Displays the operations that would be performed without actually running them", false).action((options) => {
|
|
855
|
+
unarchive(options);
|
|
1260
856
|
});
|
|
1261
|
-
cli.command("validate").description(
|
|
1262
|
-
|
|
1263
|
-
).action(async () => {
|
|
1264
|
-
await validate();
|
|
857
|
+
cli.command("validate").description("Validate the current Tamaro configuration to avoid common errors").action(async () => {
|
|
858
|
+
await validate();
|
|
1265
859
|
});
|
|
1266
860
|
(async () => {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
logError(error.stack);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
861
|
+
try {
|
|
862
|
+
logTitle(`${name} ${version}\n`);
|
|
863
|
+
await cli.parseAsync(process.argv);
|
|
864
|
+
} catch (error) {
|
|
865
|
+
if (error.signal === "SIGINT" && error.signalDescription) logError(`\n${error.signalDescription}`);
|
|
866
|
+
else {
|
|
867
|
+
console.log("");
|
|
868
|
+
logError(error.stack);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
1280
871
|
})();
|
|
872
|
+
|
|
873
|
+
//#endregion
|
|
874
|
+
export { };
|