uniweb 1.34.10 → 1.34.11

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": "uniweb",
3
- "version": "1.34.10",
3
+ "version": "1.34.11",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,15 +41,15 @@
41
41
  "js-yaml": "^4.3.2",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
- "@uniweb/semantic-parser": "~1.13.5",
44
+ "@uniweb/content-writer": "~1.3.2",
45
45
  "@uniweb/core": "~1.6.13",
46
46
  "@uniweb/schemas": "~1.7.4",
47
- "@uniweb/content-writer": "~1.3.2"
47
+ "@uniweb/semantic-parser": "~1.13.5"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/semantic-parser": "~1.13.5",
50
+ "@uniweb/build": "~1.23.8",
51
51
  "@uniweb/content-reader": "~1.5.10",
52
- "@uniweb/build": "~1.23.8"
52
+ "@uniweb/semantic-parser": "~1.13.5"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -99,7 +99,7 @@ npx uniweb@latest update --yes # align @uniweb/* deps AND refresh AGENTS.
99
99
 
100
100
  When `status` names a newer release, take it: update, restart any running dev server, build, look at the pages, commit what changed. A foundation is a federated ES module that links to the runtime at load time, like a shared library: the contract between them is stable across releases, and the runtime version a foundation was built against is a floor, not a pin. A hosted site moves forward when it is republished, to a runtime at or above its foundation's floor. The docs describe the latest release; a project that is behind should move, not be documented as it is. A **patch** brings fixes and features; a **minor** is where breaking changes go (`update` lists each package crossing one — build and check before shipping); a **major** is for something big. Dependencies are tilde ranges (`~1.0.1`), so `pnpm install` never crosses a minor on its own.
101
101
 
102
- **Write `@latest`.** In a project, `uniweb` resolves to the copy in your own `node_modules`, pinned by your own `package.json`; it reconciles against the matrix it already has and correctly reports nothing to do. `pnpm uniweb update` and a stale global install are the same. `@latest` makes it a question about the newest release and bumps the pin. Don't `npm update` / `pnpm update` the `@uniweb/*` packages — a matched set, and it won't refresh AGENTS.md, so the guide silently drifts from the code. `update` won't refresh AGENTS.md while declared deps lag the CLI or edited deps aren't installed. Updating the CLI itself is your package manager's job (`npm i -g uniweb@latest`).
102
+ **Write `@latest`.** In a project, `uniweb` resolves to the copy in your own `node_modules`, pinned by your own `package.json`; it reconciles against the matrix it already has and correctly reports nothing to do. `pnpm uniweb update` and a stale global install are the same. `@latest` makes it a question about the newest release and bumps the pin. Don't `npm update` / `pnpm update` the `@uniweb/*` packages — a matched set, and it won't refresh AGENTS.md, so the guide silently drifts from the code. `update` won't refresh AGENTS.md while declared deps lag the CLI or edited deps aren't installed. After a `git pull` that brings a teammate's update, run it too: the files name the new versions while `node_modules` still holds the old ones, and `update` installs what the lockfile holds. Updating the CLI itself is your package manager's job (`npm i -g uniweb@latest`).
103
103
 
