Skip to content

Commit

Permalink
Support installing as an executable via npm.
Browse files Browse the repository at this point in the history
  • Loading branch information
rimesc committed Apr 12, 2019
1 parent 4838cd3 commit 524e19e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A simple Node.JS application that uses REST APIs to update a Google calendar bas

It was written for a very specific use case (that of a spreadsheet used to track availability of volunteers for a code club) so it's unlikely to be generally useful, but it can hopefully serve as a reference or starting-point for anyone looking to do something similar.

## Developing ##

### Setup ###

Run `npm install` to install dependencies.
Expand All @@ -13,41 +15,47 @@ Follow the linked instructions to enable both the [Google Calendar](https://deve
Edit [environment.ts](src/environment/environment.ts) to configure the locations of your Google calendar and spreadsheet
and other aspects of the application.

Tested on node 10.3.0.
Tested on node 10.15.3.

### Run once ###
### Running ###

* `npm run start` - update the calendar with data from the spreadsheet
* `npm run dry-run` - log the updates that would have been made, without actually making them

The first time you run the application it will prompt you to visit a web site to authenticate - simply follow the instructions
in the console. The credentials are save to disk and re-used for future runs.

### Run on a schedule ###
## Installation ##

Run `npm install -g` to install the application globally. This will add a `google-sheets-calendar-connector` executable to the path.

You can use the `TOKEN_DIR` environment variable to control where the API token is stored.

### Running on a schedule ###

The application does not provide support for scheduling - use an OS provided system such as `cron` (linux) or `launchd` (MacOS).

### Docker ###
## Docker ##

##### Build #####
#### Build ####

docker build -t google-sheets-calendar-connector .
docker volume create google-api-token
docker create -i -v google-api-token:/var/token --name google-sheets-calendar-connector google-sheets-calendar-connector

##### First run #####
#### First run ####

docker start -i google-sheets-calendar-connector

Follow the instructions to authenticate and then press `Ctrl+D` to stop the container.

##### Subsequent runs #####
#### Subsequent runs ####

docker start google-sheets-calendar-connector

The application will run once and the container will stop on completion.

### Licensing
## Licensing

Portions of this code were taken from https://developers.google.com/google-apps/calendar/quickstart/nodejs,
licensed under the Apache 2.0 License (http://www.apache.org/licenses/LICENSE-2.0).
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./dist/app/cli.js')
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "google-sheets-calendar-connector",
"version": "1.0.2",
"description": "Updates a Google calendar with events from a Google sheet.",
"main": "calendar.js",
"main": "cli.js",
"bin": {
"google-sheets-calendar-connector": "./index.js"
},
"dependencies": {
"@types/backoff": "^2.5.0",
"@types/moment": "^2.13.0",
Expand Down

0 comments on commit 524e19e

Please sign in to comment.