para-cli 1.19.0 → 1.19.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.
Files changed (3) hide show
  1. package/README.md +30 -6
  2. package/index.js +15 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -17,9 +17,9 @@ This is the command-line tool for interacting with a Para server.
17
17
  ## Installation
18
18
 
19
19
  ```sh
20
- $ npm install -g para-cli
21
- $ para-cli setup
22
- $ para-cli ping
20
+ npm install -g para-cli
21
+ para-cli setup
22
+ para-cli ping
23
23
  ```
24
24
 
25
25
  ## Usage
@@ -41,6 +41,7 @@ $ para-cli ping
41
41
  setup Initial setup, prompts you to enter your Para API keys and endpoint
42
42
  apps Returns a list of all Para apps
43
43
  select <appid> Selects a Para app as a target for all subsequent read/write requests.
44
+ endpoints [add|remove] List and select Para server endpoints, add new or remove an exiting one.
44
45
  create <file|glob> [--id] [--type] Persists files as Para objects and makes them searchable
45
46
  read --id 123 [--id 345 ...] Fetches objects with the given ids
46
47
  update <file.json|glob> ... Updates Para objects with the data from a JSON file (must contain id field)
@@ -83,6 +84,9 @@ $ para-cli ping
83
84
  $ para-cli search "*" --type article --page all
84
85
  $ para-cli new-key
85
86
  $ para-cli new-app "mynewapp" --name "Full app name"
87
+ $ para-cli apps
88
+ $ para-cli select scoold
89
+ $ para-cli endpoints
86
90
 
87
91
  ```
88
92
 
@@ -95,7 +99,7 @@ The plan is to add more functionality in the near future.
95
99
 
96
100
  **Quick start:**
97
101
  ```
98
- $ para-cli setup
102
+ para-cli setup
99
103
  ```
100
104
 
101
105
  The configuration file is located in `~/.config/para-cli-nodejs/config.json` and contains the keys used to authenticate
@@ -115,12 +119,32 @@ Here's an example `config.json` file:
115
119
  Once configured you can test your connection to the server:
116
120
 
117
121
  ```
118
- $ para-cli ping
122
+ para-cli ping
119
123
  ```
120
124
 
121
125
  To get the currently authenticated app/user object run:
122
126
  ```
123
- $ para-cli me
127
+ para-cli me
128
+ ```
129
+
130
+ ## Switching between apps and endpoints
131
+
132
+ Para CLI can be configured to work with multiple Para servers and apps. Here's how to add additional Para server endpoints:
133
+ ```
134
+ para-cli endpoints add
135
+ ```
136
+ To select a specific endpoint run:
137
+ ```
138
+ para-cli endpoints
139
+ ```
140
+
141
+ After selecting the Para server you wish to connect to, you can list and select apps within it:
142
+ ```
143
+ para-cli apps
144
+ ```
145
+ Select the 'scoold' app, for example:
146
+ ```
147
+ para-cli select scoold
124
148
  ```
125
149
 
126
150
  ## Para Docs
package/index.js CHANGED
@@ -38,6 +38,7 @@ import { globbySync } from 'globby';
38
38
  import chalk from 'chalk';
39
39
  import { Promise } from 'rsvp';
40
40
  import apiClient from 'superagent';
41
+ import { URL } from 'url';
41
42
  import { ParaClient, ParaObject, Pager } from 'para-client-js';
42
43
 
43
44
  const { cyan, red, yellow, green } = chalk;
@@ -516,6 +517,11 @@ export function addEndpoint(config) {
516
517
  output: process.stdout
517
518
  });
518
519
  rl.question(cyan.bold('Para Endpoint: '), function (endpoint) {
520
+ if (!isValidUrl(endpoint)) {
521
+ fail('Endpoint must be a valid URL.');
522
+ rl.close();
523
+ return;
524
+ }
519
525
  rl.question(cyan.bold('Para Secret Key (for root app app:para): '), function (secretKey) {
520
526
  var pc = new ParaClient("app:para", secretKey, {endpoint: endpoint});
521
527
  var endpoints = config.get('endpoints') || [];
@@ -716,6 +722,15 @@ function parseHTML(file) {
716
722
  };
717
723
  }
718
724
 
725
+ function isValidUrl(url) {
726
+ try {
727
+ new URL(url);
728
+ return true;
729
+ } catch (err) {
730
+ return false;
731
+ }
732
+ }
733
+
719
734
  function readFile(filePath) {
720
735
  return readFileSync(filePath, { encoding: 'utf8' });
721
736
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "para-cli",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Command-line tool for Para backend servers",
6
6
  "homepage": "https://paraio.org",
@@ -39,7 +39,7 @@
39
39
  "jsonwebtoken": "^8.5.1",
40
40
  "meow": "^11.0.0",
41
41
  "mime-types": "^2.1.35",
42
- "para-client-js": "^1.37.14",
42
+ "para-client-js": "^1.38.0",
43
43
  "resolve": "^1.22.1",
44
44
  "striptags": "^3.2.0",
45
45
  "update-notifier": "^6.0.2",