@mailmodo/cli 0.0.7-beta.pr9.13 → 0.0.7

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/bin/dev.js CHANGED
@@ -1,26 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawnSync } from 'node:child_process';
4
- import { fileURLToPath } from 'node:url';
3
+ import {spawnSync} from 'node:child_process'
4
+ import {fileURLToPath} from 'node:url'
5
5
 
6
- import { execute } from '@oclif/core';
6
+ import {execute} from '@oclif/core'
7
7
 
8
8
  if (process.env.MAILMODO_DEV_TSX) {
9
- await execute({ development: true, dir: import.meta.url });
9
+ await execute({development: true, dir: import.meta.url})
10
10
  } else {
11
- const scriptPath = fileURLToPath(import.meta.url);
12
- const result = spawnSync(
13
- process.execPath,
14
- ['--import', 'tsx', scriptPath, ...process.argv.slice(2)],
15
- {
16
- env: { ...process.env, MAILMODO_DEV_TSX: '1' },
17
- stdio: 'inherit',
18
- }
19
- );
11
+ const scriptPath = fileURLToPath(import.meta.url)
12
+ const result = spawnSync(process.execPath, ['--import', 'tsx', scriptPath, ...process.argv.slice(2)], {
13
+ env: {...process.env, MAILMODO_DEV_TSX: '1'},
14
+ stdio: 'inherit',
15
+ })
20
16
 
21
17
  if (result.status !== 0) {
22
- throw new Error(
23
- `dev bootstrap failed with exit code ${result.status ?? 1}`
24
- );
18
+ throw new Error(`dev bootstrap failed with exit code ${result.status ?? 1}`)
25
19
  }
26
20
  }
package/bin/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { execute } from '@oclif/core';
3
+ import {execute} from '@oclif/core'
4
4
 
5
- await execute({ dir: import.meta.url });
5
+ await execute({dir: import.meta.url})
@@ -12,13 +12,8 @@ export default class Billing extends BaseCommand {
12
12
  ];
13
13
  static flags = {
14
14
  ...BaseCommand.baseFlags,
15
- cap: Flags.integer({
16
- description: 'Set monthly block cap (max blocks to auto-charge)',
17
- }),
18
- status: Flags.boolean({
19
- default: false,
20
- description: 'Show billing status only',
21
- }),
15
+ cap: Flags.integer({ description: 'Set monthly block cap (max blocks to auto-charge)' }),
16
+ status: Flags.boolean({ default: false, description: 'Show billing status only' }),
22
17
  };
