@rankwrangler/cli 0.1.3 → 0.2.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/dist/index.js +12 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,8 +13,8 @@ const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
|
13
13
|
const DEFAULT_OUTPUT_PRETTY = true;
|
|
14
14
|
const SUPPORTED_COMMANDS = new Set([
|
|
15
15
|
'products:get',
|
|
16
|
-
'
|
|
17
|
-
'
|
|
16
|
+
'api-key:status',
|
|
17
|
+
'api-key:validate',
|
|
18
18
|
'config:show',
|
|
19
19
|
'config:clear',
|
|
20
20
|
'config:set',
|
|
@@ -53,7 +53,7 @@ const main = async () => {
|
|
|
53
53
|
}
|
|
54
54
|
const apiKey = resolveApiKey(config);
|
|
55
55
|
if (!apiKey) {
|
|
56
|
-
fail('MISSING_CONFIG', '
|
|
56
|
+
fail('MISSING_CONFIG', 'API key is required. set via `config set api-key <value>`');
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
const baseUrl = resolveBaseUrl(config);
|
|
@@ -73,11 +73,11 @@ const runApiCommand = async (command, client, config) => {
|
|
|
73
73
|
}
|
|
74
74
|
return client.getProductInfoBatch.mutate({ marketplaceId, asins });
|
|
75
75
|
}
|
|
76
|
-
if (command.resource === '
|
|
77
|
-
return client.
|
|
76
|
+
if (command.resource === 'api-key' && command.verb === 'status') {
|
|
77
|
+
return client.apiKey.status.mutate();
|
|
78
78
|
}
|
|
79
|
-
if (command.resource === '
|
|
80
|
-
return client.
|
|
79
|
+
if (command.resource === 'api-key' && command.verb === 'validate') {
|
|
80
|
+
return client.apiKey.validate.mutate();
|
|
81
81
|
}
|
|
82
82
|
fail('UNKNOWN_COMMAND', 'Unknown command', {
|
|
83
83
|
command: `${command.resource} ${command.verb}`,
|
|
@@ -164,7 +164,7 @@ const normalizeAsin = (value) => {
|
|
|
164
164
|
return normalized;
|
|
165
165
|
};
|
|
166
166
|
const resolveApiKey = (config) => {
|
|
167
|
-
return values.apiKey ?? config.apiKey ?? process.env.
|
|
167
|
+
return values.apiKey ?? config.apiKey ?? process.env.RR_API_KEY;
|
|
168
168
|
};
|
|
169
169
|
const resolveBaseUrl = (config) => {
|
|
170
170
|
const configured = values.baseUrl ?? config.baseUrl ?? process.env.RR_API_URL;
|
|
@@ -274,8 +274,8 @@ const printUsage = () => {
|
|
|
274
274
|
'',
|
|
275
275
|
'COMMANDS',
|
|
276
276
|
' products get <ASIN...>',
|
|
277
|
-
'
|
|
278
|
-
'
|
|
277
|
+
' api-key status',
|
|
278
|
+
' api-key validate',
|
|
279
279
|
' config show',
|
|
280
280
|
' config clear',
|
|
281
281
|
' config set api-key <value>',
|
|
@@ -293,7 +293,7 @@ const printUsage = () => {
|
|
|
293
293
|
` ${CONFIG_PATH} Local CLI config`,
|
|
294
294
|
'',
|
|
295
295
|
'ENVIRONMENT',
|
|
296
|
-
'
|
|
296
|
+
' RR_API_KEY API key fallback',
|
|
297
297
|
' RR_API_URL API origin fallback',
|
|
298
298
|
' RR_MARKETPLACE_ID Marketplace fallback',
|
|
299
299
|
' RR_ASIN Single ASIN fallback',
|
|
@@ -302,7 +302,7 @@ const printUsage = () => {
|
|
|
302
302
|
'EXAMPLES',
|
|
303
303
|
' rw config set api-key rrk_...',
|
|
304
304
|
' rw products get B0DV53VS61',
|
|
305
|
-
' rankwrangler
|
|
305
|
+
' rankwrangler api-key status',
|
|
306
306
|
];
|
|
307
307
|
console.log(usage.join('\n'));
|
|
308
308
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rankwrangler/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official RankWrangler command line interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@rankwrangler/http-client": "^0.
|
|
23
|
+
"@rankwrangler/http-client": "^0.2.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^24.3.0",
|