Creating an update.json File
The update.json file serves a very important purpose. It provides our installation process with instructions to follow when installing your app.
First Version of Your App
If this is the first version of your app the update.json file is very simple.
- Create a file named update.json
- This file contains a json object with an AddOrUpdate array. Example below.
- For each file in your app, include the file path where the app should be installed.
- You must include a “/” at the beginning of the path.
- The file must contain this array with at least one file path in it to be valid.
New Version of Existing App
If you are creating an update.json file for a new version of an existing app you have more options available that you should understand.
With existing app customers in mind, you should create these instructions with care and test them to ensure their correctness. They should allow us to update the users of your app from one version to another without breaking their apps.
Options: When a user is updating from one app version to a newer one, there are four possible actions we can take for each file.
- Add or Update- This is essentially saving a file to the user’s site. If the file already exists it will be overwritten.
- Do Nothing - This will be used often. It means that there were no changes to the file since the last version and we don’t need to save it again.
- Copy and Move - This action is used when it existed in a previous version, but it’s location in your app has changed. It should be used when the file contains data that would be troublesome if the user loses it, like a json settings file.
- Delete - You can delete files or folders if they existed in a previous version of your app but are no longer needed for the app to work properly.
These options are used by putting your files in the appropriate array within your update.json file.
Here’s an example of an update.json file that uses every available option. Notice that the files and folders that should be deleted are placed in separate arrays.
update.json file requirements
- You must have an AddOrUpdate array with at least one item in it.
- Every file in your app must have it’s path in the update.json file.
- File paths should have a leading “/” as shown in the example above.
- Folder paths should have a leading and trailing “/” as shown in the example above.