From 559b04000edbb7edbeeb4b45525e9f1bc3acc5ff Mon Sep 17 00:00:00 2001 From: John Wu Date: Fri, 25 Oct 2024 00:39:28 -0400 Subject: [PATCH] Remove optional expo references (#62) This removes all code, documentation, and references related to supporting non-Expo applications. The CLI tool will now exclusively support Expo applications. --- README.md | 13 ------------- src/commands/__tests__/notifications.test.ts | 8 ++++---- src/commands/__tests__/typescript.test.ts | 19 ------------------- src/commands/notifications.ts | 16 +++------------- src/commands/testingLibrary.ts | 11 ++--------- src/commands/typescript.ts | 4 ---- .../{jest.config.js.eta => jest.config.js} | 5 ++--- .../{tsconfig.json.eta => tsconfig.json} | 4 +--- 8 files changed, 12 insertions(+), 68 deletions(-) rename templates/testingLibrary/{jest.config.js.eta => jest.config.js} (82%) rename templates/typescript/{tsconfig.json.eta => tsconfig.json} (86%) diff --git a/README.md b/README.md index 39ac202..9aafb05 100644 --- a/README.md +++ b/README.md @@ -39,19 +39,6 @@ npx create-belt-app MyApp --pnpm npx create-belt-app MyApp --bun ``` -Or, if you already have an app and want to use Belt, run: - -```sh -# with NPM -npm install --save-dev create-belt-app - -# with Yarn -yarn add --dev create-belt-app - -# with PNPM -pnpm install --save-dev create-belt-app -``` - then run the command you'd like to perform: ```sh diff --git a/src/commands/__tests__/notifications.test.ts b/src/commands/__tests__/notifications.test.ts index c8f4aaf..9ed4467 100644 --- a/src/commands/__tests__/notifications.test.ts +++ b/src/commands/__tests__/notifications.test.ts @@ -1,7 +1,7 @@ import { confirm, input } from '@inquirer/prompts'; import { fs, vol } from 'memfs'; import { Mock, expect, test, vi } from 'vitest'; -import addDependency from '../../util/addDependency'; +import exec from '../../util/exec'; import { addNotifications } from '../notifications'; vi.mock('../../util/print', () => ({ default: vi.fn() })); @@ -10,7 +10,7 @@ vi.mock('@inquirer/prompts', () => ({ input: vi.fn(), confirm: vi.fn(), })); -vi.mock('../../util/addDependency'); +vi.mock('../../util/exec'); test('install React Native Firebase and dependencies', async () => { (input as Mock).mockResolvedValueOnce('com.myapp'); @@ -30,8 +30,8 @@ test('install React Native Firebase and dependencies', async () => { await addNotifications(); - expect(addDependency).toHaveBeenCalledWith( - '@react-native-firebase/app @react-native-firebase/messaging expo-build-properties', + expect(exec).toHaveBeenCalledWith( + 'npx expo install @react-native-firebase/app @react-native-firebase/messaging expo-build-properties', ); expect(fs.existsSync('./src/hooks/useNotifications.ts')).toBe(true); diff --git a/src/commands/__tests__/typescript.test.ts b/src/commands/__tests__/typescript.test.ts index 17c2e92..369586a 100644 --- a/src/commands/__tests__/typescript.test.ts +++ b/src/commands/__tests__/typescript.test.ts @@ -55,22 +55,3 @@ test('writes new tsconfig.json, adds dependencies', async () => { expect.stringMatching(/already exists/), ); }); - -test("doesn't extend expo/tsconfig.base if not an Expo project", async () => { - vol.fromJSON({ - 'package.json': JSON.stringify({ - scripts: {}, - dependencies: {}, - }), - }); - - await addTypescript(); - - expect(addDependency).toHaveBeenCalledWith('typescript @types/react', { - dev: true, - }); - - expect(fs.readFileSync('tsconfig.json', 'utf8')).not.toMatch( - 'expo/tsconfig.base', - ); -}); diff --git a/src/commands/notifications.ts b/src/commands/notifications.ts index b235125..04d2bff 100644 --- a/src/commands/notifications.ts +++ b/src/commands/notifications.ts @@ -1,13 +1,11 @@ import { confirm, input } from '@inquirer/prompts'; import ora from 'ora'; import { globals } from '../constants'; -import addDependency from '../util/addDependency'; import addExpoConfig from '../util/addExpoConfig'; import commit from '../util/commit'; import copyTemplateDirectory from '../util/copyTemplateDirectory'; import exec from '../util/exec'; import injectHooks from '../util/injectHooks'; -import isExpo from '../util/isExpo'; import print from '../util/print'; import readAppJson from '../util/readAppJson'; @@ -33,18 +31,10 @@ export async function addNotifications(options: Options = {}) { const spinner = ora().start('Adding React Native Firebase and dependencies'); - const expo = await isExpo(); - // Install dependencies - if (expo) { - await exec( - 'npx expo install @react-native-firebase/app @react-native-firebase/messaging expo-build-properties', - ); - } else { - await addDependency( - '@react-native-firebase/app @react-native-firebase/messaging expo-build-properties', - ); - } + await exec( + 'npx expo install @react-native-firebase/app @react-native-firebase/messaging expo-build-properties', + ); spinner.succeed('Added React Native Firebase and dependencies'); diff --git a/src/commands/testingLibrary.ts b/src/commands/testingLibrary.ts index d1815be..76b0396 100755 --- a/src/commands/testingLibrary.ts +++ b/src/commands/testingLibrary.ts @@ -5,26 +5,19 @@ import addToGitignore from '../util/addToGitignore'; import copyTemplateDirectory from '../util/copyTemplateDirectory'; import exec from '../util/exec'; import getPackageManager from '../util/getPackageManager'; -import isExpo from '../util/isExpo'; export default async function addTestingLibrary() { const spinner = ora().start('Installing Jest and Testing Library'); - const expo = await isExpo(); - if (expo) { - await exec('npx expo install jest jest-expo'); - } + await exec('npx expo install jest jest-expo'); await addDependency( - `${ - expo ? '' : 'jest' - } @testing-library/react-native @testing-library/jest-native @types/jest babel-jest`, + `@testing-library/react-native @testing-library/jest-native @types/jest babel-jest`, { dev: true }, ); await copyTemplateDirectory({ templateDir: 'testingLibrary', - variables: { expo }, }); const mgr = await getPackageManager(); diff --git a/src/commands/typescript.ts b/src/commands/typescript.ts index 11a5d5b..94af777 100755 --- a/src/commands/typescript.ts +++ b/src/commands/typescript.ts @@ -6,7 +6,6 @@ import addDependency from '../util/addDependency'; import addPackageJsonScripts from '../util/addPackageJsonScripts'; import copyTemplateDirectory from '../util/copyTemplateDirectory'; import getProjectDir from '../util/getProjectDir'; -import isExpo from '../util/isExpo'; import print from '../util/print'; export default async function addTypescript() { @@ -26,9 +25,6 @@ export default async function addTypescript() { await copyTemplateDirectory({ templateDir: 'typescript', - variables: { - expo: await isExpo(), - }, }); if (await fs.exists(path.join(projectDir, 'App.js'))) { diff --git a/templates/testingLibrary/jest.config.js.eta b/templates/testingLibrary/jest.config.js similarity index 82% rename from templates/testingLibrary/jest.config.js.eta rename to templates/testingLibrary/jest.config.js index 5cd624a..9bcbd0a 100644 --- a/templates/testingLibrary/jest.config.js.eta +++ b/templates/testingLibrary/jest.config.js @@ -1,5 +1,5 @@ module.exports = { - preset: '<%= it.expo ? "jest-expo" : "react-native" %>', + preset: 'jest-expo', collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], coveragePathIgnorePatterns: ['/node_modules', 'src/test'], transformIgnorePatterns: [ @@ -7,8 +7,7 @@ module.exports = { ], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], moduleNameMapper: { - '.+\\.(png|jpg|ttf|woff|woff2)$': - '/src/test/fileMock.js', + '.+\\.(png|jpg|ttf|woff|woff2)$': '/src/test/fileMock.js', }, setupFilesAfterEnv: [ '@testing-library/jest-native/extend-expect', diff --git a/templates/typescript/tsconfig.json.eta b/templates/typescript/tsconfig.json similarity index 86% rename from templates/typescript/tsconfig.json.eta rename to templates/typescript/tsconfig.json index 60c4c22..b151fbc 100644 --- a/templates/typescript/tsconfig.json.eta +++ b/templates/typescript/tsconfig.json @@ -21,14 +21,12 @@ "assets/*": ["assets/*"] } }, - "include": ["src/**/*", "*.js", ".*.js", "*.ts", "*.tsx", "__mocks__"], + "include": ["src/**/*", "*.js", ".*.js", "*.ts", "*.tsx", "__mocks__"], "exclude": [ "node_modules", "babel.config.js", "metro.config.js", "jest.config.js" ], - <% if(it.expo) { %> "extends": "expo/tsconfig.base" - <% } %> }