-
-
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 9 commits
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,148 @@ 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)}` | ||
} | ||
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 |
||
|
||
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) | ||
} | ||
|
||
/** | ||
* 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 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, | ||
branded, | ||
clearLine, | ||
clearConsole, | ||
error, | ||
warning, | ||
progress, | ||
spinner, | ||
success, | ||
variable, | ||
info, | ||
debug, | ||
Table, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6474,7 +6474,7 @@ caniuse-api@^3.0.0: | |
lodash.memoize "^4.1.2" | ||
lodash.uniq "^4.5.0" | ||
|
||
caniuse-lite@1.0.30001274, caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001202, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: | ||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001020, caniuse-lite@^1.0.30001093, caniuse-lite@^1.0.30001165, caniuse-lite@^1.0.30001202, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: | ||
version "1.0.30001274" | ||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001274.tgz#26ca36204d15b17601ba6fc35dbdad950a647cc7" | ||
integrity sha512-+Nkvv0fHyhISkiMIjnyjmf5YJcQ1IQHZN6U9TLUMroWR38FNwpsC51Gb68yueafX1V6ifOisInSgP9WJFS13ew== | ||
|
@@ -7156,6 +7156,13 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: | |
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" | ||
|
||
console-table-printer@^2.7.5: | ||
version "2.10.0" | ||
resolved "https://registry.yarnpkg.com/console-table-printer/-/console-table-printer-2.10.0.tgz#4a6875b95071b36542d1c55c6d9dcc6206e1e9f0" | ||
integrity sha512-7pTsysaJs1+R+OO4cCtJbl+Lr4piHYIhi7/V1qHbOg/uiYgq2yUINFgvXZtVHqm9qpW0+Uk190qkGcKvzdunvg== | ||
dependencies: | ||
simple-wcswidth "^1.0.1" | ||
|
||
constant-case@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/constant-case/-/constant-case-2.0.0.tgz#4175764d389d3fa9c8ecd29186ed6005243b6a46" | ||
|
@@ -16554,6 +16561,11 @@ readjson@^2.0.1: | |
jju "^1.4.0" | ||
try-catch "^3.0.0" | ||
|
||
[email protected]: | ||
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c" | ||
integrity sha1-xYDXfvLPyHUrEySYBg3JeTp6wBw= | ||
|
||
[email protected]: | ||
version "0.18.5" | ||
resolved "https://registry.yarnpkg.com/recast/-/recast-0.18.5.tgz#9d5adbc07983a3c8145f3034812374a493e0fe4d" | ||
|
@@ -17672,6 +17684,11 @@ simple-swizzle@^0.2.2: | |
dependencies: | ||
is-arrayish "^0.3.1" | ||
|
||
simple-wcswidth@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz#8ab18ac0ae342f9d9b629604e54d2aa1ecb018b2" | ||
integrity sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg== | ||
|
||
sinon@^1.17.6: | ||
version "1.17.7" | ||
resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" | ||
|
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.
Probably can import from next/dist/compiled/ora