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

google-calendar-logger

v0.2.4

Published

Provides ways to log time to your Google Calendar

Downloads

2

Readme

Google Calendar Logger

Work in progress, package might not work properly at this time. Known problems: can't create token.

Installation

  • pnpm i google-calendar-logger -D
  • or npm i google-calendar-logger -D
  • or yarn add google-calendar-logger -D

Usage

To start using the logger, you'll need to:

  1. generate a credentials.json at https://developers.google.com/calendar/quickstart/nodejs
  2. create an instance of the logger
  3. then, the first time, you'll be asked to visit a URL to generate a token.json

Creating an instance of the logger

For each calendar you want to log to, you'll need to create a new instance of Google Calendar Logger:

const GoogleCalendarLogger = require('./google-calendar-logger'),
      path = require('path');

const logger = new GoogleCalendarLogger({
  credentialsPath: path.resolve(process.cwd(), './gcl/credentials.json'),
  tokenPath: path.resolve(process.cwd(), './gcl/token.json'),
  calendar: 'Some calendar name',
});

How to actually log time?

Depending on the project, you'll need a way to tell the logger to start logging time and end logging time. You can do this by using the logger.logStart() and logger.logEnd() methods. To let the logger know that you're still working, use the logger.logActivity() method.

Example: logging time with Browsersync

const bs = require('browser-sync').create();

// Create GCL instance, like in the example above

// Logging start
bs.init({
  server: 'src',
  open: false,
}, () => { logger.logStart(); });

// Logging activity
bs.watch('src/index.html').on('change', handleChange);
bs.watch('src/**/*.js').on('change', handleChange);

function handleChange (...args) {
  bs.reload(...args);

  const fileNames = args.map(file => path.posix.basename(file));
  logger.logActivity('Changes in ' + fileNames.join(', '));
}

Then, use something like node-cleanup to call logger.logEnd() when you're ending the Browsersync process. Disclaimer: I'm not entirely sure this is the correct way of using node-cleanup. I'm open to suggestions!

const nodeCleanup = require('node-cleanup');

// Logging end
nodeCleanup((exitCode, signal) => {
  if (signal) {
    // Stop Browsersync
    bs.exit();

    logger.logEnd().then(() => {
      // calling process.exit() won't inform parent process of signal
      process.kill(process.pid, signal);
    });

    // don't call cleanup handler again
    nodeCleanup.uninstall();

    // tell node-cleanup not to exit yet
    return false;
  }
}, {
  ctrl_C: '\n^C\n',
});

Optional

Set minutesUntilInactivity to change how soon a log will be interrupted because of inactivity. By default, a log will be split on the next logActivity() or trimmed when calling logEnd() if there hasn't been any activity for 10 minutes or longer.

Set showLinks to true to print URLs to the created/updated events in the CLI.

You can also override strings in the strings object to customize how events are called in your calendar. You can either enter a string or a function, where the only parameter is a string equal to the calendar name (this may change later on, because it's kind of pointless). Strings you can override are:

{
  activityStarted:              projectName => `Started working on ${projectName}`,
  activityInProgress:           projectName => `Working on ${projectName}`,
  activityConcluded:            projectName => `Worked on ${projectName}`,
  activityLogged:               projectName => `Activity in ${projectName}`,
  closedDueToInactivity:        projectName => `(closed due to inactivity)`,
}