@uniweb/build 1.15.5 → 1.16.0

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.
@@ -1,8 +1,10 @@
1
- // Where a site's pages and layout live — ONE definition for the push, which reads
2
- // the tree from here (`site.js`), and the pull, which writes it back here
3
- // (`site-project.js`). A leaf module so the pull does not import the push.
1
+ // Where a site's content lives — ONE definition for the push, which reads the tree from here
2
+ // (`site.js`), the pull, which writes it back here (`site-project.js`), and every check that asks
3
+ // what a push would send or a pull would merge (the CLI's `utils/site-roots.js`). A leaf module so the
4
+ // pull does not import the push.
4
5
 
5
- import { join, resolve } from 'node:path'
6
+ import { join, relative, resolve, sep } from 'node:path'
7
+ import { mountEntriesOf } from '../site/mount-entries.js'
6
8
 
7
9
  /**
8
10
  * `site.yml::paths.pages` / `paths.layout`, else `pages/` and `layout/` — resolved
@@ -16,8 +18,8 @@ import { join, resolve } from 'node:path'
16
18
  * current.
17
19
  *
18
20
  * ⭐ Reading `site.yml` rather than the document is the fix, not a detour: it is the
19
- * file both readers use, and the pull writes the document's `settings.paths` into it
20
- * before it places a single page.
21
+ * file both readers use. And it is the project's own: no document carries `paths` since
22
+ * 2026-11-04, so a pull never moves where a project keeps its files.
21
23
  *
22
24
  * @param {string} siteRoot
23
25
  * @param {object|null} siteYml - the parsed `site.yml`
@@ -30,3 +32,45 @@ export function siteContentDirs(siteRoot, siteYml) {
30
32
  layoutDir: paths?.layout ? resolve(siteRoot, paths.layout) : join(siteRoot, 'layout'),
31
33
  }
32
34
  }
35
+
36
+ /**
37
+ * Every place a push reads the site's content from, each relative to the site in POSIX form — a
38
+ * mount's may lead out of it (`../docs`):
39
+ *
40
+ * - `config`: `site.yml`, `theme.yml`, `head.html`, `queries.yml`;
41
+ * - `translations`: `locales`;
42
+ * - `pages`, `layout`, `records`: where `paths:` puts them, else their own names;
43
+ * - `media`: `public`, where the files a page names are kept;
44
+ * - `mount`: each `paths: { pages/<segment>: <dir> }` folder, with its `segment` and `abs`.
45
+ *
46
+ * ⭐ ONE ANSWER, and the readers that kept their own drifted (2026-11-04): the push's
47
+ * committed-content check named no mount, so it let a mounted folder's uncommitted edits go out,
48
+ * while `uniweb status` counted that folder among what waits to be pushed. Which repository holds a
49
+ * mount — the site's own, one of its own, or none — is git's question, and the CLI's to ask.
50
+ *
51
+ * ⛔ What the walk reads and this lists must not part: `tests/site-content-roots.test.js` changes
52
+ * every file outside these roots and asks whether the push's document moved.
53
+ *
54
+ * @param {string} siteRoot
55
+ * @param {object|null} siteYml - the parsed `site.yml`
56
+ * @returns {Array<{ path: string, kind: 'config'|'translations'|'pages'|'layout'|'records'|'media'|'mount', segment?: string, abs: string }>}
57
+ */
58
+ export function siteContentRoots(siteRoot, siteYml) {
59
+ const paths = siteYml?.paths
60
+ const at = (dir) => {
61
+ const abs = resolve(siteRoot, String(dir))
62
+ return { abs, path: relative(siteRoot, abs).split(sep).join('/') || '.' }
63
+ }
64
+ const roots = []
65
+ for (const file of ['site.yml', 'theme.yml', 'head.html', 'queries.yml']) roots.push({ ...at(file), kind: 'config' })
66
+ roots.push({ ...at('locales'), kind: 'translations' })
67
+ roots.push({ ...at(paths?.pages || 'pages'), kind: 'pages' })
68
+ roots.push({ ...at(paths?.layout || 'layout'), kind: 'layout' })
69
+ roots.push({ ...at(paths?.records || 'records'), kind: 'records' })
70
+ roots.push({ ...at('public'), kind: 'media' })
71
+ for (const [segment, dir] of mountEntriesOf(paths)) {
72
+ if (typeof dir !== 'string' || !dir) continue
73
+ roots.push({ ...at(dir), kind: 'mount', segment })
74
+ }
75
+ return roots
76
+ }