@emailshepherd/cli 0.1.38 → 0.2.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.
Files changed (2) hide show
  1. package/dist/cli.js +41 -35
  2. package/package.json +1 -1
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.38",
11
+ version: "0.2.0",
12
12
  type: "module",
13
13
  publishConfig: {
14
14
  registry: "https://registry.npmjs.org",
@@ -216,33 +216,35 @@ async function buildHtml() {
216
216
  }
217
217
 
218
218
  // src/loadEDS.ts
219
- import { build } from "vite";
219
+ import { createServer as createServer2 } from "vite";
220
220
  import { existsSync as existsSync2 } from "fs";
221
221
  import { resolve as resolve2 } from "path";
222
+ var viteServer2 = null;
223
+ async function getViteServer2() {
224
+ if (!viteServer2) {
225
+ viteServer2 = await createServer2({
226
+ root: process.cwd(),
227
+ server: { middlewareMode: true },
228
+ appType: "custom",
229
+ logLevel: "silent"
230
+ });
231
+ }
232
+ return viteServer2;
233
+ }
234
+ async function closeViteServer2() {
235
+ if (viteServer2) {
236
+ await viteServer2.close();
237
+ viteServer2 = null;
238
+ }
239
+ }
222
240
  async function loadEDS2() {
223
241
  const edsPath = resolve2(process.cwd(), "src", "eds.ts");
224
242
  if (!existsSync2(edsPath)) {
225
243
  throw new Error("Missing src/eds.ts - this file defines your Email Design System configuration.");
226
244
  }
227
- const result = await build({
228
- root: process.cwd(),
229
- logLevel: "silent",
230
- build: {
231
- write: false,
232
- lib: {
233
- entry: edsPath,
234
- formats: ["es"]
235
- }
236
- }
237
- });
238
- const output = Array.isArray(result) ? result[0] : result;
239
- const chunk = output.output.find((o) => o.type === "chunk");
240
- if (!chunk) {
241
- throw new Error("Failed to bundle EDS");
242
- }
243
- const dataUrl = `data:text/javascript;base64,${Buffer.from(chunk.code).toString("base64")}`;
244
- const module = await import(dataUrl);
245
- return module.default;
245
+ const server = await getViteServer2();
246
+ const edsModule = await server.ssrLoadModule(edsPath);
247
+ return edsModule.default;
246
248
  }
247
249
 
248
250
  // src/typecheck.ts
@@ -281,6 +283,7 @@ function registerValidateCommand(program2) {
281
283
  eds.email_design_system_id,
282
284
  objectRepresentation
283
285
  );
286
+ await closeViteServer2();
284
287
  if (response.data.html) {
285
288
  console.log("No validation errors");
286
289
  process.exit(0);
@@ -289,6 +292,7 @@ function registerValidateCommand(program2) {
289
292
  process.exit(1);
290
293
  }
291
294
  } catch (error) {
295
+ await closeViteServer2();
292
296
  if (error instanceof AxiosError2 && error.response?.data) {
293
297
  console.log(JSON.stringify(error.response.data, null, 2));
294
298
  } else if (error instanceof Error) {
@@ -301,10 +305,10 @@ function registerValidateCommand(program2) {
301
305
  });
302
306
  }
303
307
 
304
- // src/commands/save.ts
308
+ // src/commands/deploy.ts
305
309
  import { AxiosError as AxiosError3 } from "axios";
306
- function registerSaveAllCommand(program2) {
307
- program2.command("save").description("Save the Email Design System and all components to the server").action(async () => {
310
+ function registerDeployCommand(program2) {
311
+ program2.command("deploy").description("Deploy the Email Design System and all components to the server").action(async () => {
308
312
  try {
309
313
  console.log("Checking types...");
310
314
  const typeCheck = runTypeCheck();
@@ -315,7 +319,7 @@ function registerSaveAllCommand(program2) {
315
319
  }
316
320
  configureAxios();
317
321
  const eds = await loadEDS2();
318
- console.log("Saving Email Design System...");
322
+ console.log("Deploying Email Design System...");
319
323
  const edsResponse = await syncEmailDesignSystem(
320
324
  eds.workspace_id,
321
325
  eds.email_design_system_id,
@@ -330,9 +334,11 @@ function registerSaveAllCommand(program2) {
330
334
  components: eds.components
331
335
  }
332
336
  );
333
- console.log(`Email Design System saved successfully`);
337
+ await closeViteServer2();
338
+ console.log(`Email Design System deployed successfully`);
334
339
  process.exit(0);
335
340
  } catch (error) {
341
+ await closeViteServer2();
336
342
  if (error instanceof AxiosError3 && error.response?.data) {
337
343
  console.log(JSON.stringify(error.response.data, null, 2));
338
344
  } else if (error instanceof Error) {
@@ -346,7 +352,7 @@ function registerSaveAllCommand(program2) {
346
352
  }
347
353
 
348
354
  // src/commands/dev.ts
349
- import { createServer as createServer2 } from "vite";
355
+ import { createServer as createServer3 } from "vite";
350
356
  import chokidar from "chokidar";
351
357
  import checker from "vite-plugin-checker";
352
358
 
@@ -465,7 +471,7 @@ function registerDevCommand(program2) {
465
471
  await buildHtml();
466
472
  writeDevWrapper();
467
473
  writeFieldsManifest(eds);
468
- const server = await createServer2({
474
+ const server = await createServer3({
469
475
  root: "dist",
470
476
  server: { port },
471
477
  plugins: [
@@ -486,10 +492,10 @@ function registerDevCommand(program2) {
486
492
  });
487
493
  }
488
494
 
489
- // src/commands/build.ts
495
+ // src/commands/render.ts
490
496
  import { resolve as resolve4 } from "path";
491
- function registerBuildCommand(program2) {
492
- program2.command("build").description("Build the Email Design System HTML output").action(async () => {
497
+ function registerRenderCommand(program2) {
498
+ program2.command("render").description("Render the Email Design System HTML output").action(async () => {
493
499
  try {
494
500
  console.log("Checking types...");
495
501
  const typeCheck = runTypeCheck();
@@ -498,11 +504,11 @@ function registerBuildCommand(program2) {
498
504
  console.error(typeCheck.output);
499
505
  process.exit(1);
500
506
  }
501
- console.log("Building...");
507
+ console.log("Rendering...");
502
508
  await buildHtml();
503
509
  await closeViteServer();
504
510
  const outputPath = resolve4(process.cwd(), "dist", "rendered.html");
505
- console.log(`Built successfully: ${outputPath}`);
511
+ console.log(`Rendered successfully: ${outputPath}`);
506
512
  process.exit(0);
507
513
  } catch (error) {
508
514
  if (error instanceof Error) {
@@ -523,7 +529,7 @@ Run: npm update @emailshepherd/cli`
523
529
  var program = new Command();
524
530
  program.name("emailshepherd").description("EmailShepherd CLI - run commands from within an EDS project").version(package_default.version);
525
531
  registerValidateCommand(program);
526
- registerSaveAllCommand(program);
532
+ registerDeployCommand(program);
527
533
  registerDevCommand(program);
528
- registerBuildCommand(program);
534
+ registerRenderCommand(program);
529
535
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailshepherd/cli",
3
- "version": "0.1.38",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",