Syncing development environment with production environment

Hello,

I am attempting to sync my development environment to a live environment ahead of release. This is the first time I’ve tried to do this, and I have a couple of issues:

1 - How do I transfer the logic in UI Builder? It doesn’t happen during the sync process and I can’t find any documentation that covers how to do this.

2 - Is there a way for me to import the JS files from a coded service? I have seen mention of coderunner but don’t know how to use this, is it possible to simply bulk import the folders and files?

3 - I’m not sure if this is an error, but when I sync between the environments it will show that a number of changes are needed on the database and API services, I will run the sync and it will complete successfully without any errors, the API changes show as complete but the database changes don’t show at all.

When I then run another sync inspection it shows that the changes are still needed to the database and API services.

I’m syncing from App ID - 8518B92E-A6AA-5589-FFA0-B863E4A63F00 to App ID - CDB7825D-6AD6-D444-FF6B-A9AD88ECA900

Thanks

Hi @Luc_Zentar ,

1 - How do I transfer the logic in UI Builder? It doesn’t happen during the sync process and I can’t find any documentation that covers how to do this.

Unfortunately sync logic doesn’t support sync of UI Builder yet. You can sync it yourself by zipping required UI Builder container in source app and unzipping it in target app.

2 - Is there a way for me to import the JS files from a coded service? I have seen mention of coderunner but don’t know how to use this, is it possible to simply bulk import the folders and files?

You can’t sync JS logic between two apps, this feature only supported for Codeless business logic. But you can download your JS logic from source app and redeploy it to target app.

3 - I’m not sure if this is an error, but when I sync between the environments it will show that a number of changes are needed on the database and API services, I will run the sync and it will complete successfully without any errors, the API changes show as complete but the database changes don’t show at all.

Could you please describe what database changes are not applied? Also can we check sync process between your apps by ourselves?

Regards, Andriy

Thank you @Andriy_Konoz

1 - I have zipped the file from the development app and unzipped it in the development app. I can’t figure out how to turn the unzipped files into a container though?

2 - Again, I have been able to download the zip from the source app but can’t figure out how to upload in the coded section of the production app?

3 - I’m happy for you to check by yourselves

There are 49 changes that are not being applied to the database:

And 2 in the API codeless logic:

1 Like

Hello @Luc_Zentar,

1 - I have zipped the file from the development app and unzipped it in the development app. I can’t figure out how to turn the unzipped files into a container though?

The archived container(s) should be placed to the same folder it was zipped in.
E.g. if you zipped the container from ui-builder/containers/CONTAINER_NAME, it should be placed right into the ui-builder/containers folder and unzipped there.

2 - Again, I have been able to download the zip from the source app but can’t figure out how to upload in the coded section of the production app?

All logic stored in the CONTAINER_NAME folder will be uploaded after this folder is unzipped.
If you need to sync the Cloud Code logic, you should select it here:

3 - I’m not sure if this is an error, but when I sync between the environments it will show that a number of changes are needed on the database and API services, I will run the sync and it will complete successfully without any errors, the API changes show as complete but the database changes don’t show at all.

I’ve created an internal ticket BKNDLSS-28040, we’ll check this issue as soon as possible.

Regards,
Olha

@olhadanylova Thank you, number 1 is all fixed and working

Number 2, this isn’t codeless API but coded, which I don’t think syncs in that process. I have figured it out though from the solution to number 1, I zipped and downloaded the default folder in root>server code>JS and unzipped this in the production environment and replaced the existing default folder. Just for reference in case anyone finds this thread and wanted to know the solution.

I’ll wait to hear on the internal ticket.

Thanks again for your help!

Glad it worked for you! We’ll notify you as soon as problem is investigated and fixed.

1 Like

@Luc_Zentar

About #2. I would recommend you to deploy your JS logic to target app instead of simply unzipping in in target app filesystem. During deploy Backendless analyzes deployed code and creates internal records so event handlers and API services would work correctly.
When you just unzip code in app filesystem you just place files with code and Backendless will know nothing about them since there are no internal records for them. Unzipping will only work when you made changes to existing services or event handlers.

