Skip to content

Commit

Permalink
don't use create-expo-app (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima authored Dec 13, 2023
1 parent c9b2227 commit 3a1acc9
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 105 deletions.
6 changes: 4 additions & 2 deletions docs/oauth2-oidc.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ adb reverse tcp:8080 tcp:8080 && adb reverse tcp:9080 tcp:9080
**Note:** You can do the following steps the Okta Dashboard if preferred.

Using the [Okta CLI](https://cli.okta.com/), run `okta apps create`

- For "Type of Application" choose `Native`
- For "Redirect URI" and "Post Logout Redirect URI" provide `http://localhost:19006/,https://auth.expo.io/@your-expo-username/reactNativeAppName`
- Change `@your-expo-username` to match your Expo username (run `expo whoami`)
- Change `reactNativeAppName` to the value provided during generation (look in your `.yo-rc.json`)

Copy the provided `clientId` to `app/config/app-config.js`, and set `nativeClientId` to the copied value. This is loaded in `login.sagas.js` during authentication.
Copy the provided `clientId` to `app/config/app-config.js`, and set `nativeClientId` to the copied value. This is loaded in `login.sagas.js` during authentication.

> If you're using Auth0, you'll also need to change the `audience` in `app/modules/login/login.utils.ts`. For example:
>
Expand All @@ -59,7 +60,8 @@ Follow the instructions under "Add Claims to Access Token" in the [JHipster Ioni
### Log Out from the Identity Provider (iOS/Android)
Expo's auth proxy does not currently work with logging out from the identity provider (supported and enabled on Web). If you want to completely sign out on native apps:
Expo's auth proxy does not currently work with logging out from the identity provider (supported and enabled on Web). If you want to completely sign out on native apps:
- Change `useExpoAuthProxy` to `false` in `app-config.js`
- Configure your redirect URLs for logout in your identity provider
- Usually something like `exp://127.0.0.1:19000` and `exp://10.0.0.114:19000`, where `10.0.0.114` is your local IP
Expand Down
5 changes: 5 additions & 0 deletions generators/app/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ const files = {
'.editorconfig',
'.eslintrc.js',
'.gitattributes',
'.gitignore',
'App.js',
'app.json',
'README.md',
'babel.config.js',
'metro.config.js',
'package.json',
// templated files
'app/config/app-config.js',
'app/navigation/drawer/drawer-content.js',
Expand Down Expand Up @@ -76,6 +80,7 @@ const files = {
{ file: 'app/shared/images/toggle-drawer-icon/[email protected]', method: 'copy' },
{ file: 'app/shared/images/toggle-drawer-icon/[email protected]', method: 'copy' },
{ file: 'app/shared/images/toggle-drawer-icon/[email protected]', method: 'copy' },

{
renameTo: () => 'app/shared/images/logo-jhipster.png',
file: generator => `app/shared/images/jhipster_family_member_${generator.hipsterImage}_head.png`,
Expand Down
14 changes: 1 addition & 13 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@ const jhipsterUtils = require('generator-jhipster/generators/utils');
const { askDetoxPrompt, askNamePrompt, askBackendPrompt } = require('./prompts');
const { writeFiles } = require('./files');
const packageJson = require('../../package.json');
const {
printJHipsterLogo,
loadVariables,
setupVariables,
mergeReactNativePackageJson,
createEarlyFiles,
generateReactNativeApp,
appendFiles,
patchInFile,
patchBabel,
} = require('../../lib');
const { printJHipsterLogo, loadVariables, setupVariables, createEarlyFiles, appendFiles, patchInFile, patchBabel } = require('../../lib');

module.exports = class extends AppGenerator {
constructor(args, opts, features) {
Expand Down Expand Up @@ -105,8 +95,6 @@ module.exports = class extends AppGenerator {
this.context.reactNativeAppNameKebabCase = this._.kebabCase(this.context.reactNativeAppName);
},
createEarlyFiles,
generateReactNativeApp: generateReactNativeApp.bind(this),
mergeRnPackageJson: mergeReactNativePackageJson.bind(this),
writeFiles: writeFiles.bind(this),
patchUriScheme() {
const appConfig = this.fs.readJSON('app.json');
Expand Down
11 changes: 9 additions & 2 deletions generators/app/resources/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
"@react-native-community/datetimepicker": "7.2.0",
"@react-native-masked-view/masked-view": "0.2.9",
"@react-native-picker/picker": "2.4.10",
"@react-navigation/devtools": "6.0.20",
"expo": "49.0.21",
"expo-auth-session": "~5.0.2",
"expo-constants": "~14.4.2",
"expo-image-picker": "~14.3.2",
"expo-linking": "~5.0.2",
"expo-random": "~13.2.0",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"expo-web-browser": "~12.3.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
"react-native-gesture-handler": "~2.12.0",
"react-native-reanimated": "~3.3.0",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-web": "~0.19.9"
},
"devDependencies": {
"expo": "49.0.21",
"expo-template-blank-typescript": "49.0.23",
"@babel/core": "^7.20.0",
"@react-native-community/cli-server-api": "13.0.0",
"@types/react": "~18.2.14",
"jest-expo": "^49.0.0",
"typescript": "^5.3.3"
}
Expand Down
35 changes: 35 additions & 0 deletions generators/app/templates/.gitignore.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
32 changes: 32 additions & 0 deletions generators/app/templates/app.json.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"expo": {
"name": "<%= context.reactNativeAppName %>",
"slug": "<%= context.reactNativeAppName %>",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"bundleIdentifier": "com.anonymous.<%= context.reactNativeAppName %>",
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.anonymous.<%= context.reactNativeAppName %>"
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
6 changes: 6 additions & 0 deletions generators/app/templates/babel.config.js.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
3 changes: 1 addition & 2 deletions generators/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "Dependencies managed by Blueprint - use latest versions",
"dependencies": {
"@react-native-masked-view/masked-view": "0.3.0",
"@react-navigation/devtools": "6.0.20",
"@react-navigation/drawer": "6.6.6",
"@react-navigation/native": "6.1.9",
"@react-navigation/stack": "6.3.20",
Expand All @@ -16,8 +15,8 @@
"net": "1.0.2",
"querystringify": "2.2.0",
"ramda": "0.29.1",
"react-datepicker": "4.24.0",
"react-dom": "18.2.0",
"react-datepicker": "4.24.0",
"react-native-keyboard-aware-scroll-view": "0.9.5",
"react-native-modal-datetime-picker": "17.1.0",
"react-native-picker-select": "9.0.0",
Expand Down
19 changes: 15 additions & 4 deletions generators/app/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "<%= context.reactNativeAppNameKebabCase %>",
"version": "0.0.1",
"scripts": {
"android": "expo start --android",
"ios": "expo start --ios",
"test:watch": "jest --watch",
"updateSnapshot": "jest --updateSnapshot",
"coverage": "jest --coverage && open coverage/lcov-report/index.html || xdg-open coverage/lcov-report/index.html",
Expand All @@ -19,19 +21,23 @@
"test:e2e": "./e2e/scripts/setup.sh && detox test --configuration ios.sim.release --retries 3 --loglevel trace --debug-synchronization 500",
<%_ } _%>
"postinstall": "patch-package",
"prettier": "prettier --write \"{,.,**/,.jhipster/**/}*.{md,json,yml,js,ts,tsx}\""
"prettier": "prettier --write \"{,.,**/,.jhipster/**/}*.{md,json,yml,js,ts,tsx}\"",
"start": "expo start",
"web": "expo start --web"
},
"dependencies": {
"@expo/vector-icons": "EXPO_REPLACE_WITH_VERSION",
"@react-native-async-storage/async-storage": "EXPO_REPLACE_WITH_VERSION",
"@react-native-community/datetimepicker": "EXPO_REPLACE_WITH_VERSION",
"@react-native-masked-view/masked-view": "REPLACE_WITH_VERSION",
"@react-native-masked-view/masked-view": "EXPO_REPLACE_WITH_VERSION",
"@react-native-picker/picker": "EXPO_REPLACE_WITH_VERSION",
"@react-navigation/devtools": "REPLACE_WITH_VERSION",
"@react-navigation/devtools": "EXPO_REPLACE_WITH_VERSION",
"@react-navigation/drawer": "REPLACE_WITH_VERSION",
"@react-navigation/native": "REPLACE_WITH_VERSION",
"@react-navigation/stack": "REPLACE_WITH_VERSION",
"apisauce": "REPLACE_WITH_VERSION",
"expo": "EXPO_REPLACE_WITH_VERSION",
"expo-status-bar": "EXPO_REPLACE_WITH_VERSION",
<%_ if (context.authenticationType === 'oauth2') { _%>
"expo-auth-session": "EXPO_REPLACE_WITH_VERSION",
"expo-random": "EXPO_REPLACE_WITH_VERSION",
Expand All @@ -48,7 +54,9 @@
"querystringify": "REPLACE_WITH_VERSION",
"ramda": "REPLACE_WITH_VERSION",
"react-datepicker": "REPLACE_WITH_VERSION",
"react-dom": "REPLACE_WITH_VERSION",
"react": "EXPO_REPLACE_WITH_VERSION",
"react-dom": "EXPO_REPLACE_WITH_VERSION",
"react-native": "EXPO_REPLACE_WITH_VERSION",
"react-native-gesture-handler": "EXPO_REPLACE_WITH_VERSION",
"react-native-keyboard-aware-scroll-view": "REPLACE_WITH_VERSION",
"react-native-modal-datetime-picker": "REPLACE_WITH_VERSION",
Expand All @@ -72,12 +80,15 @@
"yup": "REPLACE_WITH_VERSION"
},
"devDependencies": {
"@babel/core": "EXPO_REPLACE_WITH_VERSION",
"@react-native-community/eslint-config": "REPLACE_WITH_VERSION",
"@react-native-community/cli-server-api": "EXPO_REPLACE_WITH_VERSION",
"@storybook/addons": "REPLACE_WITH_VERSION",
"@storybook/react-native": "REPLACE_WITH_VERSION",
"@storybook/theming": "REPLACE_WITH_VERSION",
"@testing-library/jest-native": "REPLACE_WITH_VERSION",
"@testing-library/react-native": "REPLACE_WITH_VERSION",
"@types/react": "EXPO_REPLACE_WITH_VERSION",
"babel-jest": "REPLACE_WITH_VERSION",
"babel-preset-env": "REPLACE_WITH_VERSION",
"buffer": "REPLACE_WITH_VERSION",
Expand Down
39 changes: 0 additions & 39 deletions lib/generate-react-native-app.js

This file was deleted.

4 changes: 0 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { printJHipsterLogo } = require('./print-jhipster-logo');
const { loadVariables, setupVariables } = require('./setup-variables');
const { mergeReactNativePackageJson } = require('./merge-react-native-package-json');
const { createEarlyFiles } = require('./pre-write');
const { generateReactNativeApp } = require('./generate-react-native-app');
const { appendFiles } = require('./append-files');
const { getAppFolder } = require('./get-app-folder');
const { patchBabel } = require('./patch-babel');
Expand All @@ -15,9 +13,7 @@ module.exports = {
printJHipsterLogo,
loadVariables,
setupVariables,
mergeReactNativePackageJson,
createEarlyFiles,
generateReactNativeApp,
appendFiles,
getAppFolder,
patchBabel,
Expand Down
39 changes: 0 additions & 39 deletions lib/merge-react-native-package-json.js

This file was deleted.

0 comments on commit 3a1acc9

Please sign in to comment.