promptForMinimalConfig function is called with the parameters named cwd — this is the current working directory, projectConfig — this is the value returned from getProjectConfig, opts.defaults — this is a CLI argument configured with Commander.js, shown below:
export const init = new Command() .name("init") .description("initialize your project and install dependencies") .option("-y, --yes", "skip confirmation prompt.", false) .option("-d, --defaults,", "use default configuration.", false) .option( "-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd() )
This line above is picked from packages/cli/src/commands/init.ts#L232. highlight is a small util function that applies a color to a text using chalk to be displayed in your terminal.
Now that getProjectConfig function from shadcn-ui/ui CLI source code analysis is complete, I discussed few more lines of code that followed this function.
There’s a function named promptForMinimalConfig
export async function promptForMinimalConfig( cwd: string, defaultConfig: Config, defaults = false) { const highlight = (text: string) => chalk.cyan(text) let style = defaultConfig.style let baseColor = defaultConfig.tailwind.baseColor let cssVariables = defaultConfig.tailwind.cssVariables
This function has the prompts such as Which color would you like to use as base color, Which color would you like to use as base color and Would you like to use CSS variables. I haven’t exactly reached that part of code yet to discuss how these prompts are configured but found that highlight is a small util function that applies color to the text that you see in your terminal using chalk package.
Want to learn how to build shadcn-ui/ui from scratch? Check outbuild-from-scratch
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.