@eljs/create-preset-structure
Version:
Project structure template powered by @eljs/create.
68 lines (63 loc) • 1.98 kB
text/typescript
/* eslint-disable @typescript-eslint/naming-convention */
import type { Api } from '@eljs/create'
import { type PackageJson } from '@eljs/utils'
export default async (api: Api) => {
api.onStart(async () => {
api.extendPackage(() => {
const { isMonorepo, keywords = '', gitHref = '' } = api.prompts
const lintStageFiles = isMonorepo
? 'packages/**/*.{ts,tsx}'
: 'src/**/*.{ts,tsx}'
const pkg: PackageJson = {
'lint-staged': {
[lintStageFiles]: ['prettier --write', 'eslint --fix'],
},
scripts: {
format: `prettier --write '${lintStageFiles}'`,
lint: `eslint '${lintStageFiles}'`,
},
devDependencies: {
'@eljs/release': `^${api.appData.cliVersion}`,
'@eljs/utils': `^${api.appData.cliVersion}`,
},
}
if (isMonorepo) {
pkg.private = true
pkg.scripts = {
boot: `${api.prompts.tsx} scripts/bootstrap`,
build: 'turbo run build',
clean: 'turbo run clean',
dev: 'turbo run dev',
...pkg.scripts,
preinstall: 'npx only-allow pnpm',
}
pkg.devDependencies = {
turbo: '^2.4.4',
'only-allow': '^1.2.1',
...pkg.devDependencies,
}
pkg.packageManager = 'pnpm@8.15.9'
pkg.engines = pkg.engines || {}
pkg.engines.pnpm = '>=8.0.0'
} else {
pkg.keywords = [`${keywords}`]
pkg.homepage = `${gitHref}#readme`
pkg.bugs = {
url: `${gitHref}/issues`,
}
pkg.main = 'lib/index.js'
pkg.module = 'esm/index.js'
pkg.types = 'esm/index.d.ts'
pkg.files = ['esm/*', 'lib/*']
pkg.scripts = {
build: 'father build',
clean:
'rimraf lib && rimraf esm && rimraf node_modules/.cache/father',
dev: 'father dev',
...pkg.scripts,
}
}
return pkg
})
})
}