Skip to content

Commit

Permalink
feat(version): migrate template download to React Native 0.75
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Aug 15, 2024
1 parent fea5e0c commit 48dd336
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
},
"dependencies": {
"@react-native-community/cli": "^14.0.0",
"@react-native/babel-preset": "^0.74.87",
"@react-native/eslint-config": "^0.74.87",
"@react-native/metro-config": "^0.74.87",
"@react-native/typescript-config": "^0.74.87",
"@react-native/babel-preset": "^0.75.0",
"@react-native/eslint-config": "^0.75.0",
"@react-native/metro-config": "^0.75.0",
"@react-native/typescript-config": "^0.75.0",
"arg": "^5.0.2",
"command-exists": "^1.2.9",
"deepmerge": "^4.3.1",
Expand All @@ -51,12 +51,13 @@
"skip-local-postinstall": "^2.0.4"
},
"devDependencies": {
"@types/bun": "^1.1.6",
"@types/command-exists": "^1.2.3",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
"jest-fixture": "^4.1.0",
"padua": "^4.0.1",
"react-native": "^0.74.5",
"react-native": "^0.75.0",
"vitest": "^2.0.5"
},
"peerDependencies": {
Expand Down
10 changes: 8 additions & 2 deletions template-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import semverSort from 'semver-sort'
import { rmSync, readdirSync, renameSync, existsSync, mkdirSync } from 'node:fs'
import { join } from 'node:path'
import { execSync } from 'node:child_process'
import { gte } from 'semver'
import { log } from './helper'
import { NativeOptions } from './types'

Expand Down Expand Up @@ -43,12 +44,17 @@ export const cacheTemplate = (nativeOptions: NativeOptions) => {

// DOC https://github.com/react-native-community/cli/blob/master/packages/cli/src/commands/init/index.ts
try {
const separateTemplate = gte(nativeOptions.version, '0.75.0')
const usesBun = typeof Bun !== 'undefined'

execSync(
`react-native init ${
`${usesBun ? 'bunx' : 'npx'} @react-native-community/cli init ${
nativeOptions.appName
} --skip-install --install-pods false --skip-git-init true --version ${
nativeOptions.version
} --directory "${join(directory, nativeOptions.appName)}"`,
} --directory "${join(directory, nativeOptions.appName)}"${
separateTemplate ? ' --template @react-native-community/template' : ''
}${usesBun ? ' --pm bun' : ''}`,
{
cwd: process.cwd(),
encoding: 'utf8',
Expand Down
4 changes: 2 additions & 2 deletions template/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"mobx": "^6.13.1",
"mobx-react-lite": "^4.0.7",
"react": "^18.3.1",
"react-native": "^0.74.5",
"react-native": "^0.75.0",
"reactigation": "^4.0.3",
"responsive-react-native": "^1.0.5"
},
Expand All @@ -29,7 +29,7 @@
"babel-jest": "^29.7.0",
"icon-numic-plugin": "^1.4.4",
"jest": "^29.7.0",
"numic": "^2.2.0",
"numic": "^2.3.0",
"react-test-renderer": "^18.3.1",
"typescript": "^5.5.4"
},
Expand Down
4 changes: 2 additions & 2 deletions template/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"react": "^18.3.1",
"react-native": "^0.74.5"
"react-native": "^0.75.0"
},
"type": "module",
"devDependencies": {
Expand All @@ -24,7 +24,7 @@
"babel-jest": "^29.7.0",
"icon-numic-plugin": "^1.4.4",
"jest": "^29.7.0",
"numic": "^2.2.0",
"numic": "^2.3.0",
"react-test-renderer": "18.2.0",
"typescript": "^5.5.4"
},
Expand Down

0 comments on commit 48dd336

Please sign in to comment.