@emailshepherd/cli 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import updateNotifier from "update-notifier";
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@emailshepherd/cli",
11
- version: "0.2.0",
11
+ version: "0.2.1",
12
12
  type: "module",
13
13
  publishConfig: {
14
14
  registry: "https://registry.npmjs.org",
@@ -87,6 +87,37 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
87
87
  import { dirname, resolve } from "path";
88
88
  import { fileURLToPath } from "url";
89
89
  import { createServer } from "vite";
90
+
91
+ // src/env.ts
92
+ function getEDSEnvConfig() {
93
+ const workspaceIdStr = process.env.EMAILSHEPHERD_WORKSPACE_ID;
94
+ const edsIdStr = process.env.EMAILSHEPHERD_EDS_ID;
95
+ if (!workspaceIdStr) {
96
+ throw new Error(
97
+ "Missing EMAILSHEPHERD_WORKSPACE_ID environment variable. Set it in your .env file or provide it via the environment."
98
+ );
99
+ }
100
+ if (!edsIdStr) {
101
+ throw new Error(
102
+ "Missing EMAILSHEPHERD_EDS_ID environment variable. Set it in your .env file or provide it via the environment."
103
+ );
104
+ }
105
+ const workspaceId = parseInt(workspaceIdStr, 10);
106
+ const edsId = parseInt(edsIdStr, 10);
107
+ if (isNaN(workspaceId)) {
108
+ throw new Error(
109
+ `Invalid EMAILSHEPHERD_WORKSPACE_ID: "${workspaceIdStr}" is not a valid number.`
110
+ );
111
+ }
112
+ if (isNaN(edsId)) {
113
+ throw new Error(
114
+ `Invalid EMAILSHEPHERD_EDS_ID: "${edsIdStr}" is not a valid number.`
115
+ );
116
+ }
117
+ return { workspaceId, edsId };
118
+ }
119
+
120
+ // src/buildHtml.ts
90
121
  var __dirname = dirname(fileURLToPath(import.meta.url));
91
122
  var viteServer = null;
92
123
  async function getViteServer() {
@@ -188,11 +219,12 @@ async function buildHtml() {
188
219
  configureAxios();
189
220
  let html;
190
221
  try {
222
+ const { workspaceId, edsId } = getEDSEnvConfig();
191
223
  const eds = await loadEDS();
192
224
  const objectRepresentation = await buildEmailDesignSystemObject(eds);
193
225
  const response = await renderEmailDesignSystem(
194
- eds.workspace_id,
195
- eds.email_design_system_id,
226
+ workspaceId,
227
+ edsId,
196
228
  objectRepresentation
197
229
  );
198
230
  if (response.data.html) {
@@ -276,11 +308,12 @@ function registerValidateCommand(program2) {
276
308
  process.exit(1);
277
309
  }
278
310
  configureAxios();
311
+ const { workspaceId, edsId } = getEDSEnvConfig();
279
312
  const eds = await loadEDS2();
280
313
  const objectRepresentation = await buildEmailDesignSystemObject(eds);
281
314
  const response = await renderEmailDesignSystem(
282
- eds.workspace_id,
283
- eds.email_design_system_id,
315
+ workspaceId,
316
+ edsId,
284
317
  objectRepresentation
285
318
  );
286
319
  await closeViteServer2();
@@ -318,11 +351,12 @@ function registerDeployCommand(program2) {
318
351
  process.exit(1);
319
352
  }
320
353
  configureAxios();
354
+ const { workspaceId, edsId } = getEDSEnvConfig();
321
355
  const eds = await loadEDS2();
322
356
  console.log("Deploying Email Design System...");
323
357
  const edsResponse = await syncEmailDesignSystem(
324
- eds.workspace_id,
325
- eds.email_design_system_id,
358
+ workspaceId,
359
+ edsId,
326
360
  {
327
361
  email_design_system: {
328
362
  name: eds.eds_metadata.name,
package/dist/types.d.ts CHANGED
@@ -9,8 +9,6 @@ type EDSMetadata = {
9
9
  custom_styles?: RichTextCustomStyle[];
10
10
  };
11
11
  type EDSConfig = {
12
- workspace_id: number;
13
- email_design_system_id: number;
14
12
  eds_metadata: EDSMetadata;
15
13
  container_component: ComponentDefinition;
16
14
  components: ComponentDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailshepherd/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",