@hellocoop/quickstart 2.5.3 → 2.5.4
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 +2 -2
- package/next.mjs +22 -24
- package/package.json +1 -1
- package/quickstart.mjs +4 -2
package/index.js
CHANGED
|
@@ -67,14 +67,14 @@ const quickstart = async function (params) {
|
|
|
67
67
|
const hellooDomain = process.env.HELLO_DOMAIN || 'hello.coop'
|
|
68
68
|
const quickstartURL = `https://quickstart.${hellooDomain}/?${queryString}`
|
|
69
69
|
server.listen(port, host, () => {
|
|
70
|
-
console.log('
|
|
70
|
+
console.log('Obtaining a Hellō client_id with:')
|
|
71
71
|
console.log(chalk.blueBright(quickstartURL))
|
|
72
72
|
const rl = readline.createInterface({
|
|
73
73
|
input: process.stdin,
|
|
74
74
|
output: process.stdout
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
rl.question('
|
|
77
|
+
rl.question('Press ENTER to open in the browser...', (answer) => {
|
|
78
78
|
open(quickstartURL)
|
|
79
79
|
rl.close();
|
|
80
80
|
});
|
package/next.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import semver from 'semver';
|
|
|
4
4
|
import { statSync, appendFileSync } from 'fs'
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import fs from 'fs-extra'
|
|
7
|
-
import 'dotenv/config'
|
|
8
7
|
import quickstart from './index.js';
|
|
9
8
|
import { randomBytes } from 'crypto'
|
|
10
9
|
|
|
@@ -12,6 +11,13 @@ const HELLO_CONFIG_FILE = 'hello.config.ts'
|
|
|
12
11
|
const HELLO_COOP_FILE = 'pages/api/hellocoop.ts'
|
|
13
12
|
const ENV_FILE = '.env.local'
|
|
14
13
|
|
|
14
|
+
import dotenv from 'dotenv'
|
|
15
|
+
dotenv.config({ path: './.env.local' })
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
console.log('domain',process.env.HELLO_DOMAIN)
|
|
19
|
+
console.log('secret',process.env.HELLO_COOKIE_SECRET)
|
|
20
|
+
|
|
15
21
|
// check if @hellocoop/nextjs is installed
|
|
16
22
|
|
|
17
23
|
|
|
@@ -26,64 +32,55 @@ const writeConfig = async (options) => {
|
|
|
26
32
|
config.client_id = '${client_id}'
|
|
27
33
|
`
|
|
28
34
|
appendFileSync( filePath, append)
|
|
29
|
-
console.log(
|
|
30
|
-
console.log(chalk.blueBright(append))
|
|
35
|
+
console.log(`${chalk.greenBright('✓')} Updated ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
|
|
31
36
|
return
|
|
32
37
|
} catch (err) {
|
|
33
|
-
if (err.code !== 'ENOENT') { // file does not exist
|
|
38
|
+
if (err.code !== 'ENOENT') { // error other than file does not exist
|
|
34
39
|
throw(err)
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
const config =`// ${HELLO_CONFIG_FILE}
|
|
38
|
-
|
|
43
|
+
// see https://hello.dev/docs/sdks/nextjs/#configuration for details
|
|
44
|
+
import type { Config } from '@hellocoop/nextjs'
|
|
39
45
|
|
|
40
46
|
const config = {
|
|
41
47
|
client_id: '${client_id}',
|
|
42
|
-
// see https://hello.dev/docs/sdks/nextjs/#configuration for details
|
|
43
|
-
// scope:[]
|
|
44
|
-
// provider_hint:[]
|
|
45
48
|
}
|
|
46
49
|
export default config
|
|
47
50
|
`
|
|
48
51
|
fs.outputFileSync( filePath, config)
|
|
49
|
-
console.log(
|
|
50
|
-
// console.log(
|
|
51
|
-
// `You can update the:
|
|
52
|
-
// - Application Logo
|
|
53
|
-
// - Application Name
|
|
54
|
-
// - Terms of Service URL
|
|
55
|
-
// - Privacy Policy URL
|
|
56
|
-
// - Redirect URIs
|
|
57
|
-
// at the Hellō Developer Console https://console.hello.coop`)
|
|
52
|
+
console.log(`${chalk.greenBright('✓')} Created ${HELLO_CONFIG_FILE} with client_id ${chalk.blueBright(client_id)}`)
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
const writeHelloCoop = async () => {
|
|
61
56
|
const filePath = process.cwd()+'/'+HELLO_COOP_FILE
|
|
62
57
|
try {
|
|
63
58
|
statSync(filePath);
|
|
64
|
-
console.
|
|
59
|
+
console.log(`${chalk.yellowBright('⚠')} Skipping - ${HELLO_COOP_FILE} already exists`)
|
|
65
60
|
return
|
|
66
61
|
} catch (err) {
|
|
67
|
-
if (err.code !== 'ENOENT') { // file does not exist
|
|
62
|
+
if (err.code !== 'ENOENT') { // error other than file does not exist
|
|
68
63
|
throw(err)
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
const content = `// ${HELLO_COOP_FILE}
|
|
73
68
|
// generated by @hellocoop/quickstart --nextjs on ${(new Date()).toISOString()}
|
|
74
|
-
// this file should not need to be edited
|
|
69
|
+
// NOTE: this file should not need to be edited
|
|
75
70
|
import config from '../../hello.config'
|
|
76
71
|
import { pageAuth } from '@hellocoop/nextjs'
|
|
77
72
|
export default pageAuth(config)
|
|
78
73
|
`
|
|
79
74
|
fs.outputFileSync( filePath, content )
|
|
75
|
+
console.log(`${chalk.greenBright('✓')} Created ${HELLO_COOP_FILE}`)
|
|
76
|
+
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
|
|
83
80
|
const writeEnvLocal = async () => {
|
|
84
81
|
const existingSecret = process.env.HELLO_COOKIE_SECRET
|
|
85
82
|
if (existingSecret) {
|
|
86
|
-
console.
|
|
83
|
+
console.log(`${chalk.yellowBright('⚠')} Skipping - HELLO_COOKIE_SECRET already exists`)
|
|
87
84
|
return
|
|
88
85
|
}
|
|
89
86
|
|
|
@@ -94,15 +91,16 @@ HELLO_COOKIE_SECRET='${secret}'
|
|
|
94
91
|
`
|
|
95
92
|
const outputFile = process.cwd()+'/'+ENV_FILE
|
|
96
93
|
appendFileSync(outputFile,env)
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(chalk.blueBright(env))
|
|
94
|
+
console.log(`${chalk.greenBright('✓')} Updated ${ENV_FILE} with HELLO_COOKIE_SECRET ${chalk.blueBright(secret)}`)
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
const next = async (options) => {
|
|
98
|
+
if (!options.provider_hint)
|
|
99
|
+
options.provider_hint = 'google github gitlab apple-- email--'
|
|
102
100
|
try {
|
|
101
|
+
await writeConfig(options)
|
|
103
102
|
await writeHelloCoop()
|
|
104
103
|
await writeEnvLocal()
|
|
105
|
-
await writeConfig(options)
|
|
106
104
|
} catch (e) {
|
|
107
105
|
console.error(e)
|
|
108
106
|
process.exit(1)
|
package/package.json
CHANGED
package/quickstart.mjs
CHANGED
|
@@ -20,7 +20,7 @@ if (!process.stdout.isTTY) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
let {
|
|
23
|
-
values: { nextjs, provider_hint, suffix,
|
|
23
|
+
values: { nextjs, provider_hint, suffix, wildcard, integration },
|
|
24
24
|
} = parseArgs({
|
|
25
25
|
options: {
|
|
26
26
|
nextjs: {
|
|
@@ -48,8 +48,8 @@ let {
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
import 'dotenv/config'
|
|
52
51
|
import quickstart from './index.js';
|
|
52
|
+
import dotenv from 'dotenv'
|
|
53
53
|
|
|
54
54
|
(async () => {
|
|
55
55
|
|
|
@@ -58,6 +58,8 @@ import quickstart from './index.js';
|
|
|
58
58
|
process.exit(0)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
dotenv.config() // .env
|
|
62
|
+
|
|
61
63
|
const options = {}
|
|
62
64
|
if (provider_hint)
|
|
63
65
|
options.provider_hint = provider_hint
|