Is necessary to git ignore .expo-shared folder in react native project? - react-native

I started using react native 2 months ago , and when i create i project by expo init, I see that .expo-shared is not ignored, and it seems like it contains someting like a token,
so as a newbie with a web development background, I wanna know if it is okay to push it to the public repository.

There's a README in that folder which says:
> Why do I have a folder named ".expo-shared" in my project?
The ".expo-shared" folder is created when running commands that produce state that is intended to be shared with all developers on the project. For example, "npx expo-optimize".
> What does the "assets.json" file contain?
The "assets.json" file describes the assets that have been optimized through "expo-optimize" and do not need to be processed again.
> Should I commit the ".expo-shared" folder?
Yes, you should share the ".expo-shared" folder with your collaborators.
So that should answer your question

I have not git-ignored mine and all is well, but as this is an expo internal folder, you could add it to the git ignore file without problems.

Related

Are create-react-app files visible on client side?

I'm currently experimenting with react and express and I wanted to know if react files are hidden, what m trying to do right now is encrypting api responses server side then decrypting it in the frontend, but having the key visible to everyone makes the entire thing useless
When you deploy your React application, your entire source code is visible to everyone from the sources tab of the dev tools.
This is not an issue with the create-react-app but all of the source code is added because of the source map which helps to easily identify the source of the bug that will occur on the live site in the future.
There is an easy way to fix it :
Create a file with the name .env in your project folder with the below code inside it :
GENERATE_SOURCEMAP=false
Or add this in package.json file :
scripts: {
"build": "GENERATE_SOURCEMAP=false react-scripts build"
}
Now, when you run 𝗻𝗽𝗺/yarn π—Ώπ˜‚π—» π—―π˜‚π—Άπ—Ήπ—± command from the terminal, It will generate a
π—―π˜‚π—Άπ—Ήπ—± folder with minified files without a source map that you can deploy to the production.
Hope you find my answer helpful !

Use single expo codebase for multiple apps

I got an application what we white-label for others.
This means we share the same functionality through the apps but there are some specific design elements (mostly colors and pictures) in each app.
I'm looking for the easiest and best way to identify the built app for my Expo React Native codebase.
My plan is store everything in the same javascript codebase, and just get load the correct config files by the application name.
In this case, I would get a few apps in the stores:
BlueApp
RedApp
GreenApp
All of them would load the same expo app: exp.host/#comp/colours
And this expo app should set the background to blue in the BlueApp and red in the RedApp.
! I don't want to detach my expo app, I want to still build my apps with the expo.
It is possible to use a different configuration file by doing expo start --config=some-app.json. One problem I ran into is that some assets were still being required at a specific location (eg. assets/images/icon.png).
The solution I came up with is to switch the project, via a bash script, every time you start a project. That way, the development you run you will also publish without fussing around config parameters that expo may or may not support.
So in your package.json you can have run commands which look like this:
./switch project1 && expo start
The bash script would sync all assets from src directory, including app.json to their expected paths. The directory structure would looks like this:
src
- project1
- app.json
- assets
- project2
- app.json
- assets
and the script:
#!/bin/bash
if [ $1 == "swaggr" ] || [ $1 == "chatsera" ]
then
echo "switching to $1"
unlink app.json
cp ./src/$1/app.json ./app.json
rsync -rvz ./src/$1/assets/ ./assets/
else
echo "could not switch project. $1 is invalid"
fi
If you use this approach I'd probably add app.json and all assets in .gitignore.
I'm not sure if i understood you correctly but i kinda think of a solution.
I don't know if this is the best way.
You can use release channels to create 3 different version of the same code. Than you can load config for the channel using Expo.Constants.manifest.releaseChannel.
for more information https://docs.expo.io/versions/latest/distribution/release-channels

Can I Copy Over React Native Files Initialized Under One Project Over To Another Separately Initialized Project?

