@raisenow/tamaro-cli 1.6.0-dev.2 → 1.6.0

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.
@@ -74,7 +74,6 @@ import { basename, dirname, join, relative, resolve } from "path";
74
74
  import chalk2 from "chalk";
75
75
  import stripIndent2 from "strip-indent";
76
76
  import { getIfUtils } from "webpack-config-utils";
77
- import { z } from "zod";
78
77
  var require2 = createRequire(import.meta.url);
79
78
  var moduleFileExtensions = ["ts", "tsx", "js", "jsx"];
80
79
  var extensions = moduleFileExtensions.map((v) => `.${v}`);
@@ -140,7 +139,6 @@ var getPaths = (ifCore) => {
140
139
  appTsConfig: resolveApp("tsconfig.json"),
141
140
  appHtml: resolveApp("*.html"),
142
141
  appEnv: resolveApp(".env*"),
143
- configYml: resolveApp("config.yml"),
144
142
  appTailwindConfig: void 0
145
143
  }
146
144
  );
@@ -187,55 +185,17 @@ var getIfCoreFns = ({
187
185
  );
188
186
  process.exit(1);
189
187
  };
190
- var resolveAccountUuidFromConfig = (rawConfig, field) => {
191
- const epmsConfig = z.object({
192
- [field]: z.object()
193
- }).safeParse(rawConfig);
194
- if (!epmsConfig.success) {
195
- return void 0;
196
- }
197
- const simple = z.object({
198
- [field]: z.object({
199
- account_uuid: z.uuid()
200
- })
201
- }).safeParse(rawConfig);
202
- if (simple.success) {
203
- return simple.data[field].account_uuid;
204
- }
205
- const accountMapping = z.object({
206
- [field]: z.object({
207
- account_mapping: z.uuid()
208
- })
209
- }).safeParse(rawConfig);
210
- if (accountMapping.success) {
211
- return accountMapping.data[field].account_mapping;
212
- }
213
- halt(
214
- stripIndent2(
215
- `Could not extract EPMS account UUID(s) from config.yml. Please ensure that the "${field}" field is correctly formatted. Expected formats:
216
- 1. ${field}:
217
- account_uuid: <UUID>
218
-
219
- 2. ${field}:
220
- account_mapping: <UUID>
221
- `
222
- )
223
- );
224
- };
225
188
 
226
189
  // src/lib/constants.ts
227
- import envPaths from "env-paths";
228
190
  var DEFAULT_TAG = "latest";
229
191
  var DEFAULT_PORT = 1234;
230
192
  var AWS_S3_BUCKET_TAMARO = "tamaro.raisenow.com";
231
193
  var AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE = "rnw-stage-email-service";
232
194
  var AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD = "rnw-email-service";
233
- var EPMS_API_BASE_URL_STAGE = "https://api.stage.mesos.raisenow.net";
234
195
  var CORE_CONFIG_NAME = "tamaro-core";
235
196
  var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
236
197
  var HTTPS_CRT_FILE = "localhost.crt";
237
198
  var HTTPS_KEY_FILE = "localhost.key";
238
- var CACHE_DIR = envPaths("tamaro-cli", { suffix: "" }).cache;
239
199
 
240
200
  // src/lib/env.ts
241
201
  import { createRequire as createRequire2 } from "module";
