@emailshepherd/cli 0.1.37 → 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 +60 -33
- package/package.json +4 -4
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",
|
|
@@ -33,7 +33,6 @@ var package_default = {
|
|
|
33
33
|
prepublishOnly: "pnpm run build"
|
|
34
34
|
},
|
|
35
35
|
dependencies: {
|
|
36
|
-
"@emailshepherd/api-client": "workspace:*",
|
|
37
36
|
axios: "^1.13.2",
|
|
38
37
|
chokidar: "^4.0.3",
|
|
39
38
|
commander: "^14.0.2",
|
|
@@ -43,6 +42,7 @@ var package_default = {
|
|
|
43
42
|
"vite-plugin-checker": "^0.12.0"
|
|
44
43
|
},
|
|
45
44
|
devDependencies: {
|
|
45
|
+
"@emailshepherd/api-client": "workspace:*",
|
|
46
46
|
"@types/node": "^24.10.1",
|
|
47
47
|
"@types/update-notifier": "^6.0.8",
|
|
48
48
|
msw: "^2.12.7",
|
|
@@ -55,7 +55,31 @@ var package_default = {
|
|
|
55
55
|
|
|
56
56
|
// src/commands/validate.ts
|
|
57
57
|
import { AxiosError as AxiosError2 } from "axios";
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
// ../api-client/dist/index.js
|
|
60
|
+
import axios from "axios";
|
|
61
|
+
import axios2 from "axios";
|
|
62
|
+
var syncEmailDesignSystem = (workspaceId, id, syncEmailDesignSystemBody, options) => {
|
|
63
|
+
return axios.post(
|
|
64
|
+
`/api/v1/workspaces/${workspaceId}/email_design_systems/${id}/sync`,
|
|
65
|
+
syncEmailDesignSystemBody,
|
|
66
|
+
options
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
var renderEmailDesignSystem = (workspaceId, emailDesignSystemId, renderEmailDesignSystemBody, options) => {
|
|
70
|
+
return axios.post(
|
|
71
|
+
`/api/v1/workspaces/${workspaceId}/email_design_systems/${emailDesignSystemId}/renders`,
|
|
72
|
+
renderEmailDesignSystemBody,
|
|
73
|
+
options
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
function configureAxios(config) {
|
|
77
|
+
const baseUrl = config?.baseUrl ?? process.env.EMAILSHEPHERD_BASE_URL ?? "https://api.emailshepherd.com";
|
|
78
|
+
const apiKey = config?.apiKey ?? process.env.EMAILSHEPHERD_API_KEY;
|
|
79
|
+
axios2.defaults.baseURL = baseUrl;
|
|
80
|
+
axios2.defaults.headers.common["Authorization"] = `Bearer ${apiKey}`;
|
|
81
|
+
axios2.defaults.headers.common["Content-Type"] = "application/json";
|
|
82
|
+
}
|
|
59
83
|
|
|
60
84
|
// src/buildHtml.ts
|
|
61
85
|
import { AxiosError } from "axios";
|
|
@@ -63,7 +87,6 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
63
87
|
import { dirname, resolve } from "path";
|
|
64
88
|
import { fileURLToPath } from "url";
|
|
65
89
|
import { createServer } from "vite";
|
|
66
|
-
import { configureAxios, renderEmailDesignSystem } from "@emailshepherd/api-client";
|
|
67
90
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
68
91
|
var viteServer = null;
|
|
69
92
|
async function getViteServer() {
|
|
@@ -193,33 +216,35 @@ async function buildHtml() {
|
|
|
193
216
|
}
|
|
194
217
|
|
|
195
218
|
// src/loadEDS.ts
|
|
196
|
-
import {
|
|
219
|
+
import { createServer as createServer2 } from "vite";
|
|
197
220
|
import { existsSync as existsSync2 } from "fs";
|
|
198
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
|
+
}
|
|
199
240
|
async function loadEDS2() {
|
|
200
241
|
const edsPath = resolve2(process.cwd(), "src", "eds.ts");
|
|
201
242
|
if (!existsSync2(edsPath)) {
|
|
202
243
|
throw new Error("Missing src/eds.ts - this file defines your Email Design System configuration.");
|
|
203
244
|
}
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
build: {
|
|
208
|
-
write: false,
|
|
209
|
-
lib: {
|
|
210
|
-
entry: edsPath,
|
|
211
|
-
formats: ["es"]
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
const output = Array.isArray(result) ? result[0] : result;
|
|
216
|
-
const chunk = output.output.find((o) => o.type === "chunk");
|
|
217
|
-
if (!chunk) {
|
|
218
|
-
throw new Error("Failed to bundle EDS");
|
|
219
|
-
}
|
|
220
|
-
const dataUrl = `data:text/javascript;base64,${Buffer.from(chunk.code).toString("base64")}`;
|
|
221
|
-
const module = await import(dataUrl);
|
|
222
|
-
return module.default;
|
|
245
|
+
const server = await getViteServer2();
|
|
246
|
+
const edsModule = await server.ssrLoadModule(edsPath);
|
|
247
|
+
return edsModule.default;
|
|
223
248
|
}
|
|
224
249
|
|
|
225
250
|
// src/typecheck.ts
|
|
@@ -250,14 +275,15 @@ function registerValidateCommand(program2) {
|
|
|
250
275
|
console.error(typeCheck.output);
|
|
251
276
|
process.exit(1);
|
|
252
277
|
}
|
|
253
|
-
|
|
278
|
+
configureAxios();
|
|
254
279
|
const eds = await loadEDS2();
|
|
255
280
|
const objectRepresentation = await buildEmailDesignSystemObject(eds);
|
|
256
|
-
const response = await
|
|
281
|
+
const response = await renderEmailDesignSystem(
|
|
257
282
|
eds.workspace_id,
|
|
258
283
|
eds.email_design_system_id,
|
|
259
284
|
objectRepresentation
|
|
260
285
|
);
|
|
286
|
+
await closeViteServer2();
|
|
261
287
|
if (response.data.html) {
|
|
262
288
|
console.log("No validation errors");
|
|
263
289
|
process.exit(0);
|
|
@@ -266,6 +292,7 @@ function registerValidateCommand(program2) {
|
|
|
266
292
|
process.exit(1);
|
|
267
293
|
}
|
|
268
294
|
} catch (error) {
|
|
295
|
+
await closeViteServer2();
|
|
269
296
|
if (error instanceof AxiosError2 && error.response?.data) {
|
|
270
297
|
console.log(JSON.stringify(error.response.data, null, 2));
|
|
271
298
|
} else if (error instanceof Error) {
|
|
@@ -280,7 +307,6 @@ function registerValidateCommand(program2) {
|
|
|
280
307
|
|
|
281
308
|
// src/commands/save.ts
|
|
282
309
|
import { AxiosError as AxiosError3 } from "axios";
|
|
283
|
-
import { configureAxios as configureAxios3, syncEmailDesignSystem } from "@emailshepherd/api-client";
|
|
284
310
|
function registerSaveAllCommand(program2) {
|
|
285
311
|
program2.command("save").description("Save the Email Design System and all components to the server").action(async () => {
|
|
286
312
|
try {
|
|
@@ -291,7 +317,7 @@ function registerSaveAllCommand(program2) {
|
|
|
291
317
|
console.error(typeCheck.output);
|
|
292
318
|
process.exit(1);
|
|
293
319
|
}
|
|
294
|
-
|
|
320
|
+
configureAxios();
|
|
295
321
|
const eds = await loadEDS2();
|
|
296
322
|
console.log("Saving Email Design System...");
|
|
297
323
|
const edsResponse = await syncEmailDesignSystem(
|
|
@@ -308,9 +334,11 @@ function registerSaveAllCommand(program2) {
|
|
|
308
334
|
components: eds.components
|
|
309
335
|
}
|
|
310
336
|
);
|
|
337
|
+
await closeViteServer2();
|
|
311
338
|
console.log(`Email Design System saved successfully`);
|
|
312
339
|
process.exit(0);
|
|
313
340
|
} catch (error) {
|
|
341
|
+
await closeViteServer2();
|
|
314
342
|
if (error instanceof AxiosError3 && error.response?.data) {
|
|
315
343
|
console.log(JSON.stringify(error.response.data, null, 2));
|
|
316
344
|
} else if (error instanceof Error) {
|
|
@@ -324,7 +352,7 @@ function registerSaveAllCommand(program2) {
|
|
|
324
352
|
}
|
|
325
353
|
|
|
326
354
|
// src/commands/dev.ts
|
|
327
|
-
import { createServer as
|
|
355
|
+
import { createServer as createServer3 } from "vite";
|
|
328
356
|
import chokidar from "chokidar";
|
|
329
357
|
import checker from "vite-plugin-checker";
|
|
330
358
|
|
|
@@ -332,7 +360,6 @@ import checker from "vite-plugin-checker";
|
|
|
332
360
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
333
361
|
import { resolve as resolve3 } from "path";
|
|
334
362
|
import { AxiosError as AxiosError4 } from "axios";
|
|
335
|
-
import { configureAxios as configureAxios4, renderEmailDesignSystem as renderEmailDesignSystem3 } from "@emailshepherd/api-client";
|
|
336
363
|
function extractFieldSchema(field) {
|
|
337
364
|
const base = {
|
|
338
365
|
type: field.type,
|
|
@@ -386,11 +413,11 @@ function applyOverrides(eds, overrides) {
|
|
|
386
413
|
};
|
|
387
414
|
}
|
|
388
415
|
async function renderWithOverrides(overrides) {
|
|
389
|
-
|
|
416
|
+
configureAxios();
|
|
390
417
|
const eds = await loadEDS();
|
|
391
418
|
const modifiedEds = applyOverrides(eds, overrides);
|
|
392
419
|
const objectRepresentation = await buildEmailDesignSystemObject(modifiedEds);
|
|
393
|
-
const response = await
|
|
420
|
+
const response = await renderEmailDesignSystem(
|
|
394
421
|
modifiedEds.workspace_id,
|
|
395
422
|
modifiedEds.email_design_system_id,
|
|
396
423
|
objectRepresentation
|
|
@@ -444,7 +471,7 @@ function registerDevCommand(program2) {
|
|
|
444
471
|
await buildHtml();
|
|
445
472
|
writeDevWrapper();
|
|
446
473
|
writeFieldsManifest(eds);
|
|
447
|
-
const server = await
|
|
474
|
+
const server = await createServer3({
|
|
448
475
|
root: "dist",
|
|
449
476
|
server: { port },
|
|
450
477
|
plugins: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emailshepherd/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org",
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"dotenv": "^17.2.3",
|
|
26
26
|
"update-notifier": "^7.3.1",
|
|
27
27
|
"vite": "^7.2.6",
|
|
28
|
-
"vite-plugin-checker": "^0.12.0"
|
|
29
|
-
"@emailshepherd/api-client": "0.0.0"
|
|
28
|
+
"vite-plugin-checker": "^0.12.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@types/node": "^24.10.1",
|
|
@@ -35,7 +34,8 @@
|
|
|
35
34
|
"tsup": "^8.5.1",
|
|
36
35
|
"tsx": "^4.21.0",
|
|
37
36
|
"typescript": "^5.9.3",
|
|
38
|
-
"vitest": "^4.0.16"
|
|
37
|
+
"vitest": "^4.0.16",
|
|
38
|
+
"@emailshepherd/api-client": "0.0.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup && cp -r src/templates dist/",
|