diff --git a/package.json b/package.json index 6b73d79..9dd0bc5 100644 --- a/package.json +++ b/package.json @@ -55,8 +55,6 @@ }, "dependencies": { "@poppinss/colors": "4.1.0-2", - "emphasize": "^6.0.0", - "pretty-repl": "^4.0.0", "string-width": "^6.1.0" }, "author": "virk,julien-r44,adonisjs", diff --git a/src/colorizer.ts b/src/colorizer.ts deleted file mode 100644 index a4352a8..0000000 --- a/src/colorizer.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * @adonisjs/repl - * - * (c) AdonisJS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { Sheet, emphasize } from 'emphasize' -import useColors from '@poppinss/colors' -import { Colors } from '@poppinss/colors/types' - -/** - * Maps the token types to the colors - */ -const sheet = (colors: Colors): Sheet => ({ - 'comment': (s) => colors.gray(s), - 'quote': (s) => colors.gray(s), - - 'keyword': (s) => colors.cyan(s), - 'addition': (s) => colors.cyan(s), - - 'number': (s) => colors.yellow(s), - 'string': (s) => colors.green(s), - 'meta meta-string': (s) => colors.cyan(s), - 'literal': (s) => colors.yellow(s), - 'doctag': (s) => colors.cyan(s), - 'regexp': (s) => colors.red(s), - - 'attribute': (s) => colors.yellow(s), - 'attr': (s) => colors.yellow(s), - 'variable': (s) => colors.yellow(s), - 'template-variable': (s) => colors.yellow(s), - 'class title': (s) => colors.yellow(s), - 'function title': (s) => colors.yellow(s), - 'type': (s) => colors.yellow(s), - - 'symbol': (s) => colors.green(s), - 'bullet': (s) => colors.magenta(s), - 'subst': (s) => colors.magenta(s), - 'meta': (s) => colors.magenta(s), - 'meta keyword': (s) => colors.magenta(s), - 'link': (s) => colors.magenta(s), - - 'built_in': (s) => colors.cyan(s), - 'deletion': (s) => colors.red(s), - - 'emphasis': (s) => colors.italic(s), - 'strong': (s) => colors.bold(s), - 'formula': (s) => colors.inverse(s), -}) - -export function colorizer() { - const colors = useColors.ansi() - const colorSheet = sheet(colors) - - const highlight = (s: string) => emphasize.highlight('ts', s, colorSheet).value - highlight.colorizeMatchingBracket = (s: string) => colors.bgBlue(s) - - return highlight -} diff --git a/src/repl.ts b/src/repl.ts index 7447645..292be31 100644 --- a/src/repl.ts +++ b/src/repl.ts @@ -8,11 +8,9 @@ */ import useColors from '@poppinss/colors' -import { REPLServer, Recoverable } from 'node:repl' -import prettyRepl from 'pretty-repl' +import { REPLServer, Recoverable, start as startRepl } from 'node:repl' import stringWidth from 'string-width' import { inspect, promisify as utilPromisify } from 'node:util' -import { colorizer } from './colorizer.js' import { Handler, ContextOptions, Compiler } from './types.js' /** @@ -348,14 +346,12 @@ export class Repl { start() { this.#printWelcomeMessage() - this.server = prettyRepl.start({ + this.server = startRepl({ prompt: '> ', input: process.stdin, output: process.stdout, terminal: process.stdout.isTTY && !Number.parseInt(process.env.NODE_NO_READLINE!, 10), useGlobal: true, - // @ts-ignore - colorize: colorizer(), }) /**