create-houdini 1.2.24 → 1.2.26
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/bin.js +39 -18
- package/package.json +4 -3
- package/templates/react/.graphqlrc.yaml +8 -0
- package/templates/react/package.json +0 -1
- package/templates/react-typescript/.graphqlrc.yaml +8 -0
- package/templates/react-typescript/package.json +0 -1
- package/templates/sveltekit-demo/package.json +1 -1
- package/templates/sveltekit-demo/tests/test.ts +1 -1
- /package/fragments/{localApi → localSchema/react}/src/api/+schema.js +0 -0
- /package/fragments/{localApi-typescript → localSchema/react-typescript}/src/api/+schema.ts +0 -0
package/bin.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as p from '@clack/prompts'
|
|
3
|
+
import { program, Option, InvalidArgumentError } from 'commander'
|
|
3
4
|
import * as graphql from 'graphql'
|
|
4
|
-
import { bold, cyan, gray,
|
|
5
|
+
import { bold, cyan, gray, grey, italic, white } from 'kleur/colors'
|
|
5
6
|
import fs, { readFileSync, writeFileSync } from 'node:fs'
|
|
6
7
|
import path from 'node:path'
|
|
7
8
|
import { exit } from 'node:process'
|
|
@@ -28,6 +29,24 @@ const options = fs.readdirSync(templatesDir).map((templateDir) => {
|
|
|
28
29
|
return { ...data, value: templateDir }
|
|
29
30
|
})
|
|
30
31
|
|
|
32
|
+
program.argument('[project_name]', 'optional project name')
|
|
33
|
+
program.addOption(
|
|
34
|
+
new Option('-t, --template <template>', 'template you want to use').choices(
|
|
35
|
+
options.map((c) => c.value)
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
program.addOption(
|
|
39
|
+
new Option('-s, --schema <schema>', '"local" or "http..."').argParser((value) => {
|
|
40
|
+
if (value === 'local' || value.startsWith('http')) {
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
throw new InvalidArgumentError('Should be "local" or "http..." or do not set it!')
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
program.parse(process.argv)
|
|
48
|
+
const options_cli = program.opts()
|
|
49
|
+
|
|
31
50
|
p.intro('🎩 Welcome to Houdini!')
|
|
32
51
|
|
|
33
52
|
// if we weren't given a directory, then we should ask
|
|
@@ -78,11 +97,13 @@ if (dirToCreate && !fs.existsSync(projectDir)) {
|
|
|
78
97
|
fs.mkdirSync(projectDir)
|
|
79
98
|
}
|
|
80
99
|
|
|
81
|
-
const template =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
const template = options_cli.template
|
|
101
|
+
? options_cli.template
|
|
102
|
+
: await p.select({
|
|
103
|
+
message: 'Which template do you want to use?',
|
|
104
|
+
initialValue: 'react-typescript',
|
|
105
|
+
options,
|
|
106
|
+
})
|
|
86
107
|
if (p.isCancel(template)) {
|
|
87
108
|
process.exit(1)
|
|
88
109
|
}
|
|
@@ -94,14 +115,18 @@ if (!templateMeta) {
|
|
|
94
115
|
}
|
|
95
116
|
|
|
96
117
|
// ask if the schema is local or remote
|
|
97
|
-
const localSchema =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
const localSchema = templateMeta.apiUrl
|
|
119
|
+
? false
|
|
120
|
+
: options_cli.schema === 'local'
|
|
121
|
+
? true
|
|
122
|
+
: options_cli.schema?.startsWith('http')
|
|
123
|
+
? false
|
|
124
|
+
: await p.confirm({
|
|
125
|
+
message: 'Is your api going to be defined in this project too?',
|
|
126
|
+
})
|
|
102
127
|
|
|
103
128
|
// if we have a remote schema then we need to introspect it and write the value
|
|
104
|
-
let apiUrl = templateMeta.apiUrl ?? ''
|
|
129
|
+
let apiUrl = options_cli.schema?.startsWith('http') ? options_cli.schema : templateMeta.apiUrl ?? ''
|
|
105
130
|
if (!localSchema) {
|
|
106
131
|
let pullSchema_content = ''
|
|
107
132
|
if (apiUrl === '') {
|
|
@@ -153,13 +178,9 @@ copy(
|
|
|
153
178
|
['.meta.json']
|
|
154
179
|
)
|
|
155
180
|
|
|
156
|
-
// if we have a local schema then we have more
|
|
181
|
+
// if we have a local schema then we have more files to copy
|
|
157
182
|
if (localSchema) {
|
|
158
|
-
|
|
159
|
-
copy(sourcePath('./fragments/localApi'))
|
|
160
|
-
} else if (template === 'react-typescript') {
|
|
161
|
-
copy(sourcePath('./fragments/localApi-typescript'))
|
|
162
|
-
}
|
|
183
|
+
copy(sourcePath('./fragments/localSchema/' + template))
|
|
163
184
|
}
|
|
164
185
|
|
|
165
186
|
// If anything goes wrong, we don't want to block the user
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-houdini",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.26",
|
|
4
4
|
"description": "A CLI for creating new Houdini projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
"bin": "./bin.js",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@clack/prompts": "^0.6.3",
|
|
15
|
-
"
|
|
16
|
-
"graphql": "16.8.0"
|
|
15
|
+
"commander": "^9.4.0",
|
|
16
|
+
"graphql": "16.8.0",
|
|
17
|
+
"kleur": "^4.1.5"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@types/node": "^18.7.23",
|
|
@@ -2,5 +2,5 @@ import { expect, test } from '@playwright/test';
|
|
|
2
2
|
|
|
3
3
|
test('index page has expected h1', async ({ page }) => {
|
|
4
4
|
await page.goto('/');
|
|
5
|
-
await expect(page.getByRole('heading', { name: 'Welcome to
|
|
5
|
+
await expect(page.getByRole('heading', { name: 'Welcome to Houdini 🎩' })).toBeVisible();
|
|
6
6
|
});
|
|
File without changes
|
|
File without changes
|