* Fix SSR static build public file copying * chore: update lockfile * remove dirname and use URL constructor * Cleanup test and actually test what it says it tests Co-authored-by: Nate Moore <nate@skypack.dev>
This commit is contained in:
parent
a9ecefb8ac
commit
7b0fbd731e
8 changed files with 48 additions and 5 deletions
5
.changeset/metal-grapes-tickle.md
Normal file
5
.changeset/metal-grapes-tickle.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix SSR static build public files copying
|
|
@ -253,15 +253,14 @@ async function copyFiles(fromFolder: URL, toFolder: URL) {
|
|||
cwd: fileURLToPath(fromFolder),
|
||||
});
|
||||
|
||||
// Make the directory
|
||||
await fs.promises.mkdir(toFolder, { recursive: true });
|
||||
|
||||
await Promise.all(
|
||||
files.map(async (filename) => {
|
||||
const from = new URL(filename, fromFolder);
|
||||
const to = new URL(filename, toFolder);
|
||||
return fs.promises.copyFile(from, to);
|
||||
})
|
||||
const lastFolder = new URL('./', to)
|
||||
return fs.promises.mkdir(lastFolder, {recursive: true})
|
||||
.then(()=>fs.promises.copyFile(from, to) )
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
|
6
packages/astro/test/fixtures/static build SSR/astro.config.mjs
vendored
Normal file
6
packages/astro/test/fixtures/static build SSR/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
import nodejs from '@astrojs/node';
|
||||
|
||||
export default defineConfig({
|
||||
adapter: nodejs(),
|
||||
});
|
9
packages/astro/test/fixtures/static build SSR/package.json
vendored
Normal file
9
packages/astro/test/fixtures/static build SSR/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@test/static-build",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@astrojs/node": "workspace:*",
|
||||
"@test/static-build-pkg": "workspace:*",
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
1
packages/astro/test/fixtures/static build SSR/public/asset.txt
vendored
Normal file
1
packages/astro/test/fixtures/static build SSR/public/asset.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test asset
|
1
packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt
vendored
Normal file
1
packages/astro/test/fixtures/static build SSR/public/nested/asset2.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test asset
|
|
@ -168,3 +168,15 @@ describe('Static build', () => {
|
|||
expect(found).to.equal(true, 'Found the log message');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static build SSR', () => {
|
||||
|
||||
it('Copies public files', async () => {
|
||||
const fixture = await loadFixture({
|
||||
root: './fixtures/static build SSR/',
|
||||
});
|
||||
await fixture.build()
|
||||
const asset = await fixture.readFile('/client/nested/asset2.txt');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1102,6 +1102,16 @@ importers:
|
|||
'@test/static-build-pkg': link:pkg
|
||||
astro: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/static build SSR:
|
||||
specifiers:
|
||||
'@astrojs/node': workspace:*
|
||||
'@test/static-build-pkg': workspace:*
|
||||
astro: workspace:*
|
||||
dependencies:
|
||||
'@astrojs/node': link:../../../../integrations/node
|
||||
'@test/static-build-pkg': link:../static build/pkg
|
||||
astro: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/static build/pkg:
|
||||
specifiers: {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue