-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[legacy-framework] Move display package to nextjs fork #2989
Changes from 1 commit
906b41a
3cac34d
294d742
7cdd88d
74a534c
9c7443b
6de0696
ec750c5
07809a8
f0fcad0
3277e1e
730b0aa
4081227
3111da4
6446c19
740dfd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { ISettingsParam, Logger } from 'tslog' | ||
import { loadConfigAtRuntime, LogLevel } from '../config-shared' | ||
import c from 'chalk' | ||
import { Table } from 'console-table-printer' | ||
import ora from 'ora' | ||
import readline from 'readline' | ||
|
||
// eslint-disable-next-line | ||
declare module globalThis { | ||
|
@@ -65,3 +69,165 @@ export const baseLogger = (options?: ISettingsParam): Logger => { | |
|
||
return globalThis._blitz_baseLogger | ||
} | ||
|
||
export const table = Table | ||
export const chalk = c | ||
|
||
// const blitzTrueBrandColor = '6700AB' | ||
const blitzBrightBrandColor = '8a3df0' | ||
|
||
// Using bright brand color so it's better for dark terminals | ||
const brandColor = blitzBrightBrandColor | ||
|
||
const withBrand = (str: string) => { | ||
return c.hex(brandColor).bold(str) | ||
} | ||
|
||
const withWarning = (str: string) => { | ||
return `⚠️ ${c.yellow(str)}` | ||
} | ||
|
||
const withCaret = (str: string) => { | ||
return `${c.gray('>')} ${str}` | ||
} | ||
|
||
const withCheck = (str: string) => { | ||
return `${c.green('✔')} ${str}` | ||
} | ||
|
||
const withX = (str: string) => { | ||
return `${c.red.bold('✕')} ${str}` | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove in favor of tslog.error |
||
|
||
const withProgress = (str: string) => { | ||
return withCaret(str) | ||
} | ||
const withError = (str: string) => { | ||
return withX(c.red.bold(str)) | ||
} | ||
|
||
/** | ||
* Logs a branded purple message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const branded = (msg: string) => { | ||
console.log(c.hex(brandColor).bold(msg)) | ||
} | ||
|
||
/** | ||
* Clears the line and optionally log a message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const clearLine = (msg?: string) => { | ||
readline.clearLine(process.stdout, 0) | ||
readline.cursorTo(process.stdout, 0) | ||
msg && process.stdout.write(msg) | ||
} | ||
|
||
const clearConsole = () => { | ||
if (process.platform === 'win32') { | ||
process.stdout.write('\x1B[2J\x1B[0f') | ||
} else { | ||
process.stdout.write('\x1B[2J\x1B[3J\x1B[H') | ||
} | ||
} | ||
|
||
/** | ||
* Logs a red error message to stderr. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const warning = (msg: string) => { | ||
console.log(withCaret(withWarning(msg))) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove in favor of tslog.warn |
||
|
||
/** | ||
* Logs a red error message to stderr. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const error = (msg: string) => { | ||
console.error(withX(c.red.bold(msg))) | ||
} | ||
|
||
/** | ||
* Logs a subtle gray message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const meta = (msg: string) => { | ||
console.log(withCaret(c.gray(msg))) | ||
} | ||
|
||
/** | ||
* Logs a progress message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const progress = (msg: string) => { | ||
console.log(withProgress(msg)) | ||
} | ||
|
||
const info = (msg: string) => { | ||
console.log(c.bold(msg)) | ||
} | ||
|
||
const spinner = (str: string) => { | ||
return ora({ | ||
text: str, | ||
color: 'blue', | ||
spinner: { | ||
interval: 120, | ||
frames: ['◢', '◣', '◤', '◥'], | ||
}, | ||
}) | ||
} | ||
|
||
/** | ||
* Logs a green success message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const success = (msg: string) => { | ||
console.log(withCheck(c.green(msg))) | ||
} | ||
|
||
/** | ||
* Colorizes a variable for display. | ||
* | ||
* @param {string} val | ||
*/ | ||
const variable = (val: any) => { | ||
return c.cyan.bold(`${val}`) | ||
} | ||
|
||
/** | ||
* If the DEBUG env var is set this will write to the console | ||
* @param str msg | ||
*/ | ||
const debug = require('debug')('blitz') | ||
|
||
export const log = { | ||
withBrand, | ||
withWarning, | ||
withCaret, | ||
withCheck, | ||
withX, | ||
withProgress, | ||
withError, | ||
branded, | ||
clearLine, | ||
clearConsole, | ||
error, | ||
warning, | ||
meta, | ||
progress, | ||
spinner, | ||
success, | ||
variable, | ||
info, | ||
debug, | ||
Table, | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove in favor of tslog.warn