-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): add choose bundler prompt (#877)
* feat(init): add choose bundler prompt * chore: improve log * chore: improve log * chore: code review improvements * fix: linter * chore: changeset * chore: update changeset --------- Co-authored-by: Jakub Romańczyk <[email protected]>
- Loading branch information
1 parent
2390ead
commit 919ffb8
Showing
5 changed files
with
38 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@callstack/repack": minor | ||
--- | ||
|
||
Add prompt for choosing the bundler in `repack-init` |
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,25 @@ | ||
import { select } from '@inquirer/prompts'; | ||
import { isTruthyEnv } from '../utils/isTruthyEnv.js'; | ||
import logger from '../utils/logger.js'; | ||
|
||
export default async function selectBundler(): Promise<'rspack' | 'webpack'> { | ||
if (isTruthyEnv(process.env.CI)) { | ||
logger.info('Running in CI, using rspack. Use --bundler flag to override.'); | ||
return 'rspack'; | ||
} | ||
|
||
return select({ | ||
message: 'Which bundler would you like to use?', | ||
choices: [ | ||
{ | ||
name: 'Rspack (recommended)', | ||
value: 'rspack', | ||
}, | ||
{ | ||
name: 'Webpack', | ||
value: 'webpack', | ||
}, | ||
], | ||
default: 'rspack', | ||
}); | ||
} |
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 const isTruthyEnv = (env: string | undefined) => { | ||
return !!env && env !== 'false' && env !== '0'; | ||
}; |