@hellocoop/quickstart 1.0.9 → 1.0.11

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 (2) hide show
  1. package/package.json +14 -9
  2. package/quickstart.js +34 -4
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@hellocoop/quickstart",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Provides a CLI to start the Hello Quickstart web app and return a client_id",
5
- "module": "quickstart.js",
6
- "bin":{
7
- "quickstart":"./index.mjs"
5
+ "main": "quickstart.js",
6
+ "bin": {
7
+ "quickstart": "./index.mjs"
8
8
  },
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "build": "echo \"No build specified\" && exit 0"
11
12
  },
12
13
  "repository": {
13
14
  "type": "git",
14
- "url": "git+https://github.com/hellocoop/hello.git"
15
+ "url": "git+https://github.com/hellocoop/packages.git"
15
16
  },
16
17
  "keywords": [
17
18
  "hello",
@@ -19,12 +20,16 @@
19
20
  "sso",
20
21
  "quickstart"
21
22
  ],
22
- "author": "dick.hardt@hello.coop",
23
+ "author": {
24
+ "name": "Hello Identity Co-op",
25
+ "email": "contact@hello.coop",
26
+ "url": "https://hello.coop"
27
+ },
23
28
  "license": "MIT",
24
29
  "bugs": {
25
- "url": "https://github.com/hellocoop/hello/issues"
30
+ "url": "https://github.com/hellocoop/packages/issues"
26
31
  },
27
- "homepage": "https://github.com/hellocoop/hello#readme",
32
+ "homepage": "https://github.com/hellocoop/packages#readme",
28
33
  "dependencies": {
29
34
  "get-port": "^7.0.0",
30
35
  "open": "^9.1.0"
package/quickstart.js CHANGED
@@ -1,14 +1,36 @@
1
1
 
2
2
  import open from 'open'
3
3
  import getPort from 'get-port'
4
+ import readline from 'readline'
4
5
  import * as http from 'http'
5
6
  import { URLSearchParams, parse } from 'url';
6
7
  import page from './page.js'
7
8
 
9
+ export const validQuickstartParams = [
10
+ 'suffix',
11
+ 'name',
12
+ 'tos_uri',
13
+ 'pp_uri',
14
+ 'image_uri',
15
+ 'dark_image_uri',
16
+ 'redirect_uri',
17
+ 'integration',
18
+ ]
8
19
 
9
20
  const quickstart = async function (params) {
10
21
  return new Promise(async (resolve) => {
11
22
 
23
+ if (!process.stdout.isTTY) {
24
+ const error = new Error('Not running on interactive terminal. Exiting Quickstart CLI')
25
+ console.error(error)
26
+ return error
27
+ }
28
+ const paramKeys = Object.keys(params)
29
+ paramKeys || paramKeys.forEach( param => {
30
+ if (!validQuickstartParams.includes(parm))
31
+ throw(new Error(`Invalid param:${param}`))
32
+ })
33
+
12
34
  const port = await getPort()
13
35
  const host = 'localhost'
14
36
 
@@ -33,16 +55,24 @@ const quickstart = async function (params) {
33
55
 
34
56
  const response_uri = `http://${host}:${port}/`
35
57
  const queryParams = {
36
- // TODO add in passed parameters
58
+ ... params,
37
59
  response_uri,
38
60
  }
39
61
  const queryString = new URLSearchParams(queryParams).toString();
40
62
  const quickstartURL = `https://quickstart.hello.coop/?${queryString}`
41
63
  server.listen(port, host, () => {
42
- console.log('Obtaining a client_id from Hellō Quickstart using')
64
+ console.log('Obtaining a client_id from Hellō Quickstart using:')
43
65
  console.log(quickstartURL)
44
- console.log('Opening browser...')
45
- open(quickstartURL)
66
+ const rl = readline.createInterface({
67
+ input: process.stdin,
68
+ output: process.stdout
69
+ });
70
+
71
+ rl.question('Press ENTER to open in the browser...', (answer) => {
72
+ open(quickstartURL)
73
+ rl.close();
74
+ });
75
+
46
76
  })
47
77
  })
48
78
  }