uniweb 0.12.1 → 0.12.2

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.1",
3
+ "version": "0.12.2",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,8 +42,8 @@
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.0.0",
44
44
  "@uniweb/core": "0.7.9",
45
- "@uniweb/kit": "0.9.9",
46
- "@uniweb/runtime": "0.8.10"
45
+ "@uniweb/runtime": "0.8.10",
46
+ "@uniweb/kit": "0.9.9"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@uniweb/build": "0.13.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-04-29T13:42:04.684Z",
3
+ "generatedAt": "2026-04-29T13:50:36.314Z",
4
4
  "packages": {
5
5
  "@uniweb/build": {
6
6
  "version": "0.13.1",
@@ -82,7 +82,7 @@
82
82
  "deps": []
83
83
  },
84
84
  "@uniweb/templates": {
85
- "version": "0.7.35",
85
+ "version": "0.7.36",
86
86
  "path": "framework/templates",
87
87
  "deps": []
88
88
  },
@@ -92,7 +92,7 @@
92
92
  "deps": []
93
93
  },
94
94
  "@uniweb/unipress": {
95
- "version": "0.4.0",
95
+ "version": "0.4.1",
96
96
  "path": "framework/unipress",
97
97
  "deps": [
98
98
  "@uniweb/build",
package/src/index.js CHANGED
@@ -26,13 +26,14 @@ import { execSync, spawn as spawnChild } from 'node:child_process'
26
26
  import { resolve, join, relative, dirname } from 'node:path'
27
27
  import { fileURLToPath } from 'node:url'
28
28
  import prompts from 'prompts'
29
- import { doctor } from './commands/doctor.js'
29
+ // `doctor`, `add`, `publish`, and `deploy` are loaded lazily via
30
+ // importProjectCommand() — each imports `@uniweb/build` at the top,
31
+ // so a static import here would crash `npx uniweb@latest create …`
32
+ // (no @uniweb/build in the npx scratch dir) before any command runs.
33
+ // Same pattern as `build` and `docs`.
30
34
  import { i18n } from './commands/i18n.js'
31
35
  import { inspect } from './commands/inspect.js'
32
- import { add } from './commands/add.js'
33
36
  import { login } from './commands/login.js'
34
- import { publish } from './commands/publish.js'
35
- import { deploy } from './commands/deploy.js'
36
37
  import { invite } from './commands/invite.js'
37
38
  import { handoff } from './commands/handoff.js'
38
39
  import { update } from './commands/update.js'
@@ -491,8 +492,9 @@ async function main() {
491
492
  return
492
493
  }
493
494
 
494
- // Handle doctor command
495
+ // Handle doctor command (dynamic import — depends on @uniweb/build)
495
496
  if (command === 'doctor') {
497
+ const { doctor } = await importProjectCommand('./commands/doctor.js')
496
498
  await doctor(args.slice(1))
497
499
  return
498
500
  }
@@ -509,20 +511,23 @@ async function main() {
509
511
  return
510
512
  }
511
513
 
512
- // Handle add command
514
+ // Handle add command (dynamic import — depends on @uniweb/build)
513
515
  if (command === 'add') {
516
+ const { add } = await importProjectCommand('./commands/add.js')
514
517
  await add(args.slice(1))
515
518
  return
516
519
  }
517
520
 
518
- // Handle publish command
521
+ // Handle publish command (dynamic import — depends on @uniweb/build)
519
522
  if (command === 'publish') {
523
+ const { publish } = await importProjectCommand('./commands/publish.js')
520
524
  await publish(args.slice(1))
521
525
  return
522
526
  }
523
527
 
524
- // Handle deploy command
528
+ // Handle deploy command (dynamic import — depends on @uniweb/build)
525
529
  if (command === 'deploy') {
530
+ const { deploy } = await importProjectCommand('./commands/deploy.js')
526
531
  await deploy(args.slice(1))
527
532
  return
528
533
  }
@@ -10,7 +10,20 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs'
10
10
  import { readFile } from 'node:fs/promises'
11
11
  import { resolve, dirname, join } from 'node:path'
12
12
  import yaml from 'js-yaml'
13
- import { classifyPackage as classifyPackageSync } from '@uniweb/build'
13
+
14
+ // `classifyPackage` from @uniweb/build is loaded lazily — this module
15
+ // is statically imported by index.js (for `findWorkspaceRoot`), and a
16
+ // top-level @uniweb/build import would crash `npx uniweb@latest create`
17
+ // before any command runs (the npx scratch dir has only the CLI's
18
+ // declared deps; @uniweb/build comes from a project's node_modules).
19
+ let _classifyPackageSync = null
20
+ async function getClassifier() {
21
+ if (!_classifyPackageSync) {
22
+ const mod = await import('@uniweb/build')
23
+ _classifyPackageSync = mod.classifyPackage
24
+ }
25
+ return _classifyPackageSync
26
+ }
14
27
 
15
28
  /**
16
29
  * Check if a directory is a workspace root.
@@ -135,7 +148,8 @@ export async function getWorkspacePackages(workspaceRoot) {
135
148
  * @returns {Promise<'foundation'|'site'|null>}
136
149
  */
137
150
  export async function classifyPackage(packagePath) {
138
- return classifyPackageSync(packagePath)
151
+ const classify = await getClassifier()
152
+ return classify(packagePath)
139
153
  }
140
154
 
141
155
  /**
@@ -144,8 +158,11 @@ export async function classifyPackage(packagePath) {
144
158
  * @returns {Promise<string[]>} - Array of foundation paths (relative to workspace root)
145
159
  */
146
160
  export async function findFoundations(workspaceRoot) {
147
- const packages = await getWorkspacePackages(workspaceRoot)
148
- return packages.filter(pkg => classifyPackageSync(join(workspaceRoot, pkg)) === 'foundation')
161
+ const [packages, classify] = await Promise.all([
162
+ getWorkspacePackages(workspaceRoot),
163
+ getClassifier(),
164
+ ])
165
+ return packages.filter(pkg => classify(join(workspaceRoot, pkg)) === 'foundation')
149
166
  }
150
167
 
151
168
  /**
@@ -154,8 +171,11 @@ export async function findFoundations(workspaceRoot) {
154
171
  * @returns {Promise<string[]>} - Array of site paths (relative to workspace root)
155
172
  */
156
173
  export async function findSites(workspaceRoot) {
157
- const packages = await getWorkspacePackages(workspaceRoot)
158
- return packages.filter(pkg => classifyPackageSync(join(workspaceRoot, pkg)) === 'site')
174
+ const [packages, classify] = await Promise.all([
175
+ getWorkspacePackages(workspaceRoot),
176
+ getClassifier(),
177
+ ])
178
+ return packages.filter(pkg => classify(join(workspaceRoot, pkg)) === 'site')
159
179
  }
160
180
 
161
181
  /**