What HTML files should be edited in cordova? - javascript

I have seen a few references to this topic, but it's not 100% clear to me.
Inside the top level of a cordova project you have these folders '.cordova', 'merges', 'platforms', 'plugins', 'www'. I would think you edit the top level 'www' folder and it would update the files inside platforms\<platform>\assets\www because editing files directly in this path get overwrote, from what I have read and I experienced this once before deploying an app.
I can't find documentation on this (searching cordova update project just covers updating cordova itself, at least from what I am seeing maybe I'm being blind here).
How do the files in the root 'www' update the project files? I am sure there is a command for this but is it true I have to run an update command every time I make an edit in say Dreamweaver, because when I make an update it obviously doesnt make changes into the directory because it doesnt have anything telling it to.
So what I am asking.
You should edit the html/css/javascript inside the cordova projects root 'www'?
What are some solutions to updating the platform code from the main files?

Edit the content of www folder in main project directory and run cordova build command to copy these files to your platform specific directories. So the process will be like
Edit the content of www folder in project directory.
Debug the changes with any browser or emulator like Ripple.
Run cordova build command to test it in Android emulator or in a real device.
To use cordova command line tools, you need to install cordova command line interface. It can be found here.

Related

JavaScript React hiding source files in sources tab

I have recently developed a website, it's NodeJs (on Ubuntu) and running a React app. The problem is, for example, on Chrome; when you right-click on the website and check sources you can see the source codes and all the files. I want to hide all of them.
In this section, I want to hide the source codes (files) in the server.
I tried couple of solutions on the internet but none of them worked.
For example,
I've added "build": "GENERATE_SOURCEMAP=false react-scripts build", in package.json and then I did run pm2 reload (also yarn build etc)
I've created a file called .env and added this line GENERATE_SOURCEMAP=false in it.
None of them has worked. My website is currently active right now and I want to hide source files, how can I hide these source files from sources tab so people can't see the source codes?
After long research, I have found the solution.
Create a file called .env in your project. The name of the file is just .env.
In that .env file put this line GENERATE_SOURCEMAP=false and save.
Then, run npm run build or yarn build.
This will generate a build folder for production. After that, depends on what you are using, run this build file for running the website. For example, I'm using pm2 on my Ubuntu server, so I've used pm2 serve build 3000 --spa (my website is running on port 3000) Also be careful you are in the same path with the build folder.
That's it. Now all the source code files are gone and website works like a charm.

Electron - Tidy Up Packaged App Folder

Running electron-packager, I expected the resulting folder structure to be a bit neater, so that I could just zip it up and allow it to be downloaded as an app.
The main folder contains the executable app, but also a lot of .dll, .pak and .bin files. I think this may be a bit confusing to users of my app, is there any way to move all of these files into a folder when running electron packager?
The output from electron-packager is not supposed to be used by the user. It gives an output folder that you can pass into the windows installer to make an installer for users. The installer hides that messy folder under AppData\Local\appname\app-version. It uses Squirrel to do this and once configured correctly the user only sees desktop and start menu shortcuts to launch the application. Using Squirrel means it plays nicely with the Electron autoUpdater.
While using the windows installer and auto updater is recommended you could also create a shortcut to the executable created by the packager so that users don't have to see the messy folder themselves.

How do you publish a typescript website to GitHub Pages using Visual Studio?

So I made a Typescript project with Visual Studio. It works fine when I launch it with Visual Studio, but if I try to push it to my GitHub Pages site, it will put the index.html in a subfolder and I get a 404 error when I try to load my website. Even if I try to reference the index.html in the website url it doesn't really work.
I was wondering if it's possible to only publish the needed items. I think I would only need the subfolder. Correct me if I am wrong though.
Note: I have the GitHub extension for Visual Studio installed.
UPDATE:
Since some of the links don't seem to work anymore I think I should give some extra information. So basically you need to have a branch named gh-pages. On that branch you need to have an index.html file in your root folder. Then the index.html file should be visible on the github page URL.
You need to push a branch named gh-pages in order to view it as a website.
Create a new branch and then move the file into the root folder of the branch, upload it to the gh-pages and you set to go.
Check this out:
https://github.com/nirgeier/JimVliet.github.io/tree/gh-pages
This is how your file should be inside your root folder.

How do I install Meteor Atmosphere packages locally so I can make modifications to it?

