@mailmodo/cli 0.0.56-beta.pr58.105 → 0.0.56-beta.pr58.106
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/lib/config.d.ts +2 -0
- package/dist/lib/config.js +19 -10
- package/oclif.manifest.json +39 -39
- package/package.json +1 -1
package/dist/lib/config.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare function saveConfig(config: MailmodoConfig): Promise<void>;
|
|
|
28
28
|
export declare function clearConfig(): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* Returns the absolute path to the Mailmodo config directory (~/.mailmodo).
|
|
31
|
+
* Honors MAILMODO_CONFIG_DIR env var when set (used in tests to redirect away
|
|
32
|
+
* from the user's real config).
|
|
31
33
|
*
|
|
32
34
|
* @returns {string} The config directory path.
|
|
33
35
|
*/
|
package/dist/lib/config.js
CHANGED
|
@@ -2,8 +2,12 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function configDir() {
|
|
6
|
+
return process.env.MAILMODO_CONFIG_DIR ?? join(homedir(), '.mailmodo');
|
|
7
|
+
}
|
|
8
|
+
function configFile() {
|
|
9
|
+
return join(configDir(), 'config');
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
12
|
* Loads the Mailmodo CLI configuration from ~/.mailmodo/config.
|
|
9
13
|
* The config file stores the API key and account metadata as JSON.
|
|
@@ -13,10 +17,11 @@ const CONFIG_FILE = join(CONFIG_DIR, 'config');
|
|
|
13
17
|
* or null if the config file does not exist or is corrupted.
|
|
14
18
|
*/
|
|
15
19
|
export async function loadConfig() {
|
|
16
|
-
|
|
20
|
+
const file = configFile();
|
|
21
|
+
if (!existsSync(file))
|
|
17
22
|
return null;
|
|
18
23
|
try {
|
|
19
|
-
const content = await readFile(
|
|
24
|
+
const content = await readFile(file, 'utf8');
|
|
20
25
|
return JSON.parse(content);
|
|
21
26
|
}
|
|
22
27
|
catch {
|
|
@@ -32,20 +37,22 @@ export async function loadConfig() {
|
|
|
32
37
|
* at minimum an apiKey. Optional fields: email, totalFreeRemaining.
|
|
33
38
|
*/
|
|
34
39
|
export async function saveConfig(config) {
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
const dir = configDir();
|
|
41
|
+
if (!existsSync(dir)) {
|
|
42
|
+
await mkdir(dir, { recursive: true });
|
|
37
43
|
}
|
|
38
|
-
await writeFile(
|
|
44
|
+
await writeFile(configFile(), JSON.stringify(config, null, 2));
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Deletes the saved CLI config file (~/.mailmodo/config), removing the stored API key.
|
|
42
48
|
* No-op if the file does not exist.
|
|
43
49
|
*/
|
|
44
50
|
export async function clearConfig() {
|
|
45
|
-
|
|
51
|
+
const file = configFile();
|
|
52
|
+
if (!existsSync(file))
|
|
46
53
|
return;
|
|
47
54
|
try {
|
|
48
|
-
await unlink(
|
|
55
|
+
await unlink(file);
|
|
49
56
|
}
|
|
50
57
|
catch {
|
|
51
58
|
// Ignore missing file or permission errors; caller can treat as best-effort sign-out.
|
|
@@ -53,9 +60,11 @@ export async function clearConfig() {
|
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
62
|
* Returns the absolute path to the Mailmodo config directory (~/.mailmodo).
|
|
63
|
+
* Honors MAILMODO_CONFIG_DIR env var when set (used in tests to redirect away
|
|
64
|
+
* from the user's real config).
|
|
56
65
|
*
|
|
57
66
|
* @returns {string} The config directory path.
|
|
58
67
|
*/
|
|
59
68
|
export function getConfigDir() {
|
|
60
|
-
return
|
|
69
|
+
return configDir();
|
|
61
70
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -465,6 +465,44 @@
|
|
|
465
465
|
"index.js"
|
|
466
466
|
]
|
|
467
467
|
},
|
|
468
|
+
"logout": {
|
|
469
|
+
"aliases": [],
|
|
470
|
+
"args": {},
|
|
471
|
+
"description": "Sign out by removing saved credentials from this machine",
|
|
472
|
+
"examples": [
|
|
473
|
+
"<%= config.bin %> logout"
|
|
474
|
+
],
|
|
475
|
+
"flags": {
|
|
476
|
+
"json": {
|
|
477
|
+
"description": "Output as JSON",
|
|
478
|
+
"name": "json",
|
|
479
|
+
"allowNo": false,
|
|
480
|
+
"type": "boolean"
|
|
481
|
+
},
|
|
482
|
+
"yes": {
|
|
483
|
+
"char": "y",
|
|
484
|
+
"description": "Skip confirmation prompts",
|
|
485
|
+
"name": "yes",
|
|
486
|
+
"allowNo": false,
|
|
487
|
+
"type": "boolean"
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
"hasDynamicHelp": false,
|
|
491
|
+
"hiddenAliases": [],
|
|
492
|
+
"id": "logout",
|
|
493
|
+
"pluginAlias": "@mailmodo/cli",
|
|
494
|
+
"pluginName": "@mailmodo/cli",
|
|
495
|
+
"pluginType": "core",
|
|
496
|
+
"strict": true,
|
|
497
|
+
"enableJsonFlag": false,
|
|
498
|
+
"isESM": true,
|
|
499
|
+
"relativePath": [
|
|
500
|
+
"dist",
|
|
501
|
+
"commands",
|
|
502
|
+
"logout",
|
|
503
|
+
"index.js"
|
|
504
|
+
]
|
|
505
|
+
},
|
|
468
506
|
"logs": {
|
|
469
507
|
"aliases": [],
|
|
470
508
|
"args": {},
|
|
@@ -535,44 +573,6 @@
|
|
|
535
573
|
"index.js"
|
|
536
574
|
]
|
|
537
575
|
},
|
|
538
|
-
"logout": {
|
|
539
|
-
"aliases": [],
|
|
540
|
-
"args": {},
|
|
541
|
-
"description": "Sign out by removing saved credentials from this machine",
|
|
542
|
-
"examples": [
|
|
543
|
-
"<%= config.bin %> logout"
|
|
544
|
-
],
|
|
545
|
-
"flags": {
|
|
546
|
-
"json": {
|
|
547
|
-
"description": "Output as JSON",
|
|
548
|
-
"name": "json",
|
|
549
|
-
"allowNo": false,
|
|
550
|
-
"type": "boolean"
|
|
551
|
-
},
|
|
552
|
-
"yes": {
|
|
553
|
-
"char": "y",
|
|
554
|
-
"description": "Skip confirmation prompts",
|
|
555
|
-
"name": "yes",
|
|
556
|
-
"allowNo": false,
|
|
557
|
-
"type": "boolean"
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
"hasDynamicHelp": false,
|
|
561
|
-
"hiddenAliases": [],
|
|
562
|
-
"id": "logout",
|
|
563
|
-
"pluginAlias": "@mailmodo/cli",
|
|
564
|
-
"pluginName": "@mailmodo/cli",
|
|
565
|
-
"pluginType": "core",
|
|
566
|
-
"strict": true,
|
|
567
|
-
"enableJsonFlag": false,
|
|
568
|
-
"isESM": true,
|
|
569
|
-
"relativePath": [
|
|
570
|
-
"dist",
|
|
571
|
-
"commands",
|
|
572
|
-
"logout",
|
|
573
|
-
"index.js"
|
|
574
|
-
]
|
|
575
|
-
},
|
|
576
576
|
"preview": {
|
|
577
577
|
"aliases": [],
|
|
578
578
|
"args": {
|
|
@@ -932,5 +932,5 @@
|
|
|
932
932
|
]
|
|
933
933
|
}
|
|
934
934
|
},
|
|
935
|
-
"version": "0.0.56-beta.pr58.
|
|
935
|
+
"version": "0.0.56-beta.pr58.106"
|
|
936
936
|
}
|
package/package.json
CHANGED