@tideworthy/tidysites-platform 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.3
3
+ ## 0.1.7
4
4
 
5
- - Renamed to `@tideworthy/tidysites-platform`: the npm scope is the parent brand, the package name says which product it serves. First version actually published to npm. No code changes.
5
+ - Bootstrap applies the seed with the site's configured storage, so `$media` references in a template seed are downloaded into the site's media library. Before this every seed photo was skipped with "no storage configured". The storage comes from EmDash's `virtual:emdash/config` and `virtual:emdash/storage` modules, the same way the setup wizard builds it.
6
+
7
+ ## 0.1.6
8
+
9
+ - First version on npm as `@tideworthy/tidysites-platform` (the npm scope is the parent brand; the name says which product it serves). Lockfile regenerated from a clean state so `npm ci` works on Linux runners. 0.1.3, 0.1.4, and 0.1.5 were release attempts that never reached npm; do not use them.
6
10
 
7
11
  ## 0.1.2
8
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tideworthy/tidysites-platform",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "The Tidysites platform integration for EmDash sites: bootstrap, sessions, maintenance, health, and publish hooks under /_tidy/*.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,15 +15,35 @@ import { createEmdashStore } from "./store";
15
15
 
16
16
  export { workerEnv } from "./env";
17
17
 
18
+ /**
19
+ * The site's configured storage (R2 on Cloudflare), built the same way
20
+ * EmDash's setup wizard builds it: from the virtual config and storage
21
+ * modules the EmDash integration generates at build time. Without it,
22
+ * `applySeed` skips every `$media` reference in the seed.
23
+ */
24
+ async function storageProvider(): Promise<unknown> {
25
+ try {
26
+ const [cfgMod, storageMod] = await Promise.all([
27
+ import("virtual:emdash/config") as Promise<{ default?: { storage?: { config?: unknown } } }>,
28
+ import("virtual:emdash/storage") as Promise<{ createStorage?: (config: unknown) => unknown }>
29
+ ]);
30
+ const storageConfig = cfgMod.default?.storage;
31
+ if (!storageConfig || typeof storageMod.createStorage !== "function") return undefined;
32
+ return storageMod.createStorage(storageConfig.config);
33
+ } catch {
34
+ return undefined;
35
+ }
36
+ }
37
+
18
38
  export async function buildDeps(): Promise<Deps> {
19
- const db = await getDb();
39
+ const [db, storage] = await Promise.all([getDb(), storageProvider()]);
20
40
  const store = createEmdashStore(db, { OptionsRepository, UserRepository, ulid, getMigrationStatus });
21
41
  return {
22
42
  store,
23
43
  seed: {
24
44
  load: async () => (await loadSeed()) as unknown as Record<string, unknown> & { settings?: Record<string, unknown> },
25
45
  validate: (seed) => validateSeed(seed),
26
- apply: (seed) => applySeed(db, seed as unknown as Parameters<typeof applySeed>[1], { includeContent: true, onConflict: "skip" })
46
+ apply: (seed) => applySeed(db, seed as unknown as Parameters<typeof applySeed>[1], { includeContent: true, onConflict: "skip", ...(storage ? { storage: storage as never } : {}) })
27
47
  },
28
48
  tokens: {
29
49
  generate: () => generatePrefixedToken("ec_pat_"),
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Kept in step with package.json by the release checklist in MAINTAINING.md. */
2
- export const VERSION = "0.1.6";
2
+ export const VERSION = "0.1.7";
3
3
  export const PLUGIN_ID = "tidy-platform";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Virtual modules the EmDash Astro integration generates inside a site build.
3
+ * They exist only there; the package reaches them with dynamic imports that
4
+ * are wrapped in try/catch, so tests and Node never touch them.
5
+ */
6
+ declare module "virtual:emdash/config" {
7
+ const config: { storage?: { entrypoint?: string; config?: unknown } } & Record<string, unknown>;
8
+ export default config;
9
+ }
10
+ declare module "virtual:emdash/storage" {
11
+ export const createStorage: ((config: unknown) => unknown) | undefined;
12
+ }