2.1.0 • Published 4 years ago

google-calendar-generator v2.1.0

Weekly downloads
3
License
ISC
Repository
-
Last release
4 years ago

google-calendar-helper

This is just a side project I did for adding events to my personal Google Calendar using the Google API. I was tired of adding multiple events all with the same configuration and having to go back and update all of them when manually I wanted to make changes.

Disclaimer: The library isn't necessarily comprehensive in covering all of Google Calendar's available APIs, does not have test cases, and may not be generic in all scenarios; this was primarily made for my own use cases.

Usage

  1. Follow only Step 1 of Google's Node.js Quickstart. This will result in a credentials.json file.
  2. Run the following command anywhere in your terminal
npx google-calendar-generator --credentials ./PATH/TO/credentials.json --token ./PATH/TO/token.json --config ./PATH/TO/config.js

NOTE: The first time you run the program, you will not have a token.json. For the --token, just specify where you would like the token.json to be auto-generated.

  1. Check out your new calendar at https://calendar.google.com/

See ex-calendar-config.js for an example calendar configuration

Calendar Configuration Documentation

module.exports = [
  {
    name: "Example Calendar #1",
    /**
     * Int from 1 - 11
     * https://developers.google.com/calendar/v3/reference/colors/get?apix=true#try-it
     */
    colorId: 1,
    /**
     * If true, deletes any existing calendars with the same name
     * and recreates it. If false, adds events to any existing
     * calendar with the same name
     */
    recreateCalendar: false,
    /**
     * If true, deletes any existing events with the same name
     * and recreates it. If false, skips adding the event to
     * prevent creating duplicate events.
     */
    recreateEvents: false,
    events: [
      {
        summary: "Event #1",
        /**
         * Date formatted YEAR-MONTH-DAY
         */
        date: "2000-01-31",
        /**
         * String value. How often the event occurs
         * - DAILY
         * - WEEKLY
         * - BiWEEKLY
         * - MONTHLY
         * - QUARTERLY
         * - YEARLY
         * If none of the above are provided, you can supply your own. For example:
         *    recurrence: { rule: ["RRULE:FREQ=DAILY"] }
         * See "recurrence"
         * https://developers.google.com/calendar/v3/reference/events/insert#request-body
         */
        recurrence: "YEARLY",
        /**
         * Array of reminders
         * Each reminder is an object containing:
         * - method: email | popup
         * - weeksBefore or minutesBefore: int
         */
        reminders: [
          { method: "email", weeksBefore: 4 },
          { method: "email", weeksBefore: 3 },
          { method: "popup", weeksBefore: 2 },
          { method: "popup", weeksBefore: 1 }
        ]
      }
    ]
  },
  {
    name: "Example Calendar #2",
    colorId: 10,
    recreateCalendar: true,
    events: [
      {
        summary: "Event #1",
        date: "2000-12-25",
        recurrence: "YEARLY",
        reminders: [
          { method: "email", minutesBefore: 4 },
          { method: "email", minutesBefore: 3 },
          { method: "popup", minutesBefore: 2 },
          { method: "popup", minutesBefore: 1 }
        ]
      }
    ]
  }
];

References

2.1.0

4 years ago

2.0.0

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago