b8b104506d
The PR further reduces the `create-next-app` installation size by another 80 KiB: - Replace the callback version of Node.js built-in `dns` API usage with `dns/promise` + async/await - Replace `got` w/ `fetch` since Next.js and `create-next-app` now target Node.js 18.17.0+ - Download and extract the tar.gz file in the memory (without creating temporary files). This improves the performance. - Some other minor refinements. Following these changes, the size of `dist/index.js` is now 536 KiB.
26 lines
577 B
TypeScript
26 lines
577 B
TypeScript
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import validateProjectName from 'validate-npm-package-name'
|
|
|
|
type ValidateNpmNameResult =
|
|
| {
|
|
valid: true
|
|
}
|
|
| {
|
|
valid: false
|
|
problems: string[]
|
|
}
|
|
|
|
export function validateNpmName(name: string): ValidateNpmNameResult {
|
|
const nameValidation = validateProjectName(name)
|
|
if (nameValidation.validForNewPackages) {
|
|
return { valid: true }
|
|
}
|
|
|
|
return {
|
|
valid: false,
|
|
problems: [
|
|
...(nameValidation.errors || []),
|
|
...(nameValidation.warnings || []),
|
|
],
|
|
}
|
|
}
|