DEV Community

ZHZL-m
ZHZL-m

Posted on

【Journey of HarmonyOS Next】DevEco Studio User Guide (31)

Image description

1 -> Synchronize cloud functions and cloud objects

illustrate

For functions deployed prior to DevEco Studio 4.1 Canary 2, JavaScript code is synchronized.

1.1 -> Synchronize a single SCF/CF

After the SCF or Cloud Object is deployed to AGC Cloud, if new changes are made in the cloud, you can synchronize the SCF or Cloud Object from the cloud to the local project. The synchronization mode of SCF and cloud object is the same, as described in the following section, using cloud object as an example.

  1. Right-click on the function directory and select "Sync 'Function Name'". The following uses the cloud object id-generator as an example.

Image description

  1. Click "Overwrite" in the confirmation pop-up box, and the "id-generator" function of AGC Cloud will overwrite the updated local cloud object "id-generator".

Image description

  1. Wait for the synchronization to complete, and the cloud object id-generator synchronized from the cloud will be generated in the cloudfunctions directory, and the local original cloud object id-generator will be backed up in the same path.

illustrate

If you perform deployment or debugging, DevEco Studio will automatically skip backing up the data. However, for the sake of streamlining the package, it is recommended that you delete the useless backup data in time after comparing the code differences.

Image description

1.2 -> Batch synchronization of SCFs and cloud objects

Batch synchronization of SCFs/Objects synchronizes all SCFs/Objects from the current project in AGC Cloud to the local project.

  1. Right-click on the "cloudfunctions" directory and select "Sync Cloud Functions".

Image description

  1. A pop-up window prompts that a cloud function/cloud object with the same name exists in the local project.

If you select Skip, the local functions or objects with the same name will be skipped during synchronization.
If you select Overwrite, the SCF/CF object in AGC Cloud will overwrite and update the local SCF/CF object with the same name.

Image description

  1. If you select "Skip" and wait for the synchronization to be completed, all SCFs/Cloud objects in the project synchronized from the cloud will be generated in the "cloudfunctions" directory.

As shown in the following figure, the "test-cloud-function" synchronized from the cloud is added to the "cloudfunctions" directory, and the existing cloud functions/cloud objects in the above figure have not been overwritten and updated.

Image description

  1. If you select "Overwrite" and wait for the synchronization to complete, all SCUs/cloud objects in the project synchronized from the cloud will be generated in the "cloudfunctions" directory. Local SCF or cloud objects with the same name are also overwritten and updated, and the original SCF/CF objects before the update are backed up in the same path.

As shown in the following figure, the cloud object "test-cloud-function" synchronized from the cloud is added to the "cloudfunctions" directory, and several existing cloud functions/cloud objects in the local area are also overwritten and updated, and the backup file "xxxx-backup time.backup" is generated.

illustrate

If you perform deployment or debugging, DevEco Studio will automatically skip backing up the data. However, for the sake of streamlining the package, it is recommended that you delete the useless backup data in time after comparing the code differences.

Image description

2 -> Synchronize the cloud database

illustrate

Currently, only object types can be synchronized.

2.1 -> Synchronize individual object types

After the object type is deployed to the AGC cloud, if a new change occurs, the object type in the cloud can be synchronized to the local computer.

  1. Right-click the object type JSON file (take "objecttype1.json" as an example) and select "Sync 'objecttype1.json'".

Image description

  1. Click "Overwrite" in the confirmation pop-up box, and the object type "objecttype1.json" in the AGC cloud will overwrite and update the local object type "objecttype1.json".

Image description

  1. Wait for the synchronization to complete, and the object type "objecttype1.json" synchronized from the cloud will be generated in the "objecttype" directory.

If there is a discrepancy between the cloud and local objects with the same name, the original local object types are backed up in the same path.
If the content of the object type with the same name is exactly the same in the cloud and on-premise, no backup is generated.
illustrate

If the deployment is performed in the future, DevEco Studio automatically skips the backup data. However, for the sake of streamlining the package, it is recommended that you delete the useless backup data in time after comparing the code differences.

Image description

2.2 -> Batch synchronization of object types

You can synchronize all object types under the current project in the AGC cloud to the local computer with one click.

  1. Right-click the objecttype directory and select Sync Object Type.

