Skip to content

Commit

Permalink
Fix template erors in create-houdini (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet committed Oct 10, 2023
1 parent f62b3f8 commit 41e9c6c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
19 changes: 13 additions & 6 deletions packages/create-houdini/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if (!projectDir) {

if (dir) {
projectDir = dir
projectName = 'hello-houdini'
projectName = dir
} else {
projectDir = '.'
}
Expand Down Expand Up @@ -175,6 +175,7 @@ copy(
["'CLIENT_CONFIG'"]: clientConfig,
["'CONFIG_FILE'"]: configFile,
},
{ '.meta.gitignore': '.gitignore' },
['.meta.json']
)

Expand Down Expand Up @@ -213,19 +214,24 @@ function copy(
/** @type {string} */ sourceDir,
/** @type {string} */ destDir = projectDir,
/** @type {Record<string, string>} */ transformMap = {},
/** @type {Record<string, string>} */ transformFileMap = {},
/** @type {string[]} */ ignoreList = []
) {
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir)
}

const files = fs.readdirSync(sourceDir)
for (const file of files) {
const sourceFilePath = path.join(sourceDir, file)
for (const fileSource of files) {
const fileDest = Object.entries(transformFileMap).reduce((acc, [key, value]) => {
return acc.replace(key, value)
}, fileSource)
// const file = fileSource.replace(".meta.gitignore", ".gitignore")
const sourceFilePath = path.join(sourceDir, fileSource)
const sourceRelative = path.relative(templateDir, sourceFilePath)
// skip the ignore list
if (!ignoreList.includes(sourceRelative)) {
const destFilePath = path.join(destDir, file)
const destFilePath = path.join(destDir, fileDest)

const stats = fs.statSync(sourceFilePath)

Expand All @@ -247,7 +253,7 @@ function copy(
}
// if we run into a directory then we should keep going
else if (stats.isDirectory()) {
copy(sourceFilePath, destFilePath, transformMap, ignoreList)
copy(sourceFilePath, destFilePath, transformMap, transformFileMap, ignoreList)
}
}
}
Expand Down Expand Up @@ -295,7 +301,8 @@ async function pullSchemaCli() {

url_and_headers = answer.url_and_headers
const value_splited = url_and_headers.split(' ')
const apiUrl = value_splited[0]

apiUrl = value_splited[0]

const local_headers =
value_splited.length > 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// import type { PageProps } from "./$types";
import type { PageProps } from './$types'

// export default function ({}: PageProps) {
export default function () {
export default function ({}: PageProps) {
return (
<div>
<h2>Home</h2>
Expand Down
3 changes: 0 additions & 3 deletions packages/create-houdini/templates/react/src/routes/+page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// import type { PageProps } from "./$types";

// export default function ({}: PageProps) {
export default function () {
return (
<div>
Expand Down

0 comments on commit 41e9c6c

Please sign in to comment.