@lexibase/create-rdx 4.2.1 → 4.2.2-beta.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.
- package/bin/pnpm-progress.mjs +66 -14
- package/package.json +1 -1
package/bin/pnpm-progress.mjs
CHANGED
|
@@ -6,7 +6,7 @@ export function createPnpmProgress({
|
|
|
6
6
|
output = process.stdout,
|
|
7
7
|
errors = process.stderr,
|
|
8
8
|
interactive = Boolean(output.isTTY) && process.env.TERM !== 'dumb',
|
|
9
|
-
intervalMs =
|
|
9
|
+
intervalMs = 125,
|
|
10
10
|
heartbeatMs = 15_000,
|
|
11
11
|
now = () => performance.now(),
|
|
12
12
|
} = {}) {
|
|
@@ -26,9 +26,15 @@ export function createPnpmProgress({
|
|
|
26
26
|
let finished = false
|
|
27
27
|
let promptOpen = false
|
|
28
28
|
let previousPhase
|
|
29
|
+
let frameWidth = 0
|
|
30
|
+
let platformWarning
|
|
31
|
+
let skippedPlatforms = 0
|
|
29
32
|
const elapsed = () => `${((now() - started) / 1000).toFixed(1)}s`
|
|
30
33
|
const clear = () => {
|
|
31
|
-
if (interactive)
|
|
34
|
+
if (interactive && frameWidth) {
|
|
35
|
+
output.write('\r\x1b[2K')
|
|
36
|
+
frameWidth = 0
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
function render() {
|
|
34
40
|
const total = totals.size
|
|
@@ -60,8 +66,15 @@ export function createPnpmProgress({
|
|
|
60
66
|
// pnpm emits many debug records per package. Paint on the timer instead
|
|
61
67
|
// of turning each record into terminal writes during large installations.
|
|
62
68
|
if (!force && intervalMs > 0 && previousPhase === phase) return
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
const line = render()
|
|
70
|
+
const previousWidth = Math.min(
|
|
71
|
+
frameWidth,
|
|
72
|
+
Math.max(1, (output.columns || 100) - 1)
|
|
73
|
+
)
|
|
74
|
+
// Write the replacement and any trailing padding atomically. Clearing the
|
|
75
|
+
// row in a separate write exposes a blank frame in Windows terminals.
|
|
76
|
+
output.write('\r' + line.padEnd(previousWidth, ' '))
|
|
77
|
+
frameWidth = line.length
|
|
65
78
|
} else if (force || previousPhase !== phase) {
|
|
66
79
|
output.write(
|
|
67
80
|
`[RDX] ${phase}: resolved ${counts.resolved}, cached ${counts.cached}, downloaded ${counts.downloaded}, linked ${counts.linked} (${elapsed()}).\n`
|
|
@@ -70,12 +83,31 @@ export function createPnpmProgress({
|
|
|
70
83
|
previousPhase = phase
|
|
71
84
|
}
|
|
72
85
|
function message(text, stream = output) {
|
|
86
|
+
flushPlatformWarning()
|
|
73
87
|
if (!promptOpen) clear()
|
|
74
88
|
stream.write(text)
|
|
75
89
|
// Keep prompts without a newline visible and leave the cursor after them.
|
|
76
90
|
promptOpen = !text.endsWith('\n')
|
|
77
91
|
if (text.endsWith('\n')) draw(true)
|
|
78
92
|
}
|
|
93
|
+
function diagnostic(event) {
|
|
94
|
+
const error = event.err || event
|
|
95
|
+
const text = [
|
|
96
|
+
error.code,
|
|
97
|
+
error.message || event.message,
|
|
98
|
+
error.hint,
|
|
99
|
+
error.pkgsStack && JSON.stringify(error.pkgsStack),
|
|
100
|
+
]
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.join('\n')
|
|
103
|
+
message(`[pnpm] ${text || JSON.stringify(event)}\n`, errors)
|
|
104
|
+
}
|
|
105
|
+
function flushPlatformWarning() {
|
|
106
|
+
if (!platformWarning) return
|
|
107
|
+
const { event } = platformWarning
|
|
108
|
+
platformWarning = undefined
|
|
109
|
+
diagnostic(event)
|
|
110
|
+
}
|
|
79
111
|
function record(line) {
|
|
80
112
|
if (!line.trim()) {
|
|
81
113
|
if (promptOpen) message('\n')
|
|
@@ -101,6 +133,30 @@ export function createPnpmProgress({
|
|
|
101
133
|
output.write('\n')
|
|
102
134
|
promptOpen = false
|
|
103
135
|
}
|
|
136
|
+
if (platformWarning) {
|
|
137
|
+
if (
|
|
138
|
+
event.name === 'pnpm:skipped-optional-dependency' &&
|
|
139
|
+
event.reason === 'unsupported_platform' &&
|
|
140
|
+
event.package?.id === platformWarning.id &&
|
|
141
|
+
event.prefix === platformWarning.event.prefix
|
|
142
|
+
) {
|
|
143
|
+
platformWarning = undefined
|
|
144
|
+
skippedPlatforms++
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
flushPlatformWarning()
|
|
148
|
+
}
|
|
149
|
+
if (event.name === 'pnpm:install-check' && event.level === 'warn') {
|
|
150
|
+
const match = /^Unsupported platform for (.+?): wanted /.exec(
|
|
151
|
+
event.message || ''
|
|
152
|
+
)
|
|
153
|
+
if (match) {
|
|
154
|
+
// pnpm emits the warning before confirming that this is an optional
|
|
155
|
+
// package for another OS/CPU. Suppress only the confirmed matching pair.
|
|
156
|
+
platformWarning = { id: match[1], event }
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
}
|
|
104
160
|
if (
|
|
105
161
|
event.name === 'pnpm:progress' &&
|
|
106
162
|
Object.hasOwn(statuses, event.status)
|
|
@@ -129,16 +185,7 @@ export function createPnpmProgress({
|
|
|
129
185
|
} else if (event.name === 'pnpm:lifecycle' && event.line) {
|
|
130
186
|
message(`[pnpm:${event.stage || 'script'}] ${event.line}\n`)
|
|
131
187
|
} else if (event.level === 'warn' || event.level === 'error') {
|
|
132
|
-
|
|
133
|
-
const text = [
|
|
134
|
-
error.code,
|
|
135
|
-
error.message || event.message,
|
|
136
|
-
error.hint,
|
|
137
|
-
error.pkgsStack && JSON.stringify(error.pkgsStack),
|
|
138
|
-
]
|
|
139
|
-
.filter(Boolean)
|
|
140
|
-
.join('\n')
|
|
141
|
-
message(`[pnpm] ${text || JSON.stringify(event)}\n`, errors)
|
|
188
|
+
diagnostic(event)
|
|
142
189
|
} else if (event.name === 'pnpm:peer-dependency-issues') {
|
|
143
190
|
message(
|
|
144
191
|
`[pnpm] Peer dependency issues:\n${JSON.stringify(event.issuesByProjects || event, null, 2)}\n`,
|
|
@@ -179,12 +226,17 @@ export function createPnpmProgress({
|
|
|
179
226
|
record(buffer)
|
|
180
227
|
buffer = ''
|
|
181
228
|
}
|
|
229
|
+
flushPlatformWarning()
|
|
182
230
|
finished = true
|
|
183
231
|
if (promptOpen) {
|
|
184
232
|
output.write('\n')
|
|
185
233
|
promptOpen = false
|
|
186
234
|
}
|
|
187
235
|
clear()
|
|
236
|
+
if (skippedPlatforms)
|
|
237
|
+
output.write(
|
|
238
|
+
`[RDX] Skipped ${skippedPlatforms} optional package${skippedPlatforms === 1 ? '' : 's'} for other platforms.\n`
|
|
239
|
+
)
|
|
188
240
|
output.write(
|
|
189
241
|
`[RDX] ${success ? 'Dependencies installed' : 'Installation stopped'}: ${counts.linked} linked, ${counts.cached} cached, ${counts.downloaded} downloaded (${elapsed()}).\n`
|
|
190
242
|
)
|