mage-remote-run 0.5.0 → 0.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/bin/mage-remote-run.js +2 -0
- package/lib/commands/stores.js +79 -9
- package/lib/commands/webhooks.js +48 -0
- package/lib/commands/websites.js +17 -2
- package/package.json +1 -1
package/bin/mage-remote-run.js
CHANGED
|
@@ -28,6 +28,7 @@ import { registerCompanyCommands } from '../lib/commands/company.js';
|
|
|
28
28
|
import { registerTaxCommands } from '../lib/commands/tax.js';
|
|
29
29
|
import { registerInventoryCommands } from '../lib/commands/inventory.js';
|
|
30
30
|
import { registerAdobeIoEventsCommands } from '../lib/commands/adobe-io-events.js';
|
|
31
|
+
import { registerWebhooksCommands } from '../lib/commands/webhooks.js';
|
|
31
32
|
import { getActiveProfile } from '../lib/config.js';
|
|
32
33
|
|
|
33
34
|
registerConnectionCommands(program);
|
|
@@ -47,6 +48,7 @@ if (profile) {
|
|
|
47
48
|
if (profile.type === 'ac-cloud-paas' || profile.type === 'ac-saas') {
|
|
48
49
|
registerAdobeIoEventsCommands(program);
|
|
49
50
|
registerCompanyCommands(program);
|
|
51
|
+
registerWebhooksCommands(program);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
package/lib/commands/stores.js
CHANGED
|
@@ -4,19 +4,39 @@ import chalk from 'chalk';
|
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
|
|
6
6
|
export function registerStoresCommands(program) {
|
|
7
|
-
const stores = program.command('store').description('Manage
|
|
7
|
+
const stores = program.command('store').description('Manage stores');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Store Groups
|
|
10
|
+
const groups = stores.command('group').description('Manage store groups');
|
|
11
|
+
|
|
12
|
+
groups.command('list')
|
|
13
|
+
.description('List store groups')
|
|
14
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
15
|
+
.action(async (options) => {
|
|
11
16
|
try {
|
|
12
17
|
const client = await createClient();
|
|
13
|
-
const
|
|
18
|
+
const headers = {};
|
|
19
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
20
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
21
|
+
|
|
22
|
+
const data = await client.get('V1/store/storeGroups', {}, { headers });
|
|
23
|
+
|
|
24
|
+
if (options.format === 'json') {
|
|
25
|
+
console.log(JSON.stringify(data, null, 2));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (options.format === 'xml') {
|
|
29
|
+
console.log(data);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
14
33
|
const rows = data.map(s => [s.id, s.code, s.name, s.website_id, s.root_category_id]);
|
|
15
34
|
printTable(['ID', 'Code', 'Name', 'Web ID', 'Root Cat'], rows);
|
|
16
35
|
} catch (e) { handleError(e); }
|
|
17
36
|
});
|
|
18
37
|
|
|
19
|
-
|
|
38
|
+
groups.command('search <query>')
|
|
39
|
+
.description('Search store groups')
|
|
20
40
|
.action(async (query) => {
|
|
21
41
|
try {
|
|
22
42
|
const client = await createClient();
|
|
@@ -27,7 +47,8 @@ export function registerStoresCommands(program) {
|
|
|
27
47
|
} catch (e) { handleError(e); }
|
|
28
48
|
});
|
|
29
49
|
|
|
30
|
-
|
|
50
|
+
groups.command('delete <id>')
|
|
51
|
+
.description('Delete store group')
|
|
31
52
|
.action(async (id) => {
|
|
32
53
|
try {
|
|
33
54
|
const client = await createClient();
|
|
@@ -38,7 +59,8 @@ export function registerStoresCommands(program) {
|
|
|
38
59
|
} catch (e) { handleError(e); }
|
|
39
60
|
});
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
groups.command('edit <id>')
|
|
63
|
+
.description('Edit store group')
|
|
42
64
|
.action(async (id) => {
|
|
43
65
|
try {
|
|
44
66
|
const client = await createClient();
|
|
@@ -61,16 +83,33 @@ export function registerStoresCommands(program) {
|
|
|
61
83
|
const views = stores.command('view').description('Manage store views');
|
|
62
84
|
|
|
63
85
|
views.command('list')
|
|
64
|
-
.
|
|
86
|
+
.description('List store views')
|
|
87
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
88
|
+
.action(async (options) => {
|
|
65
89
|
try {
|
|
66
90
|
const client = await createClient();
|
|
67
|
-
const
|
|
91
|
+
const headers = {};
|
|
92
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
93
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
94
|
+
|
|
95
|
+
const data = await client.get('V1/store/storeViews', {}, { headers });
|
|
96
|
+
|
|
97
|
+
if (options.format === 'json') {
|
|
98
|
+
console.log(JSON.stringify(data, null, 2));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (options.format === 'xml') {
|
|
102
|
+
console.log(data);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
68
106
|
const rows = data.map(v => [v.id, v.code, v.name, v.store_group_id, v.is_active]);
|
|
69
107
|
printTable(['ID', 'Code', 'Name', 'Group ID', 'Active'], rows);
|
|
70
108
|
} catch (e) { handleError(e); }
|
|
71
109
|
});
|
|
72
110
|
|
|
73
111
|
views.command('search <query>')
|
|
112
|
+
.description('Search store views')
|
|
74
113
|
.action(async (query) => {
|
|
75
114
|
try {
|
|
76
115
|
const client = await createClient();
|
|
@@ -82,6 +121,7 @@ export function registerStoresCommands(program) {
|
|
|
82
121
|
});
|
|
83
122
|
|
|
84
123
|
views.command('delete <id>')
|
|
124
|
+
.description('Delete store view')
|
|
85
125
|
.action(async (id) => {
|
|
86
126
|
try {
|
|
87
127
|
const client = await createClient();
|
|
@@ -93,6 +133,7 @@ export function registerStoresCommands(program) {
|
|
|
93
133
|
});
|
|
94
134
|
|
|
95
135
|
views.command('edit <id>')
|
|
136
|
+
.description('Edit store view')
|
|
96
137
|
.action(async (id) => {
|
|
97
138
|
try {
|
|
98
139
|
const client = await createClient();
|
|
@@ -110,4 +151,33 @@ export function registerStoresCommands(program) {
|
|
|
110
151
|
console.log(chalk.green(`Store View ${id} updated.`));
|
|
111
152
|
} catch (e) { handleError(e); }
|
|
112
153
|
});
|
|
154
|
+
|
|
155
|
+
// Store Configs
|
|
156
|
+
const configs = stores.command('config').description('Manage store configurations');
|
|
157
|
+
|
|
158
|
+
configs.command('list')
|
|
159
|
+
.description('List store configurations')
|
|
160
|
+
.action(async () => {
|
|
161
|
+
try {
|
|
162
|
+
const client = await createClient();
|
|
163
|
+
const data = await client.get('V1/store/storeConfigs');
|
|
164
|
+
data.forEach(c => {
|
|
165
|
+
console.log(chalk.bold.cyan(`[ID: ${c.id}] ${c.code}`));
|
|
166
|
+
console.log(chalk.gray(` Website ID: `) + c.website_id);
|
|
167
|
+
console.log(chalk.gray(` Locale: `) + c.locale);
|
|
168
|
+
console.log(chalk.gray(` Timezone: `) + c.timezone);
|
|
169
|
+
console.log(chalk.gray(` Weight: `) + c.weight_unit);
|
|
170
|
+
console.log(chalk.gray(` Currency: `) + `${c.base_currency_code} / ${c.default_display_currency_code}`);
|
|
171
|
+
console.log(chalk.gray(` Base URL: `) + c.base_url);
|
|
172
|
+
console.log(chalk.gray(` Base Link URL: `) + c.base_link_url);
|
|
173
|
+
console.log(chalk.gray(` Base Static URL: `) + c.base_static_url);
|
|
174
|
+
console.log(chalk.gray(` Base Media URL: `) + c.base_media_url);
|
|
175
|
+
console.log(chalk.gray(` Secure URL: `) + c.secure_base_url);
|
|
176
|
+
console.log(chalk.gray(` Secure Link URL: `) + c.secure_base_link_url);
|
|
177
|
+
console.log(chalk.gray(` Secure Static URL: `) + c.secure_base_static_url);
|
|
178
|
+
console.log(chalk.gray(` Secure Media URL: `) + c.secure_base_media_url);
|
|
179
|
+
console.log('');
|
|
180
|
+
});
|
|
181
|
+
} catch (e) { handleError(e); }
|
|
182
|
+
});
|
|
113
183
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createClient } from '../api/factory.js';
|
|
2
|
+
import { printTable, handleError } from '../utils.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
export function registerWebhooksCommands(program) {
|
|
6
|
+
const webhooks = program.command('webhook').description('Manage webhooks');
|
|
7
|
+
|
|
8
|
+
webhooks.command('list')
|
|
9
|
+
.description('List available webhooks')
|
|
10
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
11
|
+
.option('-s, --size <number>', 'Page size', '20')
|
|
12
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
try {
|
|
15
|
+
const client = await createClient();
|
|
16
|
+
const headers = {};
|
|
17
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
18
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
19
|
+
|
|
20
|
+
const params = {
|
|
21
|
+
'searchCriteria[currentPage]': options.page,
|
|
22
|
+
'searchCriteria[pageSize]': options.size
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const data = await client.get('V1/webhooks/list', params, { headers });
|
|
26
|
+
|
|
27
|
+
if (options.format === 'json') {
|
|
28
|
+
console.log(JSON.stringify(data, null, 2));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (options.format === 'xml') {
|
|
32
|
+
console.log(data);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const rows = (data.items || []).map(w => [
|
|
37
|
+
w.hook_id,
|
|
38
|
+
w.name,
|
|
39
|
+
w.status,
|
|
40
|
+
w.store_ids ? w.store_ids.join(',') : '-',
|
|
41
|
+
w.url
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
45
|
+
printTable(['ID', 'Name', 'Status', 'Store IDs', 'URL'], rows);
|
|
46
|
+
} catch (e) { handleError(e); }
|
|
47
|
+
});
|
|
48
|
+
}
|
package/lib/commands/websites.js
CHANGED
|
@@ -8,10 +8,25 @@ export function registerWebsitesCommands(program) {
|
|
|
8
8
|
|
|
9
9
|
websites.command('list')
|
|
10
10
|
.description('List all websites')
|
|
11
|
-
.
|
|
11
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
12
|
+
.action(async (options) => {
|
|
12
13
|
try {
|
|
13
14
|
const client = await createClient();
|
|
14
|
-
const
|
|
15
|
+
const headers = {};
|
|
16
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
17
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
18
|
+
|
|
19
|
+
const data = await client.get('V1/store/websites', {}, { headers });
|
|
20
|
+
|
|
21
|
+
if (options.format === 'json') {
|
|
22
|
+
console.log(JSON.stringify(data, null, 2));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (options.format === 'xml') {
|
|
26
|
+
console.log(data);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
const rows = data.map(w => [w.id, w.code, w.name, w.default_group_id]);
|
|
16
31
|
printTable(['ID', 'Code', 'Name', 'Def Group ID'], rows);
|
|
17
32
|
} catch (e) { handleError(e); }
|