From be6c23788f202dcc3dfa3ae00749c7dbd0457159 Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Sat, 5 Sep 2026 10:31:09 -0700 Subject: [PATCH] Keep the S3 sync and filesystem storage out of the updater import graph updateAll() only runs the updaters now. The local (Node) flavour, which also uploads to S3 when configured, lives in src/app/local.js next to the filesystem storage wiring, and the entry points call that. The storage barrel no longer re-exports FilesystemStorage. With both gone, the updater tree bundles for a non-Node target with no unresolved imports. Co-Authored-By: Claude Fable 5.1 --- src/app/cron.js | 5 ++--- src/app/index.js | 5 ++--- src/app/local.js | 24 ++++++++++++++++++++++++ src/app/storage.js | 12 ------------ src/app/updater/updateAll.js | 9 --------- src/common/storage/index.js | 3 ++- test/storage/storage-contract.test.js | 3 ++- 7 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 src/app/local.js delete mode 100644 src/app/storage.js diff --git a/src/app/cron.js b/src/app/cron.js index d552013..c161410 100644 --- a/src/app/cron.js +++ b/src/app/cron.js @@ -1,13 +1,12 @@ import '../common/bootstrap.js'; import { CronJob } from 'cron'; -import { updateAll } from './updater/index.js'; -import { filesystemStorage } from './storage.js'; +import { updateAllLocally } from './local.js'; import { maybePostTweets } from './twitter/index.js'; console.info('Starting periodic tasks...'); // Run every hour at 10sec after the hour new CronJob('10 0 * * * *', async () => { - await updateAll(filesystemStorage()); + await updateAllLocally(); await maybePostTweets(); }, null, true); diff --git a/src/app/index.js b/src/app/index.js index 4f2688e..13a8686 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -1,12 +1,11 @@ import '../common/bootstrap.js'; import { runAction } from '../common/cli.js'; -import { updateAll } from './updater/index.js'; -import { filesystemStorage } from './storage.js'; +import { updateAllLocally } from './local.js'; import { maybePostTweets, testScreenshots } from './twitter/index.js'; import { sync, syncUpload, syncDownload } from './sync/index.js'; await runAction({ - splatnet: () => updateAll(filesystemStorage()), + splatnet: updateAllLocally, twitter: maybePostTweets, twitterTest: testScreenshots, sync, diff --git a/src/app/local.js b/src/app/local.js new file mode 100644 index 0000000..c9f01d8 --- /dev/null +++ b/src/app/local.js @@ -0,0 +1,24 @@ +// The local (Node) flavour of running the updaters: filesystem storage in the directories +// the site has always been built from, followed by the S3 upload when it is configured. +// The Worker entry point has its own equivalent over R2. + +import FilesystemStorage from '../common/storage/FilesystemStorage.js'; +import { updateAll } from './updater/index.js'; +import S3Syncer from './sync/S3Syncer.js'; +import { canSync } from './sync/index.js'; + +export function filesystemStorage() { + return { + publicStorage: new FilesystemStorage('dist'), + privateStorage: new FilesystemStorage('storage'), + }; +} + +export async function updateAllLocally() { + await updateAll(filesystemStorage()); + + if (canSync()) + await new S3Syncer().upload(); + + return 'Done'; +} diff --git a/src/app/storage.js b/src/app/storage.js deleted file mode 100644 index 7615fac..0000000 --- a/src/app/storage.js +++ /dev/null @@ -1,12 +0,0 @@ -import { FilesystemStorage } from '../common/storage/index.js'; - -/** - * The storage a local (Node) run uses: the same directories the site has always been - * built from, so `npm run splatnet` and the S3 sync keep working unchanged. - */ -export function filesystemStorage() { - return { - publicStorage: new FilesystemStorage('dist'), - privateStorage: new FilesystemStorage('storage'), - }; -} diff --git a/src/app/updater/updateAll.js b/src/app/updater/updateAll.js index 62aa5a3..a485fbf 100644 --- a/src/app/updater/updateAll.js +++ b/src/app/updater/updateAll.js @@ -4,8 +4,6 @@ import TimelineUpdater from './updaters/TimelineUpdater.js'; import OriginalGearImageUpdater from './updaters/OriginalGearImageUpdater.js'; import FestivalsUpdater from './updaters/FestivalsUpdater.js'; import MerchandisesUpdater from './updaters/MerchandisesUpdater.js'; -import S3Syncer from '../sync/S3Syncer.js'; -import { canSync } from '../sync/index.js'; /** @param {{ publicStorage: object, privateStorage: object }} storage */ export function createUpdaters(storage) { @@ -26,8 +24,6 @@ export function createUpdaters(storage) { * a Worker passes BucketStorage over its R2 bindings, a local run passes FilesystemStorage. */ export default async function updateAll(storage) { - const syncer = canSync() ? new S3Syncer() : null; - for (let updater of createUpdaters(storage)) { try { await updater.update(); @@ -36,9 +32,4 @@ export default async function updateAll(storage) { } } - if (syncer) { - await syncer.upload(); - } - - return 'Done'; } diff --git a/src/common/storage/index.js b/src/common/storage/index.js index bcc0669..d8c7844 100644 --- a/src/common/storage/index.js +++ b/src/common/storage/index.js @@ -1,6 +1,7 @@ +// Note: FilesystemStorage is deliberately not re-exported here; it imports node:fs, and this +// module is part of the updaters' import graph, which also has to bundle into a Worker. export { default as MemoryBucket } from './MemoryBucket.js'; export { default as BucketStorage } from './BucketStorage.js'; -export { default as FilesystemStorage } from './FilesystemStorage.js'; // What the S3 sync applied to data/ objects; the R2 objects carry it directly. export const DATA_CACHE_CONTROL = 'no-cache, stale-while-revalidate=5, stale-if-error=86400'; diff --git a/test/storage/storage-contract.test.js b/test/storage/storage-contract.test.js index 84ee734..80540b4 100644 --- a/test/storage/storage-contract.test.js +++ b/test/storage/storage-contract.test.js @@ -3,7 +3,8 @@ import assert from 'node:assert/strict'; import { mkdtemp, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import path from 'node:path'; -import { MemoryBucket, BucketStorage, FilesystemStorage } from '../../src/common/storage/index.js'; +import { MemoryBucket, BucketStorage } from '../../src/common/storage/index.js'; +import FilesystemStorage from '../../src/common/storage/FilesystemStorage.js'; // One contract for the storage interface the updaters use, run against every implementation. const implementations = {