Code Monkey home page Code Monkey logo

timecard's Introduction

timecard

Keep track of your project development time.

Build Status Coverage Status

timecard print screenshot

Install

$ npm install --global timecard

Usage

To create a new timecard for your project

$ timecard new

To clockin (start working)

$ timecard clockin

To clockout (stop working)

$ timecard clockout

To see a print summary of your time

$ timecard print

Tip: If you prefer the shorthand, all of these commands have flag aliases. Check the help output for details.

Messages

You can add a message to your shifts via the clockin and clockout commands.

To add a message, simply include the -m or --message options with your clockin and clockout commands. Here are some examples:

$ timecard clockin -m "Refactored tests to use AVA"
$ timecard clockout --message "Fixed Issue #23"

The two lines above would result in two messages being added to the shift:

messages screenshot;

If you want to add more messages to your shift, you can edit the .timecard.json file manually. In the future, I would like to make it possible to add/edit messages to a shift via the cli, but for now, you can only add one message on clockin, and one message on clockout for a total of two messages. Pull requests are welcome if anyone would like to help add these features.

.timecard.json

When you run the timecard new command, Timecard creates a hidden file called .timecard.json. This is the file where your project times are recorded.

Some important notes to consider regarding the timecard file:

  1. Version Control: Remember to update your .gitignore file if you don't want the timecard file under version control.

  2. For Node.js developers: If your project contains a package.json file, then Timecard assumes that the directory with the package.json file is the root directory, and places the .timecard.json file in the root. You can run any Timecard command from any of your project's sub-directories.

  3. Non-Node.js Projects: (or if your project DOES NOT contain a package.json file), then you can still use Timecard, you will just need to make sure that you are running the Timecard commands from the same directory each time (preferably in your project root).

  4. Manual timecard edits: Sometimes it will be necessary to update the .timecard.json file manually (if you forgot to clockout, for example), which is fine, just remember that this file must be valid JSON.

Options

$ timecard --help

  Keep track of your project development time

  Get timecard setup with the 'new' command, then use the 'clockin' and 'clockout' commands
  to record your time. When you want to see a summary of your time, use the 'print' command.

  Commands
    timecard new            Setup a blank timecard for your project
    timecard clockin        Set the start time for your shift
    timecard clockout       Set the end time for your shift
    timecard print          Print a summary of your time

  Options
    -h, --help              Show this help message
    -v, --version           Show the current timecard version
    -i, --clockin           Alias for the clockin command
    -o, --clockout          Alias for the clockout command
    -n, --new               Alias for the new command
    -p, --print             Alias for the print command
    --no-prompt             Use with `new` to silence all prompts and overwrite existing timecard
    --message, -m           Include a message summary to your shift (via clockin and clockout)

Tips

  • Export Timecard to Text File: If you want something easier to read than a .json file, you can pipe the output of the print command to a text file from the command line like this:
    $ timecard print > timecard.txt
    

License

MIT @ Michael Wuergler

timecard's People

Contributors

radiovisual avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

timecard's Issues

add in rate calculation

The ability to use the timecard data to calculate the total cost for hourly-based projects would be cool.

valid tests failing on slower CI instances

This valid test:

test('records total seconds', async t => {
    // ...
    await wait(3);
    await timecard.clockout();

    t.is(timecard.totalSeconds, 3);
});

...periodically fails on travis if the process takes too long, and the "waiting" of 3 seconds actually turns into 4 or 5 seconds, so the test needs to be a bit more lenient, like looking for a minimum of 3:

t.true(timecard.totalSeconds >= 3);

timecard print throws an error if executed before clockout

I sometimes need to print my timecard while still clocked in, doing so throws the following error:

Error: Invalid parameters passed to pendel
    at module.exports (/usr/local/lib/node_modules/timecard/node_modules/pendel/index.js:8:15)
    at TimeCard.prettyPrintEntry (/usr/local/lib/node_modules/timecard/dist/messages.js:99:53)
    at /usr/local/lib/node_modules/timecard/dist/index.js:273:27
    at Array.map (native)
    at TimeCard.callee$2$0$ (/usr/local/lib/node_modules/timecard/dist/index.js:272:36)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:334:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:105:21)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at invoke (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:146:20)

Does not span across days; only hours in day

If I start a project at 08:54:42 on Monday, and end at 08:54:43 on Tuesday, I would expect to have logged a total of exactly one day and one second, but in this scenario, timecard would only log it as one second because there is no concept of a DAY in the clockout scheme:

{
      "id": 0,
      "date": "Mon Feb 13 2017",
      "startTime": "08:54:42",
      "endTime": "08:54:43"
    }

Both clockin and clockout should have a datetime associated with it, not just a time.

cleanup error when user tries clocking in/out twice

❯ timecard clockin
Error: 
 TIMECARD ERROR  You must clockout before clocking in. 
Tip: Clock out with the clockout command, or edit the timecard file manually. 

    at TimeCard.callee$2$0$ (/usr/local/lib/node_modules/timecard/dist/index.js:137:17)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:334:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:105:21)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at invoke (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:146:20)
    at /usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:154:13
    at run (/usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/es6.promise.js:104:47)
    at /usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/es6.promise.js:115:28
    at flush (/usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/$.microtask.js:19:5)
