@hellocoop/quickstart 2.8.9 → 2.8.10-canary.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/README.md CHANGED
@@ -4,7 +4,8 @@ This package starts a local web server and launches the Hellō Quickstart Web Ap
4
4
 
5
5
  ## CLI
6
6
 
7
- If you have Node.js >= v18, you can run Quickstart with:
7
+ If you have Node.js >= v18, you can run Quickstart with:
8
+
8
9
  ```sh
9
10
  npx @hellocoop/quickstart@latest
10
11
  ```
@@ -12,4 +13,3 @@ npx @hellocoop/quickstart@latest
12
13
  This will prompt you to install the package if not already installed. It will then open up a browser window, where you will login with Hellō, and then choose to create a new app, or select an existing one, and then it will return the app's `client_id` to the console.
13
14
 
14
15
  [Quickstart CLI and SDK Documentation](https://www.hello.dev/docs/sdks/quickstart)
15
-
package/express.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // express quickstart
2
2
 
3
- import { statSync, appendFileSync } from 'fs'
4
- import chalk from 'chalk';
3
+ import { statSync, appendFileSync } from 'fs'
4
+ import chalk from 'chalk'
5
5
  import fs from 'fs-extra'
6
- import quickstart from './index.js';
6
+ import quickstart from './index.js'
7
7
  import { randomBytes } from 'crypto'
8
8
 
9
9
  const HELLO_CONFIG_FILE = 'hello.config.js'
@@ -13,25 +13,28 @@ import dotenv from 'dotenv'
13
13
 
14
14
  // TODO check if @hellocoop/express is installed
15
15
 
16
- const writeConfig = async (options,name) => {
17
- const client_id = await quickstart(options)
16
+ const writeConfig = async (options, name) => {
17
+ const client_id = await quickstart(options)
18
18
 
19
- const filePath = process.cwd()+'/'+HELLO_CONFIG_FILE
19
+ const filePath = process.cwd() + '/' + HELLO_CONFIG_FILE
20
20
  try {
21
21
  statSync(filePath)
22
22
  const append = `
23
- // added by @hellocoop/quickstart --${name} on ${(new Date()).toISOString()}
23
+ // added by @hellocoop/quickstart --${name} on ${new Date().toISOString()}
24
24
  config.client_id = '${client_id}'
25
25
  `
26
- appendFileSync( filePath, append)
27
- console.log(`${chalk.greenBright('✓')} Updated ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
26
+ appendFileSync(filePath, append)
27
+ console.log(
28
+ `${chalk.greenBright('✓')} Updated ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`,
29
+ )
28
30
  return
29
31
  } catch (err) {
30
- if (err.code !== 'ENOENT') { // error other than file does not exist
31
- throw(err)
32
+ if (err.code !== 'ENOENT') {
33
+ // error other than file does not exist
34
+ throw err
32
35
  }
33
36
  }
34
- const config =`// ${HELLO_CONFIG_FILE}
37
+ const config = `// ${HELLO_CONFIG_FILE}
35
38
  // see https://hello.dev/docs/sdks/${name}/#configuration for details
36
39
 
37
40
  const config = {
@@ -39,40 +42,44 @@ const config = {
39
42
  }
40
43
  module.exports = config
41
44
  `
42
- fs.outputFileSync( filePath, config)
43
- console.log(`${chalk.greenBright('✓')} Created ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
45
+ fs.outputFileSync(filePath, config)
46
+ console.log(
47
+ `${chalk.greenBright('✓')} Created ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`,
48
+ )
44
49
  }
45
50
 
46
-
47
51
  const writeEnvLocal = async (name) => {
48
-
49
52
  const existingSecret = process.env.HELLO_COOKIE_SECRET
50
53
  if (existingSecret) {
51
- console.log(`${chalk.yellowBright('⚠')} Skipping - HELLO_COOKIE_SECRET already exists`)
54
+ console.log(
55
+ `${chalk.yellowBright('⚠')} Skipping - HELLO_COOKIE_SECRET already exists`,
56
+ )
52
57
  return
53
- }
58
+ }
54
59
 
55
60
  const secret = randomBytes(32).toString('hex')
56
61
  const env = `
57
- # added by @hellocoop/quickstart --${name} on ${(new Date()).toISOString()}
62
+ # added by @hellocoop/quickstart --${name} on ${new Date().toISOString()}
58
63
  HELLO_COOKIE_SECRET='${secret}'
59
64
  `
60
- const outputFile = process.cwd()+'/'+ENV_FILE
61
- appendFileSync(outputFile,env)
62
- console.log(`${chalk.greenBright('✓')} Updated ${ENV_FILE} with HELLO_COOKIE_SECRET ${chalk.blueBright(secret)}`)
65
+ const outputFile = process.cwd() + '/' + ENV_FILE
66
+ appendFileSync(outputFile, env)
67
+ console.log(
68
+ `${chalk.greenBright('✓')} Updated ${ENV_FILE} with HELLO_COOKIE_SECRET ${chalk.blueBright(secret)}`,
69
+ )
63
70
  }
64
71
 
65
72
  const defaultOptions = {
66
73
  integration: 'quickstart-express',
67
74
  suffix: 'Express App',
68
75
  wildcard_domain: true,
69
- provider_hint: 'google github gitlab apple-- email--'
76
+ provider_hint: 'google github gitlab apple-- email--',
70
77
  }
71
78
  const express = async (options, name = 'express') => {
72
79
  dotenv.config()
73
80
  options = { ...defaultOptions, ...options }
74
81
  try {
75
- await writeConfig(options,name)
82
+ await writeConfig(options, name)
76
83
  await writeEnvLocal(name)
77
84
  } catch (e) {
78
85
  console.error(e)
@@ -81,9 +88,3 @@ const express = async (options, name = 'express') => {
81
88
  }
82
89
 
83
90
  export default express
84
-
85
-
86
-
87
-
88
-
89
-
package/fastify.mjs CHANGED
@@ -7,7 +7,7 @@ const defaultOptions = {
7
7
  suffix: ' Fastify App',
8
8
  }
9
9
 
10
- const fastify = async ( options ) => {
10
+ const fastify = async (options) => {
11
11
  await express({ ...defaultOptions, ...options }, 'fastify')
12
12
  }
13
13
 
package/index.js CHANGED
@@ -1,11 +1,10 @@
1
-
2
1
  import open from 'open'
3
2
  import getPort from 'get-port'
4
3
  import readline from 'readline'
5
4
  import * as http from 'http'
6
- import { URLSearchParams, parse } from 'url';
5
+ import { URLSearchParams, parse } from 'url'
7
6
  import page from './page.js'
8
- import chalk from 'chalk';
7
+ import chalk from 'chalk'
9
8
 
10
9
  export const validQuickstartParams = [
11
10
  'suffix',
@@ -21,70 +20,73 @@ export const validQuickstartParams = [
21
20
  ]
22
21
 
23
22
  const quickstart = async function (params) {
24
- return new Promise(async (resolve) => {
23
+ return new Promise((resolve, reject) => {
24
+ async function startServer() {
25
+ if (!process.stdout.isTTY) {
26
+ const error = new Error(
27
+ 'Not running on interactive terminal. Exiting Quickstart CLI',
28
+ )
29
+ console.error(error)
30
+ return reject(error)
31
+ }
25
32
 
26
- if (!process.stdout.isTTY) {
27
- const error = new Error('Not running on interactive terminal. Exiting Quickstart CLI')
28
- console.error(error)
29
- return error
30
- }
31
- const paramKeys = Object.keys(params || {})
32
- if (paramKeys) {
33
- paramKeys.forEach( param => {
34
- if (!validQuickstartParams.includes(param))
35
- throw(new Error(`Invalid param:${param}`))
36
- if (!params[param])
37
- delete params[param]
33
+ const paramKeys = Object.keys(params || {})
34
+ if (paramKeys) {
35
+ paramKeys.forEach((param) => {
36
+ if (!validQuickstartParams.includes(param)) {
37
+ reject(new Error(`Invalid param:${param}`))
38
+ return
39
+ }
40
+ if (!params[param]) delete params[param]
41
+ })
42
+ }
43
+
44
+ const port = await getPort()
45
+ const host = 'localhost'
46
+
47
+ const server = http.createServer((req, res) => {
48
+ const u = parse(req.url, true)
49
+ if (u.pathname !== '/') {
50
+ res.writeHead(200)
51
+ return res.end('ok')
52
+ }
53
+ res.writeHead(200)
54
+
55
+ const clientHTML = page(u.query.client_id)
56
+ res.end(clientHTML, () => {
57
+ server.closeAllConnections()
58
+ server.close(() => {
59
+ resolve(u.query.client_id)
60
+ })
61
+ })
38
62
  })
39
- }
40
-
41
- const port = await getPort()
42
- const host = 'localhost'
43
63
 
44
- const server = http.createServer((req, res) => {
45
- const u = parse(req.url,true)
46
- if (u.pathname != '/') {
47
- res.writeHead(200);
48
- return res.end('ok')
64
+ const response_uri = `http://${host}:${port}/`
65
+ const queryParams = {
66
+ ...params,
67
+ response_uri,
49
68
  }
50
- res.writeHead(200);
69
+ const queryString = new URLSearchParams(queryParams).toString()
70
+ const helloDomain = process.env.HELLO_DOMAIN || 'hello.coop'
71
+ const quickstartURL = `https://quickstart.${helloDomain}/?${queryString}`
72
+ server.listen(port, host, () => {
73
+ console.log('Obtaining a Hellō client_id with:')
74
+ console.log(chalk.blueBright(quickstartURL))
51
75
 
52
- // TBD - check for error response from quickstart.hello.coop
53
-
54
- const clientHTML = page(u.query.client_id)
55
- res.end(clientHTML, () => {
56
- server.closeAllConnections()
57
- server.close(() => {
58
- resolve(u.query.client_id)
59
- })
60
- })
61
- })
76
+ const rl = readline.createInterface({
77
+ input: process.stdin,
78
+ output: process.stdout,
79
+ })
62
80
 
63
- const response_uri = `http://${host}:${port}/`
64
- const queryParams = {
65
- ... params,
66
- response_uri,
81
+ rl.question('Press ENTER to open in the browser...', () => {
82
+ open(quickstartURL)
83
+ rl.close()
84
+ })
85
+ })
67
86
  }
68
- const queryString = new URLSearchParams(queryParams).toString();
69
- const hellooDomain = process.env.HELLO_DOMAIN || 'hello.coop'
70
- const quickstartURL = `https://quickstart.${hellooDomain}/?${queryString}`
71
- server.listen(port, host, () => {
72
- console.log('Obtaining a Hellō client_id with:')
73
- console.log(chalk.blueBright(quickstartURL))
74
- const rl = readline.createInterface({
75
- input: process.stdin,
76
- output: process.stdout
77
- });
78
-
79
- rl.question('Press ENTER to open in the browser...', (answer) => {
80
- open(quickstartURL)
81
- rl.close();
82
- });
83
87
 
84
- })
88
+ startServer().catch(reject)
85
89
  })
86
90
  }
87
91
 
88
- export default quickstart;
89
-
90
-
92
+ export default quickstart
package/next.mjs CHANGED
@@ -1,40 +1,41 @@
1
1
  // next.js quickstart
2
2
 
3
- import semver from 'semver';
4
- import { statSync, appendFileSync } from 'fs'
5
- import chalk from 'chalk';
3
+ import { statSync, appendFileSync } from 'fs'
4
+ import chalk from 'chalk'
6
5
  import fs from 'fs-extra'
7
- import quickstart from './index.js';
6
+ import quickstart from './index.js'
8
7
  import { randomBytes } from 'crypto'
9
8
 
9
+ let HELLO_COOP_FILE
10
10
  const HELLO_CONFIG_FILE = 'hello.config.js'
11
- const HELLO_COOP_FILE = 'pages/api/hellocoop.js'
12
11
  const ENV_FILE = '.env.local'
13
12
 
14
13
  import dotenv from 'dotenv'
15
14
 
16
15
  // check if @hellocoop/nextjs is installed
17
16
 
18
-
19
17
  const writeConfig = async (options) => {
20
- options.wildcard_domain=true
21
- const client_id = await quickstart(options)
22
- const filePath = process.cwd()+'/'+HELLO_CONFIG_FILE
18
+ options.wildcard_domain = true
19
+ const client_id = await quickstart(options)
20
+ const filePath = process.cwd() + '/' + HELLO_CONFIG_FILE
23
21
  try {
24
22
  statSync(filePath)
25
23
  const append = `
26
- // added by @hellocoop/quickstart --nextjs on ${(new Date()).toISOString()}
24
+ // added by @hellocoop/quickstart --nextjs on ${new Date().toISOString()}
27
25
  config.client_id = '${client_id}'
28
26
  `
29
- appendFileSync( filePath, append)
30
- console.log(`${chalk.greenBright('✓')} Updated ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
27
+ appendFileSync(filePath, append)
28
+ console.log(
29
+ `${chalk.greenBright('✓')} Updated ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`,
30
+ )
31
31
  return
32
32
  } catch (err) {
33
- if (err.code !== 'ENOENT') { // error other than file does not exist
34
- throw(err)
33
+ if (err.code !== 'ENOENT') {
34
+ // error other than file does not exist
35
+ throw err
35
36
  }
36
37
  }
37
- const config =`// ${HELLO_CONFIG_FILE}
38
+ const config = `// ${HELLO_CONFIG_FILE}
38
39
  // see https://hello.dev/docs/sdks/nextjs/#configuration for details
39
40
 
40
41
  const config = {
@@ -42,65 +43,83 @@ const config = {
42
43
  }
43
44
  module.exports = config
44
45
  `
45
- fs.outputFileSync( filePath, config)
46
- console.log(`${chalk.greenBright('✓')} Created ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
46
+ fs.outputFileSync(filePath, config)
47
+ console.log(
48
+ `${chalk.greenBright('✓')} Created ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`,
49
+ )
47
50
  }
48
51
 
49
- const writeHelloCoop = async () => {
50
- const filePath = process.cwd()+'/'+HELLO_COOP_FILE
52
+ const writeHelloCoop = async (pagesRouter) => {
53
+ HELLO_COOP_FILE = pagesRouter
54
+ ? 'pages/api/hellocoop.js'
55
+ : 'app/api/hellocoop/router.js'
56
+ const filePath = process.cwd() + '/' + HELLO_COOP_FILE
51
57
  try {
52
- statSync(filePath);
53
- console.log(`${chalk.yellowBright('⚠')} Skipping - ${HELLO_COOP_FILE} already exists`)
58
+ statSync(filePath)
59
+ console.log(
60
+ `${chalk.yellowBright('⚠')} Skipping - ${HELLO_COOP_FILE} already exists`,
61
+ )
54
62
  return
55
63
  } catch (err) {
56
- if (err.code !== 'ENOENT') { // error other than file does not exist
57
- throw(err)
64
+ if (err.code !== 'ENOENT') {
65
+ // error other than file does not exist
66
+ throw err
58
67
  }
59
68
  }
60
69
 
61
- const content = `// ${HELLO_COOP_FILE}
62
- // generated by @hellocoop/quickstart --nextjs on ${(new Date()).toISOString()}
70
+ const content = pagesRouter
71
+ ? `// ${HELLO_COOP_FILE}
72
+ // generated by @hellocoop/quickstart --nextjs on ${new Date().toISOString()}
63
73
  // NOTE: this file should not need to be edited
64
74
  import config from '../../hello.config'
65
75
  import { pageAuth } from '@hellocoop/nextjs'
66
76
  export default pageAuth(config)
67
77
  `
68
- fs.outputFileSync( filePath, content )
78
+ : `// ${HELLO_COOP_FILE}
79
+ // generated by @hellocoop/quickstart --nextjs on ${new Date().toISOString()}
80
+ // NOTE: this file should not need to be edited
81
+ import config from '../../../hello.config'
82
+ import { appAuth } from '@hellocoop/nextjs'
83
+ export const { GET } = appAuth(config)
84
+ `
85
+ fs.outputFileSync(filePath, content)
69
86
  console.log(`${chalk.greenBright('✓')} Created ${HELLO_COOP_FILE}`)
70
-
71
87
  }
72
88
 
73
-
74
89
  const writeEnvLocal = async () => {
75
90
  const existingSecret = process.env.HELLO_COOKIE_SECRET
76
91
  if (existingSecret) {
77
- console.log(`${chalk.yellowBright('⚠')} Skipping - HELLO_COOKIE_SECRET already exists`)
92
+ console.log(
93
+ `${chalk.yellowBright('⚠')} Skipping - HELLO_COOKIE_SECRET already exists`,
94
+ )
78
95
  return
79
- }
96
+ }
80
97
 
81
98
  const secret = randomBytes(32).toString('hex')
82
99
  const env = `
83
- # added by @hellocoop/quickstart --nextjs on ${(new Date()).toISOString()}
100
+ # added by @hellocoop/quickstart --nextjs on ${new Date().toISOString()}
84
101
  HELLO_COOKIE_SECRET='${secret}'
85
102
  `
86
- const outputFile = process.cwd()+'/'+ENV_FILE
87
- appendFileSync(outputFile,env)
88
- console.log(`${chalk.greenBright('✓')} Updated ${ENV_FILE} with HELLO_COOKIE_SECRET ${chalk.blueBright(secret)}`)
103
+ const outputFile = process.cwd() + '/' + ENV_FILE
104
+ appendFileSync(outputFile, env)
105
+ console.log(
106
+ `${chalk.greenBright('✓')} Updated ${ENV_FILE} with HELLO_COOKIE_SECRET ${chalk.blueBright(secret)}`,
107
+ )
89
108
  }
90
109
 
91
110
  const defaultOptions = {
92
111
  integration: 'quickstart-nextjs',
93
112
  suffix: 'Next.js App',
94
113
  wildcard_domain: true,
95
- provider_hint: 'google github gitlab apple-- email--'
114
+ provider_hint: 'google github gitlab apple-- email--',
96
115
  }
97
116
 
98
- const next = async (options) => {
117
+ const next = async (options, pagesRouter) => {
99
118
  dotenv.config({ path: './.env.local' })
100
119
  options = { ...defaultOptions, ...options }
101
120
  try {
102
121
  await writeConfig(options)
103
- await writeHelloCoop()
122
+ await writeHelloCoop(pagesRouter)
104
123
  await writeEnvLocal()
105
124
  } catch (e) {
106
125
  console.error(e)
@@ -109,9 +128,3 @@ const next = async (options) => {
109
128
  }
110
129
 
111
130
  export default next
112
-
113
-
114
-
115
-
116
-
117
-
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
1
  {
2
- "name": "@hellocoop/quickstart",
3
- "version": "2.8.9",
4
- "description": "A CLI and module to start the Hello Quickstart web app and return a client_id",
5
- "main": "index.js",
6
- "bin": {
7
- "quickstart": "quickstart.mjs"
8
- },
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "prebuild": "rimraf dist node_modules",
12
- "build": "echo \"No build specified\" && exit 0"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/hellocoop/packages.git"
17
- },
18
- "keywords": [
19
- "hello",
20
- "oauth",
21
- "oauth2",
22
- "OIDC",
23
- "auth",
24
- "sso",
25
- "quickstart"
26
- ],
27
- "author": {
28
- "name": "Hello Identity Co-op",
29
- "email": "contact@hello.coop",
30
- "url": "https://hello.coop"
31
- },
32
- "license": "MIT",
33
- "bugs": {
34
- "url": "https://github.com/hellocoop/packages/issues"
35
- },
36
- "homepage": "https://www.hello.dev/docs/sdk/quickstart",
37
- "dependencies": {
38
- "chalk": "^5.3.0",
39
- "dotenv": "^16.3.1",
40
- "fs-extra": "^11.1.1",
41
- "get-port": "^7.0.0",
42
- "open": "^9.1.0",
43
- "semver": "^7.6.3"
44
- },
45
- "type": "module",
46
- "engines": {
47
- "node": ">=18.3"
48
- }
2
+ "name": "@hellocoop/quickstart",
3
+ "version": "2.8.10-canary.0",
4
+ "description": "A CLI and module to start the Hello Quickstart web app and return a client_id",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "quickstart": "quickstart.mjs"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "prebuild": "rimraf dist node_modules",
12
+ "build": "echo \"No build specified\" && exit 0"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hellocoop/packages.git"
17
+ },
18
+ "keywords": [
19
+ "hello",
20
+ "oauth",
21
+ "oauth2",
22
+ "OIDC",
23
+ "auth",
24
+ "sso",
25
+ "quickstart"
26
+ ],
27
+ "author": {
28
+ "name": "Hello Identity Co-op",
29
+ "email": "contact@hello.coop",
30
+ "url": "https://hello.coop"
31
+ },
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/hellocoop/packages/issues"
35
+ },
36
+ "homepage": "https://www.hello.dev/docs/sdk/quickstart",
37
+ "dependencies": {
38
+ "chalk": "^5.3.0",
39
+ "dotenv": "^16.3.1",
40
+ "fs-extra": "^11.1.1",
41
+ "get-port": "^7.0.0",
42
+ "open": "^9.1.0",
43
+ "semver": "^7.6.3"
44
+ },
45
+ "type": "module",
46
+ "engines": {
47
+ "node": ">=18.3"
48
+ }
49
49
  }
package/page.js CHANGED
@@ -1,4 +1,4 @@
1
- export default function (client_id) {
1
+ export default function () {
2
2
  return `
3
3
  <!DOCTYPE html>
4
4
  <html lang="en">
@@ -22,4 +22,4 @@ export default function (client_id) {
22
22
  </main>
23
23
  </body>
24
24
  </html>`
25
- }
25
+ }
package/quickstart.mjs CHANGED
@@ -1,75 +1,87 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import semver from 'semver';
3
+ import semver from 'semver'
4
4
  import nextConfig from './next.mjs'
5
5
  import expressConfig from './express.mjs'
6
6
  import fastifyConfig from './fastify.mjs'
7
7
 
8
- const requiredVersion = '>=18.3.0';
8
+ const requiredVersion = '>=18.3.0'
9
9
 
10
10
  if (!semver.satisfies(process.versions.node, requiredVersion)) {
11
- console.error(`This script requires Node.js version ${requiredVersion}`);
12
- process.exit(1);
11
+ console.error(`This script requires Node.js version ${requiredVersion}`)
12
+ process.exit(1)
13
13
  }
14
14
 
15
15
  // following are in Nodejs 18+
16
- import { parseArgs } from "node:util";
16
+ import { parseArgs } from 'node:util'
17
17
 
18
18
  if (!process.stdout.isTTY) {
19
- const error = new Error('Not running on interactive terminal. Exiting Hellō Quickstart.')
19
+ const error = new Error(
20
+ 'Not running on interactive terminal. Exiting Hellō Quickstart.',
21
+ )
20
22
  console.error(error)
21
- process.exit(1);
23
+ process.exit(1)
22
24
  }
23
25
 
24
26
  let {
25
- values: { nextjs, express, fastify, provider_hint, suffix, wildcard_domain, integration },
26
- } = parseArgs({
27
- options: {
28
- nextjs: {
29
- type: "boolean"
30
- },
31
- express: {
32
- type: "boolean"
33
- },
34
- fastify: {
35
- type: "boolean"
36
- },
37
- provider_hint: {
38
- type: "string",
39
- short: "p",
40
- },
41
- suffix: {
42
- type: "string",
43
- short: "x",
27
+ values: {
28
+ nextjs,
29
+ nextjs_app_router,
30
+ nextjs_pages_router,
31
+ express,
32
+ fastify,
33
+ provider_hint,
34
+ suffix,
35
+ wildcard_domain,
36
+ integration,
44
37
  },
45
- integration: {
46
- type: "string",
47
- short: "i",
38
+ } = parseArgs({
39
+ options: {
40
+ nextjs: {
41
+ type: 'boolean',
42
+ },
43
+ nextjs_app_router: {
44
+ type: 'boolean',
45
+ },
46
+ nextjs_pages_router: {
47
+ type: 'boolean',
48
+ },
49
+ express: {
50
+ type: 'boolean',
51
+ },
52
+ fastify: {
53
+ type: 'boolean',
54
+ },
55
+ provider_hint: {
56
+ type: 'string',
57
+ short: 'p',
58
+ },
59
+ suffix: {
60
+ type: 'string',
61
+ short: 'x',
62
+ },
63
+ integration: {
64
+ type: 'string',
65
+ short: 'i',
66
+ },
67
+ wildcard_domain: {
68
+ type: 'boolean',
69
+ short: 'w',
70
+ },
48
71
  },
49
- wildcard_domain: {
50
- type: "boolean",
51
- short: "w",
52
- }
53
- },
54
- });
72
+ })
55
73
 
56
- import quickstart from './index.js';
74
+ import quickstart from './index.js'
57
75
  import dotenv from 'dotenv'
58
76
 
59
77
  const options = {}
60
- if (provider_hint)
61
- options.provider_hint = provider_hint
62
- if (suffix)
63
- options.suffix = suffix
64
- if (integration)
65
- options.integration = integration
66
- if (wildcard_domain)
67
- options.wildcard_domain = wildcard
68
-
78
+ if (provider_hint) options.provider_hint = provider_hint
79
+ if (suffix) options.suffix = suffix
80
+ if (integration) options.integration = integration
81
+ if (wildcard_domain) options.wildcard_domain = wildcard_domain
69
82
  ;(async () => {
70
-
71
- if (nextjs) {
72
- await nextConfig(options)
83
+ if (nextjs || nextjs_app_router || nextjs_pages_router) {
84
+ await nextConfig(options, nextjs_pages_router) // defaults to app router
73
85
  process.exit(0)
74
86
  }
75
87
 
@@ -89,4 +101,4 @@ if (wildcard_domain)
89
101
 
90
102
  const client_id = await quickstart(options)
91
103
  console.log(`client_id=${client_id}`)
92
- })();
104
+ })()