-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add an option to seperate the output of show with provide… (
#23172) Co-authored-by: Craigory Coppola <craigorycoppola@gmail.com>
- Loading branch information
1 parent
5edc64a
commit d9a9712
Showing
6 changed files
with
484 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { output } from '../../utils/output'; | ||
import { createProjectGraphAsync } from '../../project-graph/project-graph'; | ||
import { ShowProjectOptions } from './command-object'; | ||
import { generateGraph } from '../graph/graph'; | ||
|
||
export async function showProjectHandler( | ||
args: ShowProjectOptions | ||
): Promise<void> { | ||
const graph = await createProjectGraphAsync(); | ||
const node = graph.nodes[args.projectName]; | ||
if (!node) { | ||
console.log(`Could not find project ${args.projectName}`); | ||
process.exit(1); | ||
} | ||
if (args.json) { | ||
console.log(JSON.stringify(node.data)); | ||
} else if (args.web) { | ||
await generateGraph( | ||
{ | ||
view: 'project-details', | ||
focus: node.name, | ||
watch: true, | ||
open: true, | ||
}, | ||
[] | ||
); | ||
} else { | ||
const chalk = require('chalk') as typeof import('chalk'); | ||
const logIfExists = (label, key: keyof typeof node['data']) => { | ||
if (node.data[key]) { | ||
console.log(`${chalk.bold(label)}: ${node.data[key]}`); | ||
} | ||
}; | ||
|
||
logIfExists('Name', 'name'); | ||
logIfExists('Root', 'root'); | ||
logIfExists('Source Root', 'sourceRoot'); | ||
logIfExists('Tags', 'tags'); | ||
logIfExists('Implicit Dependencies', 'implicitDependencies'); | ||
|
||
const targets = Object.entries(node.data.targets ?? {}); | ||
const maxTargetNameLength = Math.max(...targets.map(([t]) => t.length)); | ||
const maxExecutorNameLength = Math.max( | ||
...targets.map(([, t]) => t?.executor?.length ?? 0) | ||
); | ||
|
||
if (targets.length > 0) { | ||
console.log(`${chalk.bold('Targets')}: `); | ||
for (const [target, targetConfig] of targets) { | ||
console.log( | ||
`- ${chalk.bold((target + ':').padEnd(maxTargetNameLength + 2))} ${( | ||
targetConfig?.executor ?? '' | ||
).padEnd(maxExecutorNameLength + 2)} ${(() => { | ||
const configurations = Object.keys( | ||
targetConfig.configurations ?? {} | ||
); | ||
if (configurations.length) { | ||
return chalk.dim(configurations.join(', ')); | ||
} | ||
return ''; | ||
})()}` | ||
); | ||
} | ||
} | ||
} | ||
await output.drain(); | ||
} |
Oops, something went wrong.