@raisenow/tamaro-cli 1.8.0-dev.1 → 1.8.0-dev.3

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.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+
3
+ corepack enable pnpm
4
+ corepack prepare --activate
5
+
6
+ pnpm lint-staged
@@ -18,15 +18,9 @@ definitions:
18
18
  initialize: &initialize |-
19
19
  corepack enable pnpm
20
20
  corepack prepare --activate
21
+ npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN_READ_ONLY
22
+ pnpm install --prefer-offline
21
23
  steps:
22
- - step: &install
23
- name: Install dependencies
24
- caches:
25
- - node
26
- - pnpm
27
- script:
28
- - *initialize
29
- - pnpm install --prefer-offline
30
24
  - step: &check
31
25
  name: Check
32
26
  caches:
@@ -43,5 +37,4 @@ definitions:
43
37
 
44
38
  pipelines:
45
39
  default:
46
- - step: *install
47
40
  - step: *check
package/dist/cli.js CHANGED
@@ -1,13 +1,14 @@
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-BrLTVK6y.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-LI5tXjy4.js";
3
3
  import { createCommand } from "commander";
4
- import fs, { existsSync, mkdirSync, renameSync } from "node:fs";
5
- import path from "node:path";
4
+ import { existsSync, mkdirSync, renameSync } from "fs";
5
+ import { basename, dirname, resolve } from "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";
11
12
  import Handlebars from "handlebars";
12
13
  import helpers from "handlebars-helpers";
13
14
  import { getPortPromise } from "portfinder";
@@ -22,7 +23,7 @@ const awsAuthenticate = (options) => {
22
23
  return;
23
24
  try {
24
25
  checkIdentity(options);
25
- } catch {
26
+ } catch (error) {
26
27
  login(options);
27
28
  }
28
29
  };
@@ -54,7 +55,7 @@ const login = (options) => {
54
55
  try {
55
56
  execaCommandSync(`aws sso login ${flags}`, { stdio: "inherit" });
56
57
  console.log("");
57
- } catch {
58
+ } catch (error) {
58
59
  halt("Login failed.");
59
60
  }
60
61
  };
@@ -73,25 +74,25 @@ const assertProfileValid = (profile) => {
73
74
  };
74
75
  const promptProfile = async () => {
75
76
  const { profile } = await prompts([{
77
+ type: "select",
78
+ name: "profile",
79
+ message: "Select AWS profile",
76
80
  choices: getAvailableProfiles().filter((v) => !!v).map((v) => ({
77
81
  title: v,
78
82
  value: v
79
- })),
80
- message: "Select AWS profile",
81
- name: "profile",
82
- type: "select"
83
+ }))
83
84
  }], { onCancel: () => halt() });
84
85
  return profile;
85
86
  };
86
87
  //#endregion
87
88
  //#region src/lib/notifier.ts
88
89
  const notify = (args) => {
89
- const { message = "", title } = args;
90
+ const { title, message = "" } = args;
90
91
  notifier.notify({
91
- contentImage: "https://assets.raisenow.io/favicon.png",
92
+ title,
92
93
  message: stripIndent(message).trim(),
93
- sound: "Funk",
94
- title
94
+ contentImage: "https://assets.raisenow.io/favicon.png",
95
+ sound: "Funk"
95
96
  });
96
97
  };
97
98
  //#endregion
