Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions apps/svelte.dev/scripts/get_contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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};`);
}
15 changes: 7 additions & 8 deletions apps/svelte.dev/scripts/get_donors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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};`);
}
15 changes: 9 additions & 6 deletions apps/svelte.dev/scripts/get_svelte_template.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// @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';

// This download the currente Vite template from Github, adjusts it to our needs, and saves it to static/svelte-template.json
// 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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -62,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
Expand Down