@raisenow/tamaro-cli 1.8.0-dev.4 → 1.8.0-dev.6

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.
@@ -1,31 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="03cc3f97-55ca-4737-9fe2-779ac8457ab2" name="Changes" comment="">
5
- <change beforePath="$PROJECT_DIR$/eslint.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/eslint.config.ts" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/src/cli.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/cli.ts" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/src/commands/archive.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/archive.ts" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/src/commands/build.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/build.ts" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/commands/deploy-email-config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/deploy-email-config.ts" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/src/commands/deploy.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/deploy.ts" afterDir="false" />
11
- <change beforePath="$PROJECT_DIR$/src/commands/dev.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/dev.ts" afterDir="false" />
12
- <change beforePath="$PROJECT_DIR$/src/commands/list-deployed.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/list-deployed.ts" afterDir="false" />
13
- <change beforePath="$PROJECT_DIR$/src/commands/serve.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/serve.ts" afterDir="false" />
14
- <change beforePath="$PROJECT_DIR$/src/commands/unarchive.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/unarchive.ts" afterDir="false" />
15
- <change beforePath="$PROJECT_DIR$/src/commands/undeploy-email-config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/undeploy-email-config.ts" afterDir="false" />
16
- <change beforePath="$PROJECT_DIR$/src/commands/undeploy.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/undeploy.ts" afterDir="false" />
17
- <change beforePath="$PROJECT_DIR$/src/commands/validate.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/commands/validate.ts" afterDir="false" />
18
- <change beforePath="$PROJECT_DIR$/src/lib/InterpolateHtmlPlugin.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/InterpolateHtmlPlugin.ts" afterDir="false" />
19
- <change beforePath="$PROJECT_DIR$/src/lib/aws.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/aws.ts" afterDir="false" />
20
- <change beforePath="$PROJECT_DIR$/src/lib/command.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/command.ts" afterDir="false" />
21
- <change beforePath="$PROJECT_DIR$/src/lib/env.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/env.ts" afterDir="false" />
22
- <change beforePath="$PROJECT_DIR$/src/lib/https.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/https.ts" afterDir="false" />
23
- <change beforePath="$PROJECT_DIR$/src/lib/notifier.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/notifier.ts" afterDir="false" />
24
- <change beforePath="$PROJECT_DIR$/src/lib/resolve.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/resolve.ts" afterDir="false" />
25
- <change beforePath="$PROJECT_DIR$/src/lib/validators/assertTagValid.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/validators/assertTagValid.ts" afterDir="false" />
26
- <change beforePath="$PROJECT_DIR$/src/lib/validators/validateEmailTemplates.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/validators/validateEmailTemplates.ts" afterDir="false" />
27
- <change beforePath="$PROJECT_DIR$/src/webpack.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/webpack.config.ts" afterDir="false" />
28
- </list>
4
+ <list default="true" id="03cc3f97-55ca-4737-9fe2-779ac8457ab2" name="Changes" comment="" />
29
5
  <option name="SHOW_DIALOG" value="false" />
30
6
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
31
7
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -66,7 +42,7 @@
66
42
  <option name="number" value="Default" />
67
43
  <option name="presentableId" value="Default" />
68
44
  <updated>1775412859839</updated>
69
- <workItem from="1775412861312" duration="865000" />
45
+ <workItem from="1775412861312" duration="2060000" />
70
46
  </task>
71
47
  <servers />
72
48
  </component>
package/dist/cli.js CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
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-LI5tXjy4.js";
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-B20cxmcB.js";
3
3
  import { createCommand } from "commander";
4
- import { existsSync, mkdirSync, renameSync } from "fs";
5
- import { basename, dirname, resolve } from "path";
4
+ import fs, { existsSync, mkdirSync, renameSync } from "node:fs";
5
+ import path from "node:path";
6
6
  import { execaCommandSync } from "execa";
7
7
  import prompts from "prompts";
8
8
  import stripIndent from "strip-indent";
9
9
  import notifier from "node-notifier";
10
10
  import { globSync } from "glob";
11
- import fs from "node:fs";
12
11
  import Handlebars from "handlebars";
13
12
  import helpers from "handlebars-helpers";
14
13
  import { getPortPromise } from "portfinder";
@@ -23,7 +22,7 @@ const awsAuthenticate = (options) => {
23
22
  return;
24
23
  try {
25
24
  checkIdentity(options);
26
- } catch (error) {
25
+ } catch {
27
26
  login(options);
28
27
  }
29
28
  };
@@ -55,7 +54,7 @@ const login = (options) => {
55
54
  try {
56
55
  execaCommandSync(`aws sso login ${flags}`, { stdio: "inherit" });
57
56
  console.log("");
58
- } catch (error) {
57
+ } catch {
59
58
  halt("Login failed.");
60
59
  }
61
60
  };
