@raisenow/tamaro-cli 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OLKERSRR.js → chunk-NJVU7WR2.js} +20 -22
- package/dist/cli.js +147 -106
- package/dist/webpack.config.js +9 -5
- package/package.json +22 -22
- package/src/cli.ts +15 -5
- package/src/commands/build.ts +13 -7
- package/src/commands/deploy-email-config.ts +76 -12
- package/src/commands/deploy.ts +28 -30
- package/src/commands/dev.ts +5 -7
- package/src/commands/list-deployed.ts +16 -10
- package/src/commands/serve.ts +4 -6
- package/src/lib/aws.ts +34 -55
- package/src/lib/command.ts +2 -2
- package/src/lib/constants.ts +3 -4
- package/src/lib/env.ts +1 -2
- package/src/webpack.config.ts +8 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/tsup@8.3.
|
|
1
|
+
// node_modules/.pnpm/tsup@8.3.5_jiti@1.21.0_postcss@8.4.47_tsx@4.19.1_typescript@5.6.3/node_modules/tsup/assets/esm_shims.js
|
|
2
2
|
import { fileURLToPath } from "url";
|
|
3
3
|
import path from "path";
|
|
4
4
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -27,12 +27,25 @@ var logDataTable = (data) => {
|
|
|
27
27
|
console.log("");
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// src/lib/command.ts
|
|
31
|
+
import { execaCommandSync } from "execa";
|
|
32
|
+
var halt = (message) => {
|
|
33
|
+
logError(message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
};
|
|
36
|
+
var prepareCommand = (cmd) => {
|
|
37
|
+
return cmd.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
|
|
38
|
+
};
|
|
39
|
+
var runCommandSync = (cmd, options) => {
|
|
40
|
+
return execaCommandSync(prepareCommand(cmd), options);
|
|
41
|
+
};
|
|
42
|
+
|
|
30
43
|
// src/lib/constants.ts
|
|
31
44
|
var DEFAULT_TAG = "latest";
|
|
32
45
|
var DEFAULT_PORT = 1234;
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
46
|
+
var AWS_S3_BUCKET_TAMARO = "tamaro.raisenow.com";
|
|
47
|
+
var AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE = "rnw-stage-email-service";
|
|
48
|
+
var AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD = "rnw-email-service";
|
|
36
49
|
var CORE_CONFIG_NAME = "tamaro-core";
|
|
37
50
|
var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
|
|
38
51
|
var HTTPS_CRT_FILE = "localhost.crt";
|
|
@@ -141,21 +154,6 @@ import { config as dotenvConfig } from "dotenv";
|
|
|
141
154
|
import { expand as dotenvExpand } from "dotenv-expand";
|
|
142
155
|
import { globSync } from "glob";
|
|
143
156
|
import stripIndent3 from "strip-indent";
|
|
144
|
-
|
|
145
|
-
// src/lib/command.ts
|
|
146
|
-
import { execaCommandSync } from "execa";
|
|
147
|
-
var halt = (message, exitCode = 1) => {
|
|
148
|
-
logError(message);
|
|
149
|
-
process.exit(exitCode);
|
|
150
|
-
};
|
|
151
|
-
var prepareCommand = (cmd) => {
|
|
152
|
-
return cmd.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
|
|
153
|
-
};
|
|
154
|
-
var runCommandSync = (cmd, options) => {
|
|
155
|
-
return execaCommandSync(prepareCommand(cmd), options);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// src/lib/env.ts
|
|
159
157
|
var require3 = createRequire2(import.meta.url);
|
|
160
158
|
var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
161
159
|
const filePath = files.find((file) => basename2(file) === ".env");
|
|
@@ -278,9 +276,9 @@ export {
|
|
|
278
276
|
runCommandSync,
|
|
279
277
|
DEFAULT_TAG,
|
|
280
278
|
DEFAULT_PORT,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
279
|
+
AWS_S3_BUCKET_TAMARO,
|
|
280
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
|
|
281
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD,
|
|
284
282
|
CORE_CONFIG_NAME,
|
|
285
283
|
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
286
284
|
HTTPS_CRT_FILE,
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
AWS_S3_BUCKET_TAMARO,
|
|
5
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD,
|
|
6
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
|
|
7
7
|
CORE_CONFIG_NAME,
|
|
8
8
|
DEFAULT_PORT,
|
|
9
9
|
DEFAULT_TAG,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveBin,
|
|
23
23
|
resolveOwn,
|
|
24
24
|
runCommandSync
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-NJVU7WR2.js";
|
|
26
26
|
|
|
27
27
|
// src/cli.ts
|
|
28
28
|
import { createCommand } from "commander";
|
|
@@ -31,10 +31,6 @@ import { createCommand } from "commander";
|
|
|
31
31
|
import { execaCommandSync } from "execa";
|
|
32
32
|
import prompts from "prompts";
|
|
33
33
|
import stripIndent from "strip-indent";
|
|
34
|
-
var withAwsAuthenticate = (fn, options) => {
|
|
35
|
-
awsAuthenticate(options);
|
|
36
|
-
return fn();
|
|
37
|
-
};
|
|
38
34
|
var awsAuthenticate = (options) => {
|
|
39
35
|
if (options.ci) {
|
|
40
36
|
return;
|
|
@@ -63,11 +59,11 @@ var getAvailableProfiles = () => {
|
|
|
63
59
|
return stdout.split("\n");
|
|
64
60
|
};
|
|
65
61
|
var checkIdentity = (options) => {
|
|
66
|
-
const flags = prepareFlags(
|
|
62
|
+
const flags = prepareFlags(options);
|
|
67
63
|
execaCommandSync(`aws sts get-caller-identity ${flags}`);
|
|
68
64
|
};
|
|
69
65
|
var login = (options) => {
|
|
70
|
-
const flags = prepareFlags(
|
|
66
|
+
const flags = prepareFlags(options);
|
|
71
67
|
try {
|
|
72
68
|
execaCommandSync(`aws sso login ${flags}`, { stdio: "inherit" });
|
|
73
69
|
console.log("");
|
|
@@ -75,12 +71,24 @@ var login = (options) => {
|
|
|
75
71
|
halt("Login failed.");
|
|
76
72
|
}
|
|
77
73
|
};
|
|
78
|
-
var prepareFlags = (
|
|
74
|
+
var prepareFlags = (options) => {
|
|
75
|
+
const flags = [];
|
|
79
76
|
const { profile } = options;
|
|
80
77
|
if (profile) {
|
|
81
78
|
flags.push(`--profile ${profile}`);
|
|
82
79
|
}
|
|
83
|
-
return flags;
|
|
80
|
+
return flags.join(" ");
|
|
81
|
+
};
|
|
82
|
+
var assertProfileValid = (profile) => {
|
|
83
|
+
const profiles = getAvailableProfiles();
|
|
84
|
+
if (!profiles.includes(profile)) {
|
|
85
|
+
halt(
|
|
86
|
+
stripIndent(`
|
|
87
|
+
AWS profile "${profile}" is not found.
|
|
88
|
+
Available profiles are: ${profiles.map((v) => `"${v}"`).join(", ")}.
|
|
89
|
+
`)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
84
92
|
};
|
|
85
93
|
var promptProfile = async () => {
|
|
86
94
|
const profiles = getAvailableProfiles().filter((v) => !!v).map((v) => ({ title: v, value: v }));
|
|
@@ -94,31 +102,11 @@ var promptProfile = async () => {
|
|
|
94
102
|
}
|
|
95
103
|
],
|
|
96
104
|
{
|
|
97
|
-
onCancel: () =>
|
|
105
|
+
onCancel: () => halt()
|
|
98
106
|
}
|
|
99
107
|
);
|
|
100
108
|
return profile;
|
|
101
109
|
};
|
|
102
|
-
var promptBucket = async () => {
|
|
103
|
-
const buckets = [
|
|
104
|
-
{ title: "stage", value: AWS_S3_EMAIL_CONFIG_STAGE_BUCKET },
|
|
105
|
-
{ title: "prod", value: AWS_S3_EMAIL_CONFIG_PROD_BUCKET }
|
|
106
|
-
];
|
|
107
|
-
const { bucket } = await prompts(
|
|
108
|
-
[
|
|
109
|
-
{
|
|
110
|
-
type: "select",
|
|
111
|
-
name: "bucket",
|
|
112
|
-
message: "Select environment",
|
|
113
|
-
choices: buckets
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
{
|
|
117
|
-
onCancel: () => process.exit(1)
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
return bucket;
|
|
121
|
-
};
|
|
122
110
|
|
|
123
111
|
// src/lib/https.ts
|
|
124
112
|
import { existsSync } from "fs";
|
|
@@ -157,13 +145,13 @@ var notify = (args) => {
|
|
|
157
145
|
// src/commands/build.ts
|
|
158
146
|
var build = async (options) => {
|
|
159
147
|
const { env } = options;
|
|
160
|
-
assertOptionsValid(options);
|
|
161
148
|
applyEnv(env);
|
|
162
|
-
if (options.deploy && !options.ci) {
|
|
149
|
+
if (options.deploy && !options.profile && !options.ci) {
|
|
163
150
|
assertProfilesPresent();
|
|
164
151
|
options.profile = await promptProfile();
|
|
165
152
|
}
|
|
166
|
-
|
|
153
|
+
assertOptionsValid(options);
|
|
154
|
+
const flags = prepareFlags2(options);
|
|
167
155
|
const { ifCore } = getIfCoreFns();
|
|
168
156
|
const paths = getPaths(ifCore);
|
|
169
157
|
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
@@ -194,7 +182,7 @@ Bundle for "${configName}" customer configuration is done.`);
|
|
|
194
182
|
});
|
|
195
183
|
};
|
|
196
184
|
var assertOptionsValid = (options) => {
|
|
197
|
-
const { localCore, https, deploy: deploy2, env } = options;
|
|
185
|
+
const { localCore, https, deploy: deploy2, env, profile } = options;
|
|
198
186
|
const { ifCore } = getIfCoreFns();
|
|
199
187
|
if (ifCore() && localCore) {
|
|
200
188
|
halt('Flag "--local-core" is redundant if running in Tamaro Core context.');
|
|
@@ -205,9 +193,13 @@ var assertOptionsValid = (options) => {
|
|
|
205
193
|
if (https) {
|
|
206
194
|
assertCrtExists();
|
|
207
195
|
}
|
|
196
|
+
if (profile) {
|
|
197
|
+
assertProfileValid(profile);
|
|
198
|
+
}
|
|
208
199
|
assertEnvValid(env);
|
|
209
200
|
};
|
|
210
|
-
var prepareFlags2 = (
|
|
201
|
+
var prepareFlags2 = (options) => {
|
|
202
|
+
const flags = [];
|
|
211
203
|
const { localCore, analyze, https, nolint } = options;
|
|
212
204
|
if (localCore) {
|
|
213
205
|
flags.push("--env localCore");
|
|
@@ -221,7 +213,7 @@ var prepareFlags2 = (flags, options) => {
|
|
|
221
213
|
if (nolint) {
|
|
222
214
|
flags.push("--env nolint");
|
|
223
215
|
}
|
|
224
|
-
return flags;
|
|
216
|
+
return flags.join(" ");
|
|
225
217
|
};
|
|
226
218
|
|
|
227
219
|
// src/commands/deploy.ts
|
|
@@ -230,16 +222,17 @@ import stripIndent4 from "strip-indent";
|
|
|
230
222
|
var deploy = async (options) => {
|
|
231
223
|
const { ifCore } = getIfCoreFns();
|
|
232
224
|
const paths = getPaths(ifCore);
|
|
233
|
-
assertOptionsValid2(options);
|
|
234
225
|
assertDistPathExists(paths.appDist);
|
|
235
|
-
if (!options.
|
|
226
|
+
if (!options.profile && !options.ci) {
|
|
236
227
|
assertProfilesPresent();
|
|
237
228
|
options.profile = await promptProfile();
|
|
238
229
|
}
|
|
239
|
-
|
|
230
|
+
assertOptionsValid2(options);
|
|
231
|
+
awsAuthenticate(options);
|
|
232
|
+
const flags = prepareFlags(options);
|
|
240
233
|
const { tag } = options;
|
|
241
234
|
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
242
|
-
const deployUrl = `s3://${
|
|
235
|
+
const deployUrl = `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}`;
|
|
243
236
|
const entryFilename = ifCore("index.js", "widget.js");
|
|
244
237
|
const cmdSyncAll = `
|
|
245
238
|
aws s3 sync ${paths.appDist} ${deployUrl}
|
|
@@ -251,10 +244,7 @@ var deploy = async (options) => {
|
|
|
251
244
|
logTitle("Deploying to AWS S3 \u2026");
|
|
252
245
|
logCommand(cmdSyncAll);
|
|
253
246
|
try {
|
|
254
|
-
|
|
255
|
-
() => runCommandSync(cmdSyncAll, { stdout: "inherit" }),
|
|
256
|
-
options
|
|
257
|
-
);
|
|
247
|
+
runCommandSync(cmdSyncAll, { stdout: "inherit" });
|
|
258
248
|
} catch (error) {
|
|
259
249
|
halt(error.stderr);
|
|
260
250
|
}
|
|
@@ -266,10 +256,7 @@ var deploy = async (options) => {
|
|
|
266
256
|
`;
|
|
267
257
|
logCommand(cmdCpEntry);
|
|
268
258
|
try {
|
|
269
|
-
|
|
270
|
-
() => runCommandSync(cmdCpEntry, { stdout: "inherit" }),
|
|
271
|
-
options
|
|
272
|
-
);
|
|
259
|
+
runCommandSync(cmdCpEntry, { stdout: "inherit" });
|
|
273
260
|
} catch (error) {
|
|
274
261
|
halt(error.stderr);
|
|
275
262
|
}
|
|
@@ -282,12 +269,12 @@ var deploy = async (options) => {
|
|
|
282
269
|
logTitle("\nInvalidating edge cache \u2026");
|
|
283
270
|
logCommand(cmdInvalidateCache);
|
|
284
271
|
try {
|
|
285
|
-
|
|
272
|
+
runCommandSync(cmdInvalidateCache);
|
|
286
273
|
} catch (error) {
|
|
287
274
|
halt(error.stderr);
|
|
288
275
|
}
|
|
289
|
-
const demoPage = `https://${
|
|
290
|
-
const entryPoint = `https://${
|
|
276
|
+
const demoPage = `https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
|
|
277
|
+
const entryPoint = `https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/${entryFilename}`;
|
|
291
278
|
logTitle(`
|
|
292
279
|
Bundle for "${configName}" is deployed with tag "${tag}".`);
|
|
293
280
|
logDataTable({
|
|
@@ -306,7 +293,10 @@ Bundle for "${configName}" is deployed with tag "${tag}".`);
|
|
|
306
293
|
});
|
|
307
294
|
};
|
|
308
295
|
var assertOptionsValid2 = (options) => {
|
|
309
|
-
const { tag } = options;
|
|
296
|
+
const { profile, tag } = options;
|
|
297
|
+
if (profile) {
|
|
298
|
+
assertProfileValid(profile);
|
|
299
|
+
}
|
|
310
300
|
assertTagValid(tag);
|
|
311
301
|
};
|
|
312
302
|
var assertDistPathExists = (distPath) => {
|
|
@@ -330,20 +320,25 @@ var assertTagValid = (tag) => {
|
|
|
330
320
|
|
|
331
321
|
// src/commands/deploy-email-config.ts
|
|
332
322
|
import { existsSync as existsSync3 } from "fs";
|
|
323
|
+
import prompts2 from "prompts";
|
|
333
324
|
var deployEmailConfig = async (options) => {
|
|
334
325
|
const { ifCore } = getIfCoreFns();
|
|
335
326
|
const paths = getPaths(ifCore);
|
|
336
327
|
const emailConfigPath = `${paths.app}/email-config`;
|
|
337
328
|
assertIsNotCore();
|
|
338
329
|
assertEmailConfigPathExists(emailConfigPath);
|
|
339
|
-
if (!options.ci) {
|
|
330
|
+
if (!options.profile && !options.ci) {
|
|
340
331
|
assertProfilesPresent();
|
|
341
332
|
options.profile = await promptProfile();
|
|
342
333
|
}
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
if (!options.bucket) {
|
|
335
|
+
options.bucket = options.ci ? AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD : await promptBucketTamaroEmailConfig();
|
|
336
|
+
}
|
|
337
|
+
assertOptionsValid3(options);
|
|
338
|
+
awsAuthenticate(options);
|
|
339
|
+
const flags = prepareFlags(options);
|
|
345
340
|
const configName = getWidgetUuid();
|
|
346
|
-
const deployUrl = `s3://${bucket}/${configName}`;
|
|
341
|
+
const deployUrl = `s3://${options.bucket}/${configName}`;
|
|
347
342
|
const cmd = `
|
|
348
343
|
aws s3 sync ${emailConfigPath} ${deployUrl}
|
|
349
344
|
--delete
|
|
@@ -355,7 +350,7 @@ var deployEmailConfig = async (options) => {
|
|
|
355
350
|
);
|
|
356
351
|
logCommand(cmd);
|
|
357
352
|
try {
|
|
358
|
-
|
|
353
|
+
runCommandSync(cmd, { stdout: "inherit" });
|
|
359
354
|
} catch (error) {
|
|
360
355
|
halt(error.stderr);
|
|
361
356
|
}
|
|
@@ -370,9 +365,18 @@ var deployEmailConfig = async (options) => {
|
|
|
370
365
|
});
|
|
371
366
|
});
|
|
372
367
|
};
|
|
368
|
+
var assertOptionsValid3 = (options) => {
|
|
369
|
+
const { profile, bucket } = options;
|
|
370
|
+
if (profile) {
|
|
371
|
+
assertProfileValid(profile);
|
|
372
|
+
}
|
|
373
|
+
if (bucket) {
|
|
374
|
+
assertBucketValid(bucket);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
373
377
|
var assertEmailConfigPathExists = (distPath) => {
|
|
374
378
|
if (!existsSync3(distPath)) {
|
|
375
|
-
halt("Email config folder does not exists. Nothing to deploy."
|
|
379
|
+
halt("Email config folder does not exists. Nothing to deploy.");
|
|
376
380
|
}
|
|
377
381
|
};
|
|
378
382
|
var assertIsNotCore = () => {
|
|
@@ -381,14 +385,43 @@ var assertIsNotCore = () => {
|
|
|
381
385
|
halt("You cannot deploy widget email configuration for Tamaro Core.");
|
|
382
386
|
}
|
|
383
387
|
};
|
|
388
|
+
var assertBucketValid = (bucket) => {
|
|
389
|
+
const buckets = [
|
|
390
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
|
|
391
|
+
AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
|
|
392
|
+
];
|
|
393
|
+
if (!buckets.includes(bucket)) {
|
|
394
|
+
halt("Invalid bucket name.");
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
var promptBucketTamaroEmailConfig = async () => {
|
|
398
|
+
const buckets = [
|
|
399
|
+
{ title: "stage", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE },
|
|
400
|
+
{ title: "prod", value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD }
|
|
401
|
+
];
|
|
402
|
+
const { bucket } = await prompts2(
|
|
403
|
+
[
|
|
404
|
+
{
|
|
405
|
+
type: "select",
|
|
406
|
+
name: "bucket",
|
|
407
|
+
message: "Select environment",
|
|
408
|
+
choices: buckets
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
{
|
|
412
|
+
onCancel: () => halt()
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
return bucket;
|
|
416
|
+
};
|
|
384
417
|
|
|
385
418
|
// src/commands/dev.ts
|
|
386
419
|
import { getPortPromise } from "portfinder";
|
|
387
420
|
var dev = async (options) => {
|
|
388
421
|
const { env } = options;
|
|
389
|
-
assertOptionsValid3(options);
|
|
390
422
|
applyEnv(env);
|
|
391
|
-
|
|
423
|
+
assertOptionsValid4(options);
|
|
424
|
+
const flags = await prepareFlags3(options);
|
|
392
425
|
const { ifCore } = getIfCoreFns();
|
|
393
426
|
const title = ifCore(
|
|
394
427
|
"Running dev web-server for Tamaro Core \u2026",
|
|
@@ -405,7 +438,7 @@ var dev = async (options) => {
|
|
|
405
438
|
logCommand(cmd);
|
|
406
439
|
runCommandSync(cmd, { stdio: "inherit" });
|
|
407
440
|
};
|
|
408
|
-
var
|
|
441
|
+
var assertOptionsValid4 = (options) => {
|
|
409
442
|
const { localCore, https, port, env } = options;
|
|
410
443
|
const { ifCore } = getIfCoreFns();
|
|
411
444
|
if (ifCore() && localCore) {
|
|
@@ -419,7 +452,8 @@ var assertOptionsValid3 = (options) => {
|
|
|
419
452
|
}
|
|
420
453
|
assertEnvValid(env);
|
|
421
454
|
};
|
|
422
|
-
var prepareFlags3 = async (
|
|
455
|
+
var prepareFlags3 = async (options) => {
|
|
456
|
+
const flags = [];
|
|
423
457
|
const { localCore, port: defaultPort, https, nolint } = options;
|
|
424
458
|
const port = await getPortPromise({ port: Number(defaultPort) });
|
|
425
459
|
if (localCore) {
|
|
@@ -432,28 +466,29 @@ var prepareFlags3 = async (flags, options) => {
|
|
|
432
466
|
if (nolint) {
|
|
433
467
|
flags.push("--env nolint");
|
|
434
468
|
}
|
|
435
|
-
return flags;
|
|
469
|
+
return flags.join(" ");
|
|
436
470
|
};
|
|
437
471
|
|
|
438
472
|
// src/commands/list-deployed.ts
|
|
439
473
|
var listDeployed = async (options) => {
|
|
440
|
-
|
|
441
|
-
if (!options.ci) {
|
|
474
|
+
if (!options.profile && !options.ci) {
|
|
442
475
|
assertProfilesPresent();
|
|
443
476
|
options.profile = await promptProfile();
|
|
444
477
|
}
|
|
445
|
-
|
|
478
|
+
assertOptionsValid5(options);
|
|
479
|
+
awsAuthenticate(options);
|
|
480
|
+
const flags = prepareFlags(options);
|
|
446
481
|
const { config } = options;
|
|
447
482
|
const { ifCore } = getIfCoreFns();
|
|
448
483
|
const configName = config ?? ifCore(CORE_CONFIG_NAME, getWidgetUuid());
|
|
449
484
|
const title = !config && ifCore() ? `Listing deployments of Tamaro Core \u2026` : `Listing deployments of "${configName}" customer configuration \u2026`;
|
|
450
|
-
const deployUrl = `s3://${
|
|
485
|
+
const deployUrl = `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/`;
|
|
451
486
|
const cmd = `aws s3 ls ${deployUrl} ${flags}`;
|
|
452
487
|
let out = "";
|
|
453
488
|
logTitle(title);
|
|
454
489
|
logCommand(cmd);
|
|
455
490
|
try {
|
|
456
|
-
const result =
|
|
491
|
+
const result = runCommandSync(cmd);
|
|
457
492
|
out = result.stdout;
|
|
458
493
|
} catch (error) {
|
|
459
494
|
out = error.stdout;
|
|
@@ -468,15 +503,18 @@ var listDeployed = async (options) => {
|
|
|
468
503
|
text = "No deployments found.";
|
|
469
504
|
} else {
|
|
470
505
|
text = tags.map((tag, idx) => {
|
|
471
|
-
return `${idx + 1}. https://${
|
|
506
|
+
return `${idx + 1}. https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
|
|
472
507
|
}).join("\n");
|
|
473
508
|
}
|
|
474
509
|
console.log(`${text}
|
|
475
510
|
`);
|
|
476
511
|
};
|
|
477
|
-
var
|
|
478
|
-
const { config } = options;
|
|
512
|
+
var assertOptionsValid5 = (options) => {
|
|
513
|
+
const { config, profile } = options;
|
|
479
514
|
assertConfigValid(config);
|
|
515
|
+
if (profile) {
|
|
516
|
+
assertProfileValid(profile);
|
|
517
|
+
}
|
|
480
518
|
};
|
|
481
519
|
var assertConfigValid = (config) => {
|
|
482
520
|
if (!config) {
|
|
@@ -498,8 +536,8 @@ var parseTags = (lines) => {
|
|
|
498
536
|
import { resolve as resolve2 } from "path";
|
|
499
537
|
import { getPortPromise as getPortPromise2 } from "portfinder";
|
|
500
538
|
var serve = async (options) => {
|
|
501
|
-
|
|
502
|
-
const flags =
|
|
539
|
+
assertOptionsValid6(options);
|
|
540
|
+
const flags = await prepareFlags4(options);
|
|
503
541
|
const { ifCore } = getIfCoreFns();
|
|
504
542
|
const paths = getPaths(ifCore);
|
|
505
543
|
const cmd = `
|
|
@@ -511,7 +549,7 @@ var serve = async (options) => {
|
|
|
511
549
|
logCommand(cmd);
|
|
512
550
|
runCommandSync(cmd, { stdio: "inherit" });
|
|
513
551
|
};
|
|
514
|
-
var
|
|
552
|
+
var assertOptionsValid6 = (options) => {
|
|
515
553
|
const { port, https } = options;
|
|
516
554
|
if (isNaN(Number(port))) {
|
|
517
555
|
halt('Flag "--port" should be a number.');
|
|
@@ -520,7 +558,8 @@ var assertOptionsValid5 = (options) => {
|
|
|
520
558
|
assertCrtExists();
|
|
521
559
|
}
|
|
522
560
|
};
|
|
523
|
-
var prepareFlags4 = async (
|
|
561
|
+
var prepareFlags4 = async (options) => {
|
|
562
|
+
const flags = [];
|
|
524
563
|
const { port: defaultPort, https } = options;
|
|
525
564
|
const port = await getPortPromise2({ port: Number(defaultPort) });
|
|
526
565
|
flags.push(`-p ${port}`);
|
|
@@ -532,20 +571,20 @@ var prepareFlags4 = async (flags, options) => {
|
|
|
532
571
|
flags.push(`--ssl-cert ${certFile}`);
|
|
533
572
|
flags.push(`--ssl-key ${keyFile}`);
|
|
534
573
|
}
|
|
535
|
-
return flags;
|
|
574
|
+
return flags.join(" ");
|
|
536
575
|
};
|
|
537
576
|
|
|
538
577
|
// package.json
|
|
539
578
|
var package_default = {
|
|
540
579
|
name: "@raisenow/tamaro-cli",
|
|
541
|
-
version: "1.1.
|
|
580
|
+
version: "1.1.7",
|
|
542
581
|
author: {
|
|
543
582
|
name: "RaiseNow",
|
|
544
583
|
email: "development@raisenow.com"
|
|
545
584
|
},
|
|
546
585
|
type: "module",
|
|
547
586
|
bin: "dist/cli.js",
|
|
548
|
-
packageManager: "pnpm@9.12.
|
|
587
|
+
packageManager: "pnpm@9.12.3",
|
|
549
588
|
engines: {
|
|
550
589
|
node: ">=20",
|
|
551
590
|
pnpm: ">= 9.12",
|
|
@@ -563,20 +602,20 @@ var package_default = {
|
|
|
563
602
|
format: "prettier --write ."
|
|
564
603
|
},
|
|
565
604
|
dependencies: {
|
|
566
|
-
"@babel/cli": "^7.25.
|
|
567
|
-
"@babel/core": "^7.
|
|
568
|
-
"@babel/plugin-proposal-decorators": "^7.25.
|
|
605
|
+
"@babel/cli": "^7.25.9",
|
|
606
|
+
"@babel/core": "^7.26.0",
|
|
607
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
569
608
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
570
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
571
|
-
"@babel/preset-env": "^7.
|
|
572
|
-
"@babel/preset-react": "^7.25.
|
|
573
|
-
"@babel/preset-typescript": "^7.
|
|
574
|
-
"@babel/runtime-corejs3": "^7.
|
|
609
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
610
|
+
"@babel/preset-env": "^7.26.0",
|
|
611
|
+
"@babel/preset-react": "^7.25.9",
|
|
612
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
613
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
575
614
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
576
615
|
"@statoscope/webpack-plugin": "^5.28.2",
|
|
577
616
|
"@types/columnify": "^1.5.4",
|
|
578
|
-
"@types/lodash": "^4.17.
|
|
579
|
-
"@types/node": "^20.
|
|
617
|
+
"@types/lodash": "^4.17.13",
|
|
618
|
+
"@types/node": "^20.17.6",
|
|
580
619
|
"@types/node-notifier": "^8.0.5",
|
|
581
620
|
"@types/prompts": "^2.4.9",
|
|
582
621
|
"@types/resolve-bin": "^0.4.3",
|
|
@@ -592,7 +631,7 @@ var package_default = {
|
|
|
592
631
|
columnify: "^1.6.0",
|
|
593
632
|
commander: "^12.1.0",
|
|
594
633
|
"copy-webpack-plugin": "^12.0.2",
|
|
595
|
-
"core-js": "^3.
|
|
634
|
+
"core-js": "^3.39.0",
|
|
596
635
|
"css-loader": "^7.1.2",
|
|
597
636
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
598
637
|
dotenv: "^16.4.5",
|
|
@@ -606,36 +645,36 @@ var package_default = {
|
|
|
606
645
|
"eslint-plugin-markdownlint": "^0.6.0",
|
|
607
646
|
"eslint-plugin-promise": "^7.1.0",
|
|
608
647
|
"eslint-plugin-unused-imports": "^3.2.0",
|
|
609
|
-
"eslint-plugin-yml": "^1.
|
|
648
|
+
"eslint-plugin-yml": "^1.15.0",
|
|
610
649
|
"eslint-webpack-plugin": "^4.2.0",
|
|
611
|
-
execa: "^9.
|
|
650
|
+
execa: "^9.5.1",
|
|
612
651
|
"file-loader": "^6.2.0",
|
|
613
652
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
614
653
|
glob: "^11.0.0",
|
|
615
654
|
"html-loader": "^5.1.0",
|
|
616
|
-
"html-webpack-plugin": "^5.6.
|
|
655
|
+
"html-webpack-plugin": "^5.6.3",
|
|
617
656
|
"json-loader": "^0.5.7",
|
|
618
657
|
lodash: "^4.17.21",
|
|
619
|
-
"mini-css-extract-plugin": "^2.9.
|
|
658
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
620
659
|
"node-notifier": "^10.0.1",
|
|
621
660
|
portfinder: "^1.0.32",
|
|
622
661
|
postcss: "^8.4.47",
|
|
623
|
-
"postcss-custom-properties": "^14.0.
|
|
662
|
+
"postcss-custom-properties": "^14.0.4",
|
|
624
663
|
"postcss-loader": "^8.1.1",
|
|
625
664
|
prettier: "^3.3.3",
|
|
626
665
|
prompts: "^2.4.2",
|
|
627
666
|
"react-refresh": "^0.14.2",
|
|
628
667
|
"resolve-url-loader": "^5.0.0",
|
|
629
|
-
sass: "^1.
|
|
630
|
-
"sass-loader": "^16.0.
|
|
668
|
+
sass: "^1.80.6",
|
|
669
|
+
"sass-loader": "^16.0.3",
|
|
631
670
|
"source-map-loader": "^5.0.0",
|
|
632
671
|
"strip-indent": "^4.0.0",
|
|
633
672
|
"style-loader": "^4.0.0",
|
|
634
673
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
635
|
-
tsup: "^8.3.
|
|
674
|
+
tsup: "^8.3.5",
|
|
636
675
|
typescript: "^5.6.3",
|
|
637
676
|
"url-loader": "^4.1.1",
|
|
638
|
-
webpack: "^5.
|
|
677
|
+
webpack: "^5.96.1",
|
|
639
678
|
"webpack-cli": "^5.1.4",
|
|
640
679
|
"webpack-config-utils": "^2.3.1",
|
|
641
680
|
"webpack-dev-server": "^5.1.0",
|
|
@@ -648,7 +687,7 @@ process.on("unhandledRejection", (error) => {
|
|
|
648
687
|
throw error;
|
|
649
688
|
});
|
|
650
689
|
process.on("SIGINT", () => {
|
|
651
|
-
|
|
690
|
+
halt();
|
|
652
691
|
});
|
|
653
692
|
var cli = createCommand().name(package_default.name).version(package_default.version, "-v, --version");
|
|
654
693
|
cli.command("dev").description(
|
|
@@ -674,7 +713,7 @@ cli.command("build").description(
|
|
|
674
713
|
"--https",
|
|
675
714
|
"Let local web server serve Tamaro with SSL encryption",
|
|
676
715
|
false
|
|
677
|
-
).option("--port <port>", "Web server port", `${DEFAULT_PORT}`).option("--env <env>", "Environment (dev, stage, prod)").option("--ci", "CI environment", false).option(
|
|
716
|
+
).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(
|
|
678
717
|
"--deploy",
|
|
679
718
|
"Deploy Tamaro Core or a customer configuration bundle to AWS S3",
|
|
680
719
|
false
|
|
@@ -700,7 +739,7 @@ cli.command("serve").description("Run a local web server for pre-built bundle").
|
|
|
700
739
|
});
|
|
701
740
|
cli.command("deploy").description(
|
|
702
741
|
"Deploy a pre-built Tamaro Core or customer configuration bundle to AWS S3"
|
|
703
|
-
).option("--ci", "CI environment", false).option(
|
|
742
|
+
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
704
743
|
"--tag <tag>",
|
|
705
744
|
"Tag which should be used for the deployment of the bundle",
|
|
706
745
|
DEFAULT_TAG
|
|
@@ -709,17 +748,19 @@ cli.command("deploy").description(
|
|
|
709
748
|
});
|
|
710
749
|
cli.command("list-deployed").description(
|
|
711
750
|
"List deployments of Tamaro Core or a particular customer configuration"
|
|
712
|
-
).option("--ci", "CI environment", false).option(
|
|
751
|
+
).option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option(
|
|
713
752
|
"--config <config>",
|
|
714
753
|
"Configuration name (default: current customer configuration)"
|
|
715
754
|
).action(async (options) => {
|
|
716
755
|
await listDeployed(options);
|
|
717
756
|
});
|
|
718
|
-
cli.command("deploy-email-config").description("Deploy a widget's email configuration to AWS S3").option("--ci", "CI environment", false).action(async (options) => {
|
|
757
|
+
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").action(async (options) => {
|
|
719
758
|
await deployEmailConfig(options);
|
|
720
759
|
});
|
|
721
760
|
(async () => {
|
|
722
761
|
try {
|
|
762
|
+
logTitle(`${package_default.name} ${package_default.version}
|
|
763
|
+
`);
|
|
723
764
|
await cli.parseAsync(process.argv);
|
|
724
765
|
} catch (error) {
|
|
725
766
|
if (error.signal === "SIGINT" && error.signalDescription) {
|