bimba-cli 0.4.5 → 0.4.7
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 +1 -1
- package/plugin.js +1 -1
- package/serve.js +19 -14
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -55,7 +55,7 @@ export const imbaPlugin = {
|
|
|
55
55
|
|
|
56
56
|
// the file has been successfully compiled
|
|
57
57
|
if (!out.errors?.length) {
|
|
58
|
-
console.log(theme.action("compiling: ") + theme.folder(dir.join(f.dir,'/')) + theme.filename(f.base) + " - " + theme.success("
|
|
58
|
+
console.log(theme.action("compiling: ") + theme.folder(dir.join(f.dir,'/')) + theme.filename(f.base) + " - " + theme.success("compiled"));
|
|
59
59
|
stats.bundled++;
|
|
60
60
|
stats.compiled++;
|
|
61
61
|
contents = out.js;
|
package/serve.js
CHANGED
|
@@ -184,9 +184,10 @@ export function serve(entrypoint, flags) {
|
|
|
184
184
|
const sockets = new Set()
|
|
185
185
|
let importMapTag = null
|
|
186
186
|
|
|
187
|
+
let _lastLines = 0
|
|
187
188
|
let _fadeTimers = []
|
|
188
189
|
let _fadeId = 0
|
|
189
|
-
let
|
|
190
|
+
let _cursorOnLine = false
|
|
190
191
|
|
|
191
192
|
function cancelFade() {
|
|
192
193
|
_fadeTimers.forEach(t => clearTimeout(t))
|
|
@@ -195,18 +196,22 @@ export function serve(entrypoint, flags) {
|
|
|
195
196
|
|
|
196
197
|
function printStatus(file, state, errors) {
|
|
197
198
|
cancelFade()
|
|
198
|
-
if (
|
|
199
|
-
process.stdout.write('\x1b[
|
|
200
|
-
|
|
199
|
+
if (_cursorOnLine) {
|
|
200
|
+
process.stdout.write('\x1b[1G\x1b[J')
|
|
201
|
+
_lastLines = 0
|
|
202
|
+
_cursorOnLine = false
|
|
203
|
+
} else if (_lastLines > 0) {
|
|
204
|
+
process.stdout.write(`\x1b[${_lastLines}A\x1b[J`)
|
|
205
|
+
_lastLines = 0
|
|
201
206
|
}
|
|
202
207
|
const now = new Date().toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit', second: '2-digit' })
|
|
203
208
|
const status = state === 'ok' ? theme.success(' ok ') : theme.failure(' fail ')
|
|
204
|
-
process.stdout.write('\x1b[s')
|
|
205
|
-
_statusSaved = true
|
|
206
209
|
if (errors?.length) {
|
|
207
210
|
process.stdout.write(` ${theme.folder(now)} ${theme.filename(file)} ${status}\n`)
|
|
211
|
+
_lastLines = 1
|
|
208
212
|
for (const err of errors) {
|
|
209
|
-
|
|
213
|
+
printerr(err)
|
|
214
|
+
_lastLines += 5
|
|
210
215
|
}
|
|
211
216
|
} else {
|
|
212
217
|
const myId = ++_fadeId
|
|
@@ -216,13 +221,16 @@ export function serve(entrypoint, flags) {
|
|
|
216
221
|
const charDelay = 22
|
|
217
222
|
|
|
218
223
|
process.stdout.write(` ${theme.folder(now)} ${theme.filename(file)} ${status}`)
|
|
224
|
+
_lastLines = 1
|
|
225
|
+
_cursorOnLine = true
|
|
219
226
|
|
|
220
227
|
for (let i = 1; i <= totalLen; i++) {
|
|
221
228
|
_fadeTimers.push(setTimeout(() => {
|
|
222
|
-
if (_fadeId !== myId) return
|
|
223
|
-
process.stdout.write('\x1b[1D
|
|
229
|
+
if (_fadeId !== myId || _lastLines !== 1) return
|
|
230
|
+
process.stdout.write('\x1b[1D\x1b[K')
|
|
224
231
|
if (i === totalLen) {
|
|
225
|
-
|
|
232
|
+
_lastLines = 0
|
|
233
|
+
_cursorOnLine = false
|
|
226
234
|
}
|
|
227
235
|
}, startDelay + i * charDelay))
|
|
228
236
|
}
|
|
@@ -277,10 +285,7 @@ export function serve(entrypoint, flags) {
|
|
|
277
285
|
}
|
|
278
286
|
return new Response(out.js, { headers: { 'Content-Type': 'application/javascript' } })
|
|
279
287
|
} catch (e) {
|
|
280
|
-
|
|
281
|
-
printStatus(file, 'fail', [{ message: e.message }])
|
|
282
|
-
const payload = JSON.stringify({ type: 'error', file, errors: [{ message: e.message }] })
|
|
283
|
-
for (const socket of sockets) socket.send(payload)
|
|
288
|
+
console.error(theme.failure('Compile error: ') + theme.filename(pathname) + '\n' + e.message)
|
|
284
289
|
return new Response(e.message, { status: 500 })
|
|
285
290
|
}
|
|
286
291
|
}
|