@@ -74,25 +73,25 @@ const assertProfileValid = (profile) => {
74
73
  };
75
74
  const promptProfile = async () => {
76
75
  const { profile } = await prompts([{
77
- type: "select",
78
- name: "profile",
79
- message: "Select AWS profile",
80
76
  choices: getAvailableProfiles().filter((v) => !!v).map((v) => ({
81
77
  title: v,
82
78
  value: v
83
- }))
79
+ })),
80
+ message: "Select AWS profile",
81
+ name: "profile",
82
+ type: "select"
84
83
  }], { onCancel: () => halt() });
85
84
  return profile;
86
85
  };
87
86
  //#endregion
88
87
  //#region src/lib/notifier.ts
89
88
  const notify = (args) => {
90
- const { title, message = "" } = args;
89
+ const { message = "", title } = args;
91
90
  notifier.notify({
92
- title,
93
- message: stripIndent(message).trim(),
94
91
  contentImage: "https://assets.raisenow.io/favicon.png",
95
- sound: "Funk"
92
+ message: stripIndent(message).trim(),
93
+ sound: "Funk",
94
+ title
96
95
  });
97
96
  };
98
97
  //#endregion
@@ -103,8 +102,9 @@ const archive = (options) => {
103
102
  assertIsNotArchived();
104
103
  const configName = getWidgetUuid();
105
104
  const cwd = process.cwd();
106
- const archiveDir = resolve(dirname(cwd), "_archived");
107
- const archiveTarget = resolve(archiveDir, configName);
105
+ const parentDir = path.dirname(cwd);
106
+ const archiveDir = path.resolve(parentDir, "_archived");
107
+ const archiveTarget = path.resolve(archiveDir, configName);
108
108
  assertArchiveTargetDoesNotExist(archiveTarget);
109
109
  assertOptionsValid$9(options);
110
110
  if (options.dryrun) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
@@ -115,8 +115,8 @@ const archive = (options) => {
115
115
  logSuccess(`\n✅ "${configName}" has been archived and moved to ${archiveTarget}`);
116
116
  process.on("exit", () => {
117
117
  notify({
118
- title: "archive",
119
- message: `"${configName}" has been archived.`
118
+ message: `"${configName}" has been archived.`,
119
+ title: "archive"
120
120
  });
121
121
  });
122
122
  };
@@ -128,7 +128,7 @@ const assertIsNotCore$3 = (ifCore) => {
128
128
  if (ifCore()) halt("You cannot archive Tamaro Core.");
129
129
  };
130
130
  const assertIsNotArchived = () => {
131
- if (basename(dirname(process.cwd())) === "_archived") halt("This configuration is already archived.");
131
+ if (path.basename(path.dirname(process.cwd())) === "_archived") halt("This configuration is already archived.");
132
132
  };
133
133
  const assertArchiveTargetDoesNotExist = (archiveTarget) => {
134
134
  if (existsSync(archiveTarget)) halt(`Archive target already exists: ${archiveTarget}. Please remove it first.`);
@@ -147,13 +147,13 @@ helpers.comparison({ handlebars: Handlebars });
147
147
  const validateEmailTemplates = (templatePaths) => {
148
148
  const errors = [];
149
149
  for (const templatePath of templatePaths) try {
150
- const template = fs.readFileSync(templatePath, "utf-8");
150
+ const template = fs.readFileSync(templatePath, "utf8");
151
151
  assureOnlySupportedHelpers(template);
152
152
  compileEmailTemplate(template);
153
153
  console.log(`${templatePath} is a valid email template`);
154
- } catch (e) {
154
+ } catch (error) {
155
155
  errors.push(`${templatePath} is invalid`);
156
- errors.push(e);
156
+ errors.push(error);
157
157
  }
158
158
  return errors;
159
159
  };
@@ -174,8 +174,8 @@ const assureOnlySupportedHelpers = (template) => {
174
174
  const visit = (node) => {
175
175
  if (!node) return;
176
176
  switch (node.type) {
177
- case "MustacheStatement":
178
- case "BlockStatement": {
177
+ case "BlockStatement":
178
+ case "MustacheStatement": {
179
179
  const name = extractHelperName(node);
180
180
  if (name) usedHelpers.add(name);
181
181
  break;
@@ -186,7 +186,7 @@ const assureOnlySupportedHelpers = (template) => {
186
186
  */
187
187
  for (const key in node) {
188
188
  const value = node[key];
189
- if (Array.isArray(value)) value.forEach(visit);
189
+ if (Array.isArray(value)) value.forEach((v) => visit(v));
190
190
  else if (value && typeof value === "object" && value.type) visit(value);
191
191
  }
192
192
  };
@@ -227,7 +227,7 @@ const assureOnlySupportedHelpers = (template) => {
227
227
  "unlessGteq",
228
228
  "unlessLteq"
229
229
  ]);
230
- const unsupportedHelpers = Array.from(usedHelpers).filter((h) => !supportedHelpers.has(h));
230
+ const unsupportedHelpers = [...usedHelpers].filter((h) => !supportedHelpers.has(h));
231
231
  if (unsupportedHelpers.length > 0) throw new Error(`Email template uses unsupported Handlebars helpers: ${unsupportedHelpers.join(", ")}`);
232
232
  };
233
233
  /**
@@ -246,8 +246,8 @@ const compileEmailTemplate = (template) => {
246
246
  * deployed.
247
247
  */
248
248
  const validate = async () => {
249
- const errors = validateEmailTemplates(globSync("email-config/templates/**/*.hbs").sort());
250
- if (errors.length) halt(errors.map((el) => el.toString()).join("\n"));
249
+ const errors = validateEmailTemplates(globSync("email-config/templates/**/*.hbs").toSorted());
250
+ if (errors.length > 0) halt(errors.map((el) => el.toString()).join("\n"));
251
251
  logTitle("Validated successfully");
252
252
  };
253
253
  //#endregion
@@ -255,8 +255,8 @@ const validate = async () => {
255
255
  const assertCrtExists = () => {
256
256
  const { ifCore } = getIfCoreFns();
257
257
  const paths = getPaths(ifCore);
258
- const certFile = resolve(paths.root, HTTPS_CRT_FILE);
259
- const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
258
+ const certFile = path.resolve(paths.root, HTTPS_CRT_FILE);
259
+ const keyFile = path.resolve(paths.root, HTTPS_KEY_FILE);
260
260
  if (existsSync(certFile) && existsSync(keyFile)) return;
261
261
  halt(stripIndent(`
262
262
  Flag "--https" is used, but "${HTTPS_CRT_FILE}" and/or "${HTTPS_KEY_FILE}" files are not found.
@@ -293,13 +293,13 @@ const build = async (options) => {
293
293
  console.log(`Path: ${paths.appDist}\n`);
294
294
  process.on("exit", () => {
295
295
  notify({
296
- title: "build",
297
- message: `Bundle for "${configName}" customer configuration is done.`
296
+ message: `Bundle for "${configName}" customer configuration is done.`,
297
+ title: "build"
298
298
  });
299
299
  });
300
300
  };
301
301
  const assertOptionsValid$8 = (options) => {
302
- const { localCore, https, deploy, env, profile } = options;
302
+ const { deploy, env, https, localCore, profile } = options;
303
303
  const { ifCore } = getIfCoreFns();
304
304
  if (ifCore() && localCore) halt("Flag \"--local-core\" is redundant if running in Tamaro Core context.");
305
305
  if (localCore && deploy) halt("Flags \"--local-core\" and \"--deploy\" must not be used together.");
@@ -309,7 +309,7 @@ const assertOptionsValid$8 = (options) => {
309
309
  };
310
310
  const prepareFlags$2 = (options) => {
311
311
  const flags = [];
312
- const { localCore, analyze, https, nolint, debug } = options;
312
+ const { analyze, debug, https, localCore, nolint } = options;
313
313
  if (localCore) flags.push("--env localCore");
314
314
  if (analyze) flags.push("--env analyze");
315
315
  if (https) flags.push("--env https");
@@ -320,7 +320,7 @@ const prepareFlags$2 = (options) => {
320
320
  //#endregion
321
321
  //#region src/lib/validators/assertTagValid.ts
322
322
  const assertTagValid = (tag) => {
323
- const regex = /^[a-zA-Z0-9-_.]+$/;
323
+ const regex = /^[\w.-]+$/;
324
324
  if (!regex.test(tag)) halt(`Flag "--tag" has forbidden format. Allowed format: ${regex.toString()}.`);
325
325
  };
326
326
  //#endregion
@@ -337,7 +337,7 @@ const deploy = async (options) => {
337
337
  await validate();
338
338
  awsAuthenticate(options);
339
339
  const flags = prepareFlags$3(options);
340
- const { tag, dryrun } = options;
340
+ const { dryrun, tag } = options;
341
341
  const dryRunFlag = dryrun ? `--dryrun` : "";
342
342
  const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid());
343
343
  const deployUrl = `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}`;
@@ -404,12 +404,12 @@ const deploy = async (options) => {
404
404
  });
405
405
  process.on("exit", () => {
406
406
  notify({
407
- title: "deploy",
408
407
  message: `
409
408
  Bundle for "${configName}" is deployed with tag "${tag}".
410
409
  Demo page: ${demoPage}
411
410
  Entry point: ${entryPoint}
412
- `
411
+ `,
412
+ title: "deploy"
413
413
  });
414
414
  });
415
415
  };
@@ -462,13 +462,13 @@ const deployEmailConfig = async (options) => {
462
462
  logDataTable({ "Deploy URL:": deployUrl });
463
463
  process.on("exit", () => {
464
464
  notify({
465
- title: "deploy-email-config",
466
- message: `Email configuration for "${configName}" customer configuration is deployed.`
465
+ message: `Email configuration for "${configName}" customer configuration is deployed.`,
466
+ title: "deploy-email-config"
467
467
  });
468
468
  });
469
469
  };
470
470
  const assertOptionsValid$6 = (options) => {
471
- const { profile, bucket } = options;
471
+ const { bucket, profile } = options;
472
472
  if (profile) assertProfileValid(profile);
473
473
  if (bucket) assertBucketValid$1(bucket);
474
474
  };
@@ -484,16 +484,16 @@ const assertBucketValid$1 = (bucket) => {
484
484
  };
485
485
  const promptBucketTamaroEmailConfig$1 = async () => {
486
486
  const { bucket } = await prompts([{
487
- type: "select",
488
- name: "bucket",
489
- message: "Select environment",
490
487
  choices: [{
491
488
  title: "stage",
492
489
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
493
490
  }, {
494
491
  title: "prod",
495
492
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
496
- }]
493
+ }],
494
+ message: "Select environment",
495
+ name: "bucket",
496
+ type: "select"
497
497
  }], { onCancel: () => halt() });
498
498
  return bucket;
499
499
  };
@@ -516,16 +516,16 @@ const dev = async (options) => {
516
516
  runCommandSync(cmd, { stdio: "inherit" });
517
517
  };
518
518
  const assertOptionsValid$5 = (options) => {
519
- const { localCore, https, port, env } = options;
519
+ const { env, https, localCore, port } = options;
520
520
  const { ifCore } = getIfCoreFns();
521
521
  if (ifCore() && localCore) halt("Flag \"--local-core\" is redundant if running in Tamaro Core context.");
522
- if (isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
522
+ if (Number.isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
523
523
  if (https) assertCrtExists();
524
524
  assertEnvValid(env);
525
525
  };
526
526
  const prepareFlags$1 = async (options) => {
527
527
  const flags = [];
528
- const { localCore, port: defaultPort, https, nolint, debug } = options;
528
+ const { debug, https, localCore, nolint, port: defaultPort } = options;
529
529
  const port = await getPortPromise({ port: Number(defaultPort) });
530
530
  if (localCore) flags.push("--env localCore");
531
531
  flags.push(`--port ${port}`);
@@ -559,9 +559,7 @@ const listDeployed = async (options) => {
559
559
  if (error.stderr) halt(error.stderr);
560
560
  }
561
561
  const tags = parseTags(out.split("\n"));
562
- let text = "";
563
- if (tags.length === 0) text = "No deployments found.";
564
- else text = tags.map((tag, idx) => {
562
+ const text = tags.length === 0 ? "No deployments found." : tags.map((tag, idx) => {
565
563
  return `${idx + 1}. https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
566
564
  }).join("\n");
567
565
  console.log(`${text}\n`);
@@ -573,7 +571,7 @@ const assertOptionsValid$4 = (options) => {
573
571
  };
574
572
  const assertConfigValid = (config) => {
575
573
  if (!config) return;
576
- const regex = /^[a-zA-Z0-9-_]+$/;
574
+ const regex = /^[\w-]+$/;
577
575
  if (!regex.test(config)) halt(`Flag "--config" has forbidden format. Allowed format: ${regex.toString()}.`);
578
576
  };
579
577
  const parseTags = (lines) => {
@@ -596,20 +594,20 @@ const serve = async (options) => {
596
594
  runCommandSync(cmd, { stdio: "inherit" });
597
595
  };
598
596
  const assertOptionsValid$3 = (options) => {
599
- const { port, https } = options;
600
- if (isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
597
+ const { https, port } = options;
598
+ if (Number.isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
601
599
  if (https) assertCrtExists();
602
600
  };
603
601
  const prepareFlags = async (options) => {
604
602
  const flags = [];
605
- const { port: defaultPort, https } = options;
603
+ const { https, port: defaultPort } = options;
606
604
  const port = await getPortPromise({ port: Number(defaultPort) });
607
605
  flags.push(`-p ${port}`);
608
606
  if (https) {
609
607
  const { ifCore } = getIfCoreFns();
610
608
  const paths = getPaths(ifCore);
611
- const certFile = resolve(paths.root, HTTPS_CRT_FILE);
612
- const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
609
+ const certFile = path.resolve(paths.root, HTTPS_CRT_FILE);
610
+ const keyFile = path.resolve(paths.root, HTTPS_KEY_FILE);
613
611
  flags.push(`--ssl-cert ${certFile}`);
614
612
  flags.push(`--ssl-key ${keyFile}`);
615
613
  }
@@ -623,7 +621,9 @@ const unarchive = (options) => {
623
621
  assertIsArchived();
624
622
  const configName = getWidgetUuid();
625
623
  const cwd = process.cwd();
626
- const restoreTarget = resolve(dirname(dirname(cwd)), configName);
624
+ const archivedDir = path.dirname(cwd);
625
+ const configsDir = path.dirname(archivedDir);
626
+ const restoreTarget = path.resolve(configsDir, configName);
627
627
  assertRestoreTargetDoesNotExist(restoreTarget);
628
628
  assertOptionsValid$2(options);
629
629
  if (options.dryrun) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
@@ -634,8 +634,8 @@ const unarchive = (options) => {
634
634
  logTitle(`✅ "${configName}" has been unarchived and moved to ${restoreTarget}`);
635
635
  process.on("exit", () => {
636
636
  notify({
637
- title: "unarchive",
638
- message: `"${configName}" has been unarchived.`
637
+ message: `"${configName}" has been unarchived.`,
638
+ title: "unarchive"
639
639
  });
640
640
  });
641
641
  };
@@ -644,7 +644,7 @@ const assertOptionsValid$2 = (options) => {
644
644
  if (profile) assertProfileValid(profile);
645
645
  };
646
646
  const assertIsArchived = () => {
647
- if (basename(dirname(process.cwd())) !== "_archived") halt("This configuration is not archived. Only archived configurations can be unarchived.");
647
+ if (path.basename(path.dirname(process.cwd())) !== "_archived") halt("This configuration is not archived. Only archived configurations can be unarchived.");
648
648
  };
649
649
  const assertIsNotCore$1 = (ifCore) => {
650
650
  if (ifCore()) halt("You cannot unarchive Tamaro Core.");
@@ -664,7 +664,7 @@ const undeploy = async (options) => {
664
664
  assertOptionsValid$1(options);
665
665
  awsAuthenticate(options);
666
666
  const flags = prepareFlags$3(options);
667
- const { tag = DEFAULT_TAG, all, dryrun } = options;
667
+ const { all, dryrun, tag = DEFAULT_TAG } = options;
668
668
  const dryRunFlag = dryrun ? `--dryrun` : "";
669
669
  const deployUrl = all ? `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/` : `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/`;
670
670
  const description = all ? `all tags of "${configName}"` : `tag "${tag}" of "${configName}"`;
@@ -702,13 +702,13 @@ const undeploy = async (options) => {
702
702
  logDataTable({ "Removed URL:": deployUrl });
703
703
  process.on("exit", () => {
704
704
  notify({
705
- title: "undeploy",
706
- message: `${description} has been undeployed.`
705
+ message: `${description} has been undeployed.`,
706
+ title: "undeploy"
707
707
  });
708
708
  });
709
709
  };
710
710
  const assertOptionsValid$1 = (options) => {
711
- const { profile, tag, all } = options;
711
+ const { all, profile, tag } = options;
712
712
  const { ifCore } = getIfCoreFns();
713
713
  if (ifCore() && all) halt("Flag \"--all\" must not be used in Tamaro Core context.");
714
714
  if (ifCore() && tag === "latest") halt("You cannot undeploy the default tag for Tamaro Core.");
@@ -755,13 +755,13 @@ const undeployEmailConfig = async (options) => {
755
755
  logDataTable({ "Removed URL:": deployUrl });
756
756
  process.on("exit", () => {
757
757
  notify({
758
- title: "undeploy-email-config",
759
- message: `Email configuration for "${configName}" has been undeployed.`
758
+ message: `Email configuration for "${configName}" has been undeployed.`,
759
+ title: "undeploy-email-config"
760
760
  });
761
761
  });
762
762
  };
763
763
  const assertOptionsValid = (options) => {
764
- const { profile, bucket } = options;
764
+ const { bucket, profile } = options;
765
765
  if (profile) assertProfileValid(profile);
766
766
  if (bucket) assertBucketValid(bucket);
767
767
  };
@@ -773,23 +773,23 @@ const assertBucketValid = (bucket) => {
773
773
  };
774
774
  const promptBucketTamaroEmailConfig = async () => {
775
775
  const { bucket } = await prompts([{
776
- type: "select",
777
- name: "bucket",
778
- message: "Select environment",
779
776
  choices: [{
780
777
  title: "stage",
781
778
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
782
779
  }, {
783
780
  title: "prod",
784
781
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
785
- }]
782
+ }],
783
+ message: "Select environment",
784
+ name: "bucket",
785
+ type: "select"
786
786
  }], { onCancel: () => halt() });
787
787
  return bucket;
788
788
  };
789
789
  //#endregion
790
790
  //#region package.json
791
791
  var name = "@raisenow/tamaro-cli";
792
- var version = "1.8.0-dev.4";
792
+ var version = "1.8.0-dev.6";
793
793
  //#endregion
794
794
  //#region src/cli.ts
795
795
  /**
@@ -1,13 +1,12 @@
1
- import { existsSync, realpathSync } from "fs";
2
- import { basename, dirname, join, relative, resolve } from "path";
1
+ import { createRequire } from "node:module";
2
+ import { existsSync, realpathSync } from "node:fs";
3
+ import path from "node:path";
3
4
  import { execaCommandSync } from "execa";
4
5
  import prompts from "prompts";
5
6
  import stripIndent from "strip-indent";
6
7
  import chalk from "chalk";
7
8
  import columnify from "columnify";
8
- import path from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
- import { createRequire } from "module";
11
10
  import { getIfUtils } from "webpack-config-utils";
12
11
  import { globSync } from "glob";
13
12
  import { config } from "dotenv";
@@ -35,7 +34,7 @@ const halt = (message) => {
35
34
  process.exit(1);
36
35
  };
37
36
  const prepareCommand = (cmd) => {
38
- return cmd.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
37
+ return cmd.replaceAll("\n", " ").replaceAll(/[ \t]{2,}/g, " ").trim();
39
38
  };
40
39
  const runCommandSync = (cmd, options) => {
41
40
  return execaCommandSync(prepareCommand(cmd), options);
@@ -43,10 +42,10 @@ const runCommandSync = (cmd, options) => {
43
42
  const promptConfirmation = async (message, skipConfirmation) => {
44
43
  if (skipConfirmation) return;
45
44
  const { confirmed } = await prompts([{
46
- type: "confirm",
47
- name: "confirmed",
45
+ initial: false,
48
46
  message,
49
- initial: false
47
+ name: "confirmed",
48
+ type: "confirm"
50
49
  }], { onCancel: () => halt() });
51
50
  if (!confirmed) halt("Operation cancelled.");
52
51
  };
@@ -68,8 +67,8 @@ const extensions = moduleFileExtensions.map((v) => `.${v}`);
68
67
  const TAMARO_CORE_PACKAGE_NAMES = ["@raisenow/tamaro-core"];
69
68
  const TAMARO_CONFIGURATIONS_PACKAGE_NAMES = ["@raisenow/tamaro-configurations"];
70
69
  const TAMARO_SELF_SERVICE_PACKAGE_NAMES = ["@raisenow/tamaro-self-service"];
71
- const resolveApp = (relativePath) => resolve(realpathSync(process.cwd()), relativePath);
72
- const resolveOwn = (relativePath) => resolve(__dirname, "..", relativePath);
70
+ const resolveApp = (relativePath) => path.resolve(realpathSync(process.cwd()), relativePath);
71
+ const resolveOwn = (relativePath) => path.resolve(__dirname, "..", relativePath);
73
72
  const resolveModule = (resolveFn, filePath) => {
74
73
  const extension = moduleFileExtensions.find((extension) => existsSync(resolveFn(`${filePath}.${extension}`)));
75
74
  if (extension) return resolveFn(`${filePath}.${extension}`);
@@ -100,9 +99,11 @@ const resolveEslintPluginConfig = (paths) => {
100
99
  const resolveBin = (name) => {
101
100
  const pkgPath = require$1.resolve(`${name}/package.json`);
102
101
  const { bin } = require$1(pkgPath);
103
- return join(dirname(pkgPath), typeof bin === "object" ? bin[name] : bin);
102
+ const dir = path.dirname(pkgPath);
103
+ const binPath = typeof bin === "object" ? bin[name] : bin;
104
+ return path.join(dir, binPath);
104
105
  };
105
- const getWidgetUuid = () => basename(resolveApp("."));
106
+ const getWidgetUuid = () => path.basename(resolveApp("."));
106
107
  /**
107
108
  * Get the appropriate tsconfig file.
108
109
  * Prefers tsconfig.app.json (composite config structure) but falls back to
@@ -149,7 +150,7 @@ const getPaths = (ifCore) => {
149
150
  };
150
151
  const getRelativePaths = (paths) => {
151
152
  const relativePaths = {};
152
- for (const [type, absPath] of Object.entries(paths)) if (absPath) relativePaths[type] = relative("./", absPath) || ".";
153
+ for (const [type, absPath] of Object.entries(paths)) if (absPath) relativePaths[type] = path.relative("./", absPath) || ".";
153
154
  return relativePaths;
154
155
  };
155
156
  const getIfCoreFns = ({ allowArchived = false } = {}) => {
@@ -185,7 +186,7 @@ const HTTPS_KEY_FILE = "localhost.key";
185
186
  //#region src/lib/env.ts
186
187
  const require = createRequire(import.meta.url);
187
188
  const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
188
- const filePath = files.find((file) => basename(file) === ".env");
189
+ const filePath = files.find((file) => path.basename(file) === ".env");
189
190
  if (filePath) config({ path: filePath });
190
191
  process.env.NODE_ENV ??= ifMin("production", "development");
191
192
  process.env.BABEL_ENV ??= ifMin("production", "development");
@@ -212,7 +213,7 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
212
213
  process.env.CORE_URL ??= process.env.CORE_URL_PATTERN.replace("{{version}}", version);
213
214
  }
214
215
  }
215
- const varNames = [
216
+ const varNames = new Set([
216
217
  "NODE_ENV",
217
218
  "BABEL_ENV",
218
219
  "EXPOSE_VAR",
@@ -238,8 +239,8 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
238
239
  "EPMS_PROXY_URL_PROD",
239
240
  "EPMS_TWINT_CHECKOUT_URL_STAGE",
240
241
  "EPMS_TWINT_CHECKOUT_URL_PROD"
241
- ];
242
- const raw = Object.keys(process.env).filter((key) => key.startsWith("PUBLIC_") || varNames.includes(key)).reduce((env, key) => {
242
+ ]);
243
+ const raw = Object.keys(process.env).filter((key) => key.startsWith("PUBLIC_") || varNames.has(key)).reduce((env, key) => {
243
244
  env[key] = process.env[key];
244
245
  return env;
245
246
  }, {});
@@ -253,11 +254,9 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
253
254
  };
254
255
  const assertEnvValid = (env) => {
255
256
  const { ifCore } = getIfCoreFns();
256
- const envs = globSync(getPaths(ifCore).appEnv).map((file) => basename(file).replace(/^\.env\./, "")).map((file) => basename(file).replace(/^\.env$/, "")).filter((v) => !!v);
257
- if (envs.length === 0) {
258
- if (env) console.log("Flag \"--env\" is ignored.");
259
- }
260
- if (envs.length !== 0) {
257
+ const envs = globSync(getPaths(ifCore).appEnv).map((file) => path.basename(file).replace(/^\.env\./, "")).map((file) => path.basename(file).replace(/^\.env$/, "")).filter((v) => !!v);
258
+ if (envs.length === 0 && env) console.log("Flag \"--env\" is ignored.");
259
+ if (envs.length > 0) {
261
260
  if (!env) halt("Flag \"--env\" is required.");
262
261
  if (env && !envs.includes(env)) halt(stripIndent(`
263
262
  Flag "--env" has wrong value.
@@ -268,7 +267,7 @@ const assertEnvValid = (env) => {
268
267
  const applyEnv = (env) => {
269
268
  if (!env) return;
270
269
  const { ifCore } = getIfCoreFns();
271
- const filePath = globSync(getPaths(ifCore).appEnv).find((file) => basename(file) === `.env.${env}`);
270
+ const filePath = globSync(getPaths(ifCore).appEnv).find((file) => path.basename(file) === `.env.${env}`);
272
271
  if (filePath) config({ path: filePath });
273
272
  };
274
273
  //#endregion
@@ -1,7 +1,7 @@
1
- import { E as logDataTable, b as resolveEslintPluginConfig, d as HTTPS_CRT_FILE, f as HTTPS_KEY_FILE, g as getRelativePaths, h as getPaths, k as logTitle, m as getIfCoreFns, p as extensions, r as getEnvVars, v as resolveApp } from "./env-LI5tXjy4.js";
2
- import { existsSync } from "fs";
3
- import { basename, dirname, resolve } from "path";
4
- import { createRequire } from "module";
1
+ import { E as logDataTable, b as resolveEslintPluginConfig, d as HTTPS_CRT_FILE, f as HTTPS_KEY_FILE, g as getRelativePaths, h as getPaths, k as logTitle, m as getIfCoreFns, p as extensions, r as getEnvVars, v as resolveApp } from "./env-B20cxmcB.js";
2
+ import { createRequire } from "node:module";
3
+ import { existsSync } from "node:fs";
4
+ import path from "node:path";
5
5
  import { getIfUtils, removeEmpty } from "webpack-config-utils";
6
6
  import { globSync } from "glob";
7
7
  import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
@@ -36,7 +36,7 @@ var InterpolateHtmlPlugin = class {
36
36
  });
37
37
  hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
38
38
  Object.entries(this.replacements).forEach(([key, value]) => {
39
- data.html = data.html.replace(new RegExp(`%${escapeStringRegexp(key)}%`, "g"), value ?? "");
39
+ data.html = data.html.replaceAll(new RegExp(`%${escapeStringRegexp(key)}%`, "g"), value ?? "");
40
40
  });
41
41
  return data;
42
42
  });
@@ -109,7 +109,7 @@ const getWebpackConfig = (env) => {
109
109
  symlinks: true,
110
110
  extensions: [...extensions, "..."],
111
111
  modules: [paths.appNodeModules, "node_modules"],
112
- alias: { "core-js": dirname(require.resolve("core-js/package.json")) },
112
+ alias: { "core-js": path.dirname(require.resolve("core-js/package.json")) },
113
113
  plugins: [new TsconfigPathsPlugin({
114
114
  configFile: paths.appTsConfig,
115
115
  extensions
@@ -264,8 +264,8 @@ const getWebpackConfig = (env) => {
264
264
  server: ifHttps({
265
265
  type: "https",
266
266
  options: {
267
- cert: resolve(paths.root, HTTPS_CRT_FILE),
268
- key: resolve(paths.root, HTTPS_KEY_FILE)
267
+ cert: path.resolve(paths.root, HTTPS_CRT_FILE),
268
+ key: path.resolve(paths.root, HTTPS_KEY_FILE)
269
269
  }
270
270
  })
271
271
  },
@@ -283,7 +283,7 @@ const getWebpackConfig = (env) => {
283
283
  ifMin(new CleanWebpackPlugin({})),
284
284
  ...appHtmlFiles.map((file) => new HtmlWebpackPlugin({
285
285
  template: file,
286
- filename: basename(file),
286
+ filename: path.basename(file),
287
287
  inject: false,
288
288
  minify: false
289
289
  })),
package/eslint.config.ts CHANGED
@@ -18,36 +18,6 @@ export default defineConfig([
18
18
  rules: {
19
19
  'jsdoc/convert-to-jsdoc-comments': OFF,
20
20
  'no-useless-assignment': OFF,
21
-
22
- // todo: remove these rules
23
- '@typescript-eslint/restrict-template-expressions': OFF,
24
- 'perfectionist/sort-objects': OFF,
25
- 'perfectionist/sort-object-types': OFF,
26
- 'perfectionist/sort-intersection-types': OFF,
27
- 'perfectionist/sort-switch-case': OFF,
28
- 'unicorn/prefer-top-level-await': OFF,
29
- 'unicorn/prefer-node-protocol': OFF,
30
- 'unicorn/import-style': OFF,
31
- 'unicorn/no-process-exit': OFF,
32
- 'unicorn/consistent-function-scoping': OFF,
33
- 'unicorn/prefer-spread': OFF,
34
- 'unicorn/no-array-callback-reference': OFF,
35
- 'unicorn/catch-error-name': OFF,
36
- 'unicorn/text-encoding-identifier-case': OFF,
37
- 'unicorn/explicit-length-check': OFF,
38
- 'unicorn/no-lonely-if': OFF,
39
- 'unicorn/prefer-set-has': OFF,
40
- 'unicorn/prefer-string-replace-all': OFF,
41
- 'unicorn/prefer-optional-catch-binding': OFF,
42
- 'unicorn/no-array-sort': OFF,
43
- 'unicorn/prefer-number-properties': OFF,
44
- 'unicorn/prefer-ternary': OFF,
45
- 'import-x/consistent-type-specifier-style': OFF,
46
- 'regexp/no-useless-flag': OFF,
47
- 'regexp/use-ignore-case': OFF,
48
- 'regexp/prefer-w': OFF,
49
- '@typescript-eslint/no-var-requires': OFF,
50
- '@typescript-eslint/no-unused-vars': OFF,
51
21
  },
52
22
  },
53
23
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raisenow/tamaro-cli",
3
- "version": "1.8.0-dev.4",
3
+ "version": "1.8.0-dev.6",
4
4
  "author": {
5
5
  "name": "RaiseNow",
6
6
  "email": "development@raisenow.com"
@@ -42,9 +42,9 @@
42
42
  "core-js": "^3.49.0",
43
43
  "css-loader": "^7.1.4",
44
44
  "css-minimizer-webpack-plugin": "^8.0.0",
45
- "dotenv": "^17.4.0",
45
+ "dotenv": "^17.4.1",
46
46
  "escape-string-regexp": "^5.0.0",
47
- "eslint-webpack-plugin": "^5.0.3",
47
+ "eslint-webpack-plugin": "^6.0.0",
48
48
  "execa": "^9.6.1",
49
49
  "file-loader": "^6.2.0",
50
50
  "fork-ts-checker-webpack-plugin": "^9.1.0",
@@ -82,9 +82,9 @@
82
82
  "yaml-loader": "^0.9.0"
83
83
  },
84
84
  "devDependencies": {
85
- "@rnw-npm/eslint-config": "2.0.0-dev.1",
85
+ "@rnw-npm/eslint-config": "^2.0.0",
86
86
  "@rnw-npm/prettier-config": "^1.0.0",
87
- "eslint": "^10.1.0",
87
+ "eslint": "^10.2.0",
88
88
  "husky": "^9.1.7",
89
89
  "lint-staged": "^16.4.0",
90
90
  "prettier": "^3.8.1"