@@ -380,18 +340,15 @@ export {
380
340
  getPaths,
381
341
  getRelativePaths,
382
342
  getIfCoreFns,
383
- resolveAccountUuidFromConfig,
384
343
  DEFAULT_TAG,
385
344
  DEFAULT_PORT,
386
345
  AWS_S3_BUCKET_TAMARO,
387
346
  AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
388
347
  AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD,
389
- EPMS_API_BASE_URL_STAGE,
390
348
  CORE_CONFIG_NAME,
391
349
  AWS_CLOUDFRONT_DISTRIBUTION_ID,
392
350
  HTTPS_CRT_FILE,
393
351
  HTTPS_KEY_FILE,
394
- CACHE_DIR,
395
352
  getEnvVars,
396
353
  assertEnvValid,
397
354
  applyEnv
package/dist/cli.js CHANGED
@@ -4,11 +4,9 @@ import {
4
4
  AWS_S3_BUCKET_TAMARO,
5
5
  AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD,
6
6
  AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_STAGE,
7
- CACHE_DIR,
8
7
  CORE_CONFIG_NAME,
9
8
  DEFAULT_PORT,
10
9
  DEFAULT_TAG,
11
- EPMS_API_BASE_URL_STAGE,
12
10
  HTTPS_CRT_FILE,
13
11
  HTTPS_KEY_FILE,
14
12
  applyEnv,
@@ -23,11 +21,10 @@ import {
23
21
  logSuccess,
24
22
  logTitle,
25
23
  promptConfirmation,
26
- resolveAccountUuidFromConfig,
27
24
  resolveBin,
28
25
  resolveOwn,
29
26
  runCommandSync
30
- } from "./chunk-FI7KZAG6.js";
27
+ } from "./chunk-5D6F3T2J.js";
31
28
 
32
29
  // src/cli.ts
33
30
  import { createCommand } from "commander";
@@ -859,7 +856,7 @@ var undeploy = async (options) => {
859
856
  }
860
857
  await promptConfirmation(
861
858
  `Are you sure you want to undeploy ${description}?`,
862
- options.ci
859
+ options.yes
863
860
  );
864
861
  const cmd = `
865
862
  aws s3 rm ${deployUrl}
@@ -940,7 +937,7 @@ var undeployEmailConfig = async (options) => {
940
937
  const deployUrl = `s3://${options.bucket}/${configName}/`;
941
938
  await promptConfirmation(
942
939
  `Are you sure you want to undeploy the email configuration for "${configName}" from "${options.bucket}"?`,
943
- options.ci
940
+ options.yes
944
941
  );
945
942
  if (dryRunFlag) {
946
943
  logTitle("\u{1F9EA} DRY RUN MODE - No actual changes will be made \u{1F9EA}");
@@ -1013,236 +1010,10 @@ var promptBucketTamaroEmailConfig2 = async () => {
1013
1010
  return bucket;
1014
1011
  };
1015
1012
 
1016
- // src/commands/update-epms.ts
1017
- import { readFileSync as readFileSync3 } from "fs";
1018
- import yaml2 from "js-yaml";
1019
-
1020
- // src/lib/epms/assert.ts
1021
- import { existsSync as existsSync6, readFileSync } from "fs";
1022
- import yaml from "js-yaml";
1023
- import stripIndent5 from "strip-indent";
1024
- var assertEpmsCredentials = (configPath) => {
1025
- if (!existsSync6(configPath)) {
1026
- throw new Error(`Config file not found at path: ${configPath}`);
1027
- }
1028
- try {
1029
- const configContent = yaml.load(readFileSync(configPath, "utf8"));
1030
- assertEpmsCredentialsPresentStage(configContent);
1031
- assertEpmsCredentialsPresentProd(configContent);
1032
- } catch (e) {
1033
- throw new Error(
1034
- `Error parsing config file at path: ${configPath}. Details: ${e}`
1035
- );
1036
- }
1037
- };
1038
- var assertEpmsCredentialsPresentStage = (rawConfig) => {
1039
- const accountsUuidsStage = resolveAccountUuidFromConfig(
1040
- rawConfig,
1041
- "epms_stage"
1042
- );
1043
- if (!accountsUuidsStage) {
1044
- return;
1045
- }
1046
- if (!process.env.EPMS_CLIENT_ID_STAGE || !process.env.EPMS_CLIENT_SECRET_STAGE) {
1047
- halt(
1048
- stripIndent5(
1049
- `EPMS credentials for stage environment are missing.
1050
- - Please set EPMS_CLIENT_ID_STAGE and EPMS_CLIENT_SECRET_STAGE in your environment variables.
1051
- - Alternatively, remove the "epms_stage" fields from your config.yml
1052
- `
1053
- )
1054
- );
1055
- }
1056
- };
1057
- var assertEpmsCredentialsPresentProd = (rawConfig) => {
1058
- const accountsUuidsProd = resolveAccountUuidFromConfig(rawConfig, "epms");
1059
- if (!accountsUuidsProd) {
1060
- return;
1061
- }
1062
- if (!process.env.EPMS_CLIENT_ID || !process.env.EPMS_CLIENT_SECRET) {
1063
- halt(
1064
- stripIndent5(
1065
- `EPMS credentials for prod environment are missing.
1066
- - Please set EPMS_CLIENT_ID and EPMS_CLIENT_SECRET in your environment variables.
1067
- - Alternatively, remove the "epms" fields from your config.yml
1068
- `
1069
- )
1070
- );
1071
- }
1072
- };
1073
-
1074
- // src/lib/epms/auth.ts
1075
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
1076
- import { dirname as dirname3, join } from "path";
1077
- import ky from "ky";
1078
- var DEFAULT_TIMEOUT = 1e4;
1079
- function getCacheFilePath() {
1080
- return join(CACHE_DIR, "token.json");
1081
- }
1082
- function readCachedToken() {
1083
- try {
1084
- const filePath = getCacheFilePath();
1085
- if (!existsSync7(filePath)) {
1086
- return void 0;
1087
- }
1088
- const data = JSON.parse(readFileSync2(filePath, "utf-8"));
1089
- if (typeof data.token === "string" && typeof data.expirationTime === "number") {
1090
- return data;
1091
- }
1092
- } catch {
1093
- }
1094
- return void 0;
1095
- }
1096
- function writeCachedToken(cached) {
1097
- try {
1098
- const filePath = getCacheFilePath();
1099
- mkdirSync2(dirname3(filePath), { recursive: true });
1100
- writeFileSync(filePath, JSON.stringify(cached), { mode: 384 });
1101
- } catch {
1102
- }
1103
- }
1104
- var createAuthorizer = (baseUrl, clientId, clientSecret) => {
1105
- const apiUnauthorized = ky.extend({
1106
- headers: {
1107
- "Access-Control-Allow-Origin": "*"
1108
- },
1109
- prefixUrl: baseUrl,
1110
- timeout: DEFAULT_TIMEOUT
1111
- });
1112
- let expirationTime = void 0;
1113
- let token = void 0;
1114
- const cached = readCachedToken();
1115
- if (cached) {
1116
- token = cached.token;
1117
- expirationTime = cached.expirationTime;
1118
- }
1119
- const authorize = async () => {
1120
- const isExpired = (expirationTime ?? 0) - Date.now() < 5 * 60 * 1e3;
1121
- if (token && !isExpired) {
1122
- return token;
1123
- }
1124
- const data = await apiUnauthorized.post("oauth2/token", {
1125
- json: {
1126
- client_id: clientId,
1127
- client_secret: clientSecret,
1128
- grant_type: "client_credentials"
1129
- }
1130
- }).json();
1131
- token = `${data.token_type} ${data.access_token}`;
1132
- expirationTime = Date.now() + data.expires_in * 1e3;
1133
- writeCachedToken({ token, expirationTime });
1134
- return token;
1135
- };
1136
- return apiUnauthorized.extend({
1137
- hooks: {
1138
- beforeRequest: [
1139
- async (request) => {
1140
- request.headers.set("Authorization", await authorize());
1141
- }
1142
- ]
1143
- }
1144
- });
1145
- };
1146
-
1147
- // src/lib/epms/client.ts
1148
- var EpmsClient = class {
1149
- #epmsClient;
1150
- constructor(baseUrl, clientId, clientSecret) {
1151
- this.#epmsClient = createAuthorizer(baseUrl, clientId, clientSecret);
1152
- }
1153
- async getOrganisationIdByAccountUuid(accountUuid) {
1154
- const query = {
1155
- query: {
1156
- $and: [
1157
- { $term: { object_uuid: accountUuid } },
1158
- { $term: { object: "account" } }
1159
- ]
1160
- },
1161
- size: 1,
1162
- from: 0
1163
- };
1164
- const response = await this.#epmsClient.post("search/events", {
1165
- json: query
1166
- }).json();
1167
- if (response.hits.length === 0) {
1168
- throw new Error(`No events found for account UUID: ${accountUuid}`);
1169
- }
1170
- const organisationId = response.hits[0].organisation_uuid;
1171
- if (!organisationId) {
1172
- throw new Error(
1173
- `Organisation UUID not found for account UUID: ${accountUuid}`
1174
- );
1175
- }
1176
- return organisationId;
1177
- }
1178
- async updateTamaro(configName, tag, json) {
1179
- return this.#epmsClient.put(`products/tamaro/${configName}/tags/${tag}`, {
1180
- json
1181
- }).json();
1182
- }
1183
- };
1184
-
1185
- // src/commands/update-epms.ts
1186
- var updateEpms = async (options) => {
1187
- const { ifCore } = getIfCoreFns();
1188
- assertIsNotCore5(ifCore);
1189
- const paths = getPaths(ifCore);
1190
- const { tag, dryrun } = options;
1191
- const dryRunFlag = dryrun ? `--dryrun` : "";
1192
- const configName = getWidgetUuid();
1193
- if (!("configYml" in paths)) {
1194
- halt("Fatal error, this should never happen");
1195
- throw new Error();
1196
- }
1197
- if (dryRunFlag) {
1198
- logTitle("\u{1F9EA} DRY RUN MODE - No actual changes will be made \u{1F9EA}");
1199
- }
1200
- assertTagValid(tag);
1201
- assertEpmsCredentials(paths.configYml);
1202
- const configContent = yaml2.load(readFileSync3(paths.configYml, "utf8"));
1203
- const accountUuidStage = resolveAccountUuidFromConfig(
1204
- configContent,
1205
- "epms_stage"
1206
- );
1207
- if (dryrun) {
1208
- logTitle(
1209
- `[DRY RUN] Would update EPMS for "${configName}" with tag "${tag}"`
1210
- );
1211
- } else {
1212
- if (accountUuidStage) {
1213
- const epmsClient = new EpmsClient(
1214
- EPMS_API_BASE_URL_STAGE,
1215
- process.env.EPMS_CLIENT_ID_STAGE,
1216
- process.env.EPMS_CLIENT_SECRET_STAGE
1217
- );
1218
- const organisationUuid = await epmsClient.getOrganisationIdByAccountUuid(accountUuidStage);
1219
- logTitle("Updating EPMS with the following details:");
1220
- const body = {
1221
- account_uuid: accountUuidStage,
1222
- organisation_uuid: organisationUuid,
1223
- configured_version: tag,
1224
- read_only: false
1225
- };
1226
- logDataTable({
1227
- name: configName,
1228
- tag,
1229
- ...body
1230
- });
1231
- await epmsClient.updateTamaro(configName, tag, body);
1232
- logSuccess("\u2705 EPMS Stage is updated.");
1233
- }
1234
- }
1235
- };
1236
- var assertIsNotCore5 = (ifCore) => {
1237
- if (ifCore()) {
1238
- halt("You cannot update EPMS in the context of Tamaro Core.");
1239
- }
1240
- };
1241
-
1242
1013
  // package.json
