Skip to content

remove shelljs #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2024
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
1 change: 0 additions & 1 deletion apps/svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"prettier-plugin-svelte": "^3.2.4",
"satori": "^0.10.13",
"satori-html": "^0.3.2",
"shelljs": "^0.8.5",
"shiki": "^1.6.4",
"shiki-twoslash": "^3.1.2",
"svelte": "5.0.0-next.243",
Expand Down
17 changes: 10 additions & 7 deletions apps/svelte.dev/scripts/update.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import sh from 'shelljs';
import { fork } from 'node:child_process';
import { fileURLToPath } from 'url';

sh.env['FORCE_UPDATE'] = process.argv.includes('--force=true');
const dir = fileURLToPath(new URL('.', import.meta.url));

Promise.all([
sh.exec('node ./scripts/get_contributors.js'),
sh.exec('node ./scripts/get_donors.js'),
sh.exec('node ./scripts/update_template.js')
]);
const env = {
FORCE_UPDATE: process.argv.includes('--force=true') || ''
};

fork(`${dir}/get_contributors.js`, { env });
fork(`${dir}/get_donors.js`, { env });
fork(`${dir}/update_template.js`);
29 changes: 14 additions & 15 deletions apps/svelte.dev/scripts/update_template.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
// @ts-check
import { lstat, readFile, stat, writeFile } from 'node:fs/promises';
import path, { dirname } from 'node:path';
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import sh from 'shelljs';
import { execSync } from 'node:child_process';
import glob from 'tiny-glob/sync.js';

const force = process.env.FORCE_UPDATE === 'true';

const __dirname = dirname(fileURLToPath(import.meta.url));
sh.cd(path.join(__dirname, '..'));
const dir = fileURLToPath(new URL('./svelte-app', import.meta.url));

const outputFile = 'static/svelte-app.json';

try {
if (!force && (await stat(outputFile))) {
if (!force && fs.existsSync(outputFile)) {
console.info(`[update/template] ${outputFile} exists. Skipping`);
process.exit(0);
}
} catch {
// fetch svelte app
sh.rm('-rf', 'scripts/svelte-app');
sh.exec('npx degit sveltejs/template scripts/svelte-app');
fs.rmdirSync(dir);
execSync(`npx degit sveltejs/template ${dir}`);

// 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');
fs.rmdirSync(`${dir}/src`);
fs.rmdirSync(`${dir}/node_modules`);

// build svelte-app.json
const appPath = 'scripts/svelte-app';
const appPath = dir;
const files = [];

for (const path of sh.find(appPath)) {
for (const path of glob(`${dir}/**`)) {
// Skip directories
if (!(await lstat(path)).isFile()) continue;
if (!fs.lstatSync(path).isFile()) continue;

const bytes = await readFile(path);
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 });
}

writeFile(outputFile, JSON.stringify(files));
fs.writeFileSync(outputFile, JSON.stringify(files));
}
69 changes: 0 additions & 69 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading