@emailshepherd/cli 0.1.38 → 0.1.40
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 +29 -23
- 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.
|
|
11
|
+
version: "0.1.40",
|
|
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 {
|
|
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
|
|
228
|
-
|
|
229
|
-
|
|
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) {
|
|
@@ -330,9 +334,11 @@ function registerSaveAllCommand(program2) {
|
|
|
330
334
|
components: eds.components
|
|
331
335
|
}
|
|
332
336
|
);
|
|
337
|
+
await closeViteServer2();
|
|
333
338
|
console.log(`Email Design System saved 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
|
|
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
|
|
474
|
+
const server = await createServer3({
|
|
469
475
|
root: "dist",
|
|
470
476
|
server: { port },
|
|
471
477
|
plugins: [
|