From 4eda155ad3e77a0a4546a018624f2ddc25c4170e Mon Sep 17 00:00:00 2001 From: Kelly Mears Date: Tue, 19 Sep 2023 03:32:36 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20improve(patch):=20cleanup=20doctor?= =?UTF-8?q?=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bud/src/cli/commands/doctor/index.tsx | 135 ++---------------- 1 file changed, 11 insertions(+), 124 deletions(-) diff --git a/sources/@roots/bud/src/cli/commands/doctor/index.tsx b/sources/@roots/bud/src/cli/commands/doctor/index.tsx index 83ab83f5c9..4dcf276c99 100644 --- a/sources/@roots/bud/src/cli/commands/doctor/index.tsx +++ b/sources/@roots/bud/src/cli/commands/doctor/index.tsx @@ -1,18 +1,15 @@ /* eslint-disable react/no-unescaped-entities */ import type {Bud} from '@roots/bud' import type {Extension} from '@roots/bud-framework/extension' -import type {InspectTreeResult} from 'fs-jetpack/types.js' import {platform} from 'node:os' import BudCommand from '@roots/bud/cli/commands' import {Error} from '@roots/bud-dashboard/components/error' import {Command} from '@roots/bud-support/clipanion' -import {bind} from '@roots/bud-support/decorators/bind' import {BudError, InputError} from '@roots/bud-support/errors' import figures from '@roots/bud-support/figures' import {Box, Text} from '@roots/bud-support/ink' -import prettyFormat from '@roots/bud-support/pretty-format' import webpack from '@roots/bud-support/webpack' import {WinError} from './WinError.js' @@ -117,18 +114,22 @@ for a lot of edge cases so it might return a false positive. Project paths {` `} project: {this.bud.path()} + input:{` `} {this.bud.path(`@src`).replace(this.bud.path(), `@project`)} + output:{` `} {this.bud.path(`@dist`).replace(this.bud.path(), `@project`)} + cache:{` `} {this.bud.path(`@os-cache`)} + storage:{` `} {this.bud.path(`@storage`).replace(this.bud.path(), `@project`)} @@ -218,6 +219,7 @@ for a lot of edge cases so it might return a false positive. Environment{`\n`} {this.bud.env.getEntries().map(([key, value]) => { const color = value.length === 0 ? `yellow` : `dimColor` + return ( {figures.triangleRightSmall} @@ -283,45 +285,25 @@ for a lot of edge cases so it might return a false positive. ) } - if (this.mode === `development`) { + if (this.bud.mode === `development`) { DoctorCommand.renderStatic( Development server URL: - {this.bud.hooks - .filter(`dev.url`, new URL(`http://0.0.0.0:3000`)) - .toString()} + {` `}{this.bud.server.url.href} - {this.bud.hooks - .filter(`dev.middleware.enabled`) - .includes(`proxy`) ? ( + + {this.bud.server?.enabledMiddleware && Object.keys(this.bud.server.enabledMiddleware).includes(`proxy`) && this.bud.server.proxyUrl && ( Proxy: - {this.bud.hooks - .filter( - `dev.middleware.proxy.options.target`, - new URL(`http://0.0.0.0:8000`), - ) - .toString()} + {` `}{this.bud.server.proxyUrl.href} - ) : null} - - Client scripts: - {[...this.bud.hooks.filter(`dev.client.scripts`, new Set([]))] - .map(fn => fn(this.bud)) - .map((script, key) => { - return ( - - {figures.triangleRightSmall} {script} - - ) - })} - + )} , ) } @@ -345,101 +327,6 @@ for a lot of edge cases so it might return a false positive. } } - @bind - public formatDepCheck( - [dependency, requestedVersion], - key: number | string, - ) { - if (dependency.startsWith(`@roots`)) return null - - const renderMessage = (type: `dependencies` | `devDependencies`) => ( - - - {figures.warning} - {` `} - {dependency} - - {` `}is overridden in your project `{type}`. If you do not require - a custom version of{` `} - {dependency} you should remove it. - - ) - - if ( - this.bud.context.manifest.devDependencies && - Object.keys(this.bud.context.manifest.devDependencies).includes( - dependency, - ) - ) { - return renderMessage(`devDependencies`) - } - - if ( - this.bud.context.manifest.dependencies && - Object.keys(this.bud.context.manifest.dependencies).includes( - dependency, - ) - ) { - return renderMessage(`dependencies`) - } - - return ( - - - {figures.tick} {dependency} - - {` `} - is managed by bud.js ({requestedVersion}) - - ) - } - - public async ls(path: string) { - const formatFilesArray = (files: Array) => { - return files.map((file, id) => { - return ( - - - - {file.children ? figures.ellipsis : figures.pointerSmall} - - {` `} - {file.name} - - {file.children ? ( - - {formatFilesArray(file.children)} - - ) : null} - - ) - }) - } - - const files = await this.bud.fs.inspectTree(path) - return files.children ? formatFilesArray(files.children) : null - } - - public mapEntrypoints( - entrypoints: Array<[string, webpack.EntryObject]>, - ) { - return entrypoints.map(([name, entry]) => { - return ( - - {name} - - {prettyFormat(entry, { - printBasicPrototype: false, - })} - - - ) - }) - } - public mapExtensions(extensions: Array<[string, Extension]>) { return extensions.map(([name, extension]) => (