This tutorial is about CLASP.
You can use locally this tool that lets you create, edit, and deploy Apps Script projects.
The clasp requires Node.js >= v4.7.4 to be installed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | C:\nodejs>npm i @google/clasp -g C:\Users\catafest\AppData\Roaming\npm\clasp -> C:\Users\your_account\AppData\Roaming \npm\node_modules\@google\clasp\src\index.js + @google/clasp@1.6.3 added 278 packages from 159 contributors in 161.263s C:\nodejs>clasp Usage: <command> [options] clasp - The Apps Script CLI Options: -h, --help output usage information Commands: login [options] Log in to script.google.com logout Log out create [options] [scriptTitle] [scriptParentId] Create a script clone [scriptId] [versionNumber] Clone a project pull [options] Fetch a remote project push [options] Update the remote project status [options] Lists files that will be push ed by clasp open [options] [scriptId] Open a script deployments List deployment ids of a scri pt deploy [version] [description] Deploy a project undeploy <deploymentId> Undeploy a deployment of a pr oject redeploy <deploymentId> <version> <description> Update a deployment versions List versions of a script version [description] Creates an immutable version of the script list List App Scripts projects logs [options] Shows the StackDriver logs run [options] <functionName> Run a function in your Apps S cripts project apis List, enable, or disable apis help Display help * Any other command is not supp orted C:\nodejs>clasp login No credentials given, continuing with default... ? Authorize clasp by visiting this url: https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https... |
This will open a webpage to authenticate with your Google account.
Next step: create your project folder and use it with Google Apps Script.
Use create command created a standalone script.
1 2 3 4 | C:\nodejs>mkdir clasp_codelab C:\nodejs>mkdir clasp_example C:\nodejs>cd clasp_example C:\nodejs\clasp_example>clasp create "clasp_example" |
This will not be linked with the Google Apps project.
You need to create one and use a clone.
To do this you can get the Script_ID
This can be found in your project: File > Project properties > Info > Script ID.
Copy the value and use it in the following command:
1 | clasp clone Script_ID |
The project is downloaded in your current directory.
To open the script in the cloud use:
1 | clasp open |
Next commands can be used to use files locally.
The clasp push replaces code that is on script.google.com and clasp pull replaces all files locally.
This tool is available on GitHub.