@mainwp/control 1.0.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/LICENSE +674 -0
- package/README.md +583 -0
- package/bin/_exit.js +12 -0
- package/bin/dev.js +7 -0
- package/bin/run.js +7 -0
- package/dist/chat/chat-engine.d.ts +213 -0
- package/dist/chat/chat-engine.d.ts.map +1 -0
- package/dist/chat/chat-engine.js +636 -0
- package/dist/chat/chat-engine.js.map +1 -0
- package/dist/chat/index.d.ts +10 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +14 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/providers/anthropic.d.ts +52 -0
- package/dist/chat/providers/anthropic.d.ts.map +1 -0
- package/dist/chat/providers/anthropic.js +292 -0
- package/dist/chat/providers/anthropic.js.map +1 -0
- package/dist/chat/providers/gemini.d.ts +52 -0
- package/dist/chat/providers/gemini.d.ts.map +1 -0
- package/dist/chat/providers/gemini.js +284 -0
- package/dist/chat/providers/gemini.js.map +1 -0
- package/dist/chat/providers/index.d.ts +19 -0
- package/dist/chat/providers/index.d.ts.map +1 -0
- package/dist/chat/providers/index.js +23 -0
- package/dist/chat/providers/index.js.map +1 -0
- package/dist/chat/providers/local.d.ts +37 -0
- package/dist/chat/providers/local.d.ts.map +1 -0
- package/dist/chat/providers/local.js +130 -0
- package/dist/chat/providers/local.js.map +1 -0
- package/dist/chat/providers/openai-compatible.d.ts +155 -0
- package/dist/chat/providers/openai-compatible.d.ts.map +1 -0
- package/dist/chat/providers/openai-compatible.js +264 -0
- package/dist/chat/providers/openai-compatible.js.map +1 -0
- package/dist/chat/providers/openai.d.ts +24 -0
- package/dist/chat/providers/openai.d.ts.map +1 -0
- package/dist/chat/providers/openai.js +62 -0
- package/dist/chat/providers/openai.js.map +1 -0
- package/dist/chat/providers/openrouter.d.ts +26 -0
- package/dist/chat/providers/openrouter.d.ts.map +1 -0
- package/dist/chat/providers/openrouter.js +65 -0
- package/dist/chat/providers/openrouter.js.map +1 -0
- package/dist/chat/providers/provider-fetch.d.ts +15 -0
- package/dist/chat/providers/provider-fetch.d.ts.map +1 -0
- package/dist/chat/providers/provider-fetch.js +35 -0
- package/dist/chat/providers/provider-fetch.js.map +1 -0
- package/dist/chat/providers/provider.d.ts +214 -0
- package/dist/chat/providers/provider.d.ts.map +1 -0
- package/dist/chat/providers/provider.js +166 -0
- package/dist/chat/providers/provider.js.map +1 -0
- package/dist/chat/providers/sse-reader.d.ts +21 -0
- package/dist/chat/providers/sse-reader.d.ts.map +1 -0
- package/dist/chat/providers/sse-reader.js +48 -0
- package/dist/chat/providers/sse-reader.js.map +1 -0
- package/dist/chat/system-prompt.d.ts +33 -0
- package/dist/chat/system-prompt.d.ts.map +1 -0
- package/dist/chat/system-prompt.js +166 -0
- package/dist/chat/system-prompt.js.map +1 -0
- package/dist/chat/tool-envelope.d.ts +72 -0
- package/dist/chat/tool-envelope.d.ts.map +1 -0
- package/dist/chat/tool-envelope.js +263 -0
- package/dist/chat/tool-envelope.js.map +1 -0
- package/dist/commands/abilities/info.d.ts +21 -0
- package/dist/commands/abilities/info.d.ts.map +1 -0
- package/dist/commands/abilities/info.js +80 -0
- package/dist/commands/abilities/info.js.map +1 -0
- package/dist/commands/abilities/list.d.ts +19 -0
- package/dist/commands/abilities/list.d.ts.map +1 -0
- package/dist/commands/abilities/list.js +98 -0
- package/dist/commands/abilities/list.js.map +1 -0
- package/dist/commands/abilities/run.d.ts +75 -0
- package/dist/commands/abilities/run.d.ts.map +1 -0
- package/dist/commands/abilities/run.js +468 -0
- package/dist/commands/abilities/run.js.map +1 -0
- package/dist/commands/chat.d.ts +54 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +384 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/config/show.d.ts +54 -0
- package/dist/commands/config/show.d.ts.map +1 -0
- package/dist/commands/config/show.js +324 -0
- package/dist/commands/config/show.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +412 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/jobs/watch.d.ts +50 -0
- package/dist/commands/jobs/watch.d.ts.map +1 -0
- package/dist/commands/jobs/watch.js +269 -0
- package/dist/commands/jobs/watch.js.map +1 -0
- package/dist/commands/login.d.ts +25 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +165 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/profile/delete.d.ts +22 -0
- package/dist/commands/profile/delete.d.ts.map +1 -0
- package/dist/commands/profile/delete.js +57 -0
- package/dist/commands/profile/delete.js.map +1 -0
- package/dist/commands/profile/list.d.ts +19 -0
- package/dist/commands/profile/list.d.ts.map +1 -0
- package/dist/commands/profile/list.js +53 -0
- package/dist/commands/profile/list.js.map +1 -0
- package/dist/commands/profile/use.d.ts +22 -0
- package/dist/commands/profile/use.d.ts.map +1 -0
- package/dist/commands/profile/use.js +46 -0
- package/dist/commands/profile/use.js.map +1 -0
- package/dist/config/fs-utils.d.ts +14 -0
- package/dist/config/fs-utils.d.ts.map +1 -0
- package/dist/config/fs-utils.js +31 -0
- package/dist/config/fs-utils.js.map +1 -0
- package/dist/config/keychain.d.ts +53 -0
- package/dist/config/keychain.d.ts.map +1 -0
- package/dist/config/keychain.js +175 -0
- package/dist/config/keychain.js.map +1 -0
- package/dist/config/profile-store.d.ts +85 -0
- package/dist/config/profile-store.d.ts.map +1 -0
- package/dist/config/profile-store.js +228 -0
- package/dist/config/profile-store.js.map +1 -0
- package/dist/config/settings.d.ts +71 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +151 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/abilities-executor.d.ts +126 -0
- package/dist/core/abilities-executor.d.ts.map +1 -0
- package/dist/core/abilities-executor.js +264 -0
- package/dist/core/abilities-executor.js.map +1 -0
- package/dist/core/batch-manager.d.ts +113 -0
- package/dist/core/batch-manager.d.ts.map +1 -0
- package/dist/core/batch-manager.js +244 -0
- package/dist/core/batch-manager.js.map +1 -0
- package/dist/core/http-client.d.ts +111 -0
- package/dist/core/http-client.d.ts.map +1 -0
- package/dist/core/http-client.js +329 -0
- package/dist/core/http-client.js.map +1 -0
- package/dist/core/safety-controller.d.ts +114 -0
- package/dist/core/safety-controller.d.ts.map +1 -0
- package/dist/core/safety-controller.js +229 -0
- package/dist/core/safety-controller.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +12 -0
- package/dist/hooks/command-not-found.d.ts.map +1 -0
- package/dist/hooks/command-not-found.js +58 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/base-command.d.ts +123 -0
- package/dist/lib/base-command.d.ts.map +1 -0
- package/dist/lib/base-command.js +285 -0
- package/dist/lib/base-command.js.map +1 -0
- package/dist/output/formatter.d.ts +48 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +138 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/json-envelope.d.ts +43 -0
- package/dist/output/json-envelope.d.ts.map +1 -0
- package/dist/output/json-envelope.js +73 -0
- package/dist/output/json-envelope.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +97 -0
- package/dist/utils/audit-logger.d.ts.map +1 -0
- package/dist/utils/audit-logger.js +169 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/colors.d.ts +29 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +36 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/errors.d.ts +107 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +149 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exit-codes.d.ts +21 -0
- package/dist/utils/exit-codes.d.ts.map +1 -0
- package/dist/utils/exit-codes.js +20 -0
- package/dist/utils/exit-codes.js.map +1 -0
- package/dist/utils/format.d.ts +64 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +69 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/prompt.d.ts +34 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +132 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/retry.d.ts +59 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +96 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/terminal-sanitizer.d.ts +60 -0
- package/dist/utils/terminal-sanitizer.d.ts.map +1 -0
- package/dist/utils/terminal-sanitizer.js +166 -0
- package/dist/utils/terminal-sanitizer.js.map +1 -0
- package/dist/validation/input-sanitizer.d.ts +76 -0
- package/dist/validation/input-sanitizer.d.ts.map +1 -0
- package/dist/validation/input-sanitizer.js +199 -0
- package/dist/validation/input-sanitizer.js.map +1 -0
- package/dist/validation/schema-validator.d.ts +75 -0
- package/dist/validation/schema-validator.d.ts.map +1 -0
- package/dist/validation/schema-validator.js +147 -0
- package/dist/validation/schema-validator.js.map +1 -0
- package/oclif.manifest.json +857 -0
- package/package.json +101 -0
- package/scripts/completions/README.md +221 -0
- package/scripts/completions/mainwpcontrol.bash +193 -0
- package/scripts/completions/mainwpcontrol.zsh +267 -0
- package/scripts/completions/profile-completer.sh +35 -0
- package/scripts/completions/regenerate.sh +78 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jobs watch command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Monitor batch job status with exponential backoff polling.
|
|
5
|
+
* Streams progress updates until job completes or times out.
|
|
6
|
+
*/
|
|
7
|
+
import { Args, Flags } from '@oclif/core';
|
|
8
|
+
import { BaseCommand, commonFlags } from '../../lib/base-command.js';
|
|
9
|
+
import { formatSuccess, formatWarning, formatError as formatErrorText, formatHeading, formatKeyValue, formatProgressBar, formatElapsed, } from '../../output/formatter.js';
|
|
10
|
+
import { safeString } from '../../utils/terminal-sanitizer.js';
|
|
11
|
+
/** Progress bar width in characters */
|
|
12
|
+
const PROGRESS_BAR_WIDTH = 30;
|
|
13
|
+
/** Terminal line width for padding */
|
|
14
|
+
const TERMINAL_LINE_WIDTH = 80;
|
|
15
|
+
/** Maximum number of result items to preview */
|
|
16
|
+
const RESULTS_PREVIEW_LIMIT = 5;
|
|
17
|
+
export default class JobsWatch extends BaseCommand {
|
|
18
|
+
static description = 'Monitor batch job status';
|
|
19
|
+
static examples = [
|
|
20
|
+
// Basic watch
|
|
21
|
+
'<%= config.bin %> jobs watch sync_abc123',
|
|
22
|
+
// With timeout
|
|
23
|
+
'<%= config.bin %> jobs watch sync_abc123 --timeout 120',
|
|
24
|
+
// JSON output for scripting
|
|
25
|
+
'<%= config.bin %> jobs watch sync_abc123 --json',
|
|
26
|
+
// With custom poll interval
|
|
27
|
+
'<%= config.bin %> jobs watch sync_abc123 --initial-delay 2000 --max-delay 60000',
|
|
28
|
+
];
|
|
29
|
+
static flags = {
|
|
30
|
+
...commonFlags,
|
|
31
|
+
timeout: Flags.integer({
|
|
32
|
+
char: 't',
|
|
33
|
+
description: 'Maximum wait time in seconds (default: 300)',
|
|
34
|
+
default: 300,
|
|
35
|
+
}),
|
|
36
|
+
'initial-delay': Flags.integer({
|
|
37
|
+
description: 'Initial poll delay in milliseconds',
|
|
38
|
+
default: 1000,
|
|
39
|
+
}),
|
|
40
|
+
'max-delay': Flags.integer({
|
|
41
|
+
description: 'Maximum poll delay in milliseconds',
|
|
42
|
+
default: 30000,
|
|
43
|
+
}),
|
|
44
|
+
'no-progress': Flags.boolean({
|
|
45
|
+
description: 'Disable progress output (only show final result)',
|
|
46
|
+
default: false,
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
static args = {
|
|
50
|
+
id: Args.string({
|
|
51
|
+
description: 'Batch job ID',
|
|
52
|
+
required: true,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
async run() {
|
|
56
|
+
const { args, flags } = await this.parse(JobsWatch);
|
|
57
|
+
await this.initCommon(flags);
|
|
58
|
+
this.debugLog('Watching batch job', {
|
|
59
|
+
jobId: args.id,
|
|
60
|
+
timeoutSeconds: flags.timeout,
|
|
61
|
+
initialDelayMs: flags['initial-delay'],
|
|
62
|
+
maxDelayMs: flags['max-delay'],
|
|
63
|
+
});
|
|
64
|
+
// Initialize batch manager
|
|
65
|
+
const manager = await this.getBatchManager();
|
|
66
|
+
// Set up abort controller for graceful shutdown
|
|
67
|
+
const controller = new AbortController();
|
|
68
|
+
const handleSignal = () => {
|
|
69
|
+
controller.abort();
|
|
70
|
+
if (!flags.json && !flags['no-progress']) {
|
|
71
|
+
this.log('\nAborted by user.');
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
process.on('SIGINT', handleSignal);
|
|
75
|
+
process.on('SIGTERM', handleSignal);
|
|
76
|
+
try {
|
|
77
|
+
// Watch the job
|
|
78
|
+
const result = await this.watchJob(manager, args.id, {
|
|
79
|
+
maxWait: flags.timeout * 1000,
|
|
80
|
+
initialDelay: flags['initial-delay'],
|
|
81
|
+
maxDelay: flags['max-delay'],
|
|
82
|
+
showProgress: !flags['no-progress'] && !flags.json,
|
|
83
|
+
signal: controller.signal,
|
|
84
|
+
});
|
|
85
|
+
// Output final result
|
|
86
|
+
this.outputResult(args.id, result);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
process.off('SIGINT', handleSignal);
|
|
90
|
+
process.off('SIGTERM', handleSignal);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Watch job with progress updates
|
|
95
|
+
*/
|
|
96
|
+
async watchJob(manager, jobId, options) {
|
|
97
|
+
if (options.showProgress) {
|
|
98
|
+
this.log(formatHeading(`Watching job: ${jobId}`));
|
|
99
|
+
this.log('');
|
|
100
|
+
}
|
|
101
|
+
const generator = manager.watchJob(jobId, {
|
|
102
|
+
maxWait: options.maxWait,
|
|
103
|
+
initialDelay: options.initialDelay,
|
|
104
|
+
maxDelay: options.maxDelay,
|
|
105
|
+
signal: options.signal,
|
|
106
|
+
});
|
|
107
|
+
let lastStatus;
|
|
108
|
+
// Process status updates
|
|
109
|
+
while (true) {
|
|
110
|
+
const result = await generator.next();
|
|
111
|
+
if (result.done) {
|
|
112
|
+
return result.value;
|
|
113
|
+
}
|
|
114
|
+
lastStatus = result.value;
|
|
115
|
+
if (options.showProgress) {
|
|
116
|
+
this.displayProgress(lastStatus);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Display progress update
|
|
122
|
+
*/
|
|
123
|
+
displayProgress(status) {
|
|
124
|
+
// Clear previous line(s) and write new status
|
|
125
|
+
// Use simple output that works in all terminals
|
|
126
|
+
const progress = status.progress ?? this.calculateProgress(status);
|
|
127
|
+
const progressBar = formatProgressBar(progress, PROGRESS_BAR_WIDTH);
|
|
128
|
+
const parts = [
|
|
129
|
+
`Status: ${this.formatStatusText(status.status)}`,
|
|
130
|
+
progressBar,
|
|
131
|
+
];
|
|
132
|
+
if (status.processed !== undefined && status.total !== undefined) {
|
|
133
|
+
parts.push(`(${status.processed}/${status.total})`);
|
|
134
|
+
}
|
|
135
|
+
if (status.errors && status.errors.length > 0) {
|
|
136
|
+
parts.push(formatWarning(`${status.errors.length} errors`));
|
|
137
|
+
}
|
|
138
|
+
// Write progress (overwrite line on TTY, newline otherwise)
|
|
139
|
+
if (process.stdout.isTTY) {
|
|
140
|
+
process.stdout.write(`\r${parts.join(' ')}`.padEnd(TERMINAL_LINE_WIDTH));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.log(parts.join(' '));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Calculate progress percentage from processed/total
|
|
148
|
+
*/
|
|
149
|
+
calculateProgress(status) {
|
|
150
|
+
if (status.processed !== undefined && status.total !== undefined && status.total > 0) {
|
|
151
|
+
return Math.round((status.processed / status.total) * 100);
|
|
152
|
+
}
|
|
153
|
+
// Estimate based on status
|
|
154
|
+
switch (status.status) {
|
|
155
|
+
case 'pending':
|
|
156
|
+
return 0;
|
|
157
|
+
case 'running':
|
|
158
|
+
return 50;
|
|
159
|
+
case 'completed':
|
|
160
|
+
return 100;
|
|
161
|
+
case 'failed':
|
|
162
|
+
case 'partial':
|
|
163
|
+
return status.progress ?? 0;
|
|
164
|
+
default:
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Format status text with color
|
|
170
|
+
*/
|
|
171
|
+
formatStatusText(status) {
|
|
172
|
+
switch (status) {
|
|
173
|
+
case 'completed':
|
|
174
|
+
return formatSuccess(status);
|
|
175
|
+
case 'failed':
|
|
176
|
+
return formatErrorText(status);
|
|
177
|
+
case 'partial':
|
|
178
|
+
return formatWarning(status);
|
|
179
|
+
case 'running':
|
|
180
|
+
return `${status}...`;
|
|
181
|
+
default:
|
|
182
|
+
return status;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Output final result
|
|
187
|
+
*/
|
|
188
|
+
outputResult(jobId, result) {
|
|
189
|
+
// Clear progress line on TTY
|
|
190
|
+
if (process.stdout.isTTY && !this.jsonOutput) {
|
|
191
|
+
process.stdout.write('\r'.padEnd(TERMINAL_LINE_WIDTH) + '\r');
|
|
192
|
+
}
|
|
193
|
+
const data = {
|
|
194
|
+
job_id: jobId,
|
|
195
|
+
...result.status,
|
|
196
|
+
timedOut: result.timedOut,
|
|
197
|
+
elapsed_ms: result.elapsed,
|
|
198
|
+
};
|
|
199
|
+
this.output(data, () => this.formatHumanOutput(jobId, result));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Format human-readable output
|
|
203
|
+
*/
|
|
204
|
+
formatHumanOutput(jobId, result) {
|
|
205
|
+
const lines = [];
|
|
206
|
+
const { status, timedOut, elapsed } = result;
|
|
207
|
+
// Header
|
|
208
|
+
if (timedOut) {
|
|
209
|
+
lines.push(formatWarning(`Job ${jobId} timed out after ${formatElapsed(elapsed)}`));
|
|
210
|
+
}
|
|
211
|
+
else if (status.status === 'completed') {
|
|
212
|
+
lines.push(formatSuccess(`Job ${jobId} completed`));
|
|
213
|
+
}
|
|
214
|
+
else if (status.status === 'failed') {
|
|
215
|
+
lines.push(formatErrorText(`Job ${jobId} failed`));
|
|
216
|
+
}
|
|
217
|
+
else if (status.status === 'partial') {
|
|
218
|
+
lines.push(formatWarning(`Job ${jobId} partially completed`));
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
lines.push(`Job ${jobId}: ${status.status}`);
|
|
222
|
+
}
|
|
223
|
+
lines.push('');
|
|
224
|
+
// Status details
|
|
225
|
+
lines.push(formatKeyValue('Status', status.status));
|
|
226
|
+
if (status.progress !== undefined) {
|
|
227
|
+
lines.push(formatKeyValue('Progress', `${status.progress}%`));
|
|
228
|
+
}
|
|
229
|
+
if (status.processed !== undefined && status.total !== undefined) {
|
|
230
|
+
lines.push(formatKeyValue('Processed', `${status.processed}/${status.total}`));
|
|
231
|
+
}
|
|
232
|
+
lines.push(formatKeyValue('Elapsed', formatElapsed(elapsed)));
|
|
233
|
+
// Results summary
|
|
234
|
+
if (status.results && status.results.length > 0) {
|
|
235
|
+
lines.push('');
|
|
236
|
+
lines.push(formatHeading('Results:'));
|
|
237
|
+
lines.push(` ${status.results.length} items processed`);
|
|
238
|
+
// Show first few results
|
|
239
|
+
const preview = status.results.slice(0, RESULTS_PREVIEW_LIMIT);
|
|
240
|
+
for (const item of preview) {
|
|
241
|
+
if (typeof item === 'object' && item !== null) {
|
|
242
|
+
const obj = item;
|
|
243
|
+
const label = safeString(obj['name'] ?? obj['url'] ?? obj['id'] ?? JSON.stringify(obj));
|
|
244
|
+
lines.push(` - ${label}`);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
lines.push(` - ${safeString(item)}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (status.results.length > RESULTS_PREVIEW_LIMIT) {
|
|
251
|
+
lines.push(` ... and ${status.results.length - RESULTS_PREVIEW_LIMIT} more`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// Errors
|
|
255
|
+
if (status.errors && status.errors.length > 0) {
|
|
256
|
+
lines.push('');
|
|
257
|
+
lines.push(formatHeading('Errors:'));
|
|
258
|
+
for (const error of status.errors) {
|
|
259
|
+
const prefix = error.code ? `[${safeString(error.code)}] ` : '';
|
|
260
|
+
lines.push(formatWarning(` ${prefix}${safeString(error.message)}`));
|
|
261
|
+
if (error.item) {
|
|
262
|
+
lines.push(` Item: ${safeString(JSON.stringify(error.item))}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return lines.join('\n');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../../src/commands/jobs/watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,IAAI,eAAe,EAC9B,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAO/D,uCAAuC;AACvC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,sCAAsC;AACtC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,gDAAgD;AAChD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,OA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M,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;YAErC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;gBACrE,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;oBACf,KAAK,CAAC,IAAI,CAAC,aAAa,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Login command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Authenticates with a MainWP Dashboard and stores credentials.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseCommand } from '../lib/base-command.js';
|
|
7
|
+
export default class Login extends BaseCommand {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'skip-ssl-verify': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
static args: {};
|
|
22
|
+
protected needsProfile(): boolean;
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAe,MAAM,wBAAwB,CAAC;AAQlE,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW;IAC5C,MAAM,CAAC,WAAW,SAA0C;IAE5D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;MAmBV;IAEF,MAAM,CAAC,IAAI,KAAM;IAGjB,SAAS,CAAC,YAAY,IAAI,OAAO;IAI3B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuK3B"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Login command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Authenticates with a MainWP Dashboard and stores credentials.
|
|
5
|
+
*/
|
|
6
|
+
import { Flags } from '@oclif/core';
|
|
7
|
+
import { BaseCommand, commonFlags } from '../lib/base-command.js';
|
|
8
|
+
import { getProfileStore } from '../config/profile-store.js';
|
|
9
|
+
import { getKeychain } from '../config/keychain.js';
|
|
10
|
+
import { createHttpClient } from '../core/http-client.js';
|
|
11
|
+
import { formatSuccess, formatWarning, formatInfo } from '../output/formatter.js';
|
|
12
|
+
import { AuthError, InputError } from '../utils/errors.js';
|
|
13
|
+
import { promptForInput, promptForPassword, isInteractive } from '../utils/prompt.js';
|
|
14
|
+
export default class Login extends BaseCommand {
|
|
15
|
+
static description = 'Authenticate with a MainWP Dashboard';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --url https://dashboard.example.com',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --name production',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
...commonFlags,
|
|
23
|
+
url: Flags.string({
|
|
24
|
+
char: 'u',
|
|
25
|
+
description: 'Dashboard URL',
|
|
26
|
+
}),
|
|
27
|
+
username: Flags.string({
|
|
28
|
+
description: 'WordPress admin username',
|
|
29
|
+
}),
|
|
30
|
+
password: Flags.string({
|
|
31
|
+
description: 'Application password (will prompt if not provided)',
|
|
32
|
+
}),
|
|
33
|
+
name: Flags.string({
|
|
34
|
+
char: 'n',
|
|
35
|
+
description: 'Profile name (defaults to hostname)',
|
|
36
|
+
}),
|
|
37
|
+
'skip-ssl-verify': Flags.boolean({
|
|
38
|
+
description: 'Skip SSL certificate verification',
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
static args = {};
|
|
42
|
+
// Login doesn't need a profile loaded
|
|
43
|
+
needsProfile() {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
async run() {
|
|
47
|
+
const { flags } = await this.parse(Login);
|
|
48
|
+
await this.initCommon(flags);
|
|
49
|
+
// Collect credentials
|
|
50
|
+
const interactive = isInteractive();
|
|
51
|
+
const url = flags.url ?? (await promptForInput('Dashboard URL'));
|
|
52
|
+
if (!url) {
|
|
53
|
+
throw new InputError('Dashboard URL is required', undefined, interactive ? undefined : 'Pass --url when running without a terminal');
|
|
54
|
+
}
|
|
55
|
+
const username = flags.username ?? (await promptForInput('WordPress username'));
|
|
56
|
+
if (!username) {
|
|
57
|
+
throw new InputError('WordPress username is required', undefined, interactive ? undefined : 'Pass --username when running without a terminal');
|
|
58
|
+
}
|
|
59
|
+
if (flags.password) {
|
|
60
|
+
this.logToStderr(formatWarning('Passing application passwords via --password exposes them in the process list. Prefer MAINWP_APP_PASSWORD.'));
|
|
61
|
+
}
|
|
62
|
+
const envPassword = process.env['MAINWP_APP_PASSWORD'];
|
|
63
|
+
const password = flags.password ?? envPassword ?? (await promptForPassword('Application password'));
|
|
64
|
+
if (!password) {
|
|
65
|
+
throw new InputError('Application password is required', undefined, interactive
|
|
66
|
+
? undefined
|
|
67
|
+
: 'Pass --password or set MAINWP_APP_PASSWORD when running without a terminal');
|
|
68
|
+
}
|
|
69
|
+
// Normalize URL
|
|
70
|
+
let normalizedUrl = url.trim();
|
|
71
|
+
if (!normalizedUrl.startsWith('http://') && !normalizedUrl.startsWith('https://')) {
|
|
72
|
+
normalizedUrl = `https://${normalizedUrl}`;
|
|
73
|
+
}
|
|
74
|
+
normalizedUrl = normalizedUrl.replace(/\/+$/, '');
|
|
75
|
+
// Generate profile name from URL if not provided
|
|
76
|
+
const profileName = flags.name ?? new URL(normalizedUrl).hostname;
|
|
77
|
+
// Test connection
|
|
78
|
+
if (!this.jsonOutput) {
|
|
79
|
+
this.log('Testing connection...');
|
|
80
|
+
}
|
|
81
|
+
const skipSSLVerification = flags['skip-ssl-verify'] ?? this.settings.skipSSLVerification;
|
|
82
|
+
this.debugLog('Testing login connection', {
|
|
83
|
+
dashboardUrl: normalizedUrl,
|
|
84
|
+
username,
|
|
85
|
+
timeoutMs: this.settings.timeout,
|
|
86
|
+
allowInsecureHttp: this.settings.allowInsecureHttp,
|
|
87
|
+
skipSSLVerification,
|
|
88
|
+
passwordSource: flags.password ? 'flag' : envPassword ? 'environment' : 'prompt',
|
|
89
|
+
});
|
|
90
|
+
try {
|
|
91
|
+
const client = createHttpClient({
|
|
92
|
+
baseUrl: normalizedUrl,
|
|
93
|
+
username,
|
|
94
|
+
appPassword: password,
|
|
95
|
+
skipSSLVerification,
|
|
96
|
+
allowInsecureHttp: this.settings.allowInsecureHttp,
|
|
97
|
+
timeout: this.settings.timeout,
|
|
98
|
+
});
|
|
99
|
+
// Try to fetch abilities to verify connection
|
|
100
|
+
const response = await client.get('/wp-json/wp-abilities/v1/abilities');
|
|
101
|
+
if (response.status !== 200) {
|
|
102
|
+
throw new AuthError('Failed to connect to Dashboard', undefined, 'Verify the Dashboard URL and network connectivity');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof AuthError) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
// Preserve hint from underlying error if available
|
|
110
|
+
const originalError = error;
|
|
111
|
+
throw new AuthError(`Connection failed: ${originalError.message}`, undefined, originalError.hint ?? 'Verify the Dashboard URL and network connectivity');
|
|
112
|
+
}
|
|
113
|
+
// Store profile
|
|
114
|
+
const profile = {
|
|
115
|
+
name: profileName,
|
|
116
|
+
dashboardUrl: normalizedUrl,
|
|
117
|
+
username,
|
|
118
|
+
createdAt: new Date().toISOString(),
|
|
119
|
+
...(flags['skip-ssl-verify'] ? { skipSSLVerification: true } : {}),
|
|
120
|
+
};
|
|
121
|
+
const profileStore = getProfileStore();
|
|
122
|
+
await profileStore.save(profile);
|
|
123
|
+
// Store password in keychain
|
|
124
|
+
const keychain = getKeychain();
|
|
125
|
+
const keychainResult = await keychain.set(profileName, password);
|
|
126
|
+
// Set as active
|
|
127
|
+
await profileStore.setActive(profileName);
|
|
128
|
+
// Output result
|
|
129
|
+
this.output({
|
|
130
|
+
profile: profileName,
|
|
131
|
+
url: normalizedUrl,
|
|
132
|
+
username,
|
|
133
|
+
credentialStorage: keychainResult.location,
|
|
134
|
+
}, () => {
|
|
135
|
+
const lines = [
|
|
136
|
+
formatSuccess(`Logged in as ${username}`),
|
|
137
|
+
` Profile: ${profileName}`,
|
|
138
|
+
` Dashboard: ${normalizedUrl}`,
|
|
139
|
+
];
|
|
140
|
+
if (keychainResult.stored) {
|
|
141
|
+
lines.push(` Credentials: Stored in system keychain`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
lines.push('');
|
|
145
|
+
lines.push(formatWarning('Credentials NOT saved to keychain.'));
|
|
146
|
+
if (keychainResult.error) {
|
|
147
|
+
lines.push(` Reason: ${keychainResult.error}`);
|
|
148
|
+
}
|
|
149
|
+
lines.push(' Future commands must continue receiving MAINWP_APP_PASSWORD because plaintext credentials are not stored locally.');
|
|
150
|
+
}
|
|
151
|
+
if (skipSSLVerification) {
|
|
152
|
+
lines.push('');
|
|
153
|
+
lines.push(formatWarning('SSL verification is disabled. This is insecure.'));
|
|
154
|
+
}
|
|
155
|
+
if (normalizedUrl.startsWith('http://')) {
|
|
156
|
+
lines.push('');
|
|
157
|
+
lines.push(formatWarning('Using HTTP instead of HTTPS. Credentials may be exposed.'));
|
|
158
|
+
}
|
|
159
|
+
lines.push('');
|
|
160
|
+
lines.push(formatInfo('Next: mainwpcontrol abilities list'));
|
|
161
|
+
return lines.join('\n');
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAgB,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,a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;aAChC,CAAC;YAEF,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;gBAC1B,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC,CAAC;gBAChE,IAAI,cAAc,CAAC,KAAK,EAAE,CAAC;oBACzB,KAAK,CAAC,IAAI,CAAC,aAAa,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;gBAClD,CAAC;gBACD,KAAK,CAAC,IAAI,CACR,qHAAqH,CACtH,CAAC;YACJ,CAAC;YAED,IAAI,mBAAmB,EAAE,CAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;YAC/E,CAAC;YAED,IAAI,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC,CAAC;YACxF,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,oCAAoC,CAAC,CAAC,CAAC;YAE7D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CACF,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile delete command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Deletes a Dashboard profile and its credentials.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
7
|
+
export default class ProfileDelete extends BaseCommand {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
static args: {
|
|
17
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
18
|
+
};
|
|
19
|
+
protected needsProfile(): boolean;
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/profile/delete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAe,MAAM,2BAA2B,CAAC;AAOrE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,MAAM,CAAC,WAAW,SAAgC;IAElD,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;MAEV;IAEF,MAAM,CAAC,IAAI;;MAKT;IAGF,SAAS,CAAC,YAAY,IAAI,OAAO;IAI3B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsC3B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile delete command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Deletes a Dashboard profile and its credentials.
|
|
5
|
+
*/
|
|
6
|
+
import { Args } from '@oclif/core';
|
|
7
|
+
import { BaseCommand, commonFlags } from '../../lib/base-command.js';
|
|
8
|
+
import { getProfileStore } from '../../config/profile-store.js';
|
|
9
|
+
import { getKeychain } from '../../config/keychain.js';
|
|
10
|
+
import { formatSuccess, formatWarning } from '../../output/formatter.js';
|
|
11
|
+
import { ConfigError } from '../../utils/errors.js';
|
|
12
|
+
import { promptForConfirmation } from '../../utils/prompt.js';
|
|
13
|
+
export default class ProfileDelete extends BaseCommand {
|
|
14
|
+
static description = 'Delete a Dashboard profile';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> profile delete staging',
|
|
17
|
+
'<%= config.bin %> profile delete old-profile --json',
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
...commonFlags,
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
name: Args.string({
|
|
24
|
+
description: 'Profile name to delete',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
// Doesn't need a profile loaded initially
|
|
29
|
+
needsProfile() {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(ProfileDelete);
|
|
34
|
+
await this.initCommon(flags);
|
|
35
|
+
const profileStore = getProfileStore();
|
|
36
|
+
const profile = await profileStore.get(args.name);
|
|
37
|
+
if (!profile) {
|
|
38
|
+
throw new ConfigError(`Profile not found: ${args.name}. Run \`mainwpcontrol profile list\` to see available profiles.`);
|
|
39
|
+
}
|
|
40
|
+
// Prompt for confirmation (returns false in non-interactive mode = safe default)
|
|
41
|
+
const confirmed = await promptForConfirmation(`Delete profile "${args.name}" and its credentials?`);
|
|
42
|
+
if (!confirmed) {
|
|
43
|
+
this.log(formatWarning('Profile deletion cancelled.'));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Delete credentials from keychain
|
|
47
|
+
const keychain = getKeychain();
|
|
48
|
+
await keychain.delete(args.name);
|
|
49
|
+
// Remove profile from profile store (handles active profile switching automatically)
|
|
50
|
+
await profileStore.remove(args.name);
|
|
51
|
+
this.output({
|
|
52
|
+
deleted: args.name,
|
|
53
|
+
message: 'Profile and credentials deleted successfully',
|
|
54
|
+
}, () => formatSuccess(`Deleted profile: ${args.name}`));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/profile/delete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,MAAM,CAAC,WAAW,GAAG,4BAA4B,CAAC;IAElD,MAAM,CAAC,QAAQ,GAAG;QAChB,0CAA0C;QAC1C,qDAAqD;KACtD,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,WAAW;KACf,CAAC;IAEF,MAAM,CAAC,IAAI,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;IAEF,0CAA0C;IAChC,YAAY;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACxD,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,WAAW,CACnB,sBAAsB,IAAI,CAAC,IAAI,iEAAiE,CACjG,CAAC;QACJ,CAAC;QAED,iFAAiF;QACjF,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAC3C,mBAAmB,IAAI,CAAC,IAAI,wBAAwB,CACrD,CAAC;QAEF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAC,CAAC;YACvD,OAAO;QACT,CAAC;QAED,mCAAmC;QACnC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjC,qFAAqF;QACrF,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErC,IAAI,CAAC,MAAM,CACT;YACE,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,OAAO,EAAE,8CAA8C;SACxD,EACD,GAAG,EAAE,CAAC,aAAa,CAAC,oBAAoB,IAAI,CAAC,IAAI,EAAE,CAAC,CACrD,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile list command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Lists all saved Dashboard profiles.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseCommand } from '../../lib/base-command.js';
|
|
7
|
+
export default class ProfileList extends BaseCommand {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static flags: {
|
|
11
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
protected needsProfile(): boolean;
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/profile/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,2BAA2B,CAAC;AAIrE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,MAAM,CAAC,WAAW,SAAmC;IAErD,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;MAEV;IAGF,SAAS,CAAC,YAAY,IAAI,OAAO;IAI3B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuC3B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile list command for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Lists all saved Dashboard profiles.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseCommand, commonFlags } from '../../lib/base-command.js';
|
|
7
|
+
import { getProfileStore } from '../../config/profile-store.js';
|
|
8
|
+
import { formatTable, formatHeading } from '../../output/formatter.js';
|
|
9
|
+
export default class ProfileList extends BaseCommand {
|
|
10
|
+
static description = 'List saved Dashboard profiles';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> profile list',
|
|
13
|
+
'<%= config.bin %> profile list --json',
|
|
14
|
+
];
|
|
15
|
+
static flags = {
|
|
16
|
+
...commonFlags,
|
|
17
|
+
};
|
|
18
|
+
// Doesn't need a profile loaded
|
|
19
|
+
needsProfile() {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
async run() {
|
|
23
|
+
const { flags } = await this.parse(ProfileList);
|
|
24
|
+
await this.initCommon(flags);
|
|
25
|
+
const profileStore = getProfileStore();
|
|
26
|
+
const profiles = await profileStore.list();
|
|
27
|
+
const activeName = await profileStore.getActiveName();
|
|
28
|
+
this.output({
|
|
29
|
+
profiles: profiles.map((p) => ({
|
|
30
|
+
name: p.name,
|
|
31
|
+
url: p.dashboardUrl,
|
|
32
|
+
username: p.username,
|
|
33
|
+
active: p.name === activeName,
|
|
34
|
+
})),
|
|
35
|
+
activeProfile: activeName,
|
|
36
|
+
}, () => {
|
|
37
|
+
if (profiles.length === 0) {
|
|
38
|
+
return 'No profiles configured. Run `mainwpcontrol login` to add one.';
|
|
39
|
+
}
|
|
40
|
+
const lines = [formatHeading('Profiles'), ''];
|
|
41
|
+
const headers = ['Name', 'URL', 'Username', 'Active'];
|
|
42
|
+
const rows = profiles.map((p) => [
|
|
43
|
+
p.name,
|
|
44
|
+
p.dashboardUrl,
|
|
45
|
+
p.username,
|
|
46
|
+
p.name === activeName ? '*' : '',
|
|
47
|
+
]);
|
|
48
|
+
lines.push(formatTable(headers, rows));
|
|
49
|
+
return lines.join('\n');
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=list.js.map
|