Error: 
 TIMECARD ERROR  You must clockout before clocking in. 
Tip: Clock out with the clockout command, or edit the timecard file manually. 

    at TimeCard.callee$2$0$ (/usr/local/lib/node_modules/timecard/dist/index.js:137:17)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:334:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:105:21)
    at tryCatch (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at invoke (/usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:146:20)
    at /usr/local/lib/node_modules/timecard/node_modules/babel-runtime/regenerator/runtime.js:154:13
    at run (/usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/es6.promise.js:104:47)
    at /usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/es6.promise.js:115:28
    at flush (/usr/local/lib/node_modules/timecard/node_modules/core-js/library/modules/$.microtask.js:19:5)

YUCK!

factor current time into `timecard print`

If someone uses the command timecard print, that printout should include the current time factored into the overall time duration.

For example, if you create a new timecard and then clockin at 12:00, and then at 13:00 you run the command timecard print, the timecard shows that you have worked for 0 Hours 0 Minutes 0 Seconds when you have actually been working for 1 hour.

project name should follow the timecard

The project name should be embedded into the timecard file, making the timecard files portable. When a user creates a new timecard it should ask you for the project name, defaulting to the name found in the package.json file

update dependencies

❯ npm outdated
Package               Current  Wanted  Latest  Location
ava                    0.12.0  0.12.0  0.15.2  ava
babel                  5.8.38  5.8.38   6.5.2  babel
babel-runtime          5.8.38  5.8.38   6.9.2  babel-runtime
inquirer                0.9.0   0.9.0   1.1.2  inquirer
nyc                     5.6.0   5.6.0   6.6.1  nyc
pendel                  1.0.1   1.0.1   2.0.2  pendel
twelve-to-twentyfour    0.1.4   0.1.4   1.0.1  twelve-to-twentyfour
update-notifier         0.6.3   0.6.3   1.0.2  update-notifier
valid-file              0.0.1   0.0.1   0.0.2  valid-file
wait-p                  0.0.1   0.0.1   1.0.0  wait-p
xo                     0.12.1  0.12.1  0.16.0  xo

project directory not printing correctly

In the print output:

This: Project: /Users/michael/gitprojects/timecard/.timecard.json

Should be: Project: /Users/michael/gitprojects/<Your Project DIR>/.timecard.json

review use of process.cwd()

If timecard is ever imported as a development dependency via npm, then the use of process.cwd() could prove problematic?

Consider this code snippet from Keystone.js:

/**
 * Don't use process.cwd() as it breaks module encapsulation
 * Instead, let's use module.parent if it's present, or the module itself if there is no parent (probably testing keystone directly if that's the case)
 * This way, the consuming app/module can be an embedded node_module and path resolutions will still work
 * (process.cwd() breaks module encapsulation if the consuming app/module is itself a node_module)
 */
var moduleRoot = (function(_rootPath) {
    var parts = _rootPath.split(path.sep);
    parts.pop(); //get rid of /node_modules from the end of the path
    return parts.join(path.sep);
})(module.parent ? module.parent.paths[0] : module.paths[0]);

Print console data in tables.

I am thinking that I would like to see the printout data to the console in table format, to reflect the look and feel of actual timecards (that get stamped when you "clockin" and "clockout").

Suggestions welcome.

format the print output

when you run the print command, you see:

Hours: 29
Minutes: 45
Seconds: 7

I would prefer:

29 Hours 45 Minutes 07 Seconds [29:45:07]

if package.json name not available, print the pwd

currently, the current working directory is the default, but timecard should look in the directory of the .timecard.json file to see if a package.json exists, if yes, use the module name from there.

add functional tests to the cli

Items that need to be tested via the CLI:

API Tests

  • timecard new (with existing .timecard.json file, should confirm overwrite)
  • timecard new (without existing .timecard.json file, shouldn't confirm overwrite)
  • timecard new --no-prompt (shouldn't confirm overwrite)
  • timecard clockin && timecard clockin (show show clockout pending error)
  • timecard clockout && timecard clockout (show show clockin pending error)
  • timecard print (should print timecard)
  • timecard clockin && timecard print (should print pending clockout message in output)
  • timecard clockin (with existing .timecard.json file, should show clockin message)
  • timecard clockout (with existing .timecard.json file, should show clockout message)
  • timecard print (with existing .timecard.json file, should print timecard)
  • timecard clockin (without existing .timecard.json file, shouldn't show error)
  • timecard clockout (without existing .timecard.json file, shouldn't show error)
  • timecard print (without existing .timecard.json file, shouldn't show error)
  • timecard clockin (with invalid .timecard.json file, should show error)
  • timecard clockout (with invalid .timecard.json file, should show error)
  • timecard print (with invalid .timecard.json file, should show error)
  • timecard version (should output version)
  • timecard (should show help when called with no arguments)
  • timecard help (should show help)

Additional Tests

In a package with a package.json file

  • Test that API commands will only effect the root .timecard.json file no matter how many directories deep the user is

In a package without a package.json file

  • Test that API commands will only attempt to work on a .timecard.json file in the same directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.