1243
1014
  var package_default = {
1244
1015
  name: "@raisenow/tamaro-cli",
1245
- version: "1.6.0-dev.2",
1016
+ version: "1.6.0",
1246
1017
  author: {
1247
1018
  name: "RaiseNow",
1248
1019
  email: "development@raisenow.com"
@@ -1305,7 +1076,6 @@ var package_default = {
1305
1076
  "css-loader": "^7.1.3",
1306
1077
  "css-minimizer-webpack-plugin": "^7.0.4",
1307
1078
  dotenv: "^17.2.3",
1308
- "env-paths": "^4.0.0",
1309
1079
  "escape-string-regexp": "^5.0.0",
1310
1080
  eslint: "^8.57.1",
1311
1081
  "eslint-config-prettier": "^10.1.8",
@@ -1325,9 +1095,7 @@ var package_default = {
1325
1095
  "handlebars-helpers": "^0.10.0",
1326
1096
  "html-loader": "^5.1.0",
1327
1097
  "html-webpack-plugin": "^5.6.6",
1328
- "js-yaml": "^4.1.1",
1329
1098
  "json-loader": "^0.5.7",
1330
- ky: "^1.14.3",
1331
1099
  lodash: "^4.17.23",
1332
1100
  "mini-css-extract-plugin": "^2.10.0",
1333
1101
  "node-notifier": "^10.0.1",
@@ -1355,11 +1123,7 @@ var package_default = {
1355
1123
  "webpack-cli": "^6.0.1",
1356
1124
  "webpack-config-utils": "^2.3.1",
1357
1125
  "webpack-dev-server": "^5.2.3",
1358
- "yaml-loader": "^0.9.0",
1359
- zod: "^4.3.6"
1360
- },
1361
- devDependencies: {
1362
- "@types/js-yaml": "^4.0.9"
1126
+ "yaml-loader": "^0.9.0"
1363
1127
  }
1364
1128
  };
1365
1129
 
@@ -1480,13 +1244,6 @@ cli.command("unarchive").description(
1480
1244
  ).action((options) => {
1481
1245
  unarchive(options);
1482
1246
  });
1483
- cli.command("update-epms").description("Update EPMS with the currently configured widget version.").option("--tag <tag>", "Tag which should be used for the update", DEFAULT_TAG).option(
1484
- "--dryrun",
1485
- "Displays the operations that would be performed without actually running them",
1486
- false
1487
- ).action(async (options) => {
1488
- await updateEpms(options);
1489
- });
1490
1247
  cli.command("validate").description(
1491
1248
  "Validate the current Tamaro configuration to avoid common errors"
1492
1249
  ).action(async () => {
@@ -10,7 +10,7 @@ import {
10
10
  logTitle,
11
11
  resolveApp,
12
12
  resolveEslintPluginConfig
13
- } from "./chunk-FI7KZAG6.js";
13
+ } from "./chunk-5D6F3T2J.js";
14
14
 
15
15
  // src/webpack.config.ts
16
16
  import { existsSync } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raisenow/tamaro-cli",
3
- "version": "1.6.0-dev.2",
3
+ "version": "1.6.0",
4
4
  "author": {
5
5
  "name": "RaiseNow",
6
6
  "email": "development@raisenow.com"
@@ -48,7 +48,6 @@
48
48
  "css-loader": "^7.1.3",
49
49
  "css-minimizer-webpack-plugin": "^7.0.4",
50
50
  "dotenv": "^17.2.3",
51
- "env-paths": "^4.0.0",
52
51
  "escape-string-regexp": "^5.0.0",
53
52
  "eslint": "^8.57.1",
54
53
  "eslint-config-prettier": "^10.1.8",
@@ -68,9 +67,7 @@
68
67
  "handlebars-helpers": "^0.10.0",
69
68
  "html-loader": "^5.1.0",
70
69
  "html-webpack-plugin": "^5.6.6",
71
- "js-yaml": "^4.1.1",
72
70
  "json-loader": "^0.5.7",
73
- "ky": "^1.14.3",
74
71
  "lodash": "^4.17.23",
75
72
  "mini-css-extract-plugin": "^2.10.0",
76
73
  "node-notifier": "^10.0.1",
@@ -98,11 +95,7 @@
98
95
  "webpack-cli": "^6.0.1",
99
96
  "webpack-config-utils": "^2.3.1",
100
97
  "webpack-dev-server": "^5.2.3",
101
- "yaml-loader": "^0.9.0",
102
- "zod": "^4.3.6"
103
- },
104
- "devDependencies": {
105
- "@types/js-yaml": "^4.0.9"
98
+ "yaml-loader": "^0.9.0"
106
99
  },
107
100
  "scripts": {
108
101
  "typecheck": "tsc --noEmit",