• Stars
    star
    1,090
  • Rank 42,497 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Setup a local development environment inside Visual Studio Code and build Google Workspace add-ons with Google Apps Script

Google Apps Script Development ๐Ÿ’ฏ

The Google Apps Script Starter kit supports the new V8 JavaScript runtime that powers Chrome and Node.js. You can write code using modern ECMAScript syntax like Arrow functions, Classes, Template Literals, Destructuring and more.

Google Apps Script Development with ES6

Please follow the ๐Ÿ‘‰ step-by-step video tutorial ๐Ÿ‘ˆ for quickly getting started with Apps Script development inside Visual Studio Code. It is recommended that you install the Extension Pack for working with Apps Script files in VS Code.

You can build Google Workspace add-ons (for Google Docs, Slides, Gmail and Google Sheets), web applications and workflow automation routines with next-generation JavaScript.

The starter kit is used by Digital Inspiration for building popular Google add-ons including Gmail Mail Merge, Google Forms Notifications and Document Studio.

Build with Google Apps Script ๐Ÿš€

Setting up a modern development environment for building Google Apps Script projects is easy and quick (video tutorial).

You also need to install Node.js which includes the npm package manager.

๐Ÿ“ฆ Getting Started

1. Clone the repository and install npm dependencies and utilities.

git clone https://github.com/labnol/apps-script-starter my-project
cd my-project
npm install

Update: The git clone command adds a .git folder to your folder that pertains to the Apps Script Starter project and not your local project. You should either re-init the repository or use degit to clone the repository.

npx degit labnol/apps-script-starter my-project

2. Log in to Google clasp and authorize using your Google account.

npx clasp login

3. Create a new Google Script bound to a Google Sheet (or set the type as standalone to create a standalone script in your Google Drive)

npx clasp create --type sheets --title "My Apps Script Project" --rootDir ./dist

4. Include the necessary OAuth Scopes in the appsscript.json file

5. Deploy the project

npm run deploy

The dist directory contains the bundled code that is pushed to Google Apps Script.

Google Apps Script - Setup Development Environment

Enable JavaScript v8 Runtime

Inside the Google Apps Script editor, select View > Show project manifest to open the appsscript.json manifest file in the editor. Add a new runtimeVersion field and set the value to V8. Save your script.

Google Apps Script - v8 Runtime

The .claspignore file

The .claspignore file allows you to specify file and directories that you do not wish to not upload to your Google Apps Script project via clasp push.

The default .claspignore file in the Apps Script Starter kit will push all the JS and HTML inside the rootDir folder and ignore all the other files.

๐Ÿ”ฐ Using Git with Google Apps Script

Google Apps Script - Github

Create a new repository in Github and make a note of the URL of the new repository. Next, open the terminal and run the above commands to push your Apps Script project to Github.

Custom Google Sheet functions

Please read the tutorial on how to write custom functions for Google Sheets using Apps Script.

Testing your Google Apps Script code

You can run tests with jest using

npm run test

This has limitations:

  • You can test code that has no dependencies to Google App Script code, e.g.
const hasCpuTime = () => !(Date.now() - START_TIME > ONE_MINUTE * 4);

  • You can not test code that has dependencies to Google App Script code, e.g.
function notTestable() {
    Logger.log("notTestable"); // <-- Google Apps Script function. Not callable in dev
    SpreadsheetApp.getUi(); // <-- Google Apps Script function. Not callable in dev
    ...
}

Check out jest 'expects' here

๐Ÿ”ฅ Meet the Developer

Amit Agarwal is a web geek, Google Developers Expert (Google Workspace, Google Apps Script), Google Cloud Innovator, and author of labnol.org, a popular tech how-to website.

He frequently uses Google Apps Script to automate workflows and enhance productivity. Reach him on Twitter or email [email protected]

๐ŸŒธ Contribution

Contributions and feature requests are welcome. If you are using the Google Apps Script starter package and fixed a bug for yourself, please consider submitting a PR!

๐Ÿ”’ License

MIT License (c) Amit Agarwal

More Repositories

1

unsubscribe-gmail

Gmail Unsubscriber is a Google Apps Script for unsubscribing from unwanted newsletters and other bulk emails.
JavaScript
1,443
star
2

code

Google Apps Script projects and code snippets written by Amit Agarwal.
JavaScript
127
star
3

covid19-vaccine-tracker

Monitor Covid-19 vaccine availability in India and get email alerts when the vaccine is available near your location.
HTML
121
star
4

website-monitor

Website Uptime Monitor built with Google Apps Script
HTML
109
star
5

email-studio-gmail-addon

Email Studio is a Gmail add-on that includes Mail Merge, Email Scheduler, Forwarder, Auto-Responder and more.
JavaScript
74
star
6

google-forms

Google Forms and Google Apps Script
JavaScript
72
star
7

saregama-carvaan

Saregama Carvaan
JavaScript
48
star
8

react-tailwind

React with Tailwind CSS Starter Kit
JavaScript
39
star
9

files

Host Files on Github
JavaScript
32
star
10

mailman

MailMan - Send Email with Google Sheets and Gmail
JavaScript
29
star
11

vscode-google-apps-script

Recommended extensions and editor settings for working with Google Apps Script in VS Code.
28
star
12

javascript-starter

A starter kit for web development with modern JavaScript ES6 and Parcel
JavaScript
23
star
13

gmail-icons

Gmail Icons
JavaScript
20
star
14

pixel-art

Make pixel paintings with Google Spreadsheets
JavaScript
18
star
15

document-generator

Document generator for Google Apps Script
Gosu
16
star
16

youtubemovies

Links to free movies on YouTube
16
star
17

labnol

9
star
18

eslint-config-labnol

ESLint and Prettier configuration for Digital Inspiration projects
JavaScript
4
star
19

Tweet-Translater

Chrome extension which helps you to view translated tweets by single click on Twitter.
JavaScript
3
star
20

twitter-screenshots

Take lightning-fast screenshots of tweets with a single click.
JavaScript
3
star
21

labnol.astro

Astro
2
star
22

WhatsApp-Assistant

Send WhatsApp Message without saving the phone number
C++
2
star
23

img2css

convert arbitrary images into huge, browser-crashing CSS box-shadow settings
JavaScript
2
star
24

testing

JavaScript
1
star