mage-remote-run 0.12.0 → 0.14.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/bin/mage-remote-run.js +68 -74
- package/lib/command-registry.js +68 -0
- package/lib/commands/adobe-io-events.js +4 -0
- package/lib/commands/company.js +8 -0
- package/lib/commands/connections.js +47 -1
- package/lib/commands/console.js +300 -0
- package/lib/commands/customers.js +28 -0
- package/lib/commands/eav.js +8 -0
- package/lib/commands/inventory.js +20 -0
- package/lib/commands/orders.js +23 -3
- package/lib/commands/products.js +24 -0
- package/lib/commands/stores.js +36 -0
- package/lib/commands/tax.js +8 -0
- package/lib/commands/webhooks.js +4 -0
- package/lib/commands/websites.js +16 -0
- package/lib/mcp.js +263 -0
- package/package.json +4 -2
package/bin/mage-remote-run.js
CHANGED
|
@@ -11,24 +11,24 @@ const pkg = require('../package.json');
|
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|
|
13
13
|
program
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
.name('mage-remote-run')
|
|
15
|
+
.description('The remote swiss army knife for Magento Open Source, Mage-OS, Adobe Commerce')
|
|
16
|
+
.version(pkg.version)
|
|
17
|
+
.configureHelp({
|
|
18
|
+
visibleCommands: (cmd) => {
|
|
19
|
+
const commands = cmd.commands.filter(c => !c._hidden);
|
|
20
|
+
return commands.sort((a, b) => {
|
|
21
|
+
if (a.name() === 'connection') return -1;
|
|
22
|
+
if (b.name() === 'connection') return 1;
|
|
23
|
+
return a.name().localeCompare(b.name());
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
subcommandTerm: (cmd) => chalk.cyan(cmd.name()),
|
|
27
|
+
subcommandDescription: (cmd) => chalk.gray(cmd.description()),
|
|
28
|
+
optionTerm: (option) => chalk.yellow(option.flags),
|
|
29
|
+
optionDescription: (option) => chalk.gray(option.description)
|
|
30
|
+
})
|
|
31
|
+
.addHelpText('before', chalk.hex('#FFA500')(`
|
|
32
32
|
_ __ ___ __ _ __ _ ___ _ __ ___ _ __ ___ ___ | |_ ___ _ __ _ _ _ __
|
|
33
33
|
| '_ \` _ \\ / _\` |/ _\` |/ _ \\____| '__/ _ \\ '_ \` _ \\ / _ \\| __/ _ \\____| '__| | | | '_ \\
|
|
34
34
|
| | | | | | (_| | (_| | __/____| | | __/ | | | | | (_) | || __/____| | | |_| | | | |
|
|
@@ -38,55 +38,49 @@ program
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
import { registerEavCommands } from '../lib/commands/eav.js';
|
|
47
|
-
import { registerProductsCommands } from '../lib/commands/products.js';
|
|
48
|
-
import { registerCompanyCommands } from '../lib/commands/company.js';
|
|
49
|
-
import { registerTaxCommands } from '../lib/commands/tax.js';
|
|
50
|
-
import { registerInventoryCommands } from '../lib/commands/inventory.js';
|
|
51
|
-
import { registerAdobeIoEventsCommands } from '../lib/commands/adobe-io-events.js';
|
|
52
|
-
import { registerWebhooksCommands } from '../lib/commands/webhooks.js';
|
|
41
|
+
import {
|
|
42
|
+
registerConnectionCommands,
|
|
43
|
+
registerCoreCommands,
|
|
44
|
+
registerCloudCommands
|
|
45
|
+
} from '../lib/command-registry.js';
|
|
53
46
|
import { getActiveProfile } from '../lib/config.js';
|
|
47
|
+
import { startMcpServer } from '../lib/mcp.js';
|
|
54
48
|
|
|
55
49
|
registerConnectionCommands(program);
|
|
56
50
|
|
|
51
|
+
program.command('mcp')
|
|
52
|
+
.description('Run as MCP server')
|
|
53
|
+
.option('--transport <type>', 'Transport type (stdio, http)', 'stdio')
|
|
54
|
+
.option('--host <host>', 'HTTP Host', '127.0.0.1')
|
|
55
|
+
.option('--port <port>', 'HTTP Port', '18098')
|
|
56
|
+
.action(async (options) => {
|
|
57
|
+
await startMcpServer(options);
|
|
58
|
+
});
|
|
59
|
+
|
|
57
60
|
const profile = await getActiveProfile();
|
|
58
61
|
|
|
59
62
|
if (profile) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
registerProductsCommands(program);
|
|
66
|
-
registerTaxCommands(program);
|
|
67
|
-
registerInventoryCommands(program);
|
|
68
|
-
|
|
69
|
-
if (profile.type === 'ac-cloud-paas' || profile.type === 'ac-saas') {
|
|
70
|
-
registerAdobeIoEventsCommands(program);
|
|
71
|
-
registerCompanyCommands(program);
|
|
72
|
-
registerWebhooksCommands(program);
|
|
73
|
-
}
|
|
63
|
+
registerCoreCommands(program);
|
|
64
|
+
|
|
65
|
+
if (profile.type === 'ac-cloud-paas' || profile.type === 'ac-saas') {
|
|
66
|
+
registerCloudCommands(program);
|
|
67
|
+
}
|
|
74
68
|
}
|
|
75
69
|
|
|
76
70
|
program.hook('preAction', async (thisCommand, actionCommand) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
71
|
+
// Check if we have an active profile and if format is not json/xml
|
|
72
|
+
// Note: 'options' are available on the command that has them defined.
|
|
73
|
+
// actionCommand is the command actually being executed.
|
|
74
|
+
if (profile) {
|
|
75
|
+
const config = await loadConfig();
|
|
76
|
+
if (config.showActiveConnectionHeader !== false) {
|
|
77
|
+
const opts = actionCommand.opts();
|
|
78
|
+
if (opts.format !== 'json' && opts.format !== 'xml') {
|
|
79
|
+
console.log(chalk.cyan(`Active Connection: ${chalk.bold(profile.name)} (${profile.type})`));
|
|
80
|
+
console.log(chalk.gray('━'.repeat(60)) + '\n');
|
|
81
|
+
}
|
|
89
82
|
}
|
|
83
|
+
}
|
|
90
84
|
});
|
|
91
85
|
|
|
92
86
|
import { expandCommandAbbreviations } from '../lib/command-helper.js';
|
|
@@ -100,28 +94,28 @@ const config = await loadConfig();
|
|
|
100
94
|
const hasProfiles = Object.keys(config.profiles || {}).length > 0;
|
|
101
95
|
|
|
102
96
|
if (!hasProfiles && args.length === 0) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
console.log(chalk.bold.blue('Welcome to mage-remote-run! 🚀'));
|
|
98
|
+
console.log(chalk.gray('The remote swiss army knife for Magento Open Source, Mage-OS, Adobe Commerce'));
|
|
99
|
+
console.log(chalk.gray('It looks like you haven\'t configured any connections yet.'));
|
|
100
|
+
console.log(chalk.gray('Let\'s set up your first connection now.\n'));
|
|
101
|
+
|
|
102
|
+
// Trigger the interactive add command directly
|
|
103
|
+
// We can simulate running the 'connection add' command
|
|
104
|
+
// But since we are at top level, we might need to invoke it manually or parse specific args.
|
|
105
|
+
// Easiest is to manually invoke program.parse with ['node', 'script', 'connection', 'add']
|
|
106
|
+
// BUT program.parse executes asynchronously usually? commander is synchronous by default but actions are async.
|
|
107
|
+
// Let's modify process.argv before parsing.
|
|
108
|
+
args = ['connection', 'add'];
|
|
115
109
|
}
|
|
116
110
|
|
|
117
111
|
try {
|
|
118
|
-
|
|
112
|
+
args = expandCommandAbbreviations(program, args);
|
|
119
113
|
} catch (e) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
if (e.isAmbiguous) {
|
|
115
|
+
console.error(e.message);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
throw e;
|
|
125
119
|
}
|
|
126
120
|
process.argv = [...process.argv.slice(0, 2), ...args];
|
|
127
121
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { registerWebsitesCommands } from './commands/websites.js';
|
|
2
|
+
import { registerStoresCommands } from './commands/stores.js';
|
|
3
|
+
import { registerConnectionCommands } from './commands/connections.js';
|
|
4
|
+
import { registerCustomersCommands } from './commands/customers.js';
|
|
5
|
+
import { registerOrdersCommands } from './commands/orders.js';
|
|
6
|
+
import { registerEavCommands } from './commands/eav.js';
|
|
7
|
+
import { registerProductsCommands } from './commands/products.js';
|
|
8
|
+
import { registerCompanyCommands } from './commands/company.js';
|
|
9
|
+
import { registerTaxCommands } from './commands/tax.js';
|
|
10
|
+
import { registerInventoryCommands } from './commands/inventory.js';
|
|
11
|
+
import { registerAdobeIoEventsCommands } from './commands/adobe-io-events.js';
|
|
12
|
+
import { registerWebhooksCommands } from './commands/webhooks.js';
|
|
13
|
+
import { registerConsoleCommand } from './commands/console.js';
|
|
14
|
+
|
|
15
|
+
export { registerConnectionCommands, registerConsoleCommand };
|
|
16
|
+
|
|
17
|
+
export function registerCoreCommands(program) {
|
|
18
|
+
registerWebsitesCommands(program);
|
|
19
|
+
registerStoresCommands(program);
|
|
20
|
+
registerCustomersCommands(program);
|
|
21
|
+
registerOrdersCommands(program);
|
|
22
|
+
registerEavCommands(program);
|
|
23
|
+
registerProductsCommands(program);
|
|
24
|
+
registerTaxCommands(program);
|
|
25
|
+
registerInventoryCommands(program);
|
|
26
|
+
registerConsoleCommand(program);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function registerCloudCommands(program) {
|
|
30
|
+
registerAdobeIoEventsCommands(program);
|
|
31
|
+
registerCompanyCommands(program);
|
|
32
|
+
registerWebhooksCommands(program);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function registerAllCommands(program) {
|
|
36
|
+
registerConnectionCommands(program);
|
|
37
|
+
registerCoreCommands(program);
|
|
38
|
+
registerCloudCommands(program);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Alias for backwards compatibility with console.js (and potential other usages)
|
|
42
|
+
export const registerCommands = (program, profile) => {
|
|
43
|
+
// Note: console.js passes profile, but registerAllCommands doesn't strictly use it
|
|
44
|
+
// (it registers everything, profile checks happen inside or via selective registration).
|
|
45
|
+
// The original behavior in console.js:
|
|
46
|
+
// const profile = await getActiveProfile();
|
|
47
|
+
// registerCommands(localProgram, profile);
|
|
48
|
+
|
|
49
|
+
// In bin/mage-remote-run.js old logic:
|
|
50
|
+
// registerConnectionCommands(program);
|
|
51
|
+
// if (profile) { registerWebsitesCommands... }
|
|
52
|
+
|
|
53
|
+
// We should replicate that 'selective' registration if we want to match exact behavior?
|
|
54
|
+
// BUT console.js wants to register ALL available commands for the profile.
|
|
55
|
+
|
|
56
|
+
registerConnectionCommands(program);
|
|
57
|
+
|
|
58
|
+
// Simple logic: If profile exists, register all.
|
|
59
|
+
// console.js usage implies profile is present if it's running (or it tries to get it).
|
|
60
|
+
|
|
61
|
+
if (profile) {
|
|
62
|
+
registerCoreCommands(program);
|
|
63
|
+
// Cloud check
|
|
64
|
+
if (profile.type === 'ac-cloud-paas' || profile.type === 'ac-saas') {
|
|
65
|
+
registerCloudCommands(program);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -5,6 +5,10 @@ import chalk from 'chalk';
|
|
|
5
5
|
export function registerAdobeIoEventsCommands(program) {
|
|
6
6
|
const adobeIoEvents = program.command('adobe-io-event').description('Manage Adobe I/O Events');
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
//-------------------------------------------------------
|
|
10
|
+
// "adobe-io-event check-configuration" Command
|
|
11
|
+
//-------------------------------------------------------
|
|
8
12
|
adobeIoEvents.command('check-configuration')
|
|
9
13
|
.description('Check Adobe I/O Event configuration')
|
|
10
14
|
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
package/lib/commands/company.js
CHANGED
|
@@ -5,6 +5,10 @@ import chalk from 'chalk';
|
|
|
5
5
|
export function registerCompanyCommands(program) {
|
|
6
6
|
const company = program.command('company').description('Manage companies');
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
//-------------------------------------------------------
|
|
10
|
+
// "company list" Command
|
|
11
|
+
//-------------------------------------------------------
|
|
8
12
|
company.command('list')
|
|
9
13
|
.description('List companies')
|
|
10
14
|
.option('-p, --page <number>', 'Page number', '1')
|
|
@@ -56,6 +60,10 @@ Examples:
|
|
|
56
60
|
} catch (e) { handleError(e); }
|
|
57
61
|
});
|
|
58
62
|
|
|
63
|
+
|
|
64
|
+
//-------------------------------------------------------
|
|
65
|
+
// "company show" Command
|
|
66
|
+
//-------------------------------------------------------
|
|
59
67
|
company.command('show <companyId>')
|
|
60
68
|
.description('Show company details')
|
|
61
69
|
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
@@ -60,6 +60,10 @@ async function configureAndTestConnection(name, initialSettings = {}) {
|
|
|
60
60
|
export function registerConnectionCommands(program) {
|
|
61
61
|
const connections = program.command('connection').description('Manage mage-remote-run connection profiles');
|
|
62
62
|
|
|
63
|
+
|
|
64
|
+
//-------------------------------------------------------
|
|
65
|
+
// "connection add" Command
|
|
66
|
+
//-------------------------------------------------------
|
|
63
67
|
connections.command('add')
|
|
64
68
|
.description('Configure a new connection profile')
|
|
65
69
|
.addHelpText('after', `
|
|
@@ -106,6 +110,10 @@ Examples:
|
|
|
106
110
|
}
|
|
107
111
|
});
|
|
108
112
|
|
|
113
|
+
|
|
114
|
+
//-------------------------------------------------------
|
|
115
|
+
// "connection list" Command
|
|
116
|
+
//-------------------------------------------------------
|
|
109
117
|
connections.command('list')
|
|
110
118
|
.description('List connection profiles')
|
|
111
119
|
.addHelpText('after', `
|
|
@@ -125,6 +133,10 @@ Examples:
|
|
|
125
133
|
} catch (e) { handleError(e); }
|
|
126
134
|
});
|
|
127
135
|
|
|
136
|
+
|
|
137
|
+
//-------------------------------------------------------
|
|
138
|
+
// "connection search" Command
|
|
139
|
+
//-------------------------------------------------------
|
|
128
140
|
connections.command('search <query>')
|
|
129
141
|
.description('Search connection profiles')
|
|
130
142
|
.addHelpText('after', `
|
|
@@ -140,6 +152,10 @@ Examples:
|
|
|
140
152
|
} catch (e) { handleError(e); }
|
|
141
153
|
});
|
|
142
154
|
|
|
155
|
+
|
|
156
|
+
//-------------------------------------------------------
|
|
157
|
+
// "connection delete" Command
|
|
158
|
+
//-------------------------------------------------------
|
|
143
159
|
connections.command('delete <name>')
|
|
144
160
|
.description('Delete a connection profile')
|
|
145
161
|
.addHelpText('after', `
|
|
@@ -161,6 +177,10 @@ Examples:
|
|
|
161
177
|
} catch (e) { handleError(e); }
|
|
162
178
|
});
|
|
163
179
|
|
|
180
|
+
|
|
181
|
+
//-------------------------------------------------------
|
|
182
|
+
// "connection edit" Command
|
|
183
|
+
//-------------------------------------------------------
|
|
164
184
|
connections.command('edit [name]')
|
|
165
185
|
.description('Edit a connection profile')
|
|
166
186
|
.addHelpText('after', `
|
|
@@ -208,6 +228,10 @@ Examples:
|
|
|
208
228
|
}
|
|
209
229
|
});
|
|
210
230
|
|
|
231
|
+
|
|
232
|
+
//-------------------------------------------------------
|
|
233
|
+
// "connection test" Command
|
|
234
|
+
//-------------------------------------------------------
|
|
211
235
|
connections.command('test')
|
|
212
236
|
.description('Test connection(s)')
|
|
213
237
|
.option('--all', 'Test all configured connections')
|
|
@@ -270,6 +294,10 @@ Examples:
|
|
|
270
294
|
if (process.env.DEBUG) console.error(e);
|
|
271
295
|
}
|
|
272
296
|
});
|
|
297
|
+
|
|
298
|
+
//-------------------------------------------------------
|
|
299
|
+
// "connection status" Command
|
|
300
|
+
//-------------------------------------------------------
|
|
273
301
|
connections.command('status')
|
|
274
302
|
.description('Show current configuration status')
|
|
275
303
|
.addHelpText('after', `
|
|
@@ -294,6 +322,10 @@ Examples:
|
|
|
294
322
|
} catch (e) { handleError(e); }
|
|
295
323
|
});
|
|
296
324
|
|
|
325
|
+
|
|
326
|
+
//-------------------------------------------------------
|
|
327
|
+
// "connection select" Command
|
|
328
|
+
//-------------------------------------------------------
|
|
297
329
|
connections.command('select')
|
|
298
330
|
.description('Select the active connection profile (aliases: change, switch)')
|
|
299
331
|
.aliases(['switch', 'change'])
|
|
@@ -317,12 +349,20 @@ Examples:
|
|
|
317
349
|
default: config.activeProfile
|
|
318
350
|
});
|
|
319
351
|
|
|
352
|
+
if (process.env.DEBUG) {
|
|
353
|
+
console.log(chalk.gray(`DEBUG: Selected profile: ${selected}`));
|
|
354
|
+
}
|
|
355
|
+
|
|
320
356
|
config.activeProfile = selected;
|
|
321
357
|
await saveConfig(config);
|
|
322
358
|
console.log(chalk.green(`Active profile set to "${selected}".`));
|
|
323
359
|
} catch (e) { handleError(e); }
|
|
324
360
|
});
|
|
325
361
|
|
|
362
|
+
|
|
363
|
+
//-------------------------------------------------------
|
|
364
|
+
// "connection clear-token-cache" Command
|
|
365
|
+
//-------------------------------------------------------
|
|
326
366
|
connections.command('clear-token-cache')
|
|
327
367
|
.description('Clear cached access tokens')
|
|
328
368
|
.addHelpText('after', `
|
|
@@ -336,6 +376,10 @@ Examples:
|
|
|
336
376
|
} catch (e) { handleError(e); }
|
|
337
377
|
});
|
|
338
378
|
|
|
379
|
+
|
|
380
|
+
//-------------------------------------------------------
|
|
381
|
+
// "connection status-header" Command
|
|
382
|
+
//-------------------------------------------------------
|
|
339
383
|
connections.command('status-header <state>')
|
|
340
384
|
.description('Enable or disable the active connection header (on|off)')
|
|
341
385
|
.addHelpText('after', `
|
|
@@ -353,6 +397,8 @@ Examples:
|
|
|
353
397
|
config.showActiveConnectionHeader = state === 'on';
|
|
354
398
|
await saveConfig(config);
|
|
355
399
|
console.log(chalk.green(`Active connection header is now ${state === 'on' ? 'enabled' : 'disabled'}.`));
|
|
356
|
-
} catch (e) {
|
|
400
|
+
} catch (e) {
|
|
401
|
+
handleError(e);
|
|
402
|
+
}
|
|
357
403
|
});
|
|
358
404
|
}
|