mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-30 00:46:29 +01:00
60806f74b9
* Push * Remove `rootDir` * Use tsconfig instead of jsconfig * Push recent changes * Better dark mode * empty commit to try and trigger a deploy * bump kit * Fix site-kit dep * Comment out blurb * Update site-kit to 3.2.1 * Externalise sourcemap-codec * Install sourcemap-codec as dep --------- Co-authored-by: Rich Harris <hello@rich-harris.dev>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import sh from 'shelljs';
|
|
import fs from 'fs';
|
|
import path, { dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const force = process.env.FORCE_UPDATE === 'true';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
sh.cd(path.join(__dirname, '..'));
|
|
|
|
const outputFile = 'static/svelte-app.json';
|
|
if (!force && fs.existsSync(outputFile)) {
|
|
console.info(`[update/template] ${outputFile} exists. Skipping`);
|
|
process.exit(0);
|
|
}
|
|
|
|
// fetch svelte app
|
|
sh.rm('-rf', 'scripts/svelte-app');
|
|
sh.exec('npx degit sveltejs/template scripts/svelte-app');
|
|
|
|
// remove src (will be recreated client-side) and node_modules
|
|
sh.rm('-rf', 'scripts/svelte-app/src');
|
|
sh.rm('-rf', 'scripts/svelte-app/node_modules');
|
|
|
|
// build svelte-app.json
|
|
const appPath = 'scripts/svelte-app';
|
|
const files = [];
|
|
|
|
for (const path of sh.find(appPath).filter((p) => fs.lstatSync(p).isFile())) {
|
|
const bytes = fs.readFileSync(path);
|
|
const string = bytes.toString();
|
|
const data = bytes.compare(Buffer.from(string)) === 0 ? string : [...bytes];
|
|
files.push({ path: path.slice(appPath.length + 1), data });
|
|
}
|
|
|
|
fs.writeFileSync(outputFile, JSON.stringify(files));
|