para-cli 1.22.5 → 1.23.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 +23 -7
- package/package.json +1 -1
- package/para-cli.js +2 -3
package/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var encoder = new TextEncoder('utf-8');
|
|
|
32
32
|
import striptags from 'striptags';
|
|
33
33
|
import { Parser } from 'htmlparser2';
|
|
34
34
|
import { createInterface } from 'readline';
|
|
35
|
+
import { Writable } from 'stream';
|
|
35
36
|
import jsonwebtoken from 'jsonwebtoken';
|
|
36
37
|
import { lookup } from 'mime-types';
|
|
37
38
|
import { globbySync } from 'globby';
|
|
@@ -48,14 +49,28 @@ var defaultConfig = { accessKey: '', secretKey: '', endpoint: 'https://paraio.co
|
|
|
48
49
|
const _defaultConfig = defaultConfig;
|
|
49
50
|
export { _defaultConfig as defaultConfig };
|
|
50
51
|
|
|
51
|
-
export function setup(config) {
|
|
52
|
+
export async function setup(config) {
|
|
53
|
+
var secretPrompt = cyan.bold('Para Secret Key: ');
|
|
54
|
+
var mutableStdout = new Writable({
|
|
55
|
+
write: function (chunk, encoding, callback) {
|
|
56
|
+
if (!this.muted || (chunk.toString() === secretPrompt))
|
|
57
|
+
process.stdout.write(chunk, encoding);
|
|
58
|
+
else if (this.muted && chunk.length === 1)
|
|
59
|
+
process.stdout.write(Buffer.from("*".repeat(Math.random() * 5)), encoding);
|
|
60
|
+
callback();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
52
63
|
var rl = createInterface({
|
|
53
64
|
input: process.stdin,
|
|
54
|
-
output:
|
|
65
|
+
output: mutableStdout,
|
|
66
|
+
terminal: true
|
|
55
67
|
});
|
|
68
|
+
mutableStdout.muted = false;
|
|
56
69
|
rl.question(cyan.bold('Para Access Key: '), function (accessKey) {
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
mutableStdout.muted = true;
|
|
71
|
+
rl.question(secretPrompt, function (secretKey) {
|
|
72
|
+
mutableStdout.muted = false;
|
|
73
|
+
rl.question(cyan.bold('Para Endpoint (Press enter for ' + defaultConfig.endpoint + '): '), function (endpoint) {
|
|
59
74
|
var access = (accessKey || config.get('accessKey') || "app:para").trim();
|
|
60
75
|
var secret = (secretKey || config.get('secretKey')).trim();
|
|
61
76
|
var endpoint = (endpoint || defaultConfig.endpoint).trim();
|
|
@@ -78,6 +93,7 @@ export function setup(config) {
|
|
|
78
93
|
});
|
|
79
94
|
});
|
|
80
95
|
}
|
|
96
|
+
rl.close();
|
|
81
97
|
});
|
|
82
98
|
});
|
|
83
99
|
});
|
|
@@ -286,7 +302,7 @@ export function newJWT(accessKey, secretKey, endpoint, config, flags) {
|
|
|
286
302
|
}
|
|
287
303
|
config.set('endpoint', endpoint || config.get('endpoint'));
|
|
288
304
|
config.set('jwt', sign(sClaim, secretKey, { algorithm: 'HS256' }));
|
|
289
|
-
if (flags.print) {
|
|
305
|
+
if (flags && flags.print) {
|
|
290
306
|
console.log(yellow(config.get('jwt')));
|
|
291
307
|
} else {
|
|
292
308
|
console.log(green('✔'), 'New JWT generated and saved in', yellow(config.path));
|
|
@@ -490,8 +506,8 @@ export function listApps(config, flags, parentAccessKey, failureCallback) {
|
|
|
490
506
|
}).then(function () {
|
|
491
507
|
var apps = results.map(function (app) {return app.appIdentifier.trim();});
|
|
492
508
|
if (apps.length) {
|
|
493
|
-
console.log('Found', p.count, 'apps on ' + cyan(endpoint) + '
|
|
494
|
-
console.log('
|
|
509
|
+
console.log('Found', p.count, 'apps on ' + cyan(endpoint) + ':\n', yellow('[') + green(apps.join(yellow('] ['))) + yellow(']'));
|
|
510
|
+
console.log('\nTyping', cyan('para-cli select'), green(apps[0]), 'will switch to that app. \nCurrent app:',
|
|
495
511
|
green(parentAccessKey));
|
|
496
512
|
process.exit(0);
|
|
497
513
|
} else {
|
package/package.json
CHANGED
package/para-cli.js
CHANGED
|
@@ -131,12 +131,12 @@ if (!input[0]) {
|
|
|
131
131
|
console.error(red('Command ' + input[0] + ' failed! Blank credentials, running setup first...'));
|
|
132
132
|
console.log("Please enter the access key and secret key for the root app 'app:para' first.");
|
|
133
133
|
process.exitCode = 1;
|
|
134
|
-
setup(config);
|
|
134
|
+
await setup(config);
|
|
135
135
|
} else {
|
|
136
136
|
var pc = new ParaClient(accessKey, secretKey, parseEndpoint(endpoint));
|
|
137
137
|
|
|
138
138
|
if (input[0] === 'setup') {
|
|
139
|
-
setup(config);
|
|
139
|
+
await setup(config);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
if (input[0] === 'apps') {
|
|
@@ -221,4 +221,3 @@ if (!input[0]) {
|
|
|
221
221
|
types(pc, config);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|