@@ -102,9 +103,8 @@ const archive = (options) => {
102
103
  assertIsNotArchived();
103
104
  const configName = getWidgetUuid();
104
105
  const cwd = process.cwd();
105
- const parentDir = path.dirname(cwd);
106
- const archiveDir = path.resolve(parentDir, "_archived");
107
- const archiveTarget = path.resolve(archiveDir, configName);
106
+ const archiveDir = resolve(dirname(cwd), "_archived");
107
+ const archiveTarget = 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
- message: `"${configName}" has been archived.`,
119
- title: "archive"
118
+ title: "archive",
119
+ message: `"${configName}" has been archived.`
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 (path.basename(path.dirname(process.cwd())) === "_archived") halt("This configuration is already archived.");
131
+ if (basename(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, "utf8");
150
+ const template = fs.readFileSync(templatePath, "utf-8");
151
151
  assureOnlySupportedHelpers(template);
152
152
  compileEmailTemplate(template);
153
153
  console.log(`${templatePath} is a valid email template`);
154
- } catch (error) {
154
+ } catch (e) {
155
155
  errors.push(`${templatePath} is invalid`);
156
- errors.push(error);
156
+ errors.push(e);
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 "BlockStatement":
178
- case "MustacheStatement": {
177
+ case "MustacheStatement":
178
+ case "BlockStatement": {
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((v) => visit(v));
189
+ if (Array.isArray(value)) value.forEach(visit);
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 = [...usedHelpers].filter((h) => !supportedHelpers.has(h));
230
+ const unsupportedHelpers = Array.from(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").toSorted());
250
- if (errors.length > 0) halt(errors.map((el) => el.toString()).join("\n"));
249
+ const errors = validateEmailTemplates(globSync("email-config/templates/**/*.hbs").sort());
250
+ if (errors.length) 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 = path.resolve(paths.root, HTTPS_CRT_FILE);
259
- const keyFile = path.resolve(paths.root, HTTPS_KEY_FILE);
258
+ const certFile = resolve(paths.root, HTTPS_CRT_FILE);
259
+ const keyFile = 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
- message: `Bundle for "${configName}" customer configuration is done.`,
297
- title: "build"
296
+ title: "build",
297
+ message: `Bundle for "${configName}" customer configuration is done.`
298
298
  });
299
299
  });
300
300
  };
301
301
  const assertOptionsValid$8 = (options) => {
302
- const { deploy, env, https, localCore, profile } = options;
302
+ const { localCore, https, deploy, env, 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 { analyze, debug, https, localCore, nolint } = options;
312
+ const { localCore, analyze, https, nolint, debug } = 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 = /^[\w.-]+$/;
323
+ const regex = /^[a-zA-Z0-9-_.]+$/;
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 { dryrun, tag } = options;
340
+ const { tag, dryrun } = 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",
407
408
  message: `
408
409
  Bundle for "${configName}" is deployed with tag "${tag}".
409
410
  Demo page: ${demoPage}
410
411
  Entry point: ${entryPoint}
411
- `,
412
- title: "deploy"
412
+ `
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
- message: `Email configuration for "${configName}" customer configuration is deployed.`,
466
- title: "deploy-email-config"
465
+ title: "deploy-email-config",
466
+ message: `Email configuration for "${configName}" customer configuration is deployed.`
467
467
  });
468
468
  });
469
469
  };
470
470
  const assertOptionsValid$6 = (options) => {
471
- const { bucket, profile } = options;
471
+ const { profile, bucket } = 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",
487
490
  choices: [{
488
491
  title: "stage",
489
492
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
490
493
  }, {
491
494
  title: "prod",
492
495
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
493
- }],
494
- message: "Select environment",
495
- name: "bucket",
496
- type: "select"
496
+ }]
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 { env, https, localCore, port } = options;
519
+ const { localCore, https, port, env } = 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 (Number.isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
522
+ if (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 { debug, https, localCore, nolint, port: defaultPort } = options;
528
+ const { localCore, port: defaultPort, https, nolint, debug } = 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,7 +559,9 @@ const listDeployed = async (options) => {
559
559
  if (error.stderr) halt(error.stderr);
560
560
  }
561
561
  const tags = parseTags(out.split("\n"));
562
- const text = tags.length === 0 ? "No deployments found." : tags.map((tag, idx) => {
562
+ let text = "";
563
+ if (tags.length === 0) text = "No deployments found.";
564
+ else text = tags.map((tag, idx) => {
563
565
  return `${idx + 1}. https://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/index.html`;
564
566
  }).join("\n");
565
567
  console.log(`${text}\n`);
@@ -571,7 +573,7 @@ const assertOptionsValid$4 = (options) => {
571
573
  };
572
574
  const assertConfigValid = (config) => {
573
575
  if (!config) return;
574
- const regex = /^[\w-]+$/;
576
+ const regex = /^[a-zA-Z0-9-_]+$/;
575
577
  if (!regex.test(config)) halt(`Flag "--config" has forbidden format. Allowed format: ${regex.toString()}.`);
576
578
  };
