1
0

deploy workflow
Some checks failed
Publish Pages / publish (push) Failing after 7s
Test / test (push) Has been cancelled

This commit is contained in:
Aiden
2026-06-11 16:05:20 +10:00
parent 731ee4e647
commit c86490542d
5 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
import { cp, mkdir, rm, stat, writeFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const rootDir = join(dirname(fileURLToPath(import.meta.url)), '..');
const distDir = join(rootDir, 'dist');
await rm(distDir, { force: true, recursive: true });
await mkdir(distDir, { recursive: true });
await copyRequired('index.html');
await copyRequired('poster.jpg');
await copyRequired('test-pages');
await copyRequired('vr180player');
await copyOptional('media');
await writeFile(
join(distDir, '_headers'),
[
'/vr180player/*',
' Cache-Control: public, max-age=3600',
'',
'/*',
' Cache-Control: public, max-age=300',
''
].join('\n')
);
console.log(`Built test app in ${distDir}`);
async function copyRequired(relativePath) {
const source = join(rootDir, relativePath);
const target = join(distDir, relativePath);
await cp(source, target, { recursive: true });
}
async function copyOptional(relativePath) {
const source = join(rootDir, relativePath);
if (!await pathExists(source)) {
console.warn(`Optional ${relativePath}/ directory not found; bundled sample media will not be included.`);
return;
}
await cp(source, join(distDir, relativePath), { recursive: true });
}
async function pathExists(path) {
try {
await stat(path);
return true;
} catch (error) {
if (error?.code === 'ENOENT') {
return false;
}
throw error;
}
}