uniweb 0.12.17 → 0.12.18

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": "0.12.17",
3
+ "version": "0.12.18",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,12 +41,12 @@
41
41
  "js-yaml": "^4.1.0",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.0.0",
44
- "@uniweb/core": "0.7.11",
44
+ "@uniweb/kit": "0.9.11",
45
45
  "@uniweb/runtime": "0.8.13",
46
- "@uniweb/kit": "0.9.11"
46
+ "@uniweb/core": "0.7.11"
47
47
  },
48
48
  "peerDependencies": {
49
- "@uniweb/build": "0.14.3",
49
+ "@uniweb/build": "0.14.4",
50
50
  "@uniweb/content-reader": "1.1.10",
51
51
  "@uniweb/semantic-parser": "1.1.17"
52
52
  },
@@ -60,5 +60,8 @@
60
60
  "@uniweb/semantic-parser": {
61
61
  "optional": true
62
62
  }
63
+ },
64
+ "scripts": {
65
+ "test": "node --test 'test/**/*.test.js'"
63
66
  }
64
67
  }
@@ -21,10 +21,9 @@ import { scaffoldFoundation, scaffoldSite, applyContent, applyStarter, mergeTemp
21
21
  import {
22
22
  readWorkspaceConfig,
23
23
  addWorkspaceGlob,
24
- discoverFoundations,
25
- discoverSites,
26
24
  updateRootScripts,
27
25
  } from '../utils/config.js'
26
+ import { discoverFoundations, discoverSites } from '../utils/discover.js'
28
27
  import { validatePackageName, getExistingPackageNames, resolveUniqueName } from '../utils/names.js'
29
28
  import { findWorkspaceRoot } from '../utils/workspace.js'
30
29
  import { detectPackageManager, filterCmd, installCmd } from '../utils/pm.js'
@@ -36,7 +36,8 @@ import { spawn } from 'node:child_process'
36
36
  import { join } from 'node:path'
37
37
 
38
38
  import { detectPackageManager, filterCmd } from '../utils/pm.js'
39
- import { discoverSites, readWorkspaceConfig } from '../utils/config.js'
39
+ import { readWorkspaceConfig } from '../utils/config.js'
40
+ import { discoverSites } from '../utils/discover.js'
40
41
  import { findWorkspaceRoot } from '../utils/workspace.js'
41
42
  import { readFlagValue } from '../utils/args.js'
42
43
 
@@ -10,7 +10,7 @@ import { loadDeployYml } from '@uniweb/build/site'
10
10
  import { listAdapters } from '@uniweb/build/hosts'
11
11
  import { getCliVersion } from '../versions.js'
12
12
  import { readAgentsVersion } from '../utils/agents-stamp.js'
13
- import { discoverFoundations, discoverSites } from '../utils/config.js'
13
+ import { discoverFoundations, discoverSites } from '../utils/discover.js'
14
14
  import { findWorkspaceRoot } from '../utils/workspace.js'
15
15
 
16
16
  /**
@@ -47,14 +47,13 @@ import yaml from 'js-yaml'
47
47
  import { isExtensionPackage } from '@uniweb/build'
48
48
  import { findWorkspaceRoot } from '../utils/workspace.js'
49
49
  import {
50
- discoverFoundations,
51
- discoverSites,
52
50
  readWorkspaceConfig,
53
51
  writeWorkspaceConfig,
54
52
  readRootPackageJson,
55
53
  writeRootPackageJson,
56
54
  updateRootScripts,
57
55
  } from '../utils/config.js'
56
+ import { discoverFoundations, discoverSites } from '../utils/discover.js'
58
57
  import { getExistingPackageNames, validatePackageName } from '../utils/names.js'
59
58
  import { detectPackageManager, installCmd } from '../utils/pm.js'
60
59
  import { getCliPrefix } from '../utils/interactive.js'
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-05-06T17:01:18.376Z",
3
+ "generatedAt": "2026-05-06T22:01:04.763Z",
4
4
  "packages": {
5
5
  "@uniweb/build": {
6
- "version": "0.14.3",
6
+ "version": "0.14.4",
7
7
  "path": "framework/build",
8
8
  "deps": [
9
9
  "@uniweb/content-reader",
@@ -1,8 +1,17 @@
1
1
  /**
2
2
  * Workspace Config Management
3
3
  *
4
- * Read/write pnpm-workspace.yaml and root package.json.
5
- * Used by both `create` and `add` commands.
4
+ * Read/write pnpm-workspace.yaml and root package.json, plus URL config
5
+ * for the platform backend / registry. Used by both `create` and `add`
6
+ * commands.
7
+ *
8
+ * This module is on the CLI's startup path (statically imported by
9
+ * `commands/login.js`, which is loaded by `src/index.js`). It MUST NOT
10
+ * import any optional peer dependency — most importantly `@uniweb/build`,
11
+ * which is absent in `npx uniweb create` scratch dirs and global
12
+ * installs. Workspace package discovery (which does need `@uniweb/build`)
13
+ * lives in `./discover.js` and is loaded only by commands that already
14
+ * require a project context.
6
15
  */
7
16
 
8
17
  import { existsSync, readFileSync } from 'node:fs'
@@ -10,7 +19,6 @@ import { readFile, writeFile } from 'node:fs/promises'
10
19
  import { join } from 'node:path'
11
20
  import { homedir } from 'node:os'
12
21
  import yaml from 'js-yaml'
13
- import { classifyPackage } from '@uniweb/build'
14
22
  import { filterCmd } from './pm.js'
15
23
 
16
24
  // ── Platform URLs ──────────────────────────────────────────────
@@ -223,63 +231,6 @@ export async function updateRootScripts(rootDir, sites, pm = 'pnpm') {
223
231
  await writeRootPackageJson(rootDir, pkg)
224
232
  }
225
233
 
226
- /**
227
- * Discover foundations in the workspace
228
- * @param {string} rootDir - Workspace root directory
229
- * @returns {Promise<Array<{name: string, path: string}>>}
230
- */
231
- export async function discoverFoundations(rootDir) {
232
- return discoverByKind(rootDir, 'foundation')
233
- }
234
-
235
- /**
236
- * Discover sites in the workspace
237
- * @param {string} rootDir - Workspace root directory
238
- * @returns {Promise<Array<{name: string, path: string}>>}
239
- */
240
- export async function discoverSites(rootDir) {
241
- return discoverByKind(rootDir, 'site')
242
- }
243
-
244
- /**
245
- * Walk the workspace globs and return packages of the requested kind.
246
- * Uses `classifyPackage` from @uniweb/build — the canonical classifier
247
- * shared with the build pipeline, which keys on real signals (site.yml
248
- * for sites, generated entry for foundations) rather than which
249
- * `@uniweb/*` packages happen to be in dependencies. Templates whose
250
- * sites pull runtime transitively through the foundation (e.g.,
251
- * marketing) used to be invisible to the older dependency-based check.
252
- */
253
- async function discoverByKind(rootDir, kind) {
254
- const { packages } = await readWorkspaceConfig(rootDir)
255
- const out = []
256
-
257
- for (const pattern of packages) {
258
- const dirs = await resolveGlob(rootDir, pattern)
259
- for (const dir of dirs) {
260
- const fullPath = join(rootDir, dir)
261
- if (classifyPackage(fullPath) !== kind) continue
262
-
263
- // Read package.json for the package name. Synthesize one from
264
- // the directory if it's missing or malformed — we still want
265
- // the package to surface in pickers.
266
- const pkgPath = join(fullPath, 'package.json')
267
- let name = dir.split('/').pop()
268
- if (existsSync(pkgPath)) {
269
- try {
270
- const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'))
271
- if (pkg.name) name = pkg.name
272
- } catch {
273
- // keep directory-derived name
274
- }
275
- }
276
- out.push({ name, path: dir })
277
- }
278
- }
279
-
280
- return out
281
- }
282
-
283
234
  // Resolve a workspace glob pattern to actual directories
284
235
  export async function resolveGlob(rootDir, pattern) {
285
236
  const clean = pattern.replace(/^["']|["']$/g, '')
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Workspace package discovery
3
+ *
4
+ * Walks the workspace globs and classifies each package as a site or
5
+ * foundation using `classifyPackage` from `@uniweb/build` — the canonical
6
+ * classifier shared with the build pipeline. It keys on real signals
7
+ * (site.yml for sites, generated entry for foundations) rather than which
8
+ * `@uniweb/*` packages happen to be in dependencies, so templates whose
9
+ * sites pull runtime transitively through the foundation (e.g., marketing)
10
+ * are classified correctly.
11
+ *
12
+ * Why this lives in its own file: `@uniweb/build` is an OPTIONAL peer
13
+ * dependency of the CLI. The CLI's startup path (`src/index.js` and
14
+ * everything it statically imports) MUST run in environments where
15
+ * `@uniweb/build` is not installed — `npx uniweb create` in a scratch
16
+ * dir, `npm i -g uniweb` before any project exists, etc. Anything that
17
+ * imports `@uniweb/build` therefore must NOT be reachable from the
18
+ * startup graph; it must be loaded dynamically by commands that already
19
+ * require a project context. Keeping discovery in this dedicated module
20
+ * makes that boundary structural rather than conventional.
21
+ */
22
+
23
+ import { existsSync } from 'node:fs'
24
+ import { readFile } from 'node:fs/promises'
25
+ import { join } from 'node:path'
26
+ import { classifyPackage } from '@uniweb/build'
27
+ import { readWorkspaceConfig, resolveGlob } from './config.js'
28
+
29
+ /**
30
+ * Discover foundations in the workspace.
31
+ * @param {string} rootDir - Workspace root directory
32
+ * @returns {Promise<Array<{name: string, path: string}>>}
33
+ */
34
+ export async function discoverFoundations(rootDir) {
35
+ return discoverByKind(rootDir, 'foundation')
36
+ }
37
+
38
+ /**
39
+ * Discover sites in the workspace.
40
+ * @param {string} rootDir - Workspace root directory
41
+ * @returns {Promise<Array<{name: string, path: string}>>}
42
+ */
43
+ export async function discoverSites(rootDir) {
44
+ return discoverByKind(rootDir, 'site')
45
+ }
46
+
47
+ async function discoverByKind(rootDir, kind) {
48
+ const { packages } = await readWorkspaceConfig(rootDir)
49
+ const out = []
50
+
51
+ for (const pattern of packages) {
52
+ const dirs = await resolveGlob(rootDir, pattern)
53
+ for (const dir of dirs) {
54
+ const fullPath = join(rootDir, dir)
55
+ if (classifyPackage(fullPath) !== kind) continue
56
+
57
+ // Read package.json for the package name. Synthesize one from
58
+ // the directory if it's missing or malformed — we still want
59
+ // the package to surface in pickers.
60
+ const pkgPath = join(fullPath, 'package.json')
61
+ let name = dir.split('/').pop()
62
+ if (existsSync(pkgPath)) {
63
+ try {
64
+ const pkg = JSON.parse(await readFile(pkgPath, 'utf-8'))
65
+ if (pkg.name) name = pkg.name
66
+ } catch {
67
+ // keep directory-derived name
68
+ }
69
+ }
70
+ out.push({ name, path: dir })
71
+ }
72
+ }
73
+
74
+ return out
75
+ }
@@ -5,7 +5,8 @@
5
5
  * and detects collisions with existing workspace packages.
6
6
  */
7
7
 
8
- import { discoverFoundations, discoverSites, readWorkspaceConfig, resolveGlob } from './config.js'
8
+ import { readWorkspaceConfig, resolveGlob } from './config.js'
9
+ import { discoverFoundations, discoverSites } from './discover.js'
9
10
  import { existsSync } from 'node:fs'
10
11
  import { readFile } from 'node:fs/promises'
11
12
  import { join } from 'node:path'