create-website-build-kit 0.1.18 → 0.1.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-website-build-kit",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Scaffold a production marketing site \u2014 Astro on Cloudflare Workers, with the gates, the migration playbook and the accessibility work already wired.",
5
5
  "keywords": [
6
6
  "astro",
@@ -237,12 +237,18 @@ for (const source of media) {
237
237
  * with that media source's `output`. Convert the field and migrate the data
238
238
  * in the same change.
239
239
  */
240
+ /** Dotted field path → the `options.path` it is scoped to, when it declares one. */
241
+ const scopedPaths = new Map();
242
+
240
243
  function imageFields(fields, prefix = '') {
241
244
  const out = [];
242
245
  for (const field of fields ?? []) {
243
246
  if (!field?.name) continue;
244
247
  const path = prefix ? `${prefix}.${field.name}` : field.name;
245
- if (field.type === 'image') out.push({ path, media: field.options?.media });
248
+ if (field.type === 'image') {
249
+ out.push({ path, media: field.options?.media });
250
+ if (field.options?.path) scopedPaths.set(path, String(field.options.path).replace(/^\.?\//, ''));
251
+ }
246
252
  if (Array.isArray(field.fields)) out.push(...imageFields(field.fields, path));
247
253
  }
248
254
  return out;
@@ -290,6 +296,24 @@ for (const entry of entries) {
290
296
  for (const { path: fieldPath, media: mediaName } of fields) {
291
297
  const source =
292
298
  (mediaName && mediaByName.get(mediaName)) ?? (media.length === 1 ? media[0] : null);
299
+
300
+ /*
301
+ * ⚠ A PICKER SCOPED TO A FOLDER THAT DOES NOT EXIST OPENS ON NOTHING.
302
+ * `options.path` narrows which directory the media browser shows. Point it
303
+ * at `public/img/brand` when the files live in `brand-v2/` and the editor
304
+ * gets an empty folder — no error, no warning, and the build does not
305
+ * care. It is visible only to the person trying to choose an image, which
306
+ * is the one person who cannot fix it.
307
+ */
308
+ if (fieldPath && typeof entry.fields === 'object') {
309
+ const scoped = scopedPaths.get(fieldPath);
310
+ if (scoped && !existsSync(scoped)) {
311
+ problems.push({
312
+ label: `${entry.name ?? entry.label} → ${fieldPath}`,
313
+ why: `\`options.path\` is ${JSON.stringify(scoped)}, which does not exist — the picker opens on an empty folder`,
314
+ });
315
+ }
316
+ }
293
317
  const output = typeof source === 'object' ? source?.output : null;
294
318
  if (!output) continue; // nothing declared to measure against
295
319
  /* `output: /` makes "starts with the output" true of every absolute path, so