Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dstcruz/purescript-gas-template
A template to get started using Purescript with Google Apps Script
https://github.com/dstcruz/purescript-gas-template
google-apps-script purescript
Last synced: 25 days ago
JSON representation
A template to get started using Purescript with Google Apps Script
- Host: GitHub
- URL: https://github.com/dstcruz/purescript-gas-template
- Owner: dstcruz
- Created: 2019-10-03T17:58:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T21:15:04.000Z (over 1 year ago)
- Last Synced: 2024-07-30T18:51:48.267Z (3 months ago)
- Topics: google-apps-script, purescript
- Language: Dhall
- Size: 839 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: Readme.org
Awesome Lists containing this project
README
* Purescript-GAS-Template
A minimal template to get you jump-started using [[https://developers.google.com/apps-script][Google Apps Script]] with [[https://www.purescript.org][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.
** InitTo init, follow standand npm/yarn procedure:
#+BEGIN_SRC shell
yarn install
#+END_SRC** Build
See ~package.json~ for build, clean, publish scripts.
** Publish
This package uses [[https://developers.google.com/apps-script/guides/clasp][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#+BEGIN_SRC shell
npx clasp login
#+END_SRCYou 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 [[https://github.com/fossamagna/gas-webpack-plugin][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.