-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add prompts for select formatter and linter
- Loading branch information
1 parent
76757ea
commit f320eba
Showing
5 changed files
with
76 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,54 @@ | ||
import { cyan, green } from 'picocolors' | ||
import { program } from '../' | ||
|
||
export function addCommand(name: string) { | ||
const projectPath = name | ||
const options = this.opts() | ||
|
||
if (!projectPath) { | ||
console.log( | ||
`\nPlease specify the project directory:\n ${cyan(program.name())} ${cyan('add')} ${green( | ||
'<project-directory>', | ||
)} ${cyan('[tools]')}\nFor example:\n ${cyan(program.name())} ${cyan('add')} ${green('website')} ${cyan( | ||
'--linter eslint', | ||
)}\n\nRun ${cyan(`${program.name()} help add`)} to see all options.`, | ||
) | ||
|
||
process.exit(1) | ||
} | ||
|
||
// TODO: Show a prompt to select the tool to add | ||
if (Object.keys(options).length === 0) { | ||
console.log( | ||
`\nPlease specify the tool to add:\n ${cyan(program.name())} ${cyan('add <project-directory>')} ${green( | ||
'[tools]', | ||
)}\nFor example:\n ${cyan(program.name())} ${cyan('add website')} ${green( | ||
'--linter eslint --formatter prettier', | ||
)}\n\nRun ${cyan(`${program.name()} help add`)} to see all options.`, | ||
) | ||
|
||
process.exit(1) | ||
} | ||
|
||
if (options.L != null && options.L !== true) { | ||
console.log(options.L) | ||
} | ||
|
||
if (options.F != null && options.F !== true) { | ||
console.log(options.F) | ||
} | ||
|
||
if (options.Gh != null && options.Gh !== true) { | ||
console.log(options.Gh) | ||
import prompts from 'prompts' | ||
|
||
export async function addCommand(tools: string[]) { | ||
const projectPath = process.cwd() | ||
|
||
if (tools.length === 0) { | ||
const { type } = await prompts([ | ||
{ | ||
type: 'multiselect', | ||
name: 'type', | ||
message: 'Select type of tools to add', | ||
choices: [ | ||
{ title: 'Linter', value: 'linter' }, | ||
{ title: 'Formatter', value: 'formatter' }, | ||
], | ||
}, | ||
]) | ||
|
||
if (!Array.isArray(type)) { | ||
return | ||
} | ||
|
||
// TODO: if select biome, ask if want to formatter | ||
if (type.includes('linter')) { | ||
const { linter } = await prompts([ | ||
{ | ||
type: 'select', | ||
name: 'linter', | ||
message: 'Select linter to add', | ||
choices: [ | ||
{ title: 'Biome', value: 'biome' }, | ||
{ title: 'ESLint', value: 'eslint' }, | ||
], | ||
}, | ||
]) | ||
} | ||
|
||
if (type.includes('formatter')) { | ||
const { formatter } = await prompts([ | ||
{ | ||
type: 'select', | ||
name: 'formatter', | ||
message: 'Select linter to add', | ||
choices: [ | ||
{ title: 'Biome', value: 'biome' }, | ||
{ title: 'Prettier', value: 'prettier' }, | ||
], | ||
}, | ||
]) | ||
} | ||
|
||
return | ||
} | ||
} |
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,3 @@ | ||
export * from './add' | ||
export * from './config' | ||
export * from './scan' |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.