ASS02: Setting Up Your Apps Script Development Environment
Introduction
The complexities of Apps Script can be daunting for beginners. This tutorial will guide you through the process of setting up your Apps Script environment, providing a clear and concise foundation for your future coding endeavors.
YouTube
Presentation
Online Environment
If you are new to coding, the Apps Script online editor is a great place to start. It is a lightweight and convenient option for small projects that allows you to access your code from anywhere with an internet connection.
Script projects are either standalone or container-bound. Unlike standalone projects, container-bound projects can be connected to Google Sheets, Docs, Slides, and Forms. Standalone script projects are necessary in certain situations, such as when building an add-on to publish on Google Workspace Marketplace.
You have 3 options to create a new Apps Script project:
- Create a standalone project by visiting https://script.google.com/home.
- Create a standalone project by using Google Apps Script app in Google Drive.
- Access the Script Editor through Google Sheets, Docs, Slides, or Forms to start a container-bound project.
* If you don’t have this option on your Google Drive, try to install it via “connect more apps”.
Local Environment
A local development environment is better suited for managing numerous files and constructing a large project.
- The first step is to ensure that nodejs and npm are installed on your local machine. If you haven't done this yet, please visit the provided link to complete the installation.
- Ensure the success of the installation by running these commands in your terminal after installing.
node –version # verify the installation of node
npm –version # verify the installation of npm
- We’ll need to install @google/clasp to develop our projects locally, CLASP stands for Command Line Apps Script Project. Here is the list of commands of CLASP, you can keep it as a reference since not all of them are used in this tutorial.
npm install -g @google/clasp
- To enable the CLASP command to function, adjust your settings to activate the Google Apps Script API.
https://script.google.com/home/usersettings
- Login with CLASP by running the command below.
clasp login
clasp logout
- Create a new project with CLASP, or clone an online project to local.
clasp create –title “ASS02” –type sheets # create a new container-bound project with title ASS02 for a Google Sheets
clasp create –title “ASS02” –type standalone # create a standalone project (type is optional)
clasp clone “script id of the project to be cloned” # clone an online project
And a hidden file .clasp.json will be created by CLASP once the new project is created or cloned. There is no parentId when the project is standalone.
{
"scriptId": "xxx",
"rootDir": "./",
"parentId": ["xxx"]
}
- Push local code to online projects once we have the .clasp.json file in the project.
clasp push
- Pull online projects to local once we have the .clasp.json file in the project.
clasp pull
- Open the project.
clasp open
- We may need to install the type @types/google-apps-script package for autocompletion.
npm init -y # initialize the project
npm install --save @types/google-apps-script # install the types for google apps script
Apps Script Simplified
Links
Join Memberships Make a copy Github Hire Me Buy Me a Coffee
Previous Read
ASS01: Overview of Google Apps Script
Next Read
Comments
Post a Comment