Giter Site home page Giter Site logo

nathgilson / google-workspace-addon-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 6.0 116 KB

A boilerplate for Google Workspace add-ons using nodejs, ES6, Typescript and Firebase for the backend.

JavaScript 23.34% TypeScript 72.30% Shell 4.36%
typescript google-apps-script google-workspace google-add-on

google-workspace-addon-boilerplate's Introduction

Your boilerplate project for
developing Google Workspace add-ons

***

Google Workspace add-ons are the extensions that can be found in the side panel of most Google apps (Gmail, Google Drive, Sheets, Docs, Slides, etc), unlike the more complexe Editor add-ons that can be found in the "Add-ons" tab of Google Sheets, Docs and Slides.


๐Ÿ“ Table of Contents


๐Ÿ”Ž About

Google Apps Script is Google's Javascript-based development platform for building applications and add-ons for Google Sheets, Docs, Forms and other Google Apps.

This repo is a boilerplate project that uses the same development tools that you use for building traditional web apps (ES6, TypeScript, Node, Firebase, etc), all inside Google Apps Script projects.

See below how to get started!


๐Ÿšœ Install

These instructions will get you set up with a copy of the project code on your local machine. It will also get you logged in to clasp so you can manage script projects from the command line.

See deploy for notes on how to deploy the project and see it live in Gmail, Calendar, and Drive.

Prerequisites

๐Ÿ Getting started

1. First, let's clone the repo and install the dependencies.

git clone https://github.com/nathgilson/Google-Workspace-Addon-Boilerplate
cd Google-Workspace-Addon-Boilerplate
cd addOn
npm install

2. Next, we'll need to log in to clasp, which lets us manage our Google Apps Script projects locally.

npm run login

3. Now let's run the setup script to create a New spreadsheet and script project from the command line.

npm run setup

Alternatively, you can use an existing Google Spreadsheet and Script file instead of creating a new one.

See instructions here for using an existing project.

You will need to update the .clasp.json file in the root of this project with the following three key/value pairs:

{
  "scriptId": "1PY037hPcy................................................",
  "parentId": ["1Df30......................................."],
  "rootDir": "./dist"
}
  • scriptId: Your existing script project's scriptId. You can find it by opening your spreadsheet, selecting Tools > Script Editor from the menubar, then File > Project properties, and it will be listed as "Script ID".

  • parentId (optional): An array with a single string, the ID of the parent file (spreadsheet, doc, etc.) that the script project is bound to. You can get this ID from the url, where the format is usually https://docs.google.com/spreadsheets/d/{id}/edit. This allows you to run npm run open and open your file directly from the command line.

  • rootDir: This should always be "./dist", i.e. the local build folder that is used to store project files.

Next, let's deploy the app so we can see it live in Google Workspace.


๐Ÿš€ Deploy

Run the deploy command. You may be prompted to update your manifest file. Type 'yes'.

npm run deploy

The deploy command will build all necessary files using production settings, including all server code (Google Apps Script code) and config files. All bundled files will be outputted to the dist/ folder, then pushed to the Google Apps Script project.

Now open Google Sheets and navigate to your new spreadsheet (e.g. the file "My Project"). You can also run npm run open. Make sure to refresh the page if you already had it open. You will now see a new menu item appear containing your app!


โ›๏ธ Usage

The included sample app

The sample app is inspired from Google's quickstart: Cats Google Workspace Add-on

Typescript

This project supports typescript.

To use, simply use a typescript extension in the code (.ts), and your typescript file will compile to the proper format.

To use typescript in server code, just change the file extension to .ts. The server-side code already utilizes type definitions for Google Apps Script APIs.

A basic typescript configuration is used here, because after code is transpiled from typescript to javascript it is once again transpiled to code that is compatible with Google Apps Script. However, if you want more control over your setup you can modify the included tsconfig.json file.

Adding packages

For instance, install axios from npm:

npm install axios

Important: Since Google Apps Scripts projects don't let you easily reference external files, this project will bundle an entire app into one .gs file. This can result in large files if you are importing large packages. To help split up the files, you can grab a CDN url for your package and declare it in the webpack file, here. If set up properly, this will add a script tag that will load packages from a CDN, reducing your bundle size.

Modifying scopes

If you modify this project to work with Google Forms or Calendar, make sure to edit the oauthScopes in the appscript.json file.

See https://developers.google.com/apps-script/manifest for information on the appsscript.json structure.

Autocomplete

This project includes support for autocompletion and complete type definitions for Google Apps Script methods.

All available methods from the Google Apps Script API are shown with full definitions and links to the official documentation, plus information on argument, return type and sample code.

Card builder

The online Card builder can help you prototype your app's interface.


google-workspace-addon-boilerplate's People

Contributors

nathgilson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

google-workspace-addon-boilerplate's Issues

Add license?

Thanks for the awesome boilerplate.
It would be great to have a software license on this. Is it open source or proprietary?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.