Skip to content

A template to get started using Purescript with Google Apps Script

Notifications You must be signed in to change notification settings

dstcruz/purescript-gas-template

Repository files navigation

Purescript-GAS-Template

A minimal template to get you jump-started using Google Apps Script with Purescript.

See src/App/Sample.purs for the simplest of interactions. Once you build and publish this code to your spreadsheet (see Publish below), you will be able to:

  • In a cell, put the formula =HELLO("world") to see “Hello wold” returned by your purescript code.
  • See a new menu called “FromPurescript”, with 2 entries which make a toast appear with a message.

Environment

If you have Nix, you can run the nix-shell with the dependencies already in place.

Init

To init, follow standand npm/yarn procedure:

yarn install

Build

See package.json for build, clean, publish scripts.

Publish

This package uses google’s clasp to upload the script to google servers. You will need to first login in order to be able to execute the clasp push command run by the publish script. Login in is as simple as

npx clasp login

You will also need to create a Spreadsheet, open “Tools > Script Editor”, name the script, and capture the scriptId from the Script Editor’s “View > Project properties” menu. Insert that value into .clasp.json.

Building notes

As a first step, we build the purescript code with spago. Once that is done, we call webpack to bundle things up with our index.js file as the entry point. Since google doesn’t understand plain, modern, javascript, webpack transpiles (via babel), and then uses the gas-webpack-plugin to massage the javascript into code that google’s app engine likes. GAS expects that all declarations be top-level, so this plugin detects expressions assigned to global and generates a top-level declaration for it.

About

A template to get started using Purescript with Google Apps Script

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published