google-apps-scriptgoogle-sheetspushadd-onclasp

How to upload only updated files in Google Apps Script using clasp?


I'm developing Google Apps Script locally. I used the clasp push --watch command for pushing updated code to the original Apps Script as per the documentation.

https://www.npmjs.com/package/@google/clasp#push

The problem is that when I update the code of any one file, it uploads the whole file. I have attached the screenshot of the file structure and vs code terminal. You can see there I had updated the code of home.html but still, it's uploaded the whole project. Because of this, we are getting time-consuming issues. It's taking a long time to upload the project. I had also attached the screen shot of clasp.json file.

Is there any way to upload the only updated file ?

Pushed Files

Folder Struture

Clasp.json


Solution

  • It seems this behavior is expected based on the documentation:

    Warning: Google scripts APIs do not currently support atomic nor per file operations. Thus the push command always replaces the whole content of the online project with the files being pushed.

    clasp push replaces code that is on script.google.com and clasp pull replaces all files locally. For this reason, follow these guidelines:

    Do not concurrently edit code locally and on script.google.com. Use a version control system, like git.

    A new feature would be required from the Google Apps Script API to accomplish what you're looking for, it seems there is already a Feature Request here, you can vote for it, add your comments and look for any future updates.

    References