@emailshepherd/cli 0.1.40 → 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.1.40",
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();
@@ -305,10 +338,10 @@ function registerValidateCommand(program2) {
305
338
  });
306
339
  }
307
340
 
308
- // src/commands/save.ts
341
+ // src/commands/deploy.ts
309
342
  import { AxiosError as AxiosError3 } from "axios";
310
- function registerSaveAllCommand(program2) {
311
- program2.command("save").description("Save the Email Design System and all components to the server").action(async () => {
343
+ function registerDeployCommand(program2) {
344
+ program2.command("deploy").description("Deploy the Email Design System and all components to the server").action(async () => {
312
345
  try {
313
346
  console.log("Checking types...");
314
347
  const typeCheck = runTypeCheck();
@@ -318,11 +351,12 @@ function registerSaveAllCommand(program2) {
318
351
  process.exit(1);
319
352
  }
320
353
  configureAxios();
354
+ const { workspaceId, edsId } = getEDSEnvConfig();
321
355
  const eds = await loadEDS2();
322
- console.log("Saving Email Design System...");
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,
@@ -335,7 +369,7 @@ function registerSaveAllCommand(program2) {
335
369
  }
336
370
  );
337
371
  await closeViteServer2();
338
- console.log(`Email Design System saved successfully`);
372
+ console.log(`Email Design System deployed successfully`);
339
373
  process.exit(0);
340
374
  } catch (error) {
341
375
  await closeViteServer2();
@@ -492,10 +526,10 @@ function registerDevCommand(program2) {
492
526
  });
493
527
  }
494
528
 
495
- // src/commands/build.ts
529
+ // src/commands/render.ts
496
530
  import { resolve as resolve4 } from "path";
497
- function registerBuildCommand(program2) {
498
- program2.command("build").description("Build the Email Design System HTML output").action(async () => {
531
+ function registerRenderCommand(program2) {
532
+ program2.command("render").description("Render the Email Design System HTML output").action(async () => {
499
533
  try {
500
534
  console.log("Checking types...");
501
535
  const typeCheck = runTypeCheck();
@@ -504,11 +538,11 @@ function registerBuildCommand(program2) {
504
538
  console.error(typeCheck.output);
505
539
  process.exit(1);
506
540
  }
507
- console.log("Building...");
541
+ console.log("Rendering...");
508
542
  await buildHtml();
509
543
  await closeViteServer();
510
544
  const outputPath = resolve4(process.cwd(), "dist", "rendered.html");
511
- console.log(`Built successfully: ${outputPath}`);
545
+ console.log(`Rendered successfully: ${outputPath}`);
512
546
  process.exit(0);
513
547
  } catch (error) {
514
548
  if (error instanceof Error) {
@@ -529,7 +563,7 @@ Run: npm update @emailshepherd/cli`
529
563
  var program = new Command();
530
564
  program.name("emailshepherd").description("EmailShepherd CLI - run commands from within an EDS project").version(package_default.version);
531
565
  registerValidateCommand(program);
532
- registerSaveAllCommand(program);
566
+ registerDeployCommand(program);
533
567
  registerDevCommand(program);
534
- registerBuildCommand(program);
568
+ registerRenderCommand(program);
535
569
  program.parse();
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.1.40",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",