para-cli 1.20.0 → 1.20.1
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/index.js +17 -4
- package/package.json +1 -1
- package/para-cli.js +2 -2
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ export function setup(config) {
|
|
|
61
61
|
var secret = (secretKey || config.get('secretKey')).trim();
|
|
62
62
|
var endpoint = (endpoint || config.get('endpoint')).trim();
|
|
63
63
|
newJWT(access, secret, endpoint, config);
|
|
64
|
-
var pc = new ParaClient(access, secret,
|
|
64
|
+
var pc = new ParaClient(access, secret, parseEndpoint(endpoint || defaultConfig.endpoint));
|
|
65
65
|
ping(pc, config);
|
|
66
66
|
if (access === 'app:para') {
|
|
67
67
|
listApps(config, {}, access, function () {
|
|
@@ -462,7 +462,7 @@ export function listApps(config, flags, parentAccessKey, failureCallback) {
|
|
|
462
462
|
var accessKey = selectedEndpoint.accessKey;
|
|
463
463
|
var secretKey = selectedEndpoint.secretKey;
|
|
464
464
|
var endpoint = selectedEndpoint.endpoint;
|
|
465
|
-
var pc = new ParaClient(accessKey, secretKey,
|
|
465
|
+
var pc = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
|
|
466
466
|
var p = new Pager();
|
|
467
467
|
var results = [];
|
|
468
468
|
p.sortby = '_docid';
|
|
@@ -503,7 +503,7 @@ export function selectApp(input, config, flags) {
|
|
|
503
503
|
appid: accessKey,
|
|
504
504
|
getCredentials: selectedApp
|
|
505
505
|
}), secretKey, { algorithm: 'HS256' });
|
|
506
|
-
var paraClient = new ParaClient(accessKey, secretKey,
|
|
506
|
+
var paraClient = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
|
|
507
507
|
paraClient.setAccessToken(jwt);
|
|
508
508
|
paraClient.me(jwt).then(function (data) {
|
|
509
509
|
if (data && data.credentials) {
|
|
@@ -553,7 +553,7 @@ export function addEndpoint(config) {
|
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
555
555
|
rl.question(cyan.bold('Para Secret Key (for root app app:para): '), function (secretKey) {
|
|
556
|
-
var pc = new ParaClient("app:para", secretKey,
|
|
556
|
+
var pc = new ParaClient("app:para", secretKey, parseEndpoint(endpoint));
|
|
557
557
|
var endpoints = config.get('endpoints') || [];
|
|
558
558
|
var existing = false;
|
|
559
559
|
for (var i = 0; i < endpoints.length; i++) {
|
|
@@ -622,6 +622,19 @@ export function selectEndpoint(config, flags) {
|
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
+
export function parseEndpoint(endpoint) {
|
|
626
|
+
try {
|
|
627
|
+
var url = new URL(endpoint);
|
|
628
|
+
if (url.pathname !== '/') {
|
|
629
|
+
var x = { endpoint: url.protocol + '//' + url.host, apiPath: url.pathname.replace(/\/*$/, '') + '/v1/' };
|
|
630
|
+
return x;
|
|
631
|
+
}
|
|
632
|
+
} catch (e) {
|
|
633
|
+
fail('Invalid Para endpoint:', endpoint);
|
|
634
|
+
}
|
|
635
|
+
return { endpoint: endpoint };
|
|
636
|
+
}
|
|
637
|
+
|
|
625
638
|
function getSelectedEndpoint(config, flags) {
|
|
626
639
|
var accessKey = flags.accessKey || process.env.PARA_ACCESS_KEY || config.get('accessKey');
|
|
627
640
|
var secretKey = flags.secretKey || process.env.PARA_SECRET_KEY || config.get('secretKey');
|
package/package.json
CHANGED
package/para-cli.js
CHANGED
|
@@ -28,7 +28,7 @@ import figlet from 'figlet';
|
|
|
28
28
|
import chalk from 'chalk';
|
|
29
29
|
import meow from 'meow';
|
|
30
30
|
import {
|
|
31
|
-
defaultConfig, setup, listApps, selectEndpoint, addEndpoint, removeEndpoint, selectApp, createAll, readAll,
|
|
31
|
+
defaultConfig, setup, listApps, parseEndpoint, selectEndpoint, addEndpoint, removeEndpoint, selectApp, createAll, readAll,
|
|
32
32
|
updateAll, deleteAll, search, newKeys, newJWT, newApp, deleteApp, ping, me, appSettings, rebuildIndex, exportData, importData
|
|
33
33
|
} from './index.js';
|
|
34
34
|
|
|
@@ -129,7 +129,7 @@ if (!input[0]) {
|
|
|
129
129
|
process.exitCode = 1;
|
|
130
130
|
setup(config);
|
|
131
131
|
} else {
|
|
132
|
-
var pc = new ParaClient(accessKey, secretKey,
|
|
132
|
+
var pc = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
|
|
133
133
|
|
|
134
134
|
if (input[0] === 'setup') {
|
|
135
135
|
setup(config);
|