IonicaBizau / github-contributions

:octocat: A tool that generates a repository which being pushed into your GitHub account creates a nice contributions calendar.
MIT License
1.33k stars 116 forks source link

Bug: Cannot read property 'date' of undefined #11

Closed ghost closed 9 years ago

ghost commented 10 years ago

OS: Windows Node Ver: 10.x

Console outputs:

C:\Users\Luke Shiels\gh-contributions>npm start

> gh-contributions@0.0.0 start C:\Users\Luke Shiels\gh-contributions
> node server.js

Listening on 9000
/css/gh-style.css - Not Modified
/js/jquery.min.js - Not Modified
/bootstrap/js/bootstrap.min.js - Not Modified
/js/index.js - Not Modified
/bootstrap/css/bootstrap.min.css - Not Modified
/css/github.css - Not Modified

C:\Users\Luke Shiels\gh-contributions\contributions.js:60
            options.dates.push(year[p.x - 1][p.y - 1].date);
                                                     ^
TypeError: Cannot read property 'date' of undefined
    at Object.module.exports.getRepo (C:\Users\Luke Shiels\gh-contributions\co
ributions.js:60:54)
    at C:\Users\Luke Shiels\gh-contributions\server.js:53:27
    at IncomingMessage.<anonymous> (C:\Users\Luke Shiels\gh-contributions\serv
.js:107:13)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

npm ERR! gh-contributions@0.0.0 start: `node server.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the gh-contributions@0.0.0 start script.
npm ERR! This is most likely a problem with the gh-contributions package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls gh-contributions
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\n
ejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! cwd C:\Users\Luke Shiels\gh-contributions
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Luke Shiels\gh-contributions\npm-debug.log
npm ERR! not ok code 0

C:\Users\Luke Shiels\gh-contributions>

The client on the browser just says: Error: undefined.

IonicaBizau commented 10 years ago

Thank you for reporting this bug. I am a Linux user. @silviubogan, can you confirm this?

ghost commented 10 years ago

I'll look into this; give me 5 minutes

Edit: This error is only thrown when you click 'Generate Repo'. Otherwise the web interface thing works wonders.

IonicaBizau commented 10 years ago

Probably, this is reproducible on Linux as well. I will look into this tomorrow.

Can you please share with us the generated json array?

ghost commented 10 years ago

Sure:

{
    "coordinates": [
        {
            "x": 1,
            "y": 1
        },
        {
            "x": 1,
            "y": 2
        },
        {
            "x": 1,
            "y": 3
        },
        {
            "x": 1,
            "y": 4
        },
        {
            "x": 1,
            "y": 5
        },
        {
            "x": 1,
            "y": 6
        },
        {
            "x": 1,
            "y": 7
        },
        {
            "x": 2,
            "y": 7
        },
        {
            "x": 3,
            "y": 7
        },
        {
            "x": 4,
            "y": 7
        },
        {
            "x": 6,
            "y": 5
        },
        {
            "x": 6,
            "y": 6
        },
        {
            "x": 6,
            "y": 7
        },
        {
            "x": 7,
            "y": 7
        },
        {
            "x": 8,
            "y": 5
        },
        {
            "x": 8,
            "y": 6
        },
        {
            "x": 8,
            "y": 7
        }
    ],
    "commitsPerDay": 2
}
IonicaBizau commented 10 years ago

Thanks!

If you find a solution until tomorrow, don't forget to create a pull request.

IonicaBizau commented 10 years ago

@shielsasaurus It works fine on Ubuntu 14.04 Beta:

Can you put the following if on line contributions.js:60?

if (!year[p.x - 1][p.y - 1]) {
    console.log(p.x, p.y);
} else {
    options.dates.push(year[p.x - 1][p.y - 1].date);
}

This will find the values when the code crashes.

IonicaBizau commented 10 years ago

Cannot reproduce the bug on Windows 8 (in VBox) as well.

BTW, on Windows this will not work because of the sh commands. Maybe someone will solve this... You can try to install an Unix based OS in your virtual box and run the scripts there. :smile:

ghost commented 10 years ago

Huh, the installer worked fine for me, so I'll try to add that code and get back to you.

ghost commented 10 years ago

Ok, as expected; it returns

'sh' is not recognised as an internal or external command, operable program or batch file.

I'll try to tweak it with Windows support and send you a pull request.

Full output:

2 < 2
Date is:  undefined ID:  17
> sh C:\Users\Luke Shiels\gh-contributions/bin/toZip.sh public/repos/n95dcbxtbgz
m2t9
stdout: stderr: 'sh' is not recognized as an internal or external command,
operable program or batch file.
exec error: undefined
Close: 1

Over and over again.

IonicaBizau commented 10 years ago

Exactly! If you can do that I would be so thankful! Where you don't understand the code, just ask me. Thanks!

ghost commented 10 years ago

Ok; i've hit a bit of a stump. I've made all of the sh files with a bat alternatives in a separate directory (see here), however, the Windows command line doesn't have (as far as I can see) any built in zip methods. D:

IonicaBizau commented 10 years ago

@shielsasaurus That's a good idea. For zipping the directory you can try to use a NodeJS module. For example this one seems to have Windows support.

ghost commented 10 years ago

For zipping the directory you can try to use a NodeJS module.

I didn't think of that.

Anyway, why don't you use a module for the linux side as well?

IonicaBizau commented 10 years ago

Just because I wrote the code quickly and I haven't Internet connection when I wrote that part. :smile:

If you can implement zipping via Node for the Linux side, do it! :+1:

IonicaBizau commented 10 years ago

@shielsasaurus Any progress on this?

ghost commented 10 years ago

Sorry not really :/

I kind of gave up on it sorry; but fell free to use the windows versions of the .sh's that I made

IonicaBizau commented 10 years ago

@shielsasaurus But why? Contributions are welcome. :smile:

silviubogan commented 7 years ago

@IonicaBizau, I can start working for Windows support if you assign this issue to me.

IonicaBizau commented 7 years ago

@silviubogan This should be working on Windows.