emailr-cli 1.3.3 → 1.4.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.
- package/dist/index.js +117 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1046,6 +1046,122 @@ To save changes: emailr templates update ${id} --html-file ${options.file}`);
|
|
|
1046
1046
|
process.exit(1);
|
|
1047
1047
|
}
|
|
1048
1048
|
});
|
|
1049
|
+
cmd.command("draft").description(`Start a live drafting session for a new template.
|
|
1050
|
+
|
|
1051
|
+
AGENTIC WORKFLOW:
|
|
1052
|
+
1. Run: emailr templates draft --file ./new-template.html
|
|
1053
|
+
2. Edit the file at ./new-template.html - browser auto-refreshes on save
|
|
1054
|
+
3. When done: emailr templates create --name "My Template" --subject "Subject" --html-file ./new-template.html
|
|
1055
|
+
|
|
1056
|
+
This command creates a starter HTML file and starts a live preview server with hot-reload. Perfect for building new templates from scratch with instant visual feedback.`).option("--file <path>", "Path to save the HTML file for drafting", "./new-template.html").option("--no-open", "Do not automatically open browser").option("--blank", "Start with a blank file instead of starter template").action(async (options) => {
|
|
1057
|
+
try {
|
|
1058
|
+
const filePath = path4.resolve(options.file);
|
|
1059
|
+
let htmlContent;
|
|
1060
|
+
if (options.blank) {
|
|
1061
|
+
htmlContent = "";
|
|
1062
|
+
} else {
|
|
1063
|
+
htmlContent = `<!DOCTYPE html>
|
|
1064
|
+
<html>
|
|
1065
|
+
<head>
|
|
1066
|
+
<meta charset="UTF-8">
|
|
1067
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1068
|
+
<title>Email Template</title>
|
|
1069
|
+
<style>
|
|
1070
|
+
body {
|
|
1071
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
1072
|
+
line-height: 1.6;
|
|
1073
|
+
color: #333;
|
|
1074
|
+
max-width: 600px;
|
|
1075
|
+
margin: 0 auto;
|
|
1076
|
+
padding: 20px;
|
|
1077
|
+
}
|
|
1078
|
+
.header {
|
|
1079
|
+
text-align: center;
|
|
1080
|
+
padding: 20px 0;
|
|
1081
|
+
border-bottom: 1px solid #eee;
|
|
1082
|
+
}
|
|
1083
|
+
.content {
|
|
1084
|
+
padding: 30px 0;
|
|
1085
|
+
}
|
|
1086
|
+
.button {
|
|
1087
|
+
display: inline-block;
|
|
1088
|
+
padding: 12px 24px;
|
|
1089
|
+
background-color: #5e5de7;
|
|
1090
|
+
color: white;
|
|
1091
|
+
text-decoration: none;
|
|
1092
|
+
border-radius: 5px;
|
|
1093
|
+
font-weight: bold;
|
|
1094
|
+
}
|
|
1095
|
+
.footer {
|
|
1096
|
+
text-align: center;
|
|
1097
|
+
padding: 20px 0;
|
|
1098
|
+
border-top: 1px solid #eee;
|
|
1099
|
+
color: #888;
|
|
1100
|
+
font-size: 12px;
|
|
1101
|
+
}
|
|
1102
|
+
</style>
|
|
1103
|
+
</head>
|
|
1104
|
+
<body>
|
|
1105
|
+
<div class="header">
|
|
1106
|
+
<h1>Your Company</h1>
|
|
1107
|
+
</div>
|
|
1108
|
+
|
|
1109
|
+
<div class="content">
|
|
1110
|
+
<h2>Hello {{name}},</h2>
|
|
1111
|
+
|
|
1112
|
+
<p>This is a starter template. Edit this file and see your changes live in the browser!</p>
|
|
1113
|
+
|
|
1114
|
+
<p>You can use variables like <code>{{name}}</code> that will be replaced when sending emails.</p>
|
|
1115
|
+
|
|
1116
|
+
<p style="text-align: center; margin: 30px 0;">
|
|
1117
|
+
<a href="https://example.com" class="button">Call to Action</a>
|
|
1118
|
+
</p>
|
|
1119
|
+
|
|
1120
|
+
<p>Best regards,<br>Your Team</p>
|
|
1121
|
+
</div>
|
|
1122
|
+
|
|
1123
|
+
<div class="footer">
|
|
1124
|
+
<p>\xA9 2024 Your Company. All rights reserved.</p>
|
|
1125
|
+
<p><a href="{{unsubscribe_link}}">Unsubscribe</a></p>
|
|
1126
|
+
</div>
|
|
1127
|
+
</body>
|
|
1128
|
+
</html>`;
|
|
1129
|
+
}
|
|
1130
|
+
fs4.writeFileSync(filePath, htmlContent, "utf-8");
|
|
1131
|
+
console.log(`Template draft created: ${filePath}`);
|
|
1132
|
+
const port = await startLivePreviewServer(filePath, () => {
|
|
1133
|
+
console.log("File changed - browser refreshed");
|
|
1134
|
+
});
|
|
1135
|
+
const previewUrl = `http://127.0.0.1:${port}/`;
|
|
1136
|
+
console.log(`
|
|
1137
|
+
Live Preview: ${previewUrl}`);
|
|
1138
|
+
console.log(`
|
|
1139
|
+
Watching for changes... Edit the file and see live updates.`);
|
|
1140
|
+
console.log(`
|
|
1141
|
+
When done, create the template:`);
|
|
1142
|
+
console.log(` emailr templates create --name "Template Name" --subject "Email Subject" --html-file ${options.file}`);
|
|
1143
|
+
console.log(`
|
|
1144
|
+
Press Ctrl+C to stop.`);
|
|
1145
|
+
if (options.open !== false) {
|
|
1146
|
+
try {
|
|
1147
|
+
const open = await import("open");
|
|
1148
|
+
await open.default(previewUrl);
|
|
1149
|
+
} catch {
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
process.on("SIGINT", async () => {
|
|
1153
|
+
console.log("\n\nStopping live preview server...");
|
|
1154
|
+
await stopLivePreviewServer();
|
|
1155
|
+
console.log("Done.");
|
|
1156
|
+
console.log(`
|
|
1157
|
+
To create template: emailr templates create --name "Template Name" --subject "Email Subject" --html-file ${options.file}`);
|
|
1158
|
+
process.exit(0);
|
|
1159
|
+
});
|
|
1160
|
+
} catch (err) {
|
|
1161
|
+
error(err instanceof Error ? err.message : "Failed to start draft session");
|
|
1162
|
+
process.exit(1);
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1049
1165
|
return cmd;
|
|
1050
1166
|
}
|
|
1051
1167
|
|
|
@@ -2125,7 +2241,7 @@ function openBrowser(url) {
|
|
|
2125
2241
|
|
|
2126
2242
|
// src/commands/login.ts
|
|
2127
2243
|
var DEFAULT_TIMEOUT_SECONDS = 120;
|
|
2128
|
-
var WEB_APP_BASE_URL = process.env.EMAILR_WEB_URL || "https://
|
|
2244
|
+
var WEB_APP_BASE_URL = process.env.EMAILR_WEB_URL || "https://app.emailr.dev";
|
|
2129
2245
|
function buildAuthorizationUrl(state, callbackPort) {
|
|
2130
2246
|
const callbackUrl = `http://127.0.0.1:${callbackPort}/callback`;
|
|
2131
2247
|
const params = new URLSearchParams({
|