mage-remote-run 1.6.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.
@@ -59,6 +59,85 @@ export async function listProductsAction(options) {
59
59
  }
60
60
  }
61
61
 
62
+ function printProductGeneralInfo(data) {
63
+ console.log(chalk.bold('\nℹ️ General Information'));
64
+ console.log(` ${chalk.bold('ID:')} ${data.id}`);
65
+ console.log(` ${chalk.bold('SKU:')} ${data.sku}`);
66
+ console.log(` ${chalk.bold('Name:')} ${data.name}`);
67
+ console.log(` ${chalk.bold('Type:')} ${data.type_id}`);
68
+ console.log(` ${chalk.bold('Set ID:')} ${data.attribute_set_id}`);
69
+ console.log(` ${chalk.bold('Created At:')} ${data.created_at}`);
70
+ console.log(` ${chalk.bold('Updated At:')} ${data.updated_at}`);
71
+ }
72
+
73
+ function printProductPricing(data) {
74
+ console.log(chalk.bold('\n💰 Pricing'));
75
+ console.log(` ${chalk.bold('Price:')} ${data.price}`);
76
+ const specialPrice = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'special_price');
77
+ if (specialPrice) {
78
+ console.log(` ${chalk.bold('Special Price:')} ${specialPrice.value}`);
79
+ }
80
+ if (data.tier_prices && data.tier_prices.length > 0) {
81
+ console.log(` ${chalk.bold('Tier Prices:')} ${data.tier_prices.length} defined`);
82
+ }
83
+ }
84
+
85
+ function printProductStock(data) {
86
+ if (data.extension_attributes && data.extension_attributes.stock_item) {
87
+ const stock = data.extension_attributes.stock_item;
88
+ console.log(chalk.bold('\n📦 Stock'));
89
+ console.log(` ${chalk.bold('In Stock:')} ${stock.is_in_stock ? chalk.green('Yes') : chalk.red('No')}`);
90
+ console.log(` ${chalk.bold('Quantity:')} ${stock.qty}`);
91
+ }
92
+ }
93
+
94
+ async function printProductContent(data) {
95
+ const { convert } = await import('html-to-text');
96
+ const description = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'description');
97
+ const shortDescription = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'short_description');
98
+
99
+ if (description || shortDescription) {
100
+ console.log(chalk.bold('\n📝 Content'));
101
+ if (shortDescription) {
102
+ console.log(chalk.bold.underline('Short Description:'));
103
+ console.log(convert(shortDescription.value, { wordwrap: 80 }));
104
+ console.log('');
105
+ }
106
+ if (description) {
107
+ console.log(chalk.bold.underline('Description:'));
108
+ console.log(convert(description.value, { wordwrap: 80 }));
109
+ console.log('');
110
+ }
111
+ }
112
+ }
113
+
114
+ function printProductAttributes(data) {
115
+ if (data.custom_attributes && data.custom_attributes.length > 0) {
116
+ const ignoredAttributes = ['description', 'short_description', 'special_price', 'category_ids', 'url_key'];
117
+ const visibleAttributes = data.custom_attributes.filter(a => !ignoredAttributes.includes(a.attribute_code));
118
+
119
+ if (visibleAttributes.length > 0) {
120
+ console.log(chalk.bold('\n📋 Additional Attributes'));
121
+ const attrRows = visibleAttributes
122
+ .filter(a => typeof a.value !== 'object')
123
+ .map(a => [a.attribute_code, a.value]);
124
+
125
+ if (attrRows.length > 0) {
126
+ printTable(['Attribute', 'Value'], attrRows);
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ function printProductMedia(data) {
133
+ if (data.media_gallery_entries && data.media_gallery_entries.length > 0) {
134
+ console.log(chalk.bold('\n🖼️ Media'));
135
+ data.media_gallery_entries.forEach(entry => {
136
+ console.log(` [${entry.media_type}] ${entry.file} (${entry.label || 'No Label'})`);
137
+ });
138
+ }
139
+ }
140
+
62
141
  export async function showProductAction(sku, options) {
63
142
  try {
64
143
  const client = await createClient();
@@ -83,72 +162,12 @@ export async function showProductAction(sku, options) {
83
162
  console.log(chalk.bold.blue('\n📦 Product Information'));
84
163
  console.log(chalk.gray('━'.repeat(60)));
85
164
 
86
- console.log(chalk.bold('\nℹ️ General Information'));
87
- console.log(` ${chalk.bold('ID:')} ${data.id}`);
88
- console.log(` ${chalk.bold('SKU:')} ${data.sku}`);
89
- console.log(` ${chalk.bold('Name:')} ${data.name}`);
90
- console.log(` ${chalk.bold('Type:')} ${data.type_id}`);
91
- console.log(` ${chalk.bold('Set ID:')} ${data.attribute_set_id}`);
92
- console.log(` ${chalk.bold('Created At:')} ${data.created_at}`);
93
- console.log(` ${chalk.bold('Updated At:')} ${data.updated_at}`);
94
-
95
- console.log(chalk.bold('\n💰 Pricing'));
96
- console.log(` ${chalk.bold('Price:')} ${data.price}`);
97
- const specialPrice = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'special_price');
98
- if (specialPrice) {
99
- console.log(` ${chalk.bold('Special Price:')} ${specialPrice.value}`);
100
- }
101
- if (data.tier_prices && data.tier_prices.length > 0) {
102
- console.log(` ${chalk.bold('Tier Prices:')} ${data.tier_prices.length} defined`);
103
- }
104
-
105
- if (data.extension_attributes && data.extension_attributes.stock_item) {
106
- const stock = data.extension_attributes.stock_item;
107
- console.log(chalk.bold('\n📦 Stock'));
108
- console.log(` ${chalk.bold('In Stock:')} ${stock.is_in_stock ? chalk.green('Yes') : chalk.red('No')}`);
109
- console.log(` ${chalk.bold('Quantity:')} ${stock.qty}`);
110
- }
111
-
112
- const { convert } = await import('html-to-text');
113
- const description = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'description');
114
- const shortDescription = data.custom_attributes && data.custom_attributes.find(a => a.attribute_code === 'short_description');
115
-
116
- if (description || shortDescription) {
117
- console.log(chalk.bold('\n📝 Content'));
118
- if (shortDescription) {
119
- console.log(chalk.bold.underline('Short Description:'));
120
- console.log(convert(shortDescription.value, { wordwrap: 80 }));
121
- console.log('');
122
- }
123
- if (description) {
124
- console.log(chalk.bold.underline('Description:'));
125
- console.log(convert(description.value, { wordwrap: 80 }));
126
- console.log('');
127
- }
128
- }
129
-
130
- if (data.custom_attributes && data.custom_attributes.length > 0) {
131
- const ignoredAttributes = ['description', 'short_description', 'special_price', 'category_ids', 'url_key'];
132
- const visibleAttributes = data.custom_attributes.filter(a => !ignoredAttributes.includes(a.attribute_code));
133
-
134
- if (visibleAttributes.length > 0) {
135
- console.log(chalk.bold('\n📋 Additional Attributes'));
136
- const attrRows = visibleAttributes
137
- .filter(a => typeof a.value !== 'object')
138
- .map(a => [a.attribute_code, a.value]);
139
-
140
- if (attrRows.length > 0) {
141
- printTable(['Attribute', 'Value'], attrRows);
142
- }
143
- }
144
- }
145
-
146
- if (data.media_gallery_entries && data.media_gallery_entries.length > 0) {
147
- console.log(chalk.bold('\n🖼️ Media'));
148
- data.media_gallery_entries.forEach(entry => {
149
- console.log(` [${entry.media_type}] ${entry.file} (${entry.label || 'No Label'})`);
150
- });
151
- }
165
+ printProductGeneralInfo(data);
166
+ printProductPricing(data);
167
+ printProductStock(data);
168
+ await printProductContent(data);
169
+ printProductAttributes(data);
170
+ printProductMedia(data);
152
171
 
153
172
  console.log(chalk.gray('━'.repeat(60)));
154
173
  } catch (e) {
@@ -19,7 +19,7 @@ export class PluginLoader {
19
19
  // If config.plugins is missing, we default to empty array
20
20
  const plugins = config.plugins || [];
21
21
 
22
- for (const pluginName of plugins) {
22
+ await Promise.all(plugins.map(async (pluginName) => {
23
23
  try {
24
24
  await this.loadPlugin(pluginName);
25
25
  } catch (e) {
@@ -28,7 +28,7 @@ export class PluginLoader {
28
28
  console.error(e);
29
29
  }
30
30
  }
31
- }
31
+ }));
32
32
  }
33
33
 
34
34
  async loadPlugin(pluginName) {
package/lib/utils.js CHANGED
@@ -178,7 +178,7 @@ export function buildSortCriteria(options) {
178
178
  for (const s of options.sort) {
179
179
  const parts = s.split(':');
180
180
  const field = parts[0];
181
- const direction = parts.length > 1 ? parts[1].toUpperCase() : 'ASC';
181
+ const direction = (parts.length > 1 && parts[1]) ? parts[1].toUpperCase() : 'ASC';
182
182
  addSort(field, direction);
183
183
  }
184
184
  } else if (options.sortBy) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mage-remote-run",
3
- "version": "1.6.0",
3
+ "version": "1.7.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": {