create-houdini 1.2.25 → 1.2.27

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 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, green, grey, italic, white } from 'kleur/colors'
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 = await p.select({
82
- message: 'Which template do you want to use?',
83
- initialValue: 'react-typescript',
84
- options,
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
- template !== 'sveltekit-demo' &&
99
- (await p.confirm({
100
- message: 'Is your api going to be defined in this project too?',
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 fiiles to copy
181
+ // if we have a local schema then we have more files to copy
157
182
  if (localSchema) {
158
- if (template === 'react') {
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.25",
3
+ "version": "1.2.27",
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
- "kleur": "^4.1.5",
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",
@@ -0,0 +1,8 @@
1
+ projects:
2
+ default:
3
+ schema:
4
+ - ./$houdini/graphql/schema.graphql
5
+ documents:
6
+ - '**/*.gql'
7
+ - '**/*.jsx'
8
+ - ./$houdini/graphql/documents.gql
@@ -13,7 +13,6 @@
13
13
  "houdini-react": "^HOUDINI_VERSION",
14
14
  "react": "^18.2.0",
15
15
  "react-dom": "^18.2.0",
16
- "react-streaming": "^0.3.14",
17
16
  "graphql-yoga": "4.0.4",
18
17
  "graphql": "15.8.0",
19
18
  "@whatwg-node/server": "^0.9.14"
@@ -0,0 +1,8 @@
1
+ projects:
2
+ default:
3
+ schema:
4
+ - ./$houdini/graphql/schema.graphql
5
+ documents:
6
+ - '**/*.gql'
7
+ - '**/*.tsx'
8
+ - ./$houdini/graphql/documents.gql
@@ -13,7 +13,6 @@
13
13
  "houdini-react": "^HOUDINI_VERSION",
14
14
  "react": "^18.2.0",
15
15
  "react-dom": "^18.2.0",
16
- "react-streaming": "^0.3.14",
17
16
  "graphql-yoga": "4.0.4",
18
17
  "graphql": "15.8.0",
19
18
  "@whatwg-node/server": "^0.9.14"
@@ -15,7 +15,7 @@
15
15
  "test:unit": "vitest"
16
16
  },
17
17
  "devDependencies": {
18
- "@playwright/test": "^1.28.1",
18
+ "@playwright/test": "1.30.0",
19
19
  "@sveltejs/adapter-auto": "^2.0.0",
20
20
  "@sveltejs/kit": "^1.20.4",
21
21
  "@typescript-eslint/eslint-plugin": "^5.45.0",
@@ -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 SvelteKit' })).toBeVisible();
5
+ await expect(page.getByRole('heading', { name: 'Welcome to Houdini 🎩' })).toBeVisible();
6
6
  });