Let's say I initialize a project under react-native init <filename>, installed a bunch of node packages, and added code.
Then separately I initialize a different project under react-viro init <filename>, installed a bunch of node packages, and added code.
If I wanted to combine what I created under react-native init into what I created under react-viro init, is it as simple as copying files over and reinstalling missing node packages into the react-viro project?
Assuming you are working in the ./src folder, every file is independent of iOS or Android as part of the JavaScript bundle.
You can simply copy the .js files over and install the node packages in that project.
You probably should not copy any files that are outside the ./src folder, but I also suspect you wouldn't need to. Files in the Android and iOS folders are rarely touched as they contain operating system config settings and custom modules that you would have wrote in the native languages.
If the file renders JSX, you will be safe to just copy it over and hook it back up.
To state it another way, go into the folder that has node_modules in it. You shouldn't copy anything that is in that folder except additional files that you created. This is where people normally create an src folder and place all their JavaScript. You probably have an index file in there that points to ./src/app.js or you may have an index.ios.js and index.android.js that both point to a ./src/app.js. Anything inside src is safe.
That's my best answer without seeing your folders and files.
If you intend to copy code from one react native project to another, make sure the code you intend to copy is JS and not any native files. Make sure you do register the correct component using AppRegistry. Rest assured you can copy the code from one project to another.
Assuming you have a project at folder
/my-project/android
/my-project/ios
/my-project/src
Copy my-project and paste it at your desired folder like
/new-my-project
Change git origin
git remote set-url origin https://gitlab.com/..../**.git
Open /new-my-project/android in Android Studio, and then rename app/java/com.myproject to com.newmyproject
Go to app/build.grade and change com.myproject to com.newmyproject and sync
Create firebase project and download google-services.json file and add to new-my-project/android/app
Build application, then test application under metro bundler
npx react-native start
Create keystore, test notifications, change base_url_api, test apk etc Android finish now, iOS
Update pods on new-my-project/ios
pod install && pod update
open myproject.xcworkspace
Change bundle identifier to org.reactjs.native.newmyproject, version to 1.0, build to 1 and desired Display name. Let it index completely
Setup in firbase and replace GoogleService-Info.Plist file and Clean build folder in xcode
Go to developer.apple.com and create identifiers, APNS certificates, profiles
Download certificates from keychain and upload to firebase
Build the project in simulator/device and test it.
Done

React native - exclude compiling folder content

I am thinking of putting my folder with design files in my open source project but being afraid that they will be used within compiling for ios or android app.
Is there a way to exclude this folder?
Thank you in advance.
If it's an open source project, I think you should keep resources in your repo and add them to your projects .npmignore file. This way, when you get the module via npm install, the resource files won't even be in node_modules folder and users that use your open source project won't need to change anything in their config files.

Rally - clone existing app

I'm trying to create a custom release burnup app for my group. There is an existing app called 'Release Burnup' in Rally, and based on the instructions for rally-app-builder I thought I would be able to clone this app as a starting point.
However, when I use the rally-app-builder clone RallyApps ReleaseBurnup command, it doesn't seem to do anything except change the title in the output html files to "Son of ReleaseBurnup". When I tried the same thing with the example from the github page (which uses rally-app-builder clone RallyApps StoryBoard) then it seems to be successfully cloning an app, with updates to the App.js file, etc.
I'm guessing that I might be using the wrong name to clone, but I'm not sure how to know what names are valid for this command to clone the app I want.
Unfortunately rally-app-builder clone functionality predates newer developments and the availability of source code of catalog apps from RallyApps/app-catalog, so it does not support drilling down those directories.
clone RallyApps StoryBoard works because there is a StoryBoard app at that location. There is no ReleaseBurnup there. ReleaseBurnup code is not available.
Here are the steps to build an app from javascript source files from GitHub app-catalog repository
Prerequisites:
Node.js
rally-app-builder
Get the source to a local directory (you may either fork the
app-catalog repo, or download zip from the same location):
in terminal, cd to the directory of the app you want to work on, and call this command:
rally-app-builder build.
As a result a deploy folder is created with App.html and
App-uncompressed.html inside, and App-debug.html is created in the
root folder of the app.
These steps make sense only if you intent to customize the catalog app and want to use the source as basis. If you want to use a catalog app as it was designed, install the app directly from the AppCatalog as described in this help document.