From 99cfeeb2d2ef76ddbebbecf25a0f0a281517bd1d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 19 Aug 2025 12:01:15 -0400 Subject: [PATCH 1/2] chore: tweak build scripts --- apps/svelte.dev/scripts/get_contributors.js | 16 +++++++--------- apps/svelte.dev/scripts/get_donors.js | 15 +++++++-------- apps/svelte.dev/scripts/get_svelte_template.js | 13 ++++++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/svelte.dev/scripts/get_contributors.js b/apps/svelte.dev/scripts/get_contributors.js index 68f5c33b5f..6624c08aa4 100644 --- a/apps/svelte.dev/scripts/get_contributors.js +++ b/apps/svelte.dev/scripts/get_contributors.js @@ -2,20 +2,18 @@ import 'dotenv/config'; import { Jimp } from 'jimp'; import { stat, writeFile } from 'node:fs/promises'; -import { dirname } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; const force = process.env.FORCE_UPDATE === 'true'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -process.chdir(__dirname); - -// ../src/routes/_home/Supporters/contributors.js -const outputFile = new URL(`../src/routes/_home/Supporters/contributors.js`, import.meta.url); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const out = path.resolve(__dirname, '../src/routes/_home/Supporters/contributors.js'); try { - if (!force && (await stat(outputFile))) { - console.info(`[update/contributors] ${outputFile} exists. Skipping`); + if (!force && (await stat(out))) { + const relative = path.relative(process.cwd(), out); + console.info(`[update/contributors] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -69,5 +67,5 @@ try { const str = `[\n\t${authors.map((a) => `'${a.login}'`).join(',\n\t')}\n]`; - writeFile(outputFile, `export default ${str};`); + writeFile(out, `export default ${str};`); } diff --git a/apps/svelte.dev/scripts/get_donors.js b/apps/svelte.dev/scripts/get_donors.js index 60773cf4a5..3d07610cb0 100644 --- a/apps/svelte.dev/scripts/get_donors.js +++ b/apps/svelte.dev/scripts/get_donors.js @@ -2,19 +2,18 @@ import 'dotenv/config'; import { Jimp } from 'jimp'; import { stat, writeFile } from 'node:fs/promises'; -import { dirname } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; const force = process.env.FORCE_UPDATE === 'true'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -process.chdir(__dirname); - -const outputFile = new URL(`../src/routes/_home/Supporters/donors.js`, import.meta.url); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const out = path.resolve(__dirname, '../src/routes/_home/Supporters/donors.js'); try { - if (!force && (await stat(outputFile))) { - console.info(`[update/donors] ${outputFile} exists. Skipping`); + if (!force && (await stat(out))) { + const relative = path.relative(process.cwd(), out); + console.info(`[update/donors] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -65,5 +64,5 @@ try { const str = `[\n\t${included.map((a) => `${JSON.stringify(a.backer.name)}`).join(',\n\t')}\n]`; - writeFile(outputFile, `export default ${str};`); + writeFile(out, `export default ${str};`); } diff --git a/apps/svelte.dev/scripts/get_svelte_template.js b/apps/svelte.dev/scripts/get_svelte_template.js index d525eaa3df..92b4a7fbbc 100644 --- a/apps/svelte.dev/scripts/get_svelte_template.js +++ b/apps/svelte.dev/scripts/get_svelte_template.js @@ -1,6 +1,6 @@ // @ts-check import { readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; -import { join } from 'node:path'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { create } from 'sv'; @@ -8,12 +8,15 @@ import { create } from 'sv'; // This is used by the Svelte REPL as part of the "download project" feature const force = process.env.FORCE_UPDATE === 'true'; -const output_file = fileURLToPath(new URL('../static/svelte-template.json', import.meta.url)); -const output_dir = fileURLToPath(new URL('./svelte-template', import.meta.url)); + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const output_file = path.resolve(__dirname, '../static/svelte-template.json'); +const output_dir = path.resolve(__dirname, './svelte-template'); try { if (!force && statSync(output_file)) { - console.info(`[update/template] ${output_file} exists. Skipping`); + const relative = path.relative(process.cwd(), output_file); + console.info(`[update/template] ${relative} exists. Skipping`); process.exit(0); } } catch { @@ -25,7 +28,7 @@ try { const items = readdirSync(dir, { withFileTypes: true }); for (const item of items) { - const full_path = join(dir, item.name); + const full_path = path.join(dir, item.name); if (item.isDirectory()) { files.push(...get_all_files(full_path)); } else { From 90d5f6330e5d54c6c37a7d49ee28d0423cf882aa Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 19 Aug 2025 12:01:58 -0400 Subject: [PATCH 2/2] fix --- apps/svelte.dev/scripts/get_svelte_template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/svelte.dev/scripts/get_svelte_template.js b/apps/svelte.dev/scripts/get_svelte_template.js index 92b4a7fbbc..7755af498f 100644 --- a/apps/svelte.dev/scripts/get_svelte_template.js +++ b/apps/svelte.dev/scripts/get_svelte_template.js @@ -65,7 +65,7 @@ try { // add CSS styles from playground to the project const html = readFileSync( - join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), + path.join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'), { encoding: 'utf-8' } ); const css = html