577
579
  const parseTags = (lines) => {
@@ -594,20 +596,20 @@ const serve = async (options) => {
594
596
  runCommandSync(cmd, { stdio: "inherit" });
595
597
  };
596
598
  const assertOptionsValid$3 = (options) => {
597
- const { https, port } = options;
598
- if (Number.isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
599
+ const { port, https } = options;
600
+ if (isNaN(Number(port))) halt("Flag \"--port\" should be a number.");
599
601
  if (https) assertCrtExists();
600
602
  };
601
603
  const prepareFlags = async (options) => {
602
604
  const flags = [];
603
- const { https, port: defaultPort } = options;
605
+ const { port: defaultPort, https } = options;
604
606
  const port = await getPortPromise({ port: Number(defaultPort) });
605
607
  flags.push(`-p ${port}`);
606
608
  if (https) {
607
609
  const { ifCore } = getIfCoreFns();
608
610
  const paths = getPaths(ifCore);
609
- const certFile = path.resolve(paths.root, HTTPS_CRT_FILE);
610
- const keyFile = path.resolve(paths.root, HTTPS_KEY_FILE);
611
+ const certFile = resolve(paths.root, HTTPS_CRT_FILE);
612
+ const keyFile = resolve(paths.root, HTTPS_KEY_FILE);
611
613
  flags.push(`--ssl-cert ${certFile}`);
612
614
  flags.push(`--ssl-key ${keyFile}`);
613
615
  }
@@ -621,15 +623,7 @@ const unarchive = (options) => {
621
623
  assertIsArchived();
622
624
  const configName = getWidgetUuid();
623
625
  const cwd = process.cwd();
624
- /**
625
- * _archived/
626
- */
627
- const archivedDir = path.dirname(cwd);
628
- /**
629
- * parent of _archived/
630
- */
631
- const configsDir = path.dirname(archivedDir);
632
- const restoreTarget = path.resolve(configsDir, configName);
626
+ const restoreTarget = resolve(dirname(dirname(cwd)), configName);
633
627
  assertRestoreTargetDoesNotExist(restoreTarget);
634
628
  assertOptionsValid$2(options);
635
629
  if (options.dryrun) logTitle("🧪 DRY RUN MODE - No actual changes will be made 🧪");
@@ -640,8 +634,8 @@ const unarchive = (options) => {
640
634
  logTitle(`✅ "${configName}" has been unarchived and moved to ${restoreTarget}`);
641
635
  process.on("exit", () => {
642
636
  notify({
643
- message: `"${configName}" has been unarchived.`,
644
- title: "unarchive"
637
+ title: "unarchive",
638
+ message: `"${configName}" has been unarchived.`
645
639
  });
646
640
  });
647
641
  };
@@ -650,7 +644,7 @@ const assertOptionsValid$2 = (options) => {
650
644
  if (profile) assertProfileValid(profile);
651
645
  };
652
646
  const assertIsArchived = () => {
653
- if (path.basename(path.dirname(process.cwd())) !== "_archived") halt("This configuration is not archived. Only archived configurations can be unarchived.");
647
+ if (basename(dirname(process.cwd())) !== "_archived") halt("This configuration is not archived. Only archived configurations can be unarchived.");
654
648
  };
655
649
  const assertIsNotCore$1 = (ifCore) => {
656
650
  if (ifCore()) halt("You cannot unarchive Tamaro Core.");
@@ -670,7 +664,7 @@ const undeploy = async (options) => {
670
664
  assertOptionsValid$1(options);
671
665
  awsAuthenticate(options);
672
666
  const flags = prepareFlags$3(options);
673
- const { all, dryrun, tag = DEFAULT_TAG } = options;
667
+ const { tag = DEFAULT_TAG, all, dryrun } = options;
674
668
  const dryRunFlag = dryrun ? `--dryrun` : "";
675
669
  const deployUrl = all ? `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/` : `s3://${AWS_S3_BUCKET_TAMARO}/${configName}/${tag}/`;
676
670
  const description = all ? `all tags of "${configName}"` : `tag "${tag}" of "${configName}"`;
@@ -708,13 +702,13 @@ const undeploy = async (options) => {
708
702
  logDataTable({ "Removed URL:": deployUrl });
709
703
  process.on("exit", () => {
710
704
  notify({
711
- message: `${description} has been undeployed.`,
712
- title: "undeploy"
705
+ title: "undeploy",
706
+ message: `${description} has been undeployed.`
713
707
  });
714
708
  });
715
709
  };
716
710
  const assertOptionsValid$1 = (options) => {
717
- const { all, profile, tag } = options;
711
+ const { profile, tag, all } = options;
718
712
  const { ifCore } = getIfCoreFns();
719
713
  if (ifCore() && all) halt("Flag \"--all\" must not be used in Tamaro Core context.");
720
714
  if (ifCore() && tag === "latest") halt("You cannot undeploy the default tag for Tamaro Core.");
@@ -761,13 +755,13 @@ const undeployEmailConfig = async (options) => {
761
755
  logDataTable({ "Removed URL:": deployUrl });
762
756
  process.on("exit", () => {
763
757
  notify({
764
- message: `Email configuration for "${configName}" has been undeployed.`,
765
- title: "undeploy-email-config"
758
+ title: "undeploy-email-config",
759
+ message: `Email configuration for "${configName}" has been undeployed.`
766
760
  });
767
761
  });
768
762
  };
769
763
  const assertOptionsValid = (options) => {
770
- const { bucket, profile } = options;
764
+ const { profile, bucket } = options;
771
765
  if (profile) assertProfileValid(profile);
772
766
  if (bucket) assertBucketValid(bucket);
773
767
  };
@@ -779,23 +773,23 @@ const assertBucketValid = (bucket) => {
779
773
  };
780
774
  const promptBucketTamaroEmailConfig = async () => {
781
775
  const { bucket } = await prompts([{
776
+ type: "select",
777
+ name: "bucket",
778
+ message: "Select environment",
782
779
  choices: [{
783
780
  title: "stage",
784
781
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE
785
782
  }, {
786
783
  title: "prod",
787
784
  value: AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD
788
- }],
789
- message: "Select environment",
790
- name: "bucket",
791
- type: "select"
785
+ }]
792
786
  }], { onCancel: () => halt() });
793
787
  return bucket;
794
788
  };
795
789
  //#endregion
796
790
  //#region package.json
797
791
  var name = "@raisenow/tamaro-cli";
798
- var version = "1.8.0-dev.1";
792
+ var version = "1.8.0-dev.3";
799
793
  //#endregion
800
794
  //#region src/cli.ts
801
795
  /**
@@ -1,12 +1,13 @@
1
- import { createRequire } from "node:module";
2
- import { existsSync, realpathSync } from "node:fs";
3
- import path from "node:path";
1
+ import { existsSync, realpathSync } from "fs";
2
+ import { basename, dirname, join, relative, resolve } from "path";
4
3
  import { execaCommandSync } from "execa";
5
4
  import prompts from "prompts";
6
5
  import stripIndent from "strip-indent";
7
6
  import chalk from "chalk";
8
7
  import columnify from "columnify";
8
+ import path from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
+ import { createRequire } from "module";
10
11
  import { getIfUtils } from "webpack-config-utils";
11
12
  import { globSync } from "glob";
12
13
  import { config } from "dotenv";
@@ -34,7 +35,7 @@ const halt = (message) => {
34
35
  process.exit(1);
35
36
  };
36
37
  const prepareCommand = (cmd) => {
37
- return cmd.replaceAll("\n", " ").replaceAll(/[ \t]{2,}/g, " ").trim();
38
+ return cmd.replace(/\n/gm, " ").replace(/[ \t]{2,}/gm, " ").trim();
38
39
  };
39
40
  const runCommandSync = (cmd, options) => {
40
41
  return execaCommandSync(prepareCommand(cmd), options);
@@ -42,10 +43,10 @@ const runCommandSync = (cmd, options) => {
42
43
  const promptConfirmation = async (message, skipConfirmation) => {
43
44
  if (skipConfirmation) return;
44
45
  const { confirmed } = await prompts([{
45
- initial: false,
46
- message,
46
+ type: "confirm",
47
47
  name: "confirmed",
48
- type: "confirm"
48
+ message,
49
+ initial: false
49
50
  }], { onCancel: () => halt() });
50
51
  if (!confirmed) halt("Operation cancelled.");
51
52
  };
@@ -67,11 +68,8 @@ const extensions = moduleFileExtensions.map((v) => `.${v}`);
67
68
  const TAMARO_CORE_PACKAGE_NAMES = ["@raisenow/tamaro-core"];
68
69
  const TAMARO_CONFIGURATIONS_PACKAGE_NAMES = ["@raisenow/tamaro-configurations"];
69
70
  const TAMARO_SELF_SERVICE_PACKAGE_NAMES = ["@raisenow/tamaro-self-service"];
70
- const resolveApp = (relativePath) => path.resolve(realpathSync(process.cwd()), relativePath);
71
- /**
72
- * __dirname is "dist" in runtime
73
- */
74
- const resolveOwn = (relativePath) => path.resolve(__dirname, "..", relativePath);
71
+ const resolveApp = (relativePath) => resolve(realpathSync(process.cwd()), relativePath);
72
+ const resolveOwn = (relativePath) => resolve(__dirname, "..", relativePath);
75
73
  const resolveModule = (resolveFn, filePath) => {
76
74
  const extension = moduleFileExtensions.find((extension) => existsSync(resolveFn(`${filePath}.${extension}`)));
77
75
  if (extension) return resolveFn(`${filePath}.${extension}`);
@@ -102,11 +100,30 @@ const resolveEslintPluginConfig = (paths) => {
102
100
  const resolveBin = (name) => {
103
101
  const pkgPath = require$1.resolve(`${name}/package.json`);
104
102
  const { bin } = require$1(pkgPath);
105
- const dir = path.dirname(pkgPath);
106
- const binPath = typeof bin === "object" ? bin[name] : bin;
107
- return path.join(dir, binPath);
103
+ return join(dirname(pkgPath), typeof bin === "object" ? bin[name] : bin);
104
+ };
105
+ const getWidgetUuid = () => basename(resolveApp("."));
106
+ /**
107
+ * Get the appropriate tsconfig file.
108
+ * Prefers tsconfig.app.json (composite config structure) but falls back to
109
+ * tsconfig.json for backwards compatibility with older versions.
110
+ */
111
+ const getTsConfigPath = () => {
112
+ const appTsConfig = resolveApp("tsconfig.app.json");
113
+ if (existsSync(appTsConfig)) return appTsConfig;
114
+ return resolveApp("tsconfig.json");
115
+ };
116
+ /**
117
+ * Get the appropriate tailwind config file.
118
+ * Prefers tailwind.config.cjs (for ESM compatibility) but falls back to
119
+ * tailwind.config.js for backwards compatibility.
120
+ */
121
+ const getTailwindConfigPath = () => {
122
+ const cjsConfig = resolveApp("tailwind.config.cjs");
123
+ if (existsSync(cjsConfig)) return cjsConfig;
124
+ const jsConfig = resolveApp("tailwind.config.js");
125
+ if (existsSync(jsConfig)) return jsConfig;
108
126
  };
109
- const getWidgetUuid = () => path.basename(resolveApp("."));
110
127
  const getPaths = (ifCore) => {
111
128
  return ifCore({
112
129
  root: resolveApp("."),
@@ -114,10 +131,10 @@ const getPaths = (ifCore) => {
114
131
  appEntry: resolveModule(resolveApp, "src/index"),
115
132
  appDist: resolveApp("dist"),
116
133
  appNodeModules: resolveApp("node_modules"),
117
- appTsConfig: resolveApp("tsconfig.json"),
134
+ appTsConfig: getTsConfigPath(),
118
135
  appHtml: resolveApp("src/*.html"),
119
136
  appEnv: resolveApp(".env*"),
120
- appTailwindConfig: resolveApp("tailwind.config.js")
137
+ appTailwindConfig: getTailwindConfigPath()
121
138
  }, {
122
139
  root: resolveApp("../.."),
123
140
  app: resolveApp("."),
@@ -132,7 +149,7 @@ const getPaths = (ifCore) => {
132
149
  };
133
150
  const getRelativePaths = (paths) => {
134
151
  const relativePaths = {};
135
- for (const [type, absPath] of Object.entries(paths)) if (absPath) relativePaths[type] = path.relative("./", absPath) || ".";
152
+ for (const [type, absPath] of Object.entries(paths)) if (absPath) relativePaths[type] = relative("./", absPath) || ".";
136
153
  return relativePaths;
137
154
  };
138
155
  const getIfCoreFns = ({ allowArchived = false } = {}) => {
@@ -168,7 +185,7 @@ const HTTPS_KEY_FILE = "localhost.key";
168
185
  //#region src/lib/env.ts
169
186
  const require = createRequire(import.meta.url);
170
187
  const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
171
- const filePath = files.find((file) => path.basename(file) === ".env");
188
+ const filePath = files.find((file) => basename(file) === ".env");
172
189
  if (filePath) config({ path: filePath });
173
190
  process.env.NODE_ENV ??= ifMin("production", "development");
174
191
  process.env.BABEL_ENV ??= ifMin("production", "development");
@@ -195,7 +212,7 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
195
212
  process.env.CORE_URL ??= process.env.CORE_URL_PATTERN.replace("{{version}}", version);
196
213
  }
197
214
  }
198
- const varNames = new Set([
215
+ const varNames = [
199
216
  "NODE_ENV",
200
217
  "BABEL_ENV",
201
218
  "EXPOSE_VAR",
@@ -221,8 +238,8 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
221
238
  "EPMS_PROXY_URL_PROD",
222
239
  "EPMS_TWINT_CHECKOUT_URL_STAGE",
223
240
  "EPMS_TWINT_CHECKOUT_URL_PROD"
224
- ]);
225
- const raw = Object.keys(process.env).filter((key) => key.startsWith("PUBLIC_") || varNames.has(key)).reduce((env, key) => {
241
+ ];
242
+ const raw = Object.keys(process.env).filter((key) => key.startsWith("PUBLIC_") || varNames.includes(key)).reduce((env, key) => {
226
243
  env[key] = process.env[key];
227
244
  return env;
228
245
  }, {});
@@ -236,9 +253,11 @@ const getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
236
253
  };
237
254
  const assertEnvValid = (env) => {
238
255
  const { ifCore } = getIfCoreFns();
239
- const envs = globSync(getPaths(ifCore).appEnv).map((file) => path.basename(file).replace(/^\.env\./, "")).map((file) => path.basename(file).replace(/^\.env$/, "")).filter((v) => !!v);
240
- if (envs.length === 0 && env) console.log("Flag \"--env\" is ignored.");
241
- if (envs.length > 0) {
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) {
242
261
  if (!env) halt("Flag \"--env\" is required.");
243
262
  if (env && !envs.includes(env)) halt(stripIndent(`
244
263
  Flag "--env" has wrong value.
@@ -249,7 +268,7 @@ const assertEnvValid = (env) => {
249
268
  const applyEnv = (env) => {
250
269
  if (!env) return;
251
270
  const { ifCore } = getIfCoreFns();
252
- const filePath = globSync(getPaths(ifCore).appEnv).find((file) => path.basename(file) === `.env.${env}`);
271
+ const filePath = globSync(getPaths(ifCore).appEnv).find((file) => basename(file) === `.env.${env}`);
253
272
  if (filePath) config({ path: filePath });
254
273
  };
255
274
  //#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-BrLTVK6y.js";
2
- import { createRequire } from "node:module";
3
- import { existsSync } from "node:fs";
4
- import path from "node:path";
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";
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.replaceAll(new RegExp(`%${escapeStringRegexp(key)}%`, "g"), value ?? "");
39
+ data.html = data.html.replace(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": path.dirname(require.resolve("core-js/package.json")) },
112
+ alias: { "core-js": dirname(require.resolve("core-js/package.json")) },
113
113
  plugins: [new TsconfigPathsPlugin({
114
114
  configFile: paths.appTsConfig,
115
115
  extensions
@@ -258,8 +258,8 @@ const getWebpackConfig = (env) => {
258
258
  server: ifHttps({
259
259
  type: "https",
260
260
  options: {
261
- cert: path.resolve(paths.root, HTTPS_CRT_FILE),
262
- key: path.resolve(paths.root, HTTPS_KEY_FILE)
261
+ cert: resolve(paths.root, HTTPS_CRT_FILE),
262
+ key: resolve(paths.root, HTTPS_KEY_FILE)
263
263
  }
264
264
  })
265
265
  },
@@ -277,7 +277,7 @@ const getWebpackConfig = (env) => {
277
277
  ifMin(new CleanWebpackPlugin({})),
278
278
  ...appHtmlFiles.map((file) => new HtmlWebpackPlugin({
279
279
  template: file,
280
- filename: path.basename(file),
280
+ filename: basename(file),
281
281
  inject: false,
282
282
  minify: false
283
283
  })),