convert update_template.sh to js for windows support

pull/1979/head
David Pershouse 6 years ago
parent 8e9f37a7d4
commit 2b1be6f8ae

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"dev": "sapper dev", "dev": "sapper dev",
"sapper": "sapper build --legacy", "sapper": "sapper build --legacy",
"update": "sh scripts/update_template.sh && node scripts/get-contributors.js", "update": "node scripts/update_template.js && node scripts/get-contributors.js",
"start": "node __sapper__/build", "start": "node __sapper__/build",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
@ -29,6 +29,7 @@
"passport-github": "^1.1.0", "passport-github": "^1.1.0",
"prismjs": "^1.15.0", "prismjs": "^1.15.0",
"session-file-store": "^1.2.0", "session-file-store": "^1.2.0",
"shelljs": "^0.8.3",
"sirv": "^0.2.0", "sirv": "^0.2.0",
"yootils": "0.0.14" "yootils": "0.0.14"
}, },

@ -0,0 +1,26 @@
const sh = require('shelljs');
const fs = require('fs')
sh.cd(__dirname+'/../')
// fetch svelte app
sh.rm('-rf','scripts/svelte-app')
sh.exec('npx degit sveltejs/template scripts/svelte-app')
// update repl-viewer.css based on template
sh.cp('scripts/svelte-app/public/global.css', 'static/repl-viewer.css')
// 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'
let files = []
for (const path of sh.find(appPath).filter(p => fs.lstatSync(p).isFile()) ) {
files.push({ path: path.slice(appPath.length + 1), data: fs.readFileSync(path).toString() });
}
fs.writeFileSync('static/svelte-app.json', JSON.stringify(files));
Loading…
Cancel
Save