Boilerplate template for developing a Google Apps Script project that supports TypeScript.
This README is written for *NIX-like environments; however, it is likely applicable to other platforms.
Install Node.js for your environment.
npm
is distributed with Node.js. For further readings, see this npm
page.
Install clasp
by running:
npm install --global @google/clasp
Authenticate clasp
with your Google Account by running:
clasp login
-
Clone this repository
-
Install dependencies
npm install
-
Create a new Apps Script project
clasp create --type standalone --title google-apps-script-typescript-boilerplate
-
Compile all source files
All TypeScript and JavaScript in
src/
will bewebpack
ed intodist/
This repository comes with a
helloWorld
function by defaultnpm run build
-
Push to Apps Script
Push all tracked files (see
.claspignore
) to Apps Scriptclasp push
-
Verify the code was pushed in the Apps Script editor
clasp open
-
Run the
helloWorld
function
clasp run [functionName]
allows you to execute Apps Script functions remotely.
clasp run
is initially rather troublesome to set up.
The Apps Script project must use a standard Google Cloud Platform Project. For more information, see the documentation on GCP Projects and Apps Script.
The standard GCP Project must also have an OAuth 2.0 client ID. For more information, see the GCP help article on Setting up OAuth 2.0.
Assuming both a standard GCP project and OAuth 2.0 client ID has been configured, this document can be followed to configure clasp run
.