Clasp the Clasp - Part 1 - Google AppsScript CLI
Appscript is built on Apps script api
Considering you are familiar with Appscript in this article we will go through the cli tool “Clasp” released by Google which allows developers to code offline a new project or clone a project rather than using their online script editor. This gives the feasibility to develop bigger codebases in your favourite tools & editors.
Make sure you have *node version ≥ 4.7.4 . If needed you can install it from here*
Now install Clasp cli using npm
Before you start using Clasp you will have to login, as you would while using firebase cli
After this you will be asked to login with a link provided on the terminal. The access token and such user specific details is kept in ~/.clasprc.json.
To initialize a project
This initializes you project and creates two files in the current directory “appsscript.json” & “.clasp.json” and a new script file in your account, you can check it out at https://script.google.com with the filename as SCRIPT_NAME_HERE.
or you can clone a project using
To find your script id GOTO the script editor > File > Project preferences > Info >> Look of script Id here.
Project structure on script.google.com:
local cloned project structure:
after create or clone a local configuration file .clasp.json is created. this can be customised
Now lets walkthrough the basic cli commands in clasp.
To pull a project
To push files to project
To open the current project in script.google.com
Listing all deployment ids
Deploy current project
by providing version number you can manage your deployment versions as off git. Currently clasp doesnt provide any kind of git level version management although git can be used inside the project and to ignore like in git clasp has a *.claspignore file.*
Redeploying the same version
Create a new version with some description
To list all versions of projects