From d0ffd784124587a59d410e1469a97322bc203b63 Mon Sep 17 00:00:00 2001 From: Seppe Dekeyser Date: Wed, 23 Oct 2024 23:02:21 +0200 Subject: [PATCH 1/2] Fix init script using incorrect houdini-svelte version --- .changeset/thirty-melons-hug.md | 5 +++++ packages/_scripts/build.js | 26 +++++++++++++++++++------- packages/houdini/src/cmd/init.ts | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .changeset/thirty-melons-hug.md diff --git a/.changeset/thirty-melons-hug.md b/.changeset/thirty-melons-hug.md new file mode 100644 index 0000000000..512c32bef6 --- /dev/null +++ b/.changeset/thirty-melons-hug.md @@ -0,0 +1,5 @@ +--- +'houdini': patch +--- + +Fix init script using incorrect version for houdini-svelte plugin diff --git a/packages/_scripts/build.js b/packages/_scripts/build.js index 70b568e65a..4a10c6c8e9 100644 --- a/packages/_scripts/build.js +++ b/packages/_scripts/build.js @@ -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) @@ -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['.'] = { @@ -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[`.`] = { @@ -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', @@ -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 ? [] @@ -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, }), ], } diff --git a/packages/houdini/src/cmd/init.ts b/packages/houdini/src/cmd/init.ts index 2275b819b9..a596b55437 100644 --- a/packages/houdini/src/cmd/init.ts +++ b/packages/houdini/src/cmd/init.ts @@ -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)}"`) From 03578685016443c8383309b9440b0c873a0a4280 Mon Sep 17 00:00:00 2001 From: Seppe Dekeyser Date: Wed, 23 Oct 2024 23:21:19 +0200 Subject: [PATCH 2/2] Update verify_init to use sv to create a template project --- .github/workflows/tests.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c82636a5b5..6b9df21c2f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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