From 6593db8e5db19b4849b688f6a96ad32b52ba83f0 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 17 Sep 2024 05:04:12 -0400 Subject: [PATCH 1/4] Remove non expo workflow This removes all the code and doc references for supporting non expo projects --- README.md | 13 ------------- src/commands/notifications.ts | 16 +++------------- src/commands/testingLibrary.ts | 13 +++---------- src/commands/typescript.ts | 6 +----- templates/testingLibrary/jest.config.js.eta | 2 +- templates/typescript/tsconfig.json.eta | 2 -- 6 files changed, 8 insertions(+), 44 deletions(-) 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/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..f25d6b7 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 }, + templateDir: 'testingLibrary' }); const mgr = await getPackageManager(); diff --git a/src/commands/typescript.ts b/src/commands/typescript.ts index 11a5d5b..a04db75 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() { @@ -25,10 +24,7 @@ export default async function addTypescript() { await addDependency('typescript @types/react', { dev: true }); await copyTemplateDirectory({ - templateDir: 'typescript', - variables: { - expo: await isExpo(), - }, + templateDir: 'typescript' }); if (await fs.exists(path.join(projectDir, 'App.js'))) { diff --git a/templates/testingLibrary/jest.config.js.eta b/templates/testingLibrary/jest.config.js.eta index 5cd624a..2e0ef4a 100644 --- a/templates/testingLibrary/jest.config.js.eta +++ b/templates/testingLibrary/jest.config.js.eta @@ -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: [ diff --git a/templates/typescript/tsconfig.json.eta b/templates/typescript/tsconfig.json.eta index 60c4c22..a4f15a7 100644 --- a/templates/typescript/tsconfig.json.eta +++ b/templates/typescript/tsconfig.json.eta @@ -28,7 +28,5 @@ "metro.config.js", "jest.config.js" ], - <% if(it.expo) { %> "extends": "expo/tsconfig.base" - <% } %> } From 01bf3485aaaab68d8b329ae828b2b0273916f648 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 17 Sep 2024 07:18:58 -0400 Subject: [PATCH 2/4] prettier fix --- src/commands/testingLibrary.ts | 2 +- src/commands/typescript.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/testingLibrary.ts b/src/commands/testingLibrary.ts index f25d6b7..76b0396 100755 --- a/src/commands/testingLibrary.ts +++ b/src/commands/testingLibrary.ts @@ -17,7 +17,7 @@ export default async function addTestingLibrary() { ); await copyTemplateDirectory({ - templateDir: 'testingLibrary' + templateDir: 'testingLibrary', }); const mgr = await getPackageManager(); diff --git a/src/commands/typescript.ts b/src/commands/typescript.ts index a04db75..94af777 100755 --- a/src/commands/typescript.ts +++ b/src/commands/typescript.ts @@ -24,7 +24,7 @@ export default async function addTypescript() { await addDependency('typescript @types/react', { dev: true }); await copyTemplateDirectory({ - templateDir: 'typescript' + templateDir: 'typescript', }); if (await fs.exists(path.join(projectDir, 'App.js'))) { From 2b12ff764aa9435e3e5976cf1f0769d10288b6f7 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 17 Sep 2024 07:27:29 -0400 Subject: [PATCH 3/4] fix tests --- src/commands/__tests__/notifications.test.ts | 8 ++++---- src/commands/__tests__/typescript.test.ts | 19 ------------------- 2 files changed, 4 insertions(+), 23 deletions(-) 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', - ); -}); From cbf450738334b5b22eecffc6e3a30d3b19514be7 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 27 Sep 2024 13:48:30 -0400 Subject: [PATCH 4/4] remove eta extension from files with no conditionals --- .../testingLibrary/{jest.config.js.eta => jest.config.js} | 3 +-- templates/typescript/{tsconfig.json.eta => tsconfig.json} | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) rename templates/testingLibrary/{jest.config.js.eta => jest.config.js} (89%) rename templates/typescript/{tsconfig.json.eta => tsconfig.json} (90%) diff --git a/templates/testingLibrary/jest.config.js.eta b/templates/testingLibrary/jest.config.js similarity index 89% rename from templates/testingLibrary/jest.config.js.eta rename to templates/testingLibrary/jest.config.js index 2e0ef4a..9bcbd0a 100644 --- a/templates/testingLibrary/jest.config.js.eta +++ b/templates/testingLibrary/jest.config.js @@ -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 90% rename from templates/typescript/tsconfig.json.eta rename to templates/typescript/tsconfig.json index a4f15a7..b151fbc 100644 --- a/templates/typescript/tsconfig.json.eta +++ b/templates/typescript/tsconfig.json @@ -21,7 +21,7 @@ "assets/*": ["assets/*"] } }, - "include": ["src/**/*", "*.js", ".*.js", "*.ts", "*.tsx", "__mocks__"], + "include": ["src/**/*", "*.js", ".*.js", "*.ts", "*.tsx", "__mocks__"], "exclude": [ "node_modules", "babel.config.js",