23
18
  async run() {
24
19
  const { flags } = await this.parse(Billing);
@@ -84,9 +79,7 @@ export default class Billing extends BaseCommand {
84
79
  * @param {boolean} jsonOutput - Whether to output JSON instead of formatted text.
85
80
  */
86
81
  async setCap(cap, jsonOutput) {
87
- const response = await this.apiClient.patch(API_ENDPOINTS.BILLING_CAP, {
88
- cap,
89
- });
82
+ const response = await this.apiClient.patch(API_ENDPOINTS.BILLING_CAP, { cap });
90
83
  if (!response.ok) {
91
84
  this.handleApiError(response);
92
85
  }
@@ -13,13 +13,8 @@ export default class Contacts extends BaseCommand {
13
13
  ];
14
14
  static flags = {
15
15
  ...BaseCommand.baseFlags,
16
- delete: Flags.string({
17
- description: 'GDPR hard delete a contact by email',
18
- }),
19
- export: Flags.boolean({
20
- default: false,
21
- description: 'Export all contacts as CSV',
22
- }),
16
+ delete: Flags.string({ description: 'GDPR hard delete a contact by email' }),
17
+ export: Flags.boolean({ default: false, description: 'Export all contacts as CSV' }),
23
18
  search: Flags.string({ description: 'Search for a contact by email' }),
24
19
  };
25
20
  async run() {
@@ -28,10 +28,7 @@ export default class Deploy extends BaseCommand {
28
28
  this.log(` This is a one-time setup. Takes about 5 minutes.\n`);
29
29
  }
30
30
  if (!flags.yes) {
31
- const setupNow = await confirm({
32
- default: true,
33
- message: 'Set up your sending domain now?',
34
- });
31
+ const setupNow = await confirm({ default: true, message: 'Set up your sending domain now?' });
35
32
  if (!setupNow) {
36
33
  this.log(`\n Sequences saved but ${chalk.yellow('NOT deployed')}.`);
37
34
  this.log(` Emails will not send until your domain is verified.`);
@@ -86,7 +83,7 @@ export default class Deploy extends BaseCommand {
86
83
  this.log(` ${chalk.dim('// On user signup:')}`);
87
84
  this.log(` ${chalk.dim("track('user.signup', { email, first_name, app_url })")}\n`);
88
85
  this.log(` ${chalk.dim('// When user creates a project:')}`);
89
- this.log(` ${chalk.dim('identify(email, { has_created_project: true })')}\n`);
86
+ this.log(` ${chalk.dim("identify(email, { has_created_project: true })")}\n`);
90
87
  this.log(` ${chalk.dim('// On trial expiry:')}`);
91
88
  this.log(` ${chalk.dim("track('user.trial_expiry', { email, first_name })")}\n`);
92
89
  this.log(` Full SDK docs: ${chalk.cyan('mailmodo.com/docs/sdk')}\n`);
@@ -118,7 +115,7 @@ export default class Deploy extends BaseCommand {
118
115
  });
119
116
  senderEmail = await input({
120
117
  message: 'Sender email address:',
121
- validate: (v) => v?.includes('@') ? true : 'Please enter a valid email',
118
+ validate: (v) => (v?.includes('@') ? true : 'Please enter a valid email'),
122
119
  });
123
120
  address = await input({
124
121
  message: 'Business address (required by law for email footers):',
@@ -13,14 +13,8 @@ export default class Domain extends BaseCommand {
13
13
  ];
14
14
  static flags = {
15
15
  ...BaseCommand.baseFlags,
16
- status: Flags.boolean({
17
- default: false,
18
- description: 'Show domain health status',
19
- }),
20
- verify: Flags.boolean({
21
- default: false,
22
- description: 'Verify DNS records',
23
- }),
16
+ status: Flags.boolean({ default: false, description: 'Show domain health status' }),
17
+ verify: Flags.boolean({ default: false, description: 'Verify DNS records' }),
24
18
  };
25
19
  async run() {
26
20
  const { flags } = await this.parse(Domain);
@@ -64,7 +58,7 @@ export default class Domain extends BaseCommand {
64
58
  senderEmail = await input({
65
59
  default: yamlConfig.project?.fromEmail,
66
60
  message: 'Sender email address:',
67
- validate: (v) => v?.includes('@') ? true : 'Please enter a valid email',
61
+ validate: (v) => (v?.includes('@') ? true : 'Please enter a valid email'),
68
62
  });
69
63
  address = await input({
70
64
  default: yamlConfig.project?.address,
@@ -3,7 +3,7 @@ import { confirm, input } from '@inquirer/prompts';
3
3
  import chalk from 'chalk';
4
4
  import { BaseCommand } from '../../lib/base-command.js';
5
5
  import { API_ENDPOINTS } from '../../lib/constants.js';
6
- import { loadTemplate, saveTemplate, saveYaml, } from '../../lib/yaml-config.js';
6
+ import { loadTemplate, saveTemplate, saveYaml } from '../../lib/yaml-config.js';
7
7
  export default class Edit extends BaseCommand {
8
8
  static args = {
9
9
  id: Args.string({ description: 'Email ID to edit', required: true }),
@@ -15,9 +15,7 @@ export default class Edit extends BaseCommand {
15
15
  ];
16
16
  static flags = {
17
17
  ...BaseCommand.baseFlags,
18
- change: Flags.string({
19
- description: 'Natural language description of the change',
20
- }),
18
+ change: Flags.string({ description: 'Natural language description of the change' }),
21
19
  };
22
20
  async run() {
23
21
  const { args, flags } = await this.parse(Edit);
@@ -36,7 +34,7 @@ export default class Edit extends BaseCommand {
36
34
  if (!changeDescription) {
37
35
  changeDescription = await input({
38
36
  message: 'What do you want to change?',
39
- validate: (value) => value?.trim() ? true : 'Please describe the change',
37
+ validate: (value) => (value?.trim() ? true : 'Please describe the change'),
40
38
  });
41
39
  }
42
40
  const response = await this.apiClient.post(API_ENDPOINTS.EDIT, {
@@ -63,10 +61,7 @@ export default class Edit extends BaseCommand {
63
61
  this.log(` ${chalk.green(`+ ${newSubject}`)}`);
64
62
  }
65
63
  if (!flags.yes) {
66
- const accepted = await confirm({
67
- default: true,
68
- message: 'Accept changes?',
69
- });
64
+ const accepted = await confirm({ default: true, message: 'Accept changes?' });
70
65
  if (!accepted) {
71
66
  this.log('\n Changes discarded.\n');
72
67
  return;
@@ -88,9 +83,7 @@ export default class Edit extends BaseCommand {
88
83
  if (flags.json) {
89
84
  this.log(JSON.stringify({
90
85
  diff: {
91
- subject: oldSubject === newSubject
92
- ? undefined
93
- : { new: newSubject, old: oldSubject },
86
+ subject: oldSubject === newSubject ? undefined : { new: newSubject, old: oldSubject },
94
87
  },
95
88
  email,
96
89
  status: 'updated',
@@ -25,9 +25,7 @@ export default class Emails extends BaseCommand {
25
25
  const id = email.id.padEnd(maxIdLen + 2);
26
26
  const trigger = `trigger: ${email.trigger}`.padEnd(maxTriggerLen + 12);
27
27
  const delay = `delay: ${email.delay}`;
28
- const condition = email.condition
29
- ? chalk.dim(` [if ${email.condition}]`)
30
- : '';
28
+ const condition = email.condition ? chalk.dim(` [if ${email.condition}]`) : '';
31
29
  this.log(` ${chalk.cyan(id)} ${trigger} ${delay}${condition}`);
32
30
  }
33
31
  this.log('');
@@ -1,9 +1,9 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { editor, input, select } from '@inquirer/prompts';
2
+ import { confirm, input } from '@inquirer/prompts';
3
3
  import chalk from 'chalk';
4
4
  import { BaseCommand } from '../../lib/base-command.js';
5
5
  import { API_ENDPOINTS, DEFAULT_BRAND_COLOR } from '../../lib/constants.js';
6
- import { saveTemplate, saveYaml, } from '../../lib/yaml-config.js';
6
+ import { saveTemplate, saveYaml } from '../../lib/yaml-config.js';
7
7
  function isValidUrl(value) {
8
8
  try {
9
9
  return Boolean(new URL(value));
@@ -55,51 +55,20 @@ export default class Init extends BaseCommand {
55
55
  }
56
56
  this.log('');
57
57
  }
58
- let analysisPayload = analysis;
59
58
  if (!flags.yes) {
60
- const userAction = await select({
61
- choices: [
62
- { name: 'Yes - continue with this result', value: 'yes' },
63
- { name: 'No - stop here', value: 'no' },
64
- { name: 'Edit - update the result before continuing', value: 'edit' },
65
- ],
66
- message: 'Does this look right?',
67
- });
68
- if (userAction === 'no') {
69
- this.log(`\n Stopped. Run ${chalk.cyan('mailmodo init')} again when you are ready.\n`);
59
+ const ok = await confirm({ default: true, message: 'Does this look right?' });
60
+ if (!ok) {
61
+ this.log(`\n Run ${chalk.cyan('mailmodo init')} again to re-analyze.\n`);
70
62
  return;
71
63
  }
72
- if (userAction === 'edit') {
73
- const editedAnalysis = await editor({
74
- default: JSON.stringify(analysis, null, 2),
75
- message: 'Edit the analysis JSON. Save and close to continue.',
76
- postfix: '.json',
77
- validate(value) {
78
- if (!value?.trim())
79
- return 'Edited analysis cannot be empty';
80
- try {
81
- JSON.parse(value);
82
- return true;
83
- }
84
- catch {
85
- return 'Please provide valid JSON';
86
- }
87
- },
88
- });
89
- analysisPayload = JSON.parse(editedAnalysis);
90
- }
91
64
  }
92
- this.log('analysisPayload', analysisPayload);
93
65
  this.log('\n Generating emails...\n');
94
- const generateResponse = await this.apiClient.post(API_ENDPOINTS.GENERATE, {
95
- analysis: analysisPayload,
96
- productUrl,
97
- });
66
+ const generateResponse = await this.apiClient.post(API_ENDPOINTS.GENERATE, { analysis, productUrl });
98
67
  if (!generateResponse.ok) {
99
68
  this.handleApiError(generateResponse);
100
69
  }
101
70
  const generatedEmails = generateResponse.data?.emails || [];
102
- const emailConfigs = analysisPayload.recommendedEmails.map((rec, index) => {
71
+ const emailConfigs = analysis.recommendedEmails.map((rec, index) => {
103
72
  const generated = generatedEmails[index];
104
73
  return {
105
74
  delay: rec.delay || '0',
@@ -108,29 +77,27 @@ export default class Init extends BaseCommand {
108
77
  ...(rec.condition ? { condition: rec.condition } : {}),
109
78
  subject: generated?.subject || `Email for ${rec.id}`,
110
79
  template: `mailmodo/${rec.id}.html`,
111
- ...(generated?.previewText
112
- ? { previewText: generated.previewText }
113
- : {}),
80
+ ...(generated?.previewText ? { previewText: generated.previewText } : {}),
114
81
  goal: rec.goal,
115
82
  };
116
83
  });
117
84
  const yamlConfig = {
118
85
  emails: emailConfigs,
119
86
  project: {
120
- brandColor: analysisPayload.brand?.color || DEFAULT_BRAND_COLOR,
87
+ brandColor: analysis.brand?.color || DEFAULT_BRAND_COLOR,
121
88
  emailStyle: 'branded',
122
89
  fromEmail: '',
123
- fromName: `Team ${analysisPayload.productName}`,
124
- logoUrl: analysisPayload.brand?.logoUrl || '',
125
- name: analysisPayload.productName,
90
+ fromName: `Team ${analysis.productName}`,
91
+ logoUrl: analysis.brand?.logoUrl || '',
92
+ name: analysis.productName,
126
93
  replyTo: '',
127
- type: analysisPayload.pricingModel,
94
+ type: analysis.pricingModel,
128
95
  url: productUrl,
129
96
  webhookUrl: '',
130
97
  },
131
98
  };
132
99
  await saveYaml(yamlConfig);
133
- const templateSaves = analysisPayload.recommendedEmails.flatMap((rec, index) => {
100
+ const templateSaves = analysis.recommendedEmails.flatMap((rec, index) => {
134
101
  const generated = generatedEmails[index];
135
102
  const saves = [];
136
103
  if (generated?.html) {
@@ -144,7 +111,7 @@ export default class Init extends BaseCommand {
144
111
  await Promise.all(templateSaves);
145
112
  if (flags.json) {
146
113
  this.log(JSON.stringify({
147
- brandDetected: analysisPayload.brand,
114
+ brandDetected: analysis.brand,
148
115
  emails: emailConfigs,
149
116
  emailsCreated: emailConfigs.length,
150
117
  style: yamlConfig.project.emailStyle,
@@ -13,10 +13,7 @@ export default class Logs extends BaseCommand {
13
13
  static flags = {
14
14
  ...BaseCommand.baseFlags,
15
15
  email: Flags.string({ description: 'Filter logs by contact email' }),
16
- failed: Flags.boolean({
17
- default: false,
18
- description: 'Show only failed/bounced events',
19
- }),
16
+ failed: Flags.boolean({ default: false, description: 'Show only failed/bounced events' }),
20
17
  };
21
18
  async run() {
22
19
  const { flags } = await this.parse(Logs);
@@ -63,10 +63,7 @@ export default class Preview extends BaseCommand {
63
63
  static flags = {
64
64
  ...BaseCommand.baseFlags,
65
65
  send: Flags.string({ description: 'Send test email to this address' }),
66
- text: Flags.boolean({
67
- default: false,
68
- description: 'Output plain text version (for AI agents)',
69
- }),
66
+ text: Flags.boolean({ default: false, description: 'Output plain text version (for AI agents)' }),
70
67
  };
71
68
  async run() {
72
69
  const { args, flags } = await this.parse(Preview);
@@ -100,9 +97,7 @@ export default class Preview extends BaseCommand {
100
97
  * and CI pipelines that cannot open a browser.
101
98
  */
102
99
  async renderText(email, templateHtml, sampleData, jsonOutput) {
103
- const rendered = templateHtml
104
- ? renderTemplate(templateHtml, sampleData)
105
- : '';
100
+ const rendered = templateHtml ? renderTemplate(templateHtml, sampleData) : '';
106
101
  const plainText = htmlToText(rendered);
107
102
  if (jsonOutput) {
108
103
  this.log(JSON.stringify({
@@ -144,9 +139,7 @@ export default class Preview extends BaseCommand {
144
139
  * template, then opens the user's default browser to view it.
145
140
  */
146
141
  async startPreviewServer(email, templateHtml, sampleData, jsonOutput) {
147
- const rendered = templateHtml
148
- ? renderTemplate(templateHtml, sampleData)
149
- : '<p>No template found.</p>';
142
+ const rendered = templateHtml ? renderTemplate(templateHtml, sampleData) : '<p>No template found.</p>';
150
143
  const wrapperHtml = `<!DOCTYPE html>
151
144
  <html>
152
145
  <head>
@@ -50,8 +50,7 @@ export default class Settings extends BaseCommand {
50
50
  if (!(propKey in project)) {
51
51
  this.error(`Unknown setting: ${key}`);
52
52
  }
53
- project[propKey] =
54
- propKey === 'monthlyCap' ? Number(value) : value;
53
+ project[propKey] = propKey === 'monthlyCap' ? Number(value) : value;
55
54
  await saveYaml(yamlConfig);
56
55
  if (flags.json) {
57
56
  this.log(JSON.stringify({ [propKey]: value, status: 'updated' }, null, 2));
@@ -38,7 +38,7 @@ export class ApiClient {
38
38
  }
39
39
  }
40
40
  const headers = {
41
- Authorization: `Bearer ${this.apiKey}`,
41
+ 'Authorization': `Bearer ${this.apiKey}`,
42
42
  'Content-Type': 'application/json',
43
43
  'User-Agent': '@mailmodo/cli',
44
44
  };
@@ -69,7 +69,7 @@ export class ApiClient {
69
69
  data: {},
70
70
  error: isConnectionError
71
71
  ? 'Cannot connect to Mailmodo API. The API service may not be available yet.'
72
- : err?.message || 'An unexpected network error occurred.',
72
+ : (err?.message || 'An unexpected network error occurred.'),
73
73
  ok: false,
74
74
  status: 0,
75
75
  };
@@ -93,7 +93,7 @@ export class ApiClient {
93
93
  const response = await fetch(url.toString(), {
94
94
  body: formData,
95
95
  headers: {
96
- Authorization: `Bearer ${this.apiKey}`,
96
+ 'Authorization': `Bearer ${this.apiKey}`,
97
97
  'User-Agent': '@mailmodo/cli',
98
98
  },
99
99
  method: 'POST',
@@ -11,11 +11,7 @@ import { loadYaml } from './yaml-config.js';
11
11
  export class BaseCommand extends Command {
12
12
  static baseFlags = {
13
13
  json: Flags.boolean({ default: false, description: 'Output as JSON' }),
14
- yes: Flags.boolean({
15
- char: 'y',
16
- default: false,
17
- description: 'Skip confirmation prompts',
18
- }),
14
+ yes: Flags.boolean({ char: 'y', default: false, description: 'Skip confirmation prompts' }),
19
15
  };
20
16
  apiClient;
21
17
  /**
@@ -13,7 +13,6 @@ const CONFIG_FILE = join(CONFIG_DIR, 'config');
13
13
  * or null if the config file does not exist or is corrupted.
14
14
  */
15
15
  export async function loadConfig() {
16
- console.log('Loading config from', CONFIG_FILE);
17
16
  if (!existsSync(CONFIG_FILE))
18
17
  return null;
19
18
  try {
@@ -31,11 +31,7 @@ export async function loadYaml(cwd) {
31
31
  */
32
32
  export async function saveYaml(config, cwd) {
33
33
  const filePath = join(cwd || process.cwd(), YAML_FILE);
34
- const content = dump(config, {
35
- lineWidth: -1,
36
- noRefs: true,
37
- quotingType: '"',
38
- });
34
+ const content = dump(config, { lineWidth: -1, noRefs: true, quotingType: '"' });
39
35
  await writeFile(filePath, content);
40
36
  }
41
37
  /**
@@ -114,14 +114,13 @@
114
114
  "index.js"
115
115
  ]
116
116
  },
117
- "domain": {
117
+ "deploy": {
118
118
  "aliases": [],
119
119
  "args": {},
120
- "description": "Set up and verify your sending domain",
120
+ "description": "Deploy email sequences and verify sending domain",
121
121
  "examples": [
122
- "<%= config.bin %> domain",
123
- "<%= config.bin %> domain --verify",
124
- "<%= config.bin %> domain --status"
122
+ "<%= config.bin %> deploy",
123
+ "<%= config.bin %> deploy --yes"
125
124
  ],
126
125
  "flags": {
127
126
  "json": {
@@ -136,23 +135,11 @@
136
135
  "name": "yes",
137
136
  "allowNo": false,
138
137
  "type": "boolean"
139
- },
140
- "status": {
141
- "description": "Show domain health status",
142
- "name": "status",
143
- "allowNo": false,
144
- "type": "boolean"
145
- },
146
- "verify": {
147
- "description": "Verify DNS records",
148
- "name": "verify",
149
- "allowNo": false,
150
- "type": "boolean"
151
138
  }
152
139
  },
153
140
  "hasDynamicHelp": false,
154
141
  "hiddenAliases": [],
155
- "id": "domain",
142
+ "id": "deploy",
156
143
  "pluginAlias": "@mailmodo/cli",
157
144
  "pluginName": "@mailmodo/cli",
158
145
  "pluginType": "core",
@@ -162,17 +149,18 @@
162
149
  "relativePath": [
163
150
  "dist",
164
151
  "commands",
165
- "domain",
152
+ "deploy",
166
153
  "index.js"
167
154
  ]
168
155
  },
169
- "deploy": {
156
+ "domain": {
170
157
  "aliases": [],
171
158
  "args": {},
172
- "description": "Deploy email sequences and verify sending domain",
159
+ "description": "Set up and verify your sending domain",
173
160
  "examples": [
174
- "<%= config.bin %> deploy",
175
- "<%= config.bin %> deploy --yes"
161
+ "<%= config.bin %> domain",
162
+ "<%= config.bin %> domain --verify",
163
+ "<%= config.bin %> domain --status"
176
164
  ],
177
165
  "flags": {
178
166
  "json": {
@@ -187,11 +175,23 @@
187
175
  "name": "yes",
188
176
  "allowNo": false,
189
177
  "type": "boolean"
178
+ },
179
+ "status": {
180
+ "description": "Show domain health status",
181
+ "name": "status",
182
+ "allowNo": false,
183
+ "type": "boolean"
184
+ },
185
+ "verify": {
186
+ "description": "Verify DNS records",
187
+ "name": "verify",
188
+ "allowNo": false,
189
+ "type": "boolean"
190
190
  }
191
191
  },
192
192
  "hasDynamicHelp": false,
193
193
  "hiddenAliases": [],
194
- "id": "deploy",
194
+ "id": "domain",
195
195
  "pluginAlias": "@mailmodo/cli",
196
196
  "pluginName": "@mailmodo/cli",
197
197
  "pluginType": "core",
@@ -201,7 +201,7 @@
201
201
  "relativePath": [
202
202
  "dist",
203
203
  "commands",
204
- "deploy",
204
+ "domain",
205
205
  "index.js"
206
206
  ]
207
207
  },
@@ -580,5 +580,5 @@
580
580
  ]
581
581
  }
582
582
  },
583
- "version": "0.0.7-beta.pr9.13"
583
+ "version": "0.0.7"
584
584
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mailmodo/cli",
3
3
  "description": "Email lifecycle automation for the AI-native builder generation.",
4
- "version": "0.0.7-beta.pr9.13",
4
+ "version": "0.0.7",
5
5
  "author": "provishalk",
6
6
  "bin": {
7
7
  "mailmodo": "bin/run.js"