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

gsheet-to-calendar

v0.0.6

Published

CLI app and package that uses google spreadsheet api to export calendar data directly into google agenda or other supported methods :)

Downloads

1

Readme

CLI app and package that uses google spreadsheet api to export calendar data directly into google agenda or other supported methods :)

Planned releases

  • Web application (Working on)
  • Publish to homebrew

Supported exports

| Method | Status | | | -------- | -------------------------------------------------------------------------------- | --- | | Google | Only with access_token or by integrating with valid google oauth api credentials | ⚠️ | | ICS | Fully supported | ✅ | | JSON | Fully supported | ✅ | | Terminal | Fully supported | ✅ |

CLI usage

# Run
$ gsToCalendar

| Props | Description | Required | Default | | ------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- | ------------- | | sheetId | Google sheet id from current document | false | null | | options | Options object | false | null | | options.debug | Enable error logging | false | false | | options.docId | Defines the google document id | false | null | | options.sheetId | Defines the google sheet id | false | null | | options.dateFormat | Defines the date string format.Follow date-fns parse documentation | false | "d 'de' MMMM" | | options.dateStringColumn | Defines wich column contains the date string | false | null | | options.titleStringColumn | Defines wich column contains the event title string | false | null | | options.locale | Defines the locale for the date-fns. (ISO 639-1) | false | ptBR | | options.startColumn | Define the initial column | false | A |

Usage as a package

Install the package using your favorite package manager.

$ npm i gsheet-to-calendar

Add the following enviroment variable:

// .env
// https://developers.google.com/sheets

DOC_API_KEY= Your google spreadsheet api key

Example snippet

Here's a basic usage of the package.

// yourApiRoute.ts

import { loadSheetDocument } from 'gsheet-to-calendar';

export const handle = async (documentUrl: string) => {
  const data = await loadSheetDocument({
    url: documentUrl
  });

  if (!document) return;

  const events = await data.fetchEvents();

  if (!events) return;

  return events.saveToGoogle(body.token as string);
};

loadSheetDocument()

| Props | Description | Required | | ----- | ------------------------------- | -------- | | url | Google spreadsheet document url | true |

// Return of loadSheetDocument()

document: GoogleSpreadsheet; // Read more at https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#spreadsheetproperties
sheetList: [{
  value: string;
  name: string;
}, ...]
fetchEvents: () => Promise<{...}>;

fetchEvents()

Fetch events from the spreadsheet and return.

| Props | Description | Required | Default | | ------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- | ------------- | | sheetId | Google sheet id from current document | false | null | | options | Options object | false | null | | options.debug | Enable error logging | false | false | | options.docId | Defines the google document id | false | null | | options.sheetId | Defines the google sheet id | false | null | | options.dateFormat | Defines the date string format.Follow date-fns parse documentation | false | "d 'de' MMMM" | | options.dateStringColumn | Defines wich column contains the date string | false | null | | options.titleStringColumn | Defines wich column contains the event title string | false | null | | options.locale | Defines the locale for the date-fns. (ISO 639-1) | false | ptBR | | options.startColumn | Define the initial column | false | A |

// Return of fetch events()

events: EventTypes[];
saveToGoogle: (accessToken: string) => Promise<void>;
calendarTitle: string;

EventTypes

interface EventTypes {
  date: Date;
  title: string;
}

saveToGoogle()

Save events to google calendar.

| Props | Description | Required | | ----------- | ------------------------- | -------- | | accessToken | Google OAuth access_token | true |

Standalone functions

You can also import each function and execute it directly anytime.

import { fetchEvents, googleSheet, saveToGoogle } from 'gsheet-to-calendar';

fetchEvents(document, {
  sheetId,
  options: {
    dateFormat,
    locale,
    startColumn,
    dateStringColumn,
    debug,
    titleStringColumn
  }
});

googleSheet.loadDocument(url, (error) => console.log(error));
googleSheet.getSheets(document);

saveToGoogle(calendarTitle, events, accessToken);