Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yasmaryhd/61e36f6ef41770cc394c415750b16b55 to your computer and use it in GitHub Desktop.
Save yasmaryhd/61e36f6ef41770cc394c415750b16b55 to your computer and use it in GitHub Desktop.
Getting Started with: Clasp, Apps Script CLI tool

The Apps Script CLI, or clasp, is a tool that lets you to create, edit, and deploy Apps Script projects locally. It allows you to create and publish web apps and add-ons for products like Sheets, Docs, Forms, and Slides from the command line. There are two ways you can develop Apps Script, using script.google.com or locally on your computer. Repo: https://github.com/google/clasp

Prerequisites

  • Node.js >= v6.0.0: install via homebrew or direct download
  • Google Account: will be used to authenticate with clasp. If a GCP project will be used, this account should have access to it.
  • Enable Apps Script API: Log into your Google Account and navigate to https://script.google.com/home/usersettings.
    • Google Apps Script API allows third-party applications you authorize to use the Apps Script API to modify your Apps Script projects and deployments. This includes:
      • Creating new projects with you as the owner
      • Updating or deleting your projects
      • Adding and removing deployments to and from your projects
      • Changing the way your project is deployed by adding or removing entry points or modifying which version of your project is executed
      • Changing which users have access to your projects’ deployments

Getting Started

Codelab Codelab will cover:

  • How to create new Apps Script projects
  • How to clone, pull, and push existing projects
  • How to manage deployments of your scripts

Things to make a note of while you are going through the codelab:

  • Google moved and renamed how users can navigate to the Script Editor.
    • Instead of: Tools -> Script Editor, it is now: Extensions -> Apps Script

Limitations

  • Concurrently editing code locally and on script.google.com will result in loss of changes
    • clasp push replaces code that is on script.google.com and clasp pull replaces all files locally

Command Cheatsheet

  • clasp open: Opens script remotely via script.google.com site
  • clasp pull: Fetch remote script files associated with local clasp directory; Changes need to be saved remotely to pull them in.
  • clasp push: Overwrites remote script files with local changes
  • clasp version: A "snapshot" of a script project. A version can be considered a read-only branch used for deployments.
  • clasp deploy: A published release of a script project (often as an add-on or web app). Requires a version number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment