Skip to content

Commit

Permalink
Fix init script using incorrect houdini-svelte version
Browse files Browse the repository at this point in the history
  • Loading branch information
SeppahBaws committed Oct 23, 2024
1 parent 03ede8e commit d0ffd78
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-melons-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

Fix init script using incorrect version for houdini-svelte plugin
26 changes: 19 additions & 7 deletions packages/_scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ export default async function ({ plugin }) {
delete package_json['bin']
delete package_json['types']

// We also need to pull in the versions of our other packages.
const packages = {}
for (const dirname of await fs.readdir(path.dirname(process.cwd()))) {
packages[dirname] = JSON.parse(
await fs.readFile(
path.join(path.dirname(process.cwd()), dirname, 'package.json'),
'utf-8'
)
)
}

// look at every directory in the source
for (const dirname of await fs.readdir(src_dir)) {
const dir = path.join(src_dir, dirname)
Expand All @@ -34,7 +45,7 @@ export default async function ({ plugin }) {

// plugins get bundled
if (dirname === 'plugin') {
await build({ package_json, source: dir, plugin })
await build({ packages, source: dir, plugin })
// when there's a plugin directory, that is the main entry point
package_json.main = './build/plugin-cjs/index.js'
package_json.exports['.'] = {
Expand All @@ -47,7 +58,7 @@ export default async function ({ plugin }) {

// lib defines the main entry point
else if (dirname === 'lib') {
await build({ package_json, source: dir, plugin })
await build({ packages, source: dir, plugin })
// when there's a plugin directory, that is the main entry point
package_json.main = `./build/${dirname}-cjs/index.js`
package_json.exports[`.`] = {
Expand All @@ -59,18 +70,18 @@ export default async function ({ plugin }) {
}
// runtimes can't be bundled
else if (dirname === 'runtime') {
await build({ package_json, source: dir, bundle: false, plugin })
await build({ packages, source: dir, bundle: false, plugin })
}
// cmd needs to be bundled and set as the project's bin
else if (dirname === 'cmd') {
package_json.bin = './build/cmd-esm/index.js'
await build({ package_json, source: dir, plugin, bundle: true, cmd: true })
await build({ packages, source: dir, plugin, bundle: true, cmd: true })
}

// its not a special directory, treat it as a sub module
else {
await build({
package_json,
packages,
source: dir,
plugin,
bundle: dirname !== 'server' && dirname !== 'streaming',
Expand All @@ -92,7 +103,7 @@ export default async function ({ plugin }) {
}

// create esm and cjs builds of the source
async function build({ package_json, source, bundle = true, plugin, cmd }) {
async function build({ packages, source, bundle = true, plugin, cmd }) {
// if we aren't bundling, look up the entrypoints once
const children = bundle
? []
Expand Down Expand Up @@ -132,7 +143,8 @@ async function build({ package_json, source, bundle = true, plugin, cmd }) {
},
plugins: [
replace({
PACKAGE_VERSION: package_json.version,
HOUDINI_PACKAGE_VERSION: packages.houdini.version,
HOUDINI_SVELTE_PACKAGE_VERSION: packages['houdini-svelte'].version,
}),
],
}
Expand Down
4 changes: 2 additions & 2 deletions packages/houdini/src/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,13 @@ async function packageJSON(targetPath: string, frameworkInfo: HoudiniFrameworkIn
// houdini should be a dev dependencies
packageJSON.devDependencies = {
...packageJSON.devDependencies,
houdini: '^PACKAGE_VERSION',
houdini: '^HOUDINI_PACKAGE_VERSION',
}

if (frameworkInfo.framework === 'svelte' || frameworkInfo.framework === 'kit') {
packageJSON.devDependencies = {
...packageJSON.devDependencies,
'houdini-svelte': '^PACKAGE_VERSION',
'houdini-svelte': '^HOUDINI_SVELTE_PACKAGE_VERSION',
}
} else {
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`)
Expand Down

0 comments on commit d0ffd78

Please sign in to comment.