Appscirpt allows you to interact & integrate with all these Google products.

Appscript is this small scripting language that allows you to develop apps/integrations/addons/extensions for Google suite. Common applications could be storing a form data into Google sheets directly, automating emails etc all this is done purely using Javascript.

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

npm i @google/clasp -g

Before you start using Clasp you will have to login, as you would while using firebase cli

clasp login

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

clasp create SCRIPT_NAME_HERE

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

clasp clone SCRIPT_ID_HERE

To find your script id GOTO the script editor > File > Project preferences > Info >> Look of script Id here.

Project structure on script.google.com:

project_folder/slides.gs

local cloned project structure:

project_folder/slides.js

after create or clone a local configuration file .clasp.json is created.

this can be customised

{

scriptId : "" # required,

rootDir : "" # default current directory

}

Now lets walkthrough the basic cli commands in clasp.

clasp login --no-localhost

# --no-localhost this will instead allow you to enter # code instead of running local server anything is ok.

To logout

clasp logout

To pull a project

clasp pull

To push files to project

clasp push

To open the current project in script.google.com

clasp open # in the project directory

Listing all deployment ids

clasp deployments

Deploy current project

clasp deploy [version] [description]

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

clasp redeploy <previousDeploymentId> <version> <description>

Create a new version with some description

clasp version [description]

To list all versions of projects

clasp versions

Appscript Github repo : https://github.com/google/clasp

Appscript api : https://developers.google.com/apps-script/api/

—

In the next part , we shall build a sheets to slides script that converts sheets rows into Google slide’s slide using clasp.