mage-remote-run 0.6.0 → 0.8.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.
@@ -13,7 +13,21 @@ const program = new Command();
13
13
  program
14
14
  .name('mage-remote-run')
15
15
  .description('The remote swiss army knife for Magento Open Source, Mage-OS, Adobe Commerce')
16
- .version(pkg.version);
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
+ });
17
31
 
18
32
 
19
33
 
@@ -7,7 +7,7 @@ import inquirer from 'inquirer';
7
7
  import chalk from 'chalk';
8
8
 
9
9
  export function registerConnectionCommands(program) {
10
- const connections = program.command('connection').description('Manage connection profiles');
10
+ const connections = program.command('connection').description('Manage mage-remote-run connection profiles');
11
11
 
12
12
  connections.command('add')
13
13
  .description('Configure a new connection profile')
@@ -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 store groups');
7
+ const stores = program.command('store').description('Manage stores');
8
8
 
9
- stores.command('list')
10
- .action(async () => {
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 data = await client.get('V1/store/storeGroups');
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
- stores.command('search <query>')
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
- stores.command('delete <id>')
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
- stores.command('edit <id>')
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
- .action(async () => {
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 data = await client.get('V1/store/storeViews');
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-remote-run",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "The remote swiss army knife for Magento Open Source, Mage-OS, Adobe Commerce",
5
5
  "main": "index.js",
6
6
  "scripts": {