CLASP
Chester Wyke April 17, 2023 Updated: May 11, 2026 #MiscSetup
If this is your first time using clasp or first time on a new computer the best instructions to get started can be found in the Readme of the project it self at https://github.com/google/clasp
In particular you will need:
- To install Node.js
- To install clasp
npm install -g @google/clasp - And the enable the to use the Google Apps Script API: https://script.google.com/home/usersettings
How to use
- Once everything has been setup (ie. both Setup and New project setup are completed)
- Edit your code inside of the
srcfolder then usenpm run deployto upload to the cloud - See other commands in
package.json - You can use clasp normally as the
rootDiris set but you need to bundle the typescript first so you would need to usenpm run build.
New project setup
- Create new git repo from the template repo (big green button on top right)
- Create Google Apps Script project (On Standalone, Sheets, etc.)
-
Clone Scripts Project into an EMPTY FOLDER using clasp (We won’t be keeping this folder we just need two files from the clone)
clasp clone <scriptID> -
Copy/Move
.clasp.jsonandappsscript.jsoninto the root of the repo created from the template. - You may delete the temporary folder at this point
-
Edit
.clasp.jsonto set therootDirtodist"rootDir": "dist", -
Install npm dependencies
npm install
Additional Steps for Wykies Library
-
Add ts_lib
- Part of wykies
git submodule add ../ts_lib.git src/ts_lib- Outside of wykies
git submodule add git@github.com:wykies/ts_lib.git src/ts_lib
Converting an existing Javascript (JS) project to TypeScript (TS)
-
Move files into a directory called
src -
Remove
js_libif in use see removal instructions for submodule -
Change all
.jsfiles to.tsfiles - Download
- Follow normal instructions from New TS project
Ignore files
File location
Source: https://github.com/google/clasp#ignore-file-claspignore
Put a .claspignore in the root of the project’s directory.
All paths are relative to root.
Format
Uses multimatch
*matches any number of characters, but not /?matches a single character, but not /**matches any number of characters, including /, as long as it’s the only thing in a path part{}allows for a comma-separated list of “or” expressions!at the beginning of a pattern will negate the match
Example
js_lib/**