From 1777db0f5aca1b37f811b98938a86b877cc0dee2 Mon Sep 17 00:00:00 2001 From: koehr Date: Thu, 26 Nov 2020 23:45:29 +0100 Subject: [PATCH] adapt helper scripts --- compile-list.js => compile-list.mjs | 13 +- package.json | 29 +- pages.txt | 1 - refresh-pages.sh | 2 +- src/components/PageList.svelte | 2 +- src/components/{pages.js => pages.mjs} | 2 +- yarn.lock | 427 ++++++++++++++++++++++++- 7 files changed, 445 insertions(+), 31 deletions(-) rename compile-list.js => compile-list.mjs (88%) rename src/components/{pages.js => pages.mjs} (99%) diff --git a/compile-list.js b/compile-list.mjs similarity index 88% rename from compile-list.js rename to compile-list.mjs index d1d6a697..0e8ca0f2 100644 --- a/compile-list.js +++ b/compile-list.mjs @@ -1,10 +1,10 @@ -const fs = require('fs') -const chalk = require('chalk') -const phantomas = require('phantomas') -const pageData = require('./src/pages.json') +import fs from 'fs' +import chalk from 'chalk' +import phantomas from 'phantomas' +import pageData from './src/components/pages.mjs' const INPUT_FILE = './pages.txt' -const OUTPUT_FILE = './src/pages.json' +const OUTPUT_FILE = './src/components/pages.mjs' const RECHECK_THRESHOLD = 60*60*24*7*1000 // recheck pages older than 1 week const REJECT_THRESHOLD = 256000 @@ -66,7 +66,8 @@ async function generateMetrics (urls) { } try { - fs.writeFileSync(OUTPUT_FILE, JSON.stringify(metricsList)) + // TODO: poor mans JSON to JS converter? + fs.writeFileSync(OUTPUT_FILE, 'export default ' + JSON.stringify(metricsList)) } catch (err) { error(`failed to write results to ${OUTPUT_FILE}`, err) } diff --git a/package.json b/package.json index b20225a0..822cbb4a 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,18 @@ { - "name": "the-250kb-club", - "version": "0.0.1", - "scripts": { - "dev": "svelte dev", - "build": "svelte build" - }, - "devDependencies": { - "@sveltejs/adapter-node": "0.0.14", - "@sveltejs/adapter-static": "^0.0.14", - "@sveltejs/kit": "0.0.25", - "@sveltejs/snowpack-config": "0.0.5", - "svelte": "^3.29.0" - } + "name": "the-250kb-club", + "version": "0.0.1", + "scripts": { + "dev": "svelte dev", + "build": "svelte build", + "update-pages": "node ./scripts/refresh-pages.js" + }, + "devDependencies": { + "@sveltejs/adapter-node": "0.0.14", + "@sveltejs/adapter-static": "^0.0.14", + "@sveltejs/kit": "0.0.25", + "@sveltejs/snowpack-config": "0.0.5", + "svelte": "^3.29.0", + "chalk": "^4.1.0", + "phantomas": "^2.0.0" + } } diff --git a/pages.txt b/pages.txt index 14d5b9cc..aaac5464 100644 --- a/pages.txt +++ b/pages.txt @@ -121,4 +121,3 @@ https://www.unindented.org/ https://tom.kobalt.dev/map https://fanael.github.io/ https://matthall.codes/ -https://nixnet.services/ diff --git a/refresh-pages.sh b/refresh-pages.sh index ff801b7d..1ce89d9f 100755 --- a/refresh-pages.sh +++ b/refresh-pages.sh @@ -2,6 +2,6 @@ node ./compile-list.js && yarn build && -scp -r public/* 250kb.club:/srv/http/250kb.club/ && +scp -r build/* 250kb.club:/srv/http/250kb.club/ && git commit -am 'updates URLs' && git push sourcehut main && git push origin main diff --git a/src/components/PageList.svelte b/src/components/PageList.svelte index 3a22a5ad..162ac792 100644 --- a/src/components/PageList.svelte +++ b/src/components/PageList.svelte @@ -1,6 +1,6 @@