uniweb 1.25.0 → 1.25.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 +6 -6
- package/src/commands/build.js +7 -21
- package/src/framework-index.json +5 -5
- package/src/index.js +2 -0
- package/src/utils/closed-reader.js +65 -0
- package/src/utils/exit.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.2",
|
|
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/content-writer": "~1.3.1",
|
|
45
|
-
"@uniweb/core": "~1.6.0",
|
|
46
44
|
"@uniweb/schemas": "~1.6.7",
|
|
47
|
-
"@uniweb/
|
|
45
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
46
|
+
"@uniweb/semantic-parser": "~1.13.2",
|
|
47
|
+
"@uniweb/core": "~1.6.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@uniweb/
|
|
50
|
+
"@uniweb/semantic-parser": "~1.13.2",
|
|
51
51
|
"@uniweb/content-reader": "~1.5.8",
|
|
52
|
-
"@uniweb/
|
|
52
|
+
"@uniweb/build": "~1.14.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@uniweb/build": {
|
package/src/commands/build.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
|
|
58
58
|
import { resolve, join, dirname, basename, relative } from 'node:path'
|
|
59
|
-
import {
|
|
59
|
+
import { runRelayed } from '../utils/closed-reader.js'
|
|
60
60
|
import { writeFile, mkdir } from 'node:fs/promises'
|
|
61
61
|
import { createRequire } from 'node:module'
|
|
62
62
|
|
|
@@ -143,27 +143,13 @@ function detectProjectType(projectDir) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
|
-
* Run a command and
|
|
146
|
+
* Run a command, and throw if it fails
|
|
147
147
|
*/
|
|
148
|
-
function runCommand(command, args, cwd) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
cwd,
|
|
154
|
-
stdio: 'inherit'
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
proc.on('close', (code) => {
|
|
158
|
-
if (code === 0) {
|
|
159
|
-
resolve()
|
|
160
|
-
} else {
|
|
161
|
-
reject(new Error(`Command failed with exit code ${code}`))
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
proc.on('error', reject)
|
|
166
|
-
})
|
|
148
|
+
async function runCommand(command, args, cwd) {
|
|
149
|
+
// No shell: the command is node and a script path, which needs none — and a shell
|
|
150
|
+
// splits a path with a space in it. (Node warns DEP0190 on args passed with one.)
|
|
151
|
+
const code = await runRelayed(command, args, { cwd })
|
|
152
|
+
if (code !== 0) throw new Error(`Command failed with exit code ${code}`)
|
|
167
153
|
}
|
|
168
154
|
|
|
169
155
|
/**
|
package/src/framework-index.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-02T00:59:43.168Z",
|
|
4
4
|
"packages": {
|
|
5
5
|
"@uniweb/api": {
|
|
6
6
|
"version": "1.6.8"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"version": "1.1.2"
|
|
31
31
|
},
|
|
32
32
|
"@uniweb/press": {
|
|
33
|
-
"version": "1.2.
|
|
33
|
+
"version": "1.2.1"
|
|
34
34
|
},
|
|
35
35
|
"@uniweb/projections": {
|
|
36
36
|
"version": "1.2.10"
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
"version": "1.1.2"
|
|
55
55
|
},
|
|
56
56
|
"@uniweb/templates": {
|
|
57
|
-
"version": "1.2.
|
|
57
|
+
"version": "1.2.1"
|
|
58
58
|
},
|
|
59
59
|
"@uniweb/theming": {
|
|
60
60
|
"version": "1.2.1"
|
|
61
61
|
},
|
|
62
62
|
"@uniweb/unipress": {
|
|
63
|
-
"version": "1.1.
|
|
63
|
+
"version": "1.1.30"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"templates": {
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
},
|
|
199
199
|
"business-docs": {
|
|
200
200
|
"name": "Business Documents",
|
|
201
|
-
"description": "A complete business-document site: invoice and SOW records, pages listing them, and
|
|
201
|
+
"description": "A complete business-document site: invoice and SOW records, pages listing them, and an engagement report, each page downloadable as Word, Excel or a print page. Built on @unipress/business-docs and demonstrates the same foundation that ships the unipress invoice template.",
|
|
202
202
|
"tags": [
|
|
203
203
|
"business-docs",
|
|
204
204
|
"invoice",
|
package/src/index.js
CHANGED
|
@@ -73,6 +73,7 @@ import {
|
|
|
73
73
|
} from './utils/interactive.js'
|
|
74
74
|
import { findWorkspaceRoot } from './utils/workspace.js'
|
|
75
75
|
import { exitWhenDrained } from './utils/exit.js'
|
|
76
|
+
import { outliveTheReader } from './utils/closed-reader.js'
|
|
76
77
|
import { isGitRepo } from './utils/git.js'
|
|
77
78
|
|
|
78
79
|
// Colors for terminal output
|
|
@@ -646,6 +647,7 @@ function computeFoundationFilePath(sitePath, foundationPath) {
|
|
|
646
647
|
}
|
|
647
648
|
|
|
648
649
|
async function main() {
|
|
650
|
+
outliveTheReader()
|
|
649
651
|
const rawArgs = process.argv.slice(2)
|
|
650
652
|
const nonInteractive = isNonInteractive(rawArgs)
|
|
651
653
|
const args = stripNonInteractiveFlag(rawArgs)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reader that goes away stops the output, never the work.
|
|
3
|
+
*
|
|
4
|
+
* ⛔ An agent trims what it reads, and `uniweb create x | head -20` closes the pipe after twenty
|
|
5
|
+
* lines. The next line raised EPIPE, which nothing handled, so the process ended there: 14 of the
|
|
6
|
+
* project's 27 files, and the same command again said the directory exists. `uniweb build | head -5`
|
|
7
|
+
* left no site. Merged with `2>&1` the stack trace went into the closed pipe too, so what came back
|
|
8
|
+
* was healthy lines and head's exit status, 0 (measured 2026-11-01).
|
|
9
|
+
*
|
|
10
|
+
* ⭐ So a process nobody is reading keeps going, and exits with what the work came to.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { spawn } from 'node:child_process'
|
|
14
|
+
import { fstatSync } from 'node:fs'
|
|
15
|
+
import { whenDrained } from './exit.js'
|
|
16
|
+
|
|
17
|
+
/** For the CLI's own process, once, before it prints. Any other write error stays an error. */
|
|
18
|
+
export function outliveTheReader() {
|
|
19
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
20
|
+
stream.on('error', (err) => {
|
|
21
|
+
if (err.code !== 'EPIPE') throw err
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A terminal or a file can't stop reading, and a child handed one directly keeps its colours and
|
|
27
|
+
// the exact order of its two streams.
|
|
28
|
+
function readerCanLeave(fd) {
|
|
29
|
+
try {
|
|
30
|
+
const at = fstatSync(fd)
|
|
31
|
+
return at.isFIFO() || at.isSocket()
|
|
32
|
+
} catch {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Run a child that does work and prints as it goes. Handed our output directly, it meets a closed
|
|
39
|
+
* pipe in its own process and dies of it, as Vite does. So where the reader can leave, the child
|
|
40
|
+
* writes to us and we pass it on, and only our writes can fail. pnpm and npm survive a closed reader
|
|
41
|
+
* (measured 2026-11-01), our own CLI does through `outliveTheReader`, and a dev server has no work to
|
|
42
|
+
* finish, so those keep `stdio: 'inherit'`.
|
|
43
|
+
*
|
|
44
|
+
* Resolves with the exit code, once the child's output has left this process, so an exit straight
|
|
45
|
+
* after loses none of it (`exit.js`).
|
|
46
|
+
*
|
|
47
|
+
* @param {string} command
|
|
48
|
+
* @param {string[]} args
|
|
49
|
+
* @param {import('node:child_process').SpawnOptions} [options]
|
|
50
|
+
* @returns {Promise<number|null>}
|
|
51
|
+
*/
|
|
52
|
+
export function runRelayed(command, args, options = {}) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const child = spawn(command, args, {
|
|
55
|
+
...options,
|
|
56
|
+
stdio: ['inherit', readerCanLeave(1) ? 'pipe' : 'inherit', readerCanLeave(2) ? 'pipe' : 'inherit']
|
|
57
|
+
})
|
|
58
|
+
// Not `.pipe()`: that stops reading when its destination fails, and the child then blocks on a
|
|
59
|
+
// full pipe for good.
|
|
60
|
+
child.stdout?.on('data', (chunk) => process.stdout.write(chunk))
|
|
61
|
+
child.stderr?.on('data', (chunk) => process.stderr.write(chunk))
|
|
62
|
+
child.on('error', reject)
|
|
63
|
+
child.on('close', (code) => whenDrained().then(() => resolve(code)))
|
|
64
|
+
})
|
|
65
|
+
}
|
package/src/utils/exit.js
CHANGED
|
@@ -18,10 +18,15 @@
|
|
|
18
18
|
* @returns {Promise<never>}
|
|
19
19
|
*/
|
|
20
20
|
export async function exitWhenDrained(code = 0) {
|
|
21
|
-
await
|
|
21
|
+
await whenDrained()
|
|
22
22
|
process.exit(code)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** Once everything written so far to stdout and stderr has left this process. */
|
|
26
|
+
export function whenDrained() {
|
|
27
|
+
return Promise.all([process.stdout, process.stderr].map(drained))
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
function drained(stream) {
|
|
26
31
|
return new Promise((resolve) => {
|
|
27
32
|
if (!stream || stream.destroyed || stream.writableEnded) return resolve()
|