Image description

  1. A pop-up window prompts that an object type with the same name already exists in the local project, as shown in the following figure "Post.json" and "objecttype1.json".

If you select Skip, the local object type with the same name will be skipped during synchronization.
If you select Overwrite, the object type in the AGC cloud will overwrite and update the local object type with the same name.

Image description

  1. If you select "Skip" and wait for the synchronization to be completed, all object types in the project will be generated in the "objecttype" directory, and all the existing local object types will be generated in the "objecttype" directory.

As shown in the figure below, the "test_object.json" synchronized from the cloud is added to the "objecttype" directory, and the existing "Post.json" and "objecttype1.json" are not overwritten and updated.

Image description

  1. If you select "Overwrite", after the synchronization is completed, all object types synchronized from the cloud will be generated in the "objecttype" directory, and the existing object types will also be overwritten and updated.

If there is a discrepancy between the cloud and local objects with the same name, the original local object types are backed up in the same path.
If the content of the object type with the same name is exactly the same in the cloud and on-premise, no backup is generated.
As shown in the figure below, three object type files are generated in the "objecttype" directory: "test_object.json", "Post.json", and "objecttype1.json", where "test_object.json" is the object type newly synchronized from the cloud; The "objecttype1.json" already exists locally and is consistent with the content in the cloud, and no backup is generated. The Post.json already exists locally but is different from the cloud content, so it is overwritten and updated, and the original backup of the Post.json is Post.json-backuptime.backup.

illustrate

If the deployment is performed in the future, DevEco Studio automatically skips the backup data. However, for the sake of streamlining the package, it is recommended that you delete the useless backup data in time after comparing the code differences.

Image description

3 -> One-click synchronization of cloud-side code

illustrate

For functions deployed prior to DevEco Studio 4.1 Canary 2, JavaScript code is synchronized.

  1. Right-click on the Cloud Development Project ("CloudProgram") and select "Sync Cloud Program".

Image description

  1. A pop-up window prompts that an object type with the same name/SF/CF exists in the local project.

If you select Skip, the local object type with the same name, SCF, or CF will be skipped during synchronization.
If you select Overwrite, the object type/function/cloud object of AGC cloud will overwrite and update the local object type with the same name/SCF/cloud object.

Image description

  1. If you select "Skip" and wait for the synchronization to be completed, all object types in the project synchronized from the cloud will be generated in the objecttype directory, and all SCFs/cloud objects in the project synchronized from the cloud will be generated in the "cloudfunctions" directory.

As shown below:

The "test_object.json" synchronized from the cloud has been added to the "objecttype" directory, and the existing "Post.json" and "objecttype1.json" have not been updated locally.
The test-cloud-function object synchronized from the cloud is generated in the cloudfunctions directory, but the existing id-generator, my-cloud-function, and my-cloud-object are not overwritten and updated.

Image description

  1. If you select Overwrite, after the synchronization is complete, all object types in the project synchronized from the cloud will be generated in the objecttype directory, and all SCFs/cloud objects in the project synchronized from the cloud will be generated in the cloudfunctions directory, and the existing local functions/cloud objects/object types will also be overwritten and updated.

If there is a discrepancy between the cloud and local objects with the same name, the original local object types are backed up in the same path.
If the content of the object type with the same name is exactly the same in the cloud and on-premise, no backup is generated.
Regardless of whether the functions or objects with the same name are the same in the cloud and on-premises, the original functions or objects in the same path are backed up.
As shown below:

In the "objecttype" directory, three object type files are generated: "test _object.json", "Post.json", and "objecttype1.json", where "test _object.json" is the object type that is newly synchronized from the cloud. The "Post.json" already exists locally and is consistent with the content in the cloud, and no backup is generated. "objecttype1.json" already exists locally but is different from the content in the cloud, so it is overwritten and updated, and the original backup of "objecttype1.json" is "objecttype1.json-backuptime.backup".
The cloud object "test-cloud-function" synchronized from the cloud is generated in the "cloudfunctions" directory, and the existing "id-generator", "my-cloud-function" and "my-cloud-object" are also overwritten and updated, and the backup file "xxxx-backuptime.backup" is generated.
illustrate

If you perform deployment or debugging, DevEco Studio will automatically skip backing up the data. However, for the sake of streamlining the package, it is recommended that you delete the useless backup data in time after comparing the code differences.

Image description

Top comments (0)