To perform correct sync of JS code between two apps you should do the next:

  1. In source app go to “Cloud Code” > “Coding” section, select “JS” as language, select required model (by default all code is placed in “default” model) and click “Download project” button.
  2. Unzip archive locally and open unzipped folder.
  3. Open file “coderunner.json” file in text editor, locate field “app”.
  4. Locate fields “id” and “apiKey” in nexted object from that field. In field “id” paste ID of the target app. In field “apiKey” paste CoudCode API key from the target app.
  5. Save changes to the file.
  6. exetute npm i
  7. execute npm run deploy

Regards, Andriy

@Andriy_Konoz Thank you for explaining this, I have followed the instructions above but when I run npm i it removes a number of the node modules and then the deployment fails as it can’t find the required folders. Can I execute npm run deploy without the prior npm i?

@Luc_Zentar

If you can deploy the logic you want without the npm i step, try skipping it. Can youu deploy the logic in that case?

Regards, Marina

@Marina.Kan I have tried and get this error:

Mina_Development__JS_default_coding % npm run deploy

Mina_Development-servercode@1.0.0 deploy
coderunner deploy

sh: coderunner: command not found

@Luc_Zentar, try the next steps:

  1. npm i
  2. npm i [module_name, which was deleted]
  3. npm run deploy

Hope it will help you!

Regards, Marina

@Marina.Kan Thanks for your help, the problem is that running npm i removes a lot of modules.

npm i

added 119 packages, removed 48 packages, and audited 138 packages in 633ms

5 packages are looking for funding
run npm fund for details

So after I ran npm i [deleted module name] for 3 modules that made the deployment fail (example)

12:29:02.617 [master] Errors (1):

12:29:02.617 [master] Cannot find module ‘validator’

Require stack:

  • /Users/luczentar/Desktop/Software development/Backups/Mina_Development__JS_default_coding/services/DocusignService.js

  • /Users/luczentar/Desktop/Software development/Backups/Mina_Development__JS_default_coding/node_modules/backendless-coderunner/lib/server-code/api/index.js

  • /Users/luczentar/Desktop/Software development/Backups/Mina_Development__JS_default_coding/node_modules/backendless-coderunner/lib/index.js

  • /Users/luczentar/Desktop/Software development/Backups/Mina_Development__JS_default_coding/node_modules/backendless-coderunner/lib/cli/clirunner.js

  • /Users/luczentar/Desktop/Software development/Backups/Mina_Development__JS_default_coding/node_modules/backendless-coderunner/bin/coderunner (services/DocusignService.js:7:19)

12:29:02.618 [master] Error: Nothing to publish

luczentar@Lucs-iMac Mina_Development__JS_default_coding % npm i validator

added 1 package, and audited 176 packages in 620ms

, it did succeed but then the coded section in the production environment is showing errors because further modules are missing.

I’ve run npm i moment and that seems to have fixed that issue, but other lines in other files are red too. The solution seems a little problematic, is there a better way to approach this?

Thanks again!

Hello @Luc_Zentar,

This is how npm works. Basically, all modules that you’re using in your code, should be specified in your package.json and installed directly using npm i module_name syntax.
If you need moment, you make npm i moment, validator - npm i validator, and so on for all modules that are required for your app to work. There is no other way to install it.
Did you install all of your modules and still see the errors?

Regards,
Stanislaw

Thank you @stanislaw.grin - what I couldn’t understand was where to find these modules, so if I go into the file package.json I just need to identify the modules and then run npm i [name] for each? is this the correct list?

When you run npm i [name], npm automatically updates the package.json including module to it. So there’s no need to specify modules by hands, npm will do it automatically.

Thanks, sorry I haven’t used npm before.

So when I first run npm i it removes a number of modules needed for the code to function. Is there any way to see which modules have been removed so I then know which npm i [name] commands to run?

Or do I just have to respond to errors as they happen until I have added all modules that are shown as errors?

I don’t know how it could happen that you used modules that are not listed in your package.json, but yes - the only way to install the missing modules is to install everything that comes across in the errors until everything is installed in this way. But this will be the only time you have to do this, in the future these modules will already be specified in the package.json and will not be removed on subsequent invocations of the npm i.

1 Like

Hello @Luc_Zentar!

I would like to clarify one point:
In these screenshots a step that shows the description of the changes that will be made after the deployment. In order for them to be applied - you need to select the changes you want by selecting the checkbox and clicking Deploy.
The changes were not applied after you clicked Deploy?

Regards,
Alexander

@Alexander_Pavelko sorry for the delay!

That was the case, but I have tried this recently and it has worked. So whatever was causing the problem is now fixed I guess :slight_smile: