Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix init script using incorrect houdini-svelte version #1376

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 2 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,8 @@ jobs:
- name: Build packages
run: cd houdini && pnpm run compile

- name: Checkout template
uses: actions/checkout@v4
with:
repository: sveltejs/kit
path: kit

- name: Extract Template
run: mv kit/packages/create-svelte/templates/default project
- name: Create template project
run: pnpm dlx sv create project --check-types none --template demo --no-integrations --no-install

- name: Run init
run: cd project && node ../houdini/packages/houdini/build/cmd-esm/index.js init -y
Expand Down
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
Loading