Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove optional expo references #62

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/commands/__tests__/notifications.test.ts
Original file line number Diff line number Diff line change
@@ -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() }));
Expand All @@ -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');
Expand All @@ -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);
Expand Down
19 changes: 0 additions & 19 deletions src/commands/__tests__/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
});
16 changes: 3 additions & 13 deletions src/commands/notifications.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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');

Expand Down
11 changes: 2 additions & 9 deletions src/commands/testingLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions src/commands/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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'))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module.exports = {
preset: '<%= it.expo ? "jest-expo" : "react-native" %>',
preset: 'jest-expo',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
coveragePathIgnorePatterns: ['/node_modules', 'src/test'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native-community|@react-native|react-native|@react-navigation)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'.+\\.(png|jpg|ttf|woff|woff2)$':
'<rootDir>/src/test/fileMock.js',
'.+\\.(png|jpg|ttf|woff|woff2)$': '<rootDir>/src/test/fileMock.js',
},
setupFilesAfterEnv: [
'@testing-library/jest-native/extend-expect',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
<% } %>
}
Loading