104
104
  `uniweb update` rewrites AGENTS.md each version and keeps only blocks between a `<!-- project-notes:start -->` line and a `<!-- project-notes:end -->` line, which it moves to the end (markers that don't pair leave the file as it is) — keep project conventions in a file of your own (`NOTES.md`) and point to it from that block.
105
105
 
@@ -48,7 +48,7 @@ import { spawn } from 'node:child_process'
48
48
  import prompts from 'prompts'
49
49
 
50
50
  import { findUniwebWorkspace, getWorkspacePackages } from '../utils/workspace.js'
51
- import { lockedUniwebPackages, liftCommand, liftMoves } from '../utils/lockfile-uniweb.js'
51
+ import { lockedUniwebPackages, liftCommand, liftMoves, installBehindLockfile } from '../utils/lockfile-uniweb.js'
52
52
  import {
53
53
  readAgentsVersion,
54
54
  refreshAgentsContent,
@@ -257,6 +257,48 @@ async function liftUniwebPackages(workspaceDir, pm) {
257
257
  log('')
258
258
  }
259
259
 
260
+ /**
261
+ * Bring node_modules to what the lockfile holds, when the declared versions are aligned and the
262
+ * install is not: say which packages differ, then install as the rest of this command does, `--yes`
263
+ * running it, a run with no terminal printing it, and otherwise asking.
264
+ *
265
+ * @returns {Promise<boolean>} whether the install ran and succeeded
266
+ */
267
+ async function installToTheLockfile({ behind, installPm, workspaceDir, hasYes, nonInteractive, dryRun }) {
268
+ const cmd = installCmd(installPm)
269
+ warn("What node_modules holds isn't what the lockfile holds:")
270
+ for (const { name, locked, installed } of behind.slice(0, 8)) {
271
+ log(` ${name} ${installed.join(', ') || 'not installed'} → ${locked.join(', ') || 'not in the lockfile'}`)
272
+ }
273
+ if (behind.length > 8) log(` … and ${behind.length - 8} more`)
274
+ log(`${colors.dim}A pull that brings a teammate's update moves the lockfile and leaves node_modules as it was.${colors.reset}`)
275
+ if (dryRun) {
276
+ log(`${colors.dim}Dry-run: would run${colors.reset} ${colors.cyan}${cmd}${colors.reset}`)
277
+ return false
278
+ }
279
+ let go = hasYes
280
+ if (!go && nonInteractive) {
281
+ info(`${colors.dim}Non-interactive — run the install yourself:${colors.reset} ${colors.cyan}${cmd}${colors.reset}`)
282
+ return false
283
+ }
284
+ if (!go) {
285
+ const answer = await prompts({ type: 'confirm', name: 'go', message: `Run \`${cmd}\` now?`, initial: true })
286
+ go = !!answer.go
287
+ }
288
+ if (!go) {
289
+ log(`${colors.dim}Skipped install; run${colors.reset} ${colors.cyan}${cmd}${colors.reset} ${colors.dim}to bring node_modules to the lockfile.${colors.reset}`)
290
+ return false
291
+ }
292
+ const code = await runCommand(cmd, workspaceDir)
293
+ if (code !== 0) {
294
+ error(`Install failed (exit ${code}).`)
295
+ log(`${colors.dim}To retry:${colors.reset} ${colors.cyan}${cmd}${colors.reset}`)
296
+ process.exit(code)
297
+ }
298
+ success('Install complete: node_modules holds what the lockfile does.')
299
+ return true
300
+ }
301
+
260
302
  /** Run a shell command, inheriting stdio. Resolves with the exit code. */
261
303
  function runCommand(cmd, cwd) {
262
304
  return new Promise((resolve) => {
@@ -549,6 +591,16 @@ export async function update(args = []) {
549
591
  warn(
550
592
  `No ${colors.bright}node_modules${colors.reset} in the workspace — run ${colors.cyan}${installCmd(installPm || pmToInstall(workspaceDir))}${colors.reset} to install.`
551
593
  )
594
+ } else {
595
+ // ⭐ ALIGNED IS WHAT THE PROJECT DECLARES; WHAT IS INSTALLED CAN BE OTHER. A `git pull` that
596
+ // brings a teammate's update moves package.json and the lockfile and leaves node_modules, so
597
+ // the project goes on running the CLI it had (`installBehindLockfile`). ⛔ Until 2026-11-13 this
598
+ // said "aligned" and installed nothing: a teammate told to pull and run `update` kept the old
599
+ // CLI, and its pull and push went on behaving as the old ones did.
600
+ const behind = installPm ? installBehindLockfile(workspaceDir, installPm) : null
601
+ if (behind?.length) {
602
+ installRan = await installToTheLockfile({ behind, installPm, workspaceDir, hasYes, nonInteractive, dryRun })
603
+ }
552
604
  }
553
605
  log('')
554
606
  } else {
@@ -48,41 +48,76 @@ const isUniwebPackage = (name) => typeof name === 'string' && name.startsWith('@
48
48
  export function lockedUniwebPackages(workspaceDir, pm) {
49
49
  const file = LOCKFILES[pm]
50
50
  if (!file) return null
51
- const path = join(workspaceDir, file)
51
+ return readPackages(join(workspaceDir, file), pm, isUniwebPackage)
52
+ }
53
+
54
+ // What a package manager records of its last install, inside node_modules: pnpm a copy of the
55
+ // lockfile it installed from, npm its hidden lockfile. Each reads as the lockfile does.
56
+ const INSTALLED = { pnpm: 'node_modules/.pnpm/lock.yaml', npm: 'node_modules/.package-lock.json' }
57
+
58
+ // The framework's packages: the CLI (`uniweb`) and each `@uniweb/*`.
59
+ const isFrameworkPackage = (name) => name === 'uniweb' || isUniwebPackage(name)
60
+
61
+ /**
62
+ * The framework's packages whose versions in the lockfile are not the ones the last install put in
63
+ * node_modules, as the package manager records that install.
64
+ *
65
+ * ⭐ A `git pull` that brings a teammate's `uniweb update` moves package.json and the lockfile, and
66
+ * leaves node_modules as it was, so the project goes on running the CLI and the packages it had.
67
+ * `update` then finds the declared versions aligned, and it has to install all the same.
68
+ *
69
+ * @param {string} workspaceDir
70
+ * @param {'pnpm'|'npm'|'yarn'|null} pm
71
+ * @returns {Array<{ name: string, locked: string[], installed: string[] }>|null} each package that
72
+ * differs; [] when they agree; null when either side can't be read (nothing installed yet, yarn)
73
+ */
74
+ export function installBehindLockfile(workspaceDir, pm) {
75
+ const file = LOCKFILES[pm]
76
+ if (!file || !INSTALLED[pm]) return null
77
+ const locked = readPackages(join(workspaceDir, file), pm, isFrameworkPackage)
78
+ const installed = readPackages(join(workspaceDir, INSTALLED[pm]), pm, isFrameworkPackage)
79
+ if (!locked || !installed) return null
80
+ return [...new Set([...locked.keys(), ...installed.keys()])]
81
+ .sort()
82
+ .map((name) => ({ name, locked: locked.get(name) || [], installed: installed.get(name) || [] }))
83
+ .filter(({ locked, installed }) => locked.join() !== installed.join())
84
+ }
85
+
86
+ function readPackages(path, pm, keep) {
52
87
  if (!existsSync(path)) return null
53
88
  try {
54
89
  const text = readFileSync(path, 'utf8')
55
- return pm === 'pnpm' ? fromPnpmLock(yaml.load(text)) : fromNpmLock(JSON.parse(text))
90
+ return pm === 'pnpm' ? fromPnpmLock(yaml.load(text), keep) : fromNpmLock(JSON.parse(text), keep)
56
91
  } catch {
57
92
  return null
58
93
  }
59
94
  }
60
95
 
61
96
  /** `packages:` keys: `'@uniweb/core@1.6.12'` (v9), `/@uniweb/core@1.6.12(react@19.0.0)` (v6). */
62
- function fromPnpmLock(lock) {
97
+ function fromPnpmLock(lock, keep) {
63
98
  const found = new Map()
64
99
  for (const key of Object.keys(lock?.packages || {})) {
65
100
  const id = key.replace(/^\//, '').replace(/\(.*$/, '')
66
101
  const at = id.lastIndexOf('@')
67
102
  if (at <= 0) continue
68
- add(found, id.slice(0, at), id.slice(at + 1))
103
+ add(found, id.slice(0, at), id.slice(at + 1), keep)
69
104
  }
70
105
  return sorted(found)
71
106
  }
72
107
 
73
108
  /** `packages:` keys: `node_modules/@uniweb/core`, `node_modules/x/node_modules/@uniweb/core`. */
74
- function fromNpmLock(lock) {
109
+ function fromNpmLock(lock, keep) {
75
110
  const found = new Map()
76
111
  for (const [key, entry] of Object.entries(lock?.packages || {})) {
77
112
  const at = key.lastIndexOf('node_modules/')
78
113
  if (at < 0 || entry?.link || !entry?.version) continue
79
- add(found, key.slice(at + 'node_modules/'.length), entry.version)
114
+ add(found, key.slice(at + 'node_modules/'.length), entry.version, keep)
80
115
  }
81
116
  return sorted(found)
82
117
  }
83
118
 
84
- function add(found, name, version) {
85
- if (!isUniwebPackage(name) || !version) return
119
+ function add(found, name, version, keep) {
120
+ if (!keep(name) || !version) return
86
121
  if (!found.has(name)) found.set(name, new Set())
87
122
  found.get(name).add(version)
88
123
  }