@cakemail-org/cakemail-cli 1.3.0 → 1.7.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/README.md +312 -12
- package/dist/cli.js +59 -8
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -7
- package/dist/client.js.map +1 -1
- package/dist/commands/account.d.ts +5 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +231 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/attributes.d.ts.map +1 -1
- package/dist/commands/attributes.js +43 -15
- package/dist/commands/attributes.js.map +1 -1
- package/dist/commands/campaigns.d.ts.map +1 -1
- package/dist/commands/campaigns.js +255 -26
- package/dist/commands/campaigns.js.map +1 -1
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +294 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/contacts.d.ts.map +1 -1
- package/dist/commands/contacts.js +321 -47
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/interests.d.ts +5 -0
- package/dist/commands/interests.d.ts.map +1 -0
- package/dist/commands/interests.js +172 -0
- package/dist/commands/interests.js.map +1 -0
- package/dist/commands/lists.d.ts.map +1 -1
- package/dist/commands/lists.js +165 -30
- package/dist/commands/lists.js.map +1 -1
- package/dist/commands/logs.d.ts +5 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +237 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/reports.d.ts.map +1 -1
- package/dist/commands/reports.js +90 -13
- package/dist/commands/reports.js.map +1 -1
- package/dist/commands/segments.d.ts.map +1 -1
- package/dist/commands/segments.js +59 -21
- package/dist/commands/segments.js.map +1 -1
- package/dist/commands/senders.d.ts.map +1 -1
- package/dist/commands/senders.js +46 -12
- package/dist/commands/senders.js.map +1 -1
- package/dist/commands/suppressed.d.ts.map +1 -1
- package/dist/commands/suppressed.js +20 -6
- package/dist/commands/suppressed.js.map +1 -1
- package/dist/commands/tags.d.ts +5 -0
- package/dist/commands/tags.d.ts.map +1 -0
- package/dist/commands/tags.js +124 -0
- package/dist/commands/tags.js.map +1 -0
- package/dist/commands/templates.d.ts.map +1 -1
- package/dist/commands/templates.js +11 -3
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/transactional-templates.d.ts +5 -0
- package/dist/commands/transactional-templates.d.ts.map +1 -0
- package/dist/commands/transactional-templates.js +354 -0
- package/dist/commands/transactional-templates.js.map +1 -0
- package/dist/types/profile.d.ts +92 -0
- package/dist/types/profile.d.ts.map +1 -0
- package/dist/types/profile.js +119 -0
- package/dist/types/profile.js.map +1 -0
- package/dist/utils/auth.d.ts +33 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +226 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/config-file.d.ts +99 -0
- package/dist/utils/config-file.d.ts.map +1 -0
- package/dist/utils/config-file.js +259 -0
- package/dist/utils/config-file.js.map +1 -0
- package/dist/utils/config.d.ts +13 -2
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +82 -8
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/confirm.d.ts +38 -0
- package/dist/utils/confirm.d.ts.map +1 -0
- package/dist/utils/confirm.js +124 -0
- package/dist/utils/confirm.js.map +1 -0
- package/dist/utils/defaults.d.ts +39 -0
- package/dist/utils/defaults.d.ts.map +1 -0
- package/dist/utils/defaults.js +195 -0
- package/dist/utils/defaults.js.map +1 -0
- package/dist/utils/errors.d.ts +67 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +395 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/interactive.d.ts +97 -0
- package/dist/utils/interactive.d.ts.map +1 -0
- package/dist/utils/interactive.js +265 -0
- package/dist/utils/interactive.js.map +1 -0
- package/dist/utils/list-defaults.d.ts +33 -0
- package/dist/utils/list-defaults.d.ts.map +1 -0
- package/dist/utils/list-defaults.js +52 -0
- package/dist/utils/list-defaults.js.map +1 -0
- package/dist/utils/output.d.ts +72 -2
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +407 -38
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/progress.d.ts +139 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +216 -0
- package/dist/utils/progress.js.map +1 -0
- package/package.json +19 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Ora } from 'ora';
|
|
2
|
+
/**
|
|
3
|
+
* Progress indicator utilities for long-running operations
|
|
4
|
+
*/
|
|
5
|
+
export interface ProgressConfig {
|
|
6
|
+
text: string;
|
|
7
|
+
prefixText?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PollingConfig {
|
|
10
|
+
checkInterval?: number;
|
|
11
|
+
maxAttempts?: number;
|
|
12
|
+
onCheck?: (attempt: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface BatchProgressConfig {
|
|
15
|
+
total: number;
|
|
16
|
+
current: number;
|
|
17
|
+
operation: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Simple spinner for basic operations (existing pattern)
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSpinner(text: string): Ora;
|
|
23
|
+
/**
|
|
24
|
+
* Progress indicator for async operations with polling
|
|
25
|
+
* Use for exports, imports, and other async tasks
|
|
26
|
+
*/
|
|
27
|
+
export declare class PollingProgress {
|
|
28
|
+
private spinner;
|
|
29
|
+
private startTime;
|
|
30
|
+
private attempts;
|
|
31
|
+
private config;
|
|
32
|
+
constructor(initialText: string, config?: PollingConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Update progress text during polling
|
|
35
|
+
*/
|
|
36
|
+
update(text: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Check if max attempts reached
|
|
39
|
+
*/
|
|
40
|
+
isTimeout(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get check interval
|
|
43
|
+
*/
|
|
44
|
+
getInterval(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Mark as successful
|
|
47
|
+
*/
|
|
48
|
+
succeed(text?: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Mark as failed
|
|
51
|
+
*/
|
|
52
|
+
fail(text?: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Stop without status
|
|
55
|
+
*/
|
|
56
|
+
stop(): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Progress indicator for batch operations
|
|
60
|
+
* Use for bulk tagging, multiple deletes, etc.
|
|
61
|
+
*/
|
|
62
|
+
export declare class BatchProgress {
|
|
63
|
+
private spinner;
|
|
64
|
+
private total;
|
|
65
|
+
private current;
|
|
66
|
+
private operation;
|
|
67
|
+
private startTime;
|
|
68
|
+
private failures;
|
|
69
|
+
constructor(config: BatchProgressConfig);
|
|
70
|
+
private formatText;
|
|
71
|
+
private createProgressBar;
|
|
72
|
+
/**
|
|
73
|
+
* Increment progress
|
|
74
|
+
*/
|
|
75
|
+
increment(count?: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Record a failure
|
|
78
|
+
*/
|
|
79
|
+
recordFailure(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Mark as complete
|
|
82
|
+
*/
|
|
83
|
+
complete(successMessage?: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Mark as failed
|
|
86
|
+
*/
|
|
87
|
+
fail(errorMessage?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Stop without status
|
|
90
|
+
*/
|
|
91
|
+
stop(): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Multi-step progress indicator
|
|
95
|
+
* Use for operations with distinct phases
|
|
96
|
+
*/
|
|
97
|
+
export declare class MultiStepProgress {
|
|
98
|
+
private spinner;
|
|
99
|
+
private steps;
|
|
100
|
+
private currentStep;
|
|
101
|
+
private startTime;
|
|
102
|
+
constructor(steps: string[]);
|
|
103
|
+
private formatText;
|
|
104
|
+
/**
|
|
105
|
+
* Move to next step
|
|
106
|
+
*/
|
|
107
|
+
nextStep(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Update current step text
|
|
110
|
+
*/
|
|
111
|
+
updateStepText(text: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Mark as complete
|
|
114
|
+
*/
|
|
115
|
+
complete(finalMessage?: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Mark as failed
|
|
118
|
+
*/
|
|
119
|
+
fail(errorMessage?: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Stop without status
|
|
122
|
+
*/
|
|
123
|
+
stop(): void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Helper to wait with a delay (for polling)
|
|
127
|
+
*/
|
|
128
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Poll an async operation until complete
|
|
131
|
+
* @param checkFn Function that returns status: { complete: boolean, status?: string, progress?: number }
|
|
132
|
+
* @param config Polling configuration
|
|
133
|
+
*/
|
|
134
|
+
export declare function pollUntilComplete<T>(checkFn: () => Promise<{
|
|
135
|
+
complete: boolean;
|
|
136
|
+
status?: string;
|
|
137
|
+
data?: T;
|
|
138
|
+
}>, initialText: string, config?: PollingConfig): Promise<T>;
|
|
139
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/utils/progress.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG/B;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,C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AG,IAAI;IAiBvC;;OAEG;IACH,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,IAAI,IAAI,IAAI;CAGb;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,SAAS,CAAS;gBAEd,KAAK,EAAE,MAAM,EAAE;IAM3B,OAAO,CAAC,UAAU;IAMlB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKlC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAKrC;;OAEG;IACH,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,IAAI,IAAI,IAAI;CAGb;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,OAAO,EAAE,MAAM,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,EACxE,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
/**
|
|
4
|
+
* Simple spinner for basic operations (existing pattern)
|
|
5
|
+
*/
|
|
6
|
+
export function createSpinner(text) {
|
|
7
|
+
return ora(text).start();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Progress indicator for async operations with polling
|
|
11
|
+
* Use for exports, imports, and other async tasks
|
|
12
|
+
*/
|
|
13
|
+
export class PollingProgress {
|
|
14
|
+
constructor(initialText, config = {}) {
|
|
15
|
+
this.attempts = 0;
|
|
16
|
+
this.config = {
|
|
17
|
+
checkInterval: config.checkInterval || 2000,
|
|
18
|
+
maxAttempts: config.maxAttempts || 30,
|
|
19
|
+
onCheck: config.onCheck || (() => { }),
|
|
20
|
+
};
|
|
21
|
+
this.spinner = ora(initialText).start();
|
|
22
|
+
this.startTime = Date.now();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Update progress text during polling
|
|
26
|
+
*/
|
|
27
|
+
update(text) {
|
|
28
|
+
this.attempts++;
|
|
29
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
30
|
+
this.spinner.text = `${text} ${chalk.gray(`(${elapsed}s, attempt ${this.attempts})`)}`;
|
|
31
|
+
this.config.onCheck(this.attempts);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if max attempts reached
|
|
35
|
+
*/
|
|
36
|
+
isTimeout() {
|
|
37
|
+
return this.attempts >= this.config.maxAttempts;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get check interval
|
|
41
|
+
*/
|
|
42
|
+
getInterval() {
|
|
43
|
+
return this.config.checkInterval;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mark as successful
|
|
47
|
+
*/
|
|
48
|
+
succeed(text) {
|
|
49
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
50
|
+
this.spinner.succeed(`${text || this.spinner.text} ${chalk.gray(`(${elapsed}s)`)}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mark as failed
|
|
54
|
+
*/
|
|
55
|
+
fail(text) {
|
|
56
|
+
this.spinner.fail(text || this.spinner.text);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Stop without status
|
|
60
|
+
*/
|
|
61
|
+
stop() {
|
|
62
|
+
this.spinner.stop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Progress indicator for batch operations
|
|
67
|
+
* Use for bulk tagging, multiple deletes, etc.
|
|
68
|
+
*/
|
|
69
|
+
export class BatchProgress {
|
|
70
|
+
constructor(config) {
|
|
71
|
+
this.current = 0;
|
|
72
|
+
this.failures = 0;
|
|
73
|
+
this.total = config.total;
|
|
74
|
+
this.current = config.current || 0;
|
|
75
|
+
this.operation = config.operation;
|
|
76
|
+
this.startTime = Date.now();
|
|
77
|
+
this.spinner = ora(this.formatText()).start();
|
|
78
|
+
}
|
|
79
|
+
formatText() {
|
|
80
|
+
const percentage = this.total > 0 ? Math.round((this.current / this.total) * 100) : 0;
|
|
81
|
+
const bar = this.createProgressBar(percentage);
|
|
82
|
+
return `${this.operation} ${bar} ${this.current}/${this.total} ${chalk.gray(`(${percentage}%)`)}`;
|
|
83
|
+
}
|
|
84
|
+
createProgressBar(percentage) {
|
|
85
|
+
const width = 20;
|
|
86
|
+
const filled = Math.round((percentage / 100) * width);
|
|
87
|
+
const empty = width - filled;
|
|
88
|
+
return chalk.cyan('█'.repeat(filled)) + chalk.gray('░'.repeat(empty));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Increment progress
|
|
92
|
+
*/
|
|
93
|
+
increment(count = 1) {
|
|
94
|
+
this.current = Math.min(this.current + count, this.total);
|
|
95
|
+
this.spinner.text = this.formatText();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Record a failure
|
|
99
|
+
*/
|
|
100
|
+
recordFailure() {
|
|
101
|
+
this.failures++;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Mark as complete
|
|
105
|
+
*/
|
|
106
|
+
complete(successMessage) {
|
|
107
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
108
|
+
const message = successMessage || this.operation;
|
|
109
|
+
if (this.failures > 0) {
|
|
110
|
+
this.spinner.warn(`${message} completed with ${this.failures} error${this.failures > 1 ? 's' : ''} ` +
|
|
111
|
+
chalk.gray(`(${elapsed}s)`));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.spinner.succeed(`${message} completed successfully ` +
|
|
115
|
+
chalk.gray(`(${this.total} items, ${elapsed}s)`));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Mark as failed
|
|
120
|
+
*/
|
|
121
|
+
fail(errorMessage) {
|
|
122
|
+
this.spinner.fail(errorMessage || `${this.operation} failed`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Stop without status
|
|
126
|
+
*/
|
|
127
|
+
stop() {
|
|
128
|
+
this.spinner.stop();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Multi-step progress indicator
|
|
133
|
+
* Use for operations with distinct phases
|
|
134
|
+
*/
|
|
135
|
+
export class MultiStepProgress {
|
|
136
|
+
constructor(steps) {
|
|
137
|
+
this.currentStep = 0;
|
|
138
|
+
this.steps = steps;
|
|
139
|
+
this.startTime = Date.now();
|
|
140
|
+
this.spinner = ora(this.formatText()).start();
|
|
141
|
+
}
|
|
142
|
+
formatText() {
|
|
143
|
+
const step = this.steps[this.currentStep];
|
|
144
|
+
const progress = `${this.currentStep + 1}/${this.steps.length}`;
|
|
145
|
+
return `${step} ${chalk.gray(`[${progress}]`)}`;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Move to next step
|
|
149
|
+
*/
|
|
150
|
+
nextStep() {
|
|
151
|
+
if (this.currentStep < this.steps.length - 1) {
|
|
152
|
+
this.currentStep++;
|
|
153
|
+
this.spinner.text = this.formatText();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Update current step text
|
|
158
|
+
*/
|
|
159
|
+
updateStepText(text) {
|
|
160
|
+
this.steps[this.currentStep] = text;
|
|
161
|
+
this.spinner.text = this.formatText();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Mark as complete
|
|
165
|
+
*/
|
|
166
|
+
complete(finalMessage) {
|
|
167
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
168
|
+
this.spinner.succeed(`${finalMessage || 'All steps completed'} ${chalk.gray(`(${elapsed}s)`)}`);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Mark as failed
|
|
172
|
+
*/
|
|
173
|
+
fail(errorMessage) {
|
|
174
|
+
this.spinner.fail(errorMessage || `Failed at step ${this.currentStep + 1}`);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Stop without status
|
|
178
|
+
*/
|
|
179
|
+
stop() {
|
|
180
|
+
this.spinner.stop();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Helper to wait with a delay (for polling)
|
|
185
|
+
*/
|
|
186
|
+
export function sleep(ms) {
|
|
187
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Poll an async operation until complete
|
|
191
|
+
* @param checkFn Function that returns status: { complete: boolean, status?: string, progress?: number }
|
|
192
|
+
* @param config Polling configuration
|
|
193
|
+
*/
|
|
194
|
+
export async function pollUntilComplete(checkFn, initialText, config = {}) {
|
|
195
|
+
const progress = new PollingProgress(initialText, config);
|
|
196
|
+
while (true) {
|
|
197
|
+
await sleep(progress.getInterval());
|
|
198
|
+
try {
|
|
199
|
+
const result = await checkFn();
|
|
200
|
+
if (result.complete) {
|
|
201
|
+
progress.succeed(result.status || 'Operation completed');
|
|
202
|
+
return result.data;
|
|
203
|
+
}
|
|
204
|
+
if (progress.isTimeout()) {
|
|
205
|
+
progress.fail('Operation timed out');
|
|
206
|
+
throw new Error('Operation timed out');
|
|
207
|
+
}
|
|
208
|
+
progress.update(result.status || initialText);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
progress.fail('Operation failed');
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/utils/progress.ts"],"names":[],"mappings":"AAAA,OAAO,GAAY,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAuB1B;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,eAAe;IAM1B,YAAY,WAAmB,EAAE,SAAwB,EAAE;QAHnD,aAAQ,GAAW,CAAC,CAAC;QAI3B,IAAI,CAAC,MAAM,GAAG;YACZ,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;YAC3C,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;SACtC,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,cAAc,IAAI,CAAC,QAAQ,GAAG,CAAC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1
1
|
{
|
|
2
2
|
"name": "@cakemail-org/cakemail-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Official Cakemail CLI - Command-line interface for the Cakemail API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
"clean": "rm -rf dist",
|
|
20
20
|
"rebuild": "npm run clean && npm run build",
|
|
21
21
|
"generate:types": "openapi-typescript https://api.cakemail.com/openapi.json -o src/types/api.ts",
|
|
22
|
-
"test": "
|
|
22
|
+
"test": "npm run build && vitest run",
|
|
23
|
+
"test:watch": "vitest watch",
|
|
24
|
+
"test:coverage": "npm run build && vitest run --coverage",
|
|
25
|
+
"test:pty": "npm run build && vitest run tests/pty",
|
|
26
|
+
"test:integration": "npm run build && vitest run tests/integration",
|
|
27
|
+
"test:ci": "npm run build && vitest run --coverage --reporter=junit"
|
|
23
28
|
},
|
|
24
29
|
"keywords": [
|
|
25
30
|
"cakemail",
|
|
@@ -44,12 +49,23 @@
|
|
|
44
49
|
"cli-table3": "^0.6.3",
|
|
45
50
|
"commander": "^12.0.0",
|
|
46
51
|
"dotenv": "^16.4.0",
|
|
52
|
+
"inquirer": "^9.3.8",
|
|
47
53
|
"ora": "^8.0.1"
|
|
48
54
|
},
|
|
49
55
|
"devDependencies": {
|
|
56
|
+
"@types/express": "^4.17.21",
|
|
57
|
+
"@types/inquirer": "^9.0.9",
|
|
50
58
|
"@types/node": "^20.11.0",
|
|
59
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
60
|
+
"execa": "^8.0.1",
|
|
61
|
+
"express": "^4.18.2",
|
|
51
62
|
"openapi-typescript": "^7.8.0",
|
|
52
|
-
"
|
|
63
|
+
"strip-ansi": "^7.1.2",
|
|
64
|
+
"typescript": "^5.8.0",
|
|
65
|
+
"vitest": "^1.6.1"
|
|
66
|
+
},
|
|
67
|
+
"optionalDependencies": {
|
|
68
|
+
"node-pty": "^1.0.0"
|
|
53
69
|
},
|
|
54
70
|
"engines": {
|
|
55
71
|
"node": ">=18.0.0"
|