Require locally packaged assets in remotely downloaded js bundle - react-native

I used this solution to download js bundle each time my app starts because I want an easy way to deploy minor changes during development stage.
The downloaded file is the one I exract from built apk. However, no images required in js (like require('../grapic/pic.png')) show up when application is run in this mode.
I save the js file like this:
File jsCodeDir = getApplicationContext().getDir("assets", Context.MODE_PRIVATE);
File f = new File(jsCodeDir, "remote.android.jsbundle");
// ... download file and put it into f
It seems that the problem is with paths: js isn't able to require images when it is stored in assets/ folder of internal storage, as opposed to when it is run from default assets/ folder from within apk.
So the question: is there a way to make a bundle such that it is able to use locally packaged resources (images from within apk just like locally packaged js does).

Related

generating certain assets in production after changes are made - Nuxt.js

I store user uploaded images inside /assets directory, so I serve them using require() which takes an uploaded image built inside _nuxt directory.
Now these uploads can be uploaded by users through the form and in production after every upload made I need to build them manually through the command line since the assets are not built on changes as it is in development.
Is there a sollution to build certain assets (uploaded images) after changes are made in production?

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

load local files outside NWJS app

When I work locally I want to share code among two or more (nwjs and other kinds of) projects. Folder structure:
-project 1
-project 2
-shared code
When releasing the apps I build the external files into a file inside each project app.
But I cannot access files outside the node-webkit/nwjs app folder.
I tried things like:
Setting "chromium-args": "--allow-file-access-from-files" in the manifest file but I think this is default now.
Using file:/// and chromium-extension:/// prepending the relative paths but I think this is only for absolute paths?
Load files dynamically and using path.relative( process.cwd(), "../shared_code/scripts/controllers/searchController.js" );
The user of the app will be able to put it anywhere on his computer.
Is it possible to load js and css files and images from outside the nwjs project folder locally?
nwjs sdk version 0.19.5
I had a similar problem trying to load images outside of the NW.js application. I found that this fixed my issues. Try adding this to your JSON manifest file. This worked for me...
"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir"
Just so you know, I had originally tried this...
"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir --mixed-context"
But it stopped jquery loading.
You can then access files with file:/// and use absolute paths anywhere on the machine.
I hope that helps.
For sharing code, when the code is (or can be) a node module, it's very helpful to be able to npm link it into your project. (It works the same with NW.js apps as for Node.js:)
cd shared-code
npm link
cd ../project-1
npm link shared-code
cd ../project-2
npm link shared-code

can't access uploaded files in dist mode in play framework

I have done all mandatory / required steps to run the project in 'dist' mode,though it is running perfectly,i can't access the files which i've uploaded in the same.
i can see the uploaded files,in 'my_project\bin\public' folder but not able to download it.
being newbie in play framework i would like to facilitate the users who have uploaded their files in the system to download the same.

How to build an app from javascript source files in GitHub app-catalog repository?

How do I take the JS and CSS source for an app like the Iteration Tracking Board (https://github.com/RallyApps/app-catalog/tree/master/src/apps/iterationtrackingboard) or Release Burndown (https://github.com/RallyApps/app-catalog/tree/master/src/apps/charts/burndown) and turn that into HTML source that can be used as a Custom HTML app in a page in Rally?
Prerequisites:
Node.js
rally-app-builder
After source files are copied to a local directory (you may either fork the app-catalog repo, or download zip from the same location):
in terminal, cd to the app
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.
Copy/paste App.html or App-uncompressed.html file from deploy folder to the HTML section of the custom page in Rally.