diff --git a/README.md b/README.md index 504f3dd..7afe2e5 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ export const tailwind = object | File export const postcss = object | File export const babel = object | File (JavaScript only) export const metro = object | 'react-native' | File (JavaScript only) +export const reactNative = object | File export const vercel = 'spa' | 'SPA' | 'single-page-application' | 'spa-routes' | 'github-silent' | { extends: 'spa', routes: { ... }} export const license = 'MIT' | 'mit' export const ignore = true | 'recommended' | 'bundle' | string[] diff --git a/configuration/index.ts b/configuration/index.ts index 9f261ca..eb87ba3 100644 --- a/configuration/index.ts +++ b/configuration/index.ts @@ -10,6 +10,7 @@ import * as next from './next' import * as playwright from './playwright' import * as postcss from './postcss' import * as prettier from './prettier' +import * as reactNative from './react-native' import * as rsbuild from './rsbuild' import * as tailwind from './tailwind' import * as typescript from './typescript' @@ -38,6 +39,8 @@ export type ConfigurationKeys = | 'postcss' | 'babel' | 'metro' + | 'react-native' + | 'reactNative' | 'vercel' | 'license' // Require separate logic, not found in configuraitons below. @@ -107,6 +110,11 @@ export const configurations: Configuration[] = [ name: 'metro', configuration: metro, }, + { + name: 'react-native', + alias: 'reactNative', + configuration: reactNative, + }, { name: 'vercel', configuration: vercel, diff --git a/configuration/react-native.ts b/configuration/react-native.ts new file mode 100644 index 0000000..8cd02e9 --- /dev/null +++ b/configuration/react-native.ts @@ -0,0 +1,12 @@ +import { log } from '../log' + +export const extension = (path: string) => ({ extends: path }) + +export function createFile(configuration: object) { + if (typeof configuration !== 'object') { + log('Configuration for "react-native" (app.json) must be an object', 'warning') + return + } + + return { name: 'app.json', contents: JSON.stringify(configuration, null, 2) } +} diff --git a/configuration/typescript.ts b/configuration/typescript.ts index e07a0fa..24bae30 100644 --- a/configuration/typescript.ts +++ b/configuration/typescript.ts @@ -33,6 +33,13 @@ export const templates = { noEmit: true, }, }, + 'react-native': { + extends: '@react-native/typescript-config/tsconfig.json', + compilerOptions: { + module: 'NodeNext', + moduleResolution: 'node', + }, + }, } export const extension = (path: string) => ({ extends: path }) diff --git a/test/basic.test.ts b/test/basic.test.ts index 1722c3c..9cc740c 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -41,6 +41,7 @@ test('Adds configuration files for basic file setup.', async () => { expect(existsSync(join(fixturePath, 'biome.json'))).toBe(true) expect(existsSync(join(fixturePath, 'vitest.config.ts'))).toBe(true) expect(existsSync(join(fixturePath, 'cypress.config.ts'))).toBe(true) + expect(existsSync(join(fixturePath, 'app.json'))).toBe(true) // TODO should not work with TS. expect(existsSync(join(fixturePath, 'eslint.config.js'))).toBe(true) @@ -175,6 +176,7 @@ test("Doesn't add deployment files to gitignore in CI.", async () => { expect(existsSync(join(fixturePath, 'vercel.json'))).toBe(true) expect(existsSync(join(fixturePath, 'metro.config.cjs'))).toBe(true) expect(existsSync(join(fixturePath, '.gitignore'))).toBe(true) + expect(existsSync(join(fixturePath, 'app.json'))).toBe(true) const gitignoreFile = await Bun.file(join(fixturePath, '.gitignore')).text() diff --git a/test/fixture/file/configuration.ts b/test/fixture/file/configuration.ts index 4112de7..25e479d 100644 --- a/test/fixture/file/configuration.ts +++ b/test/fixture/file/configuration.ts @@ -41,3 +41,8 @@ export const vitest = { } export const eslint = true + +export const reactNative = { + name: "break'a'bit", + displayName: "break'a'bit", +} \ No newline at end of file diff --git a/test/fixture/package/package.json b/test/fixture/package/package.json index 9ffb45e..3f5e332 100644 --- a/test/fixture/package/package.json +++ b/test/fixture/package/package.json @@ -19,6 +19,10 @@ "silent": true } }, - "metro": "react-native" + "metro": "react-native", + "react-native": { + "name": "hairplan", + "displayName": "hairplan" + } } }