diff options
| author | 2023-11-03 21:25:40 +0800 | |
|---|---|---|
| committer | 2023-11-03 21:25:40 +0800 | |
| commit | 9029588590bea8b10451575c5142dcde77ecd1b5 (patch) | |
| tree | 04cf8aee56c23fd225ff19d340f7cee621d874ef /packages/turbo-workspaces/src/commands/summary | |
| parent | 94071d7ce16c56641d67d488e2bac6be84ffe731 (diff) | |
| download | HydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.tar.gz HydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.zip | |
chore: delete useless files
Diffstat (limited to 'packages/turbo-workspaces/src/commands/summary')
| -rw-r--r-- | packages/turbo-workspaces/src/commands/summary/index.ts | 98 | ||||
| -rw-r--r-- | packages/turbo-workspaces/src/commands/summary/types.ts | 1 |
2 files changed, 0 insertions, 99 deletions
diff --git a/packages/turbo-workspaces/src/commands/summary/index.ts b/packages/turbo-workspaces/src/commands/summary/index.ts deleted file mode 100644 index 9696a14..0000000 --- a/packages/turbo-workspaces/src/commands/summary/index.ts +++ /dev/null @@ -1,98 +0,0 @@ -import inquirer from "inquirer"; -import path from "path"; -import { Logger } from "../../logger"; -import chalk from "chalk"; -import { SummaryCommandArgument } from "./types"; -import { directoryInfo } from "../../utils"; -import getWorkspaceDetails from "../../getWorkspaceDetails"; -import { Workspace } from "../../types"; - -export default async function summary(directory: SummaryCommandArgument) { - const logger = new Logger(); - logger.hero(); - - const answer = await inquirer.prompt<{ - directoryInput?: string; - }>({ - type: "input", - name: "directoryInput", - message: "Where is the root of the repo?", - when: !directory, - default: ".", - validate: (directory: string) => { - const { exists, absolute } = directoryInfo({ directory }); - if (exists) { - return true; - } else { - return `Directory ${chalk.dim(`(${absolute})`)} does not exist`; - } - }, - filter: (directory: string) => directory.trim(), - }); - - const { directoryInput: selectedDirectory = directory as string } = answer; - const { exists, absolute: root } = directoryInfo({ - directory: selectedDirectory, - }); - if (!exists) { - console.error(`Directory ${chalk.dim(`(${root})`)} does not exist`); - return process.exit(1); - } - - const project = await getWorkspaceDetails({ root }); - - const numWorkspaces = project.workspaceData.workspaces.length; - const hasWorkspaces = numWorkspaces > 0; - // group workspaces - const workspacesByDirectory: Record<string, Array<Workspace>> = {}; - project.workspaceData.workspaces.forEach((workspace) => { - const workspacePath = path.relative(root, workspace.paths.root); - const rootDirectory = workspacePath.split(path.sep)[0]; - if (!workspacesByDirectory[rootDirectory]) { - workspacesByDirectory[rootDirectory] = []; - } - workspacesByDirectory[rootDirectory].push(workspace); - }); - - const renderWorkspace = (w: Workspace) => { - return `${w.name} (${chalk.italic( - `./${path.relative(root, w.paths.root)}` - )})`; - }; - - const renderDirectory = ({ - number, - directory, - workspaces, - }: { - number: number; - directory: string; - workspaces: Array<Workspace>; - }) => { - logger.indented(2, `${number}. ${chalk.bold(directory)}`); - workspaces.forEach((workspace, idx) => { - logger.indented(3, `${idx + 1}. ${renderWorkspace(workspace)}`); - }); - }; - - // repo header - logger.header(`Repository Summary`); - logger.indented(1, `${chalk.underline(project.name)}:`); - // workspace manager header - logger.indented( - 1, - `Package Manager: ${chalk.bold(chalk.italic(project.packageManager))}` - ); - if (hasWorkspaces) { - // workspaces header - logger.indented(1, `Workspaces (${chalk.bold(numWorkspaces.toString())}):`); - Object.keys(workspacesByDirectory).forEach((directory, idx) => { - renderDirectory({ - number: idx + 1, - directory, - workspaces: workspacesByDirectory[directory], - }); - }); - logger.blankLine(); - } -} diff --git a/packages/turbo-workspaces/src/commands/summary/types.ts b/packages/turbo-workspaces/src/commands/summary/types.ts deleted file mode 100644 index 0cc5830..0000000 --- a/packages/turbo-workspaces/src/commands/summary/types.ts +++ /dev/null @@ -1 +0,0 @@ -export type SummaryCommandArgument = string; |
