npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gcal

v1.0.3

Published

Google Calendar command line tool for Node.js

Downloads

16

Readme

gcal

Google Calendar command line tool for Node.js

Programmatic event listing, insert or bulk insert made easy:

Installation

Install it as a global module:

npm install -g gcal

Authentication

Authorization and authentication is done with OAuth 2.0.

Ok, this will take only 2 minutes:

1) Get your project credentials

You will need a file with your credentials: client ID, client secret and redirect URI. This can be obtained in the Developer Console:

  • Go to your project
  • Click in Credentials
  • Click Create credentialsOAuth client ID ( Application type must be Other )
  • Download the JSON file

2) Generate consent page URL

Once we got the credentials we must generate a consent page URL.

$ gcal generateUrl

(By default the credentials will be searched in your home directory under the name client_secret.json).

The page will prompt you to authorize access, follow the instructions.

3) Get the token!

With the code we got through the authorization page, we can obtain a token and store it in our machine.

$ gcal storeToken <code>

(By default the token is stored in your home folder under the name calendar_api_token.json).

NOTE: The token will expiry after one hour, but a refresh_token is included as well, allowing the app to refresh automatically the token each time it's used.

With this we are good to go. The stored token and credentials files will be required from now on to use this tool.

Usage

List

List today events:

$ gcal list

List events using natural language (powered by Sherlock):

$ gcal list tomorrow
$ gcal list 'from 03/23/2017 to 03/27/2017'
$ gcal list 'from March 23th to 27th'

Or with specific ISO dates:

$ gcal list -f 2017-03-23 -t 2017-03-27

Insert

Insert events using natural language:

$ gcal insert 'Party tomorrow from 3pm to 5pm'

Insert events specifying the parameters:

$ gcal insert -s 'Party' -d 2017-03-23 -t 15:00 -D 2h

Bulk Insert

Bulk insert passing a .js or .json file:

events.json

[{
  "calendarId": "primary",
  "resource": {
    "summary": "Having coffee with Okuyasu",
    "location": "Morio City",
    "description": "I'm not very imaginative now so some description goes here",
    "start": {
      "dateTime": "2017-09-08T09:00:00"
    },
    "end": {
      "dateTime": "2017-09-08T10:00:00"
    }
  }
}, {
  "calendarId": "primary",
  "resource": {
    "summary": "Defeat Dio",
    "location": "179 Orouba St, Cairo",
    "description": "Dio is a bad boy so I need to kick his ass asap",
    "start": {
      "date": "1987-06-01"
    },
    "end": {
      "date": "1987-06-12"
    }
  }
}]
$ gcal bulk -e ./events.json

Using a .js file can be useful for relative dates and more:

events.js

const today = new Date();
today.setHours('17', '00', '00');
const tomorrow = new Date(today.getTime()+1000*60*60*24);
module.exports = [{
  "calendarId": "primary",
  "resource": {
    "summary": `Release`,
    "start": {
      "dateTime": today.toISOString()
    },
    "end": {
      "dateTime": today.toISOString()
    }
  }
}, {
  "calendarId": "primary",
  "resource": {
    "summary": "Release",
    "start": {
      "dateTime": tomorrow.toISOString()
    },
    "end": {
      "dateTime": tomorrow.toISOString()
    }
  }
}];
$ gcal bulk -e ./events.js

The available properties are listed here.

Overwriting default config

Using the option -C <file> the default config can be overwritten. This file must be .js or .json. Configurable options are located in ./conf.js.

Example:

/somepath/config.json

{
  "CRED_PATH": "/my/secret/path/credentials.json",
  "TOKEN_PATH": "/my/secret/path/token.json"
}
$ gcal -C /somepath/config.json generateUrl

Doing this you can store your credential files wherever you want.

API

Use the help command. More details will be added soon.

$ gcal help

Usage:
  gcal [-C <file>] [cmd] [--debug]

      OPTIONS
          -C, --config <file>
          --debug

Commands:

  list [<term> | [-f <date | datetime>] [-t <date | datetime>]] [-i]
      List events. By default it shows today events (executed without arguments).

      OPTIONS
          -f, --from <date | datetime>

          -t, --to <date | datetime>

          -i, --show-id


  insert <term> | -s <summary> -d <date> [-t <time>] [-D <duration>]
      Insert events. <term> is specified in natural language, in case it's not specified,
      -s and -d are mandatory.

      OPTIONS
          -s, --summary <summary>

          -d, --date <date>

          -t, --time <time>

          -D, --duration <duration>


  bulk -e <file>
      Bulk insert of events. File can be .json or .js.

      OPTIONS
          -e, --events <file>


  generateUrl
      Generate consent page URL. In order to work client_secret.js must be in your
      home folder.


  storeToken <code>
      Store Token in your home folder.


  help
      Show this help page.

About version 0.3.0

Version 0.3.0 used an immersive-cli instead of shell commands. If you want to use it, go to the branch 0.3.0.

License

MIT © Antonio V