I am trying to get up and running with Meteor and seeing what it can offer, while I like it overall, it seems it's a very very rigid system.
I set up a small testing setup using Velocity, it opens a small overlay window on the side which has a class of "velocityOverlay". The overlay is really small and makes error stack traces wrap. All I wanted to do was to edit the css of the "velocityOverlay" and increase the width.
I somehow (after wasting time) managed to find that Meteor is actually putting all the packages in my user directory by default, once I found that, I found the needed css file...
velocity_html-reporter/.0.5.1.aykpxq++os+web.browser+web.cordova/web.browser/packages/velocity_html-reporter/lib/client-report.less.css
And I did a small edit to the width, next thing you know the meteor app crashes when trying to launch using the "meteor" command throwing a "Error: couldn't read entire resource" error. I can't even edit the bootstrap.css file I installed using "ian_bootstrap-3".
Further more, I can't find any way to install packages locally just for my particular project, what if I wanted to modify a package only for my particular project? this is very easy to do in vanilla Node.js, you simply don't use the "-g" when using "npm install".
To add to that, within my project root, there is another ".meteor/local/build/web.browser" folder with most of the global package files replicated again. When does Meteor use which? This is very confusing.
You can run a package locally very easily.
Download it from Github (for example) and put it in the packages/ directory of your application like this /packages/package_name.
Then add it to your application with the same meteor add package_name command as usual.
Meteor will automatically look in the local folder before anywhere else and compile the package with the rest of your code.
This allows you to do any modification you want on the package and test it locally before publishing it to the registry.
Also, folders located in .meteor/local/* are used for building purpose only and are generated automatically by Meteor. So it is not the best place to edit the files!
This worked for me https://atmospherejs.com/i/publishing. mrt link-package didn't work for me, might just be outdated code.
Steps:
Download (or clone) package from GitHub to local dir
Stop meteor if running
2.1. Make sure you have a packages folder: mkdir packages
Locally link your package:
3.1 If you have mrt installed: Run mrt link-package /path/to/package in a project dir
3.2 If you don't have mrt: ln -s /path/to/package packages/package
Then run meteor add developer:package-name, do not forget to change package name
Run meteor in a project dir
From now any changes in developer:package-name package folder will cause rebuilding of project app
Download the package and place it in new package directory in your project root.
open the package.js inside the downloaded package and remove the author's name in the property "name:"
e.g: - name:'dburles:google-maps' to name:'google-maps'
then run
meteor add google-maps

XCode Build not updating JS and HTML

I am using XCode 5.0.2 and Cordova 3.4.0-0.1.3 - What I find is after creating the project using the Cordova CLI and opening in XCode, no changes to the index.html file and index.js file are ever carried over to the simulator when I click run.
I have to open terminal and issues a Cordova Build command and then run the simulator and it works
I followed all the instructions here:
Phonegap - developing and launching app on simulator
xcode 4 + phonegap ... not update JS upon build?
And none of it works! any one a have a solution to this, because having to switch back and forth is becoming a pain.
You can add a pre-action script to your XCode project's build. To do this:
Select Product > Scheme > Edit Scheme from the menu (or ⌘ < on keyboard)
Select Build > Pre-actions from the left
Click + and select "New Run Script Action"
Add a script like this:
cd /path/to/your/cordova/project/
cordova prepare ios > xcode-prepare-results.txt
Now XCode should always run cordova prepare before building your project so you don't have to jump to terminal. You can see the output of prepare in the file xcode-prepare-results.txt.
Note, that depending on how your cordova executable is set up and which shell you use, you might have to either change the shell or modify your PATH in order for the script to find cordova.
So after much searching I seem to have found a solution that works, here is what I did. After looking at other Stackoverflow questions I found someone that said this worked for them.
Find the file called copy-www-build-step.sh.
Mine was in
[project_folder]/platforms/ios/cordova/lib/copy-www-build-step.sh
In that file, find the lines beginning rsync -a "...
Add -c to the rsync lines, so they ready rsync -a -c "...
Well I tried that and it did not work on its own. I also tried the answer from Ville and that pulled closer but no cigar. Finally I took what the command from Ville and put it in the copy-www-build-step.sh file
so my top line is now
cd /path/to/your/cordova/project/
cordova prepare
SRC_DIR="www/"
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/www"
COPY_HIDDEN=
ORIG_IFS=$IFS
IFS=$(echo -en "\n\b")
.....
.....
.....etc etc
And now I make change , and click run , bam all is updated. I hope this helps someone else.
Other answers in this thread either didn't work for me or screwed up cordova plugins e.g. InAppBrowser, so i finally came up with this:
Edit the file copy-www-build-step.sh and add the following row in the beginning:
cp -fR ../../www/ www/
so it should look like:
...
cp -fR ../../www/ www/ # new code
SRC_DIR="www/"
...
This way your code will be updated properly and your plugins will work
I also edited the copy-www-build-step.sh file, however you don't want to use an absolute path from your User folder. If you are working with other developers you would have to change that every time you check out code.
It's not a big deal, just change:
SRC_DIR="www/"
To:
SRC_DIR="../../www/"
UPDATE
Worked for me on Cordova and Phonegap.
To have the source files automatically copied from the www source directory to the platforms/ios/www directory when you click the Run button in XCode:
In XCode, choose Product->Scheme->Edit Scheme...
Expand the triangle for Build->Pre-actions
Click the "+" to create a new Pre-action
You can leave the "Shell" setting blank.
Set "Provide build settings from" to the project you are building. This is important.
In the script area enter:
cd ${PROJECT_DIR}/../..
echo "--- Start ---" > xcode-prepare-ios-results.txt
echo "Running cordova prepare ios command..."
pwd >> xcode-prepare-ios-results.txt
cordova prepare ios --verbose >> xcode-prepare-ios-results.txt
echo "--- Finished ---" >> xcode-prepare-ios-results.txt
This works for me with XCode 8.2 and Apache Cordova 6.x
I suggest you clean before build your xcode project. And one more thing, make sure you build again your project using cordova build, not inside xcode because it's totally different.
cordova build yourproject
#Ksliman
I modified you code a bit to work on my system and make slight bit more generic.
top of file copy-www-build-step.sh
## New Code Begin ###
cd ../../
PATH=${PATH}:/usr/local/bin
cordova prepare ios
## New Code End ###
SRC_DIR="www/"
simply type:
cordova prepare
on your terminal and run your project again in Xcode
Simple solutions is to build the app with cordova using:
sudo cordova build ios
Then go to xcode > Product > Clean
Then go to xcode > Run (Play Button)
Run "cordova prepare ios" during the building phases:
Open Xcode.
Select your project.
Go to "Build Phases".
Go on "+" to add a "New Run Script Phase".
Move this section before "Copy www directory".
Add the following lines (for Mac):
cd /Users/*/YOUR_PROJECT_FOLDER (Change your project folder)
/Users/*/.nvm/versions/node/v?.?.?/bin/node node_modules/cordova/bin/cordova prepare ios (Change the path to node version)
After "Play" the www-folder will automatically refresh!
All I had to do was to include the full absolute src path for my project. For example:
From your project directory, vim platforms/ios/cordova/lib/copy-www-build-step.sh
change SRC_DIR to the absolute path of your www, SRC_DIR="/Users/michael/Documents/Development/SampleMobileApp/www/"
Save, build, and you should be good to go.
I found that sometimes Cordova gets confused... you need to do a "cordova platform rm ios" (just leave your plugins alone), and then do a "cordova platform add iOS", which will reinstall all your plugins into your platform... then try your build again.
Every time I use cordova build its overrides content in my platform specific www file. So I use cordova compile instead.
From help:
compile <platforms> compiles platform project without preparing it
It is important to just compile the changes not to build entire projects especially if you creating mobile app for many platforms and you have to do some platform specific improvements.
For me, there was an error in my code. I simply needed to run npm start to locate it.
If you are directly changing html from the Xcode, then you should change the code/html of the staging folder, not main folder
In the staging folder you will get same structure which you have in the main folder, but it will reflected directly in the xcode (iOS) build
Staging folder
Note: The changes you made in the xcode will be replace when you build again from the cordova build/run, so please copy your changes in the main folder before doing firing cordova commands
You can get more information from this answer: Purpose of Staging folder in PhoneGap 3.4? Only changes to index.html in this folder get recognized?
This is the correct solution taken from:
Cordova + Xcode 7.3 (html + Javascript) not changed or updated when build and emulate

Categories