@mailmodo/cli 0.0.56-beta.pr58.100 → 0.0.56-beta.pr58.101

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.
@@ -1,7 +1,7 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../lib/base-command.js';
3
3
  import { API_ENDPOINTS } from '../../lib/constants.js';
4
- import { loadYaml, saveYaml } from '../../lib/yaml-config.js';
4
+ import { loadYaml, saveYaml, } from '../../lib/yaml-config.js';
5
5
  import { analyzeProduct, promptProductUrl, } from '../../lib/commands/init/analysis.js';
6
6
  import { confirmOverwrite, logInitSuccess, } from '../../lib/commands/init/output.js';
7
7
  import { applyMonthlyCap, buildEmailConfigs, buildYamlConfig, preserveUserFields, saveAllTemplates, } from '../../lib/commands/init/payload.js';
@@ -20,10 +20,12 @@ export default class Init extends BaseCommand {
20
20
  await this.ensureAuth();
21
21
  const ctx = this.makeCtx();
22
22
  const baseFlags = { json: flags.json, yes: flags.yes };
23
+ let serverYaml = null;
23
24
  if (this.isBlankDirectory()) {
24
- const restored = await this.promptInitServerRestore(baseFlags);
25
- if (restored)
25
+ const result = await this.promptInitServerRestore(baseFlags);
26
+ if (result.restored)
26
27
  return;
28
+ serverYaml = result.serverYaml;
27
29
  }
28
30
  const existing = await loadYaml();
29
31
  if (!(await confirmOverwrite(ctx, baseFlags, existing)))
@@ -38,8 +40,9 @@ export default class Init extends BaseCommand {
38
40
  const generatedEmails = generateResponse.data?.emails || [];
39
41
  const emailConfigs = buildEmailConfigs(analysisPayload, generatedEmails);
40
42
  const yamlConfig = buildYamlConfig(analysisPayload, emailConfigs, productUrl);
41
- if (existing)
42
- preserveUserFields(yamlConfig, existing);
43
+ const fieldSource = existing ?? serverYaml;
44
+ if (fieldSource)
45
+ preserveUserFields(yamlConfig, fieldSource);
43
46
  await saveYaml(yamlConfig);
44
47
  await applyMonthlyCap(ctx, yamlConfig);
45
48
  await saveAllTemplates(analysisPayload.recommendedEmails, generatedEmails);
@@ -74,7 +74,10 @@ export declare abstract class BaseCommand extends Command {
74
74
  protected promptInitServerRestore(flags: {
75
75
  json?: boolean;
76
76
  yes?: boolean;
77
- }): Promise<boolean>;
77
+ }): Promise<{
78
+ restored: boolean;
79
+ serverYaml: MailmodoYaml | null;
80
+ }>;
78
81
  private fetchAndWriteYaml;
79
82
  /**
80
83
  * Attempts to fetch mailmodo.yaml from the server and save it locally.
@@ -11,7 +11,7 @@ import { API_ENDPOINTS, IS_DEV_MODE, TEMPLATES_DIR, YAML_FILE, } from './constan
11
11
  import { syncTemplatesToServer, syncTemplateToServer, fetchTemplatesFromServer, fetchTemplateFromServer, } from './templates/sync.js';
12
12
  import { getMissingTemplateIds } from './templates/missing-templates.js';
13
13
  import { BLANK_DIR, ERRORS, INFO, PROMPTS, quotaExhaustedMessage, recordLabel, VALIDATION, } from './messages.js';
14
- import { loadYaml, saveYaml } from './yaml-config.js';
14
+ import { loadYaml, parseYamlText, saveYaml, } from './yaml-config.js';
15
15
  export const FREE_TIER = 'free';
16
16
  /**
17
17
  * Abstract base command providing shared functionality for all Mailmodo CLI commands.
@@ -151,7 +151,7 @@ export class BaseCommand extends Command {
151
151
  async promptInitServerRestore(flags) {
152
152
  const yamlText = await this.fetchYamlText();
153
153
  if (!yamlText)
154
- return false;
154
+ return { restored: false, serverYaml: null };
155
155
  let shouldRestore = Boolean(flags.yes || flags.json);
156
156
  if (!shouldRestore) {
157
157
  const choice = await select({
@@ -163,17 +163,18 @@ export class BaseCommand extends Command {
163
163
  });
164
164
  shouldRestore = choice === 'restore';
165
165
  }
166
- if (!shouldRestore)
167
- return false;
166
+ if (!shouldRestore) {
167
+ return { restored: false, serverYaml: parseYamlText(yamlText) };
168
+ }
168
169
  await writeFile(join(process.cwd(), YAML_FILE), yamlText);
169
170
  const yaml = await loadYaml();
170
171
  if (!yaml)
171
- return false;
172
+ return { restored: false, serverYaml: null };
172
173
  const client = this.apiClient;
173
174
  if (client)
174
175
  await this.fetchMissingTemplates(client, yaml);
175
176
  this.log(`\n ${BLANK_DIR.RESTORED_INIT}\n`);
176
- return true;
177
+ return { restored: true, serverYaml: yaml };
177
178
  }
178
179
  async fetchAndWriteYaml(client) {
179
180
  try {
@@ -14,7 +14,7 @@ export declare const PROMPTS: {
14
14
  readonly SENDER_EMAIL: "Sender email address:";
15
15
  };
16
16
  export declare const BLANK_DIR: {
17
- readonly CHOICE_FRESH: "Start fresh — create a new project here";
17
+ readonly CHOICE_FRESH: "Start fresh — new emails will be generated (your domain, sender, and address settings will be kept)";
18
18
  readonly CHOICE_RESTORE: "Restore project files from server";
19
19
  readonly CHOICE_RESTORE_INIT: "Restore existing project files from server";
20
20
  readonly CHOICE_SKIP: "Skip — I'll navigate to my project directory manually";
@@ -15,7 +15,7 @@ export const PROMPTS = {
15
15
  SENDER_EMAIL: 'Sender email address:',
16
16
  };
17
17
  export const BLANK_DIR = {
18
- CHOICE_FRESH: 'Start fresh — create a new project here',
18
+ CHOICE_FRESH: 'Start fresh — new emails will be generated (your domain, sender, and address settings will be kept)',
19
19
  CHOICE_RESTORE: 'Restore project files from server',
20
20
  CHOICE_RESTORE_INIT: 'Restore existing project files from server',
21
21
  CHOICE_SKIP: "Skip — I'll navigate to my project directory manually",
@@ -44,6 +44,7 @@ export interface MailmodoYaml {
44
44
  * formatted Error with the line number if the file contains invalid YAML syntax.
45
45
  */
46
46
  export declare function loadYaml(cwd?: string): Promise<MailmodoYaml | null>;
47
+ export declare function parseYamlText(text: string): MailmodoYaml | null;
47
48
  /**
48
49
  * Serializes and writes the mailmodo.yaml configuration to disk.
49
50
  *
@@ -25,6 +25,14 @@ export async function loadYaml(cwd) {
25
25
  throw new Error(yamlParseError(error.message));
26
26
  }
27
27
  }
28
+ export function parseYamlText(text) {
29
+ try {
30
+ return load(text);
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
28
36
  /**
29
37
  * Serializes and writes the mailmodo.yaml configuration to disk.
30
38
  *
@@ -289,58 +289,6 @@
289
289
  "index.js"
290
290
  ]
291
291
  },
292
- "edit": {
293
- "aliases": [],
294
- "args": {
295
- "id": {
296
- "description": "Email template ID to edit",
297
- "name": "id",
298
- "required": true
299
- }
300
- },
301
- "description": "Edit an email using AI-assisted natural language changes",
302
- "examples": [
303
- "<%= config.bin %> edit welcome",
304
- "<%= config.bin %> edit welcome --change \"make subject more urgent\" --yes"
305
- ],
306
- "flags": {
307
- "json": {
308
- "description": "Output as JSON",
309
- "name": "json",
310
- "allowNo": false,
311
- "type": "boolean"
312
- },
313
- "yes": {
314
- "char": "y",
315
- "description": "Skip confirmation prompts",
316
- "name": "yes",
317
- "allowNo": false,
318
- "type": "boolean"
319
- },
320
- "change": {
321
- "description": "Natural language description of the change",
322
- "name": "change",
323
- "hasDynamicHelp": false,
324
- "multiple": false,
325
- "type": "option"
326
- }
327
- },
328
- "hasDynamicHelp": false,
329
- "hiddenAliases": [],
330
- "id": "edit",
331
- "pluginAlias": "@mailmodo/cli",
332
- "pluginName": "@mailmodo/cli",
333
- "pluginType": "core",
334
- "strict": true,
335
- "enableJsonFlag": false,
336
- "isESM": true,
337
- "relativePath": [
338
- "dist",
339
- "commands",
340
- "edit",
341
- "index.js"
342
- ]
343
- },
344
292
  "emails": {
345
293
  "aliases": [],
346
294
  "args": {},
@@ -763,7 +711,59 @@
763
711
  "status",
764
712
  "index.js"
765
713
  ]
714
+ },
715
+ "edit": {
716
+ "aliases": [],
717
+ "args": {
718
+ "id": {
719
+ "description": "Email template ID to edit",
720
+ "name": "id",
721
+ "required": true
722
+ }
723
+ },
724
+ "description": "Edit an email using AI-assisted natural language changes",
725
+ "examples": [
726
+ "<%= config.bin %> edit welcome",
727
+ "<%= config.bin %> edit welcome --change \"make subject more urgent\" --yes"
728
+ ],
729
+ "flags": {
730
+ "json": {
731
+ "description": "Output as JSON",
732
+ "name": "json",
733
+ "allowNo": false,
734
+ "type": "boolean"
735
+ },
736
+ "yes": {
737
+ "char": "y",
738
+ "description": "Skip confirmation prompts",
739
+ "name": "yes",
740
+ "allowNo": false,
741
+ "type": "boolean"
742
+ },
743
+ "change": {
744
+ "description": "Natural language description of the change",
745
+ "name": "change",
746
+ "hasDynamicHelp": false,
747
+ "multiple": false,
748
+ "type": "option"
749
+ }
750
+ },
751
+ "hasDynamicHelp": false,
752
+ "hiddenAliases": [],
753
+ "id": "edit",
754
+ "pluginAlias": "@mailmodo/cli",
755
+ "pluginName": "@mailmodo/cli",
756
+ "pluginType": "core",
757
+ "strict": true,
758
+ "enableJsonFlag": false,
759
+ "isESM": true,
760
+ "relativePath": [
761
+ "dist",
762
+ "commands",
763
+ "edit",
764
+ "index.js"
765
+ ]
766
766
  }
767
767
  },
768
- "version": "0.0.56-beta.pr58.100"
768
+ "version": "0.0.56-beta.pr58.101"
769
769
  }
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.56-beta.pr58.100",
4
+ "version": "0.0.56-beta.pr58.101",
5
5
  "author": "provishalk",
6
6
  "bin": {
7
7
  "mailmodo": "bin/run.js"