Giter VIP home page Giter VIP logo

github-gas-sample's Introduction

Google Apps Script Template powered by esbuild

Starter template for Google App Script development in local.

image

How to use

GitHub Template Create a repo from this template on GitHub

  1. Fix the project_id in .clasp.json to your GAS project.
{
  "scriptId": "<YOUR_SCRIPT_ID>",
  "rootDir": "./dist"
}
  1. Write your code with TypeScript and any npm libraries with ESM styles.
  • Google Apps Script requires executable function to be registered globally.
  • In this template, the main function of index.ts is registered globally, so if you need a single function, you can write the process you want to execute from GAS here(Functions, not registered globally, are treated as private).
  • If you want to register multiple executable functions, do not forget to register them in global!
import { sum } from "./utils"

const main = (): void => {
  Logger.log(sum(12, 20))
}

const sub = (): void => {
  Logger.log(sum(32, 28))
}

declare let global: any;
global.main = main;
global.sub = sub;  // Can be called directly from Google Apps Script as `sub`
  1. Compile & transpile your scripts with esbuild.
# `bundle.js` are output to the `dist` directory
npm run build
  1. (First time only) Copy src/appsscript.json to the dist directory. See the Known Issues

  2. Push your scripts to Google Apps Script with clasp.

# Upload and open your scripts.
npm run deploy

Known Issues (PR Welcome)

  • The clasp requires appsscript.json(manifest of Google Apps Script) to be included in the dist, but it is not automated (I haven't figured out how to do it automatically with esbuild).

github-gas-sample's People

Contributors

ikumatadokoro avatar

Stargazers

 avatar

Watchers

 avatar

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.