From 622551f6472c1b10f3818269b478330674abb9b7 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Wed, 16 Oct 2024 16:37:27 +0200 Subject: [PATCH] use bash script --- .../test-applications/nuxt-3/copyIITM.bash | 7 +++ .../test-applications/nuxt-3/copyIITM.mjs | 52 ------------------- .../test-applications/nuxt-3/package.json | 2 +- .../test-applications/nuxt-4/copyIITM.bash | 7 +++ .../test-applications/nuxt-4/copyIITM.mjs | 52 ------------------- .../test-applications/nuxt-4/package.json | 2 +- 6 files changed, 16 insertions(+), 106 deletions(-) create mode 100644 dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.bash delete mode 100644 dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.mjs create mode 100644 dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.bash delete mode 100644 dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.mjs diff --git a/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.bash b/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.bash new file mode 100644 index 000000000000..0e04d001c968 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.bash @@ -0,0 +1,7 @@ +# This script copies the `import-in-the-middle` content of the E2E test project root `node_modules` to the build output `node_modules` +# For some reason, some files are missing in the output (like `hook.mjs`) and this is not reproducible in external, standalone projects. +# +# Things we tried (that did not fix the problem): +# - Adding a resolution for `@vercel/nft` v0.27.0 (this worked in the standalone project) +# - Also adding `@vercel/nft` v0.27.0 to pnpm `peerDependencyRules` +cp -r node_modules/.pnpm/import-in-the-middle@1.*/node_modules/import-in-the-middle .output/server/node_modules/import-in-the-middle diff --git a/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.mjs b/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.mjs deleted file mode 100644 index d1c75e337710..000000000000 --- a/dev-packages/e2e-tests/test-applications/nuxt-3/copyIITM.mjs +++ /dev/null @@ -1,52 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -/* This script copies the `import-in-the-middle` content of the E2E test project root `node_modules` to the build output `node_modules` - For some reason, some files are missing in the output (like `hook.mjs`) and this is not reproducible in external, standalone projects. - - Things we tried (that did not fix the problem): - - Adding a resolution for `@vercel/nft` v0.27.0 (this worked in the standalone project) - - Also adding `@vercel/nft` v0.27.0 to pnpm `peerDependencyRules` - */ -function copyFolderSync(src, dest) { - if (!fs.existsSync(dest)) { - fs.mkdirSync(dest, { recursive: true }); - } - - const entries = fs.readdirSync(src, { withFileTypes: true }); - - for (let entry of entries) { - const srcPath = path.join(src, entry.name); - const destPath = path.join(dest, entry.name); - - if (entry.isDirectory()) { - copyFolderSync(srcPath, destPath); - } else { - fs.copyFileSync(srcPath, destPath); - } - } -} - -function getSourceFolder() { - const specificVersionFolder = `node_modules${path.sep}.pnpm${path.sep}import-in-the-middle@1.11.2${path.sep}node_modules${path.sep}import-in-the-middle`; - - if (fs.existsSync(specificVersionFolder)) { - return specificVersionFolder; - } - - const parentFolder = `node_modules${path.sep}.pnpm`; - const folders = fs.readdirSync(parentFolder, { withFileTypes: true }); - - for (let folder of folders) { - if (folder.isDirectory() && folder.name.startsWith('import-in-the-middle@')) { - return path.join(parentFolder, folder.name, 'node_modules', 'import-in-the-middle'); - } - } - - throw new Error('No suitable import-in-the-middle folder found'); -} - -const sourceFolder = getSourceFolder(); -const destinationFolder = `.output${path.sep}server${path.sep}node_modules${path.sep}import-in-the-middle`; - -copyFolderSync(sourceFolder, destinationFolder); diff --git a/dev-packages/e2e-tests/test-applications/nuxt-3/package.json b/dev-packages/e2e-tests/test-applications/nuxt-3/package.json index 410a01530b6e..079beb8bfc86 100644 --- a/dev-packages/e2e-tests/test-applications/nuxt-3/package.json +++ b/dev-packages/e2e-tests/test-applications/nuxt-3/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "build": "nuxt build && node ./copyIITM.mjs", + "build": "nuxt build && bash ./copyIITM.bash", "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.bash b/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.bash new file mode 100644 index 000000000000..0e04d001c968 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.bash @@ -0,0 +1,7 @@ +# This script copies the `import-in-the-middle` content of the E2E test project root `node_modules` to the build output `node_modules` +# For some reason, some files are missing in the output (like `hook.mjs`) and this is not reproducible in external, standalone projects. +# +# Things we tried (that did not fix the problem): +# - Adding a resolution for `@vercel/nft` v0.27.0 (this worked in the standalone project) +# - Also adding `@vercel/nft` v0.27.0 to pnpm `peerDependencyRules` +cp -r node_modules/.pnpm/import-in-the-middle@1.*/node_modules/import-in-the-middle .output/server/node_modules/import-in-the-middle diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.mjs b/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.mjs deleted file mode 100644 index d1c75e337710..000000000000 --- a/dev-packages/e2e-tests/test-applications/nuxt-4/copyIITM.mjs +++ /dev/null @@ -1,52 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -/* This script copies the `import-in-the-middle` content of the E2E test project root `node_modules` to the build output `node_modules` - For some reason, some files are missing in the output (like `hook.mjs`) and this is not reproducible in external, standalone projects. - - Things we tried (that did not fix the problem): - - Adding a resolution for `@vercel/nft` v0.27.0 (this worked in the standalone project) - - Also adding `@vercel/nft` v0.27.0 to pnpm `peerDependencyRules` - */ -function copyFolderSync(src, dest) { - if (!fs.existsSync(dest)) { - fs.mkdirSync(dest, { recursive: true }); - } - - const entries = fs.readdirSync(src, { withFileTypes: true }); - - for (let entry of entries) { - const srcPath = path.join(src, entry.name); - const destPath = path.join(dest, entry.name); - - if (entry.isDirectory()) { - copyFolderSync(srcPath, destPath); - } else { - fs.copyFileSync(srcPath, destPath); - } - } -} - -function getSourceFolder() { - const specificVersionFolder = `node_modules${path.sep}.pnpm${path.sep}import-in-the-middle@1.11.2${path.sep}node_modules${path.sep}import-in-the-middle`; - - if (fs.existsSync(specificVersionFolder)) { - return specificVersionFolder; - } - - const parentFolder = `node_modules${path.sep}.pnpm`; - const folders = fs.readdirSync(parentFolder, { withFileTypes: true }); - - for (let folder of folders) { - if (folder.isDirectory() && folder.name.startsWith('import-in-the-middle@')) { - return path.join(parentFolder, folder.name, 'node_modules', 'import-in-the-middle'); - } - } - - throw new Error('No suitable import-in-the-middle folder found'); -} - -const sourceFolder = getSourceFolder(); -const destinationFolder = `.output${path.sep}server${path.sep}node_modules${path.sep}import-in-the-middle`; - -copyFolderSync(sourceFolder, destinationFolder); diff --git a/dev-packages/e2e-tests/test-applications/nuxt-4/package.json b/dev-packages/e2e-tests/test-applications/nuxt-4/package.json index 2dac1b6af20f..5e7bcd57af0e 100644 --- a/dev-packages/e2e-tests/test-applications/nuxt-4/package.json +++ b/dev-packages/e2e-tests/test-applications/nuxt-4/package.json @@ -3,7 +3,7 @@ "private": true, "type": "module", "scripts": { - "build": "nuxt build && node ./copyIITM.mjs", + "build": "nuxt build && bash ./copyIITM.bash", "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview",