node-gh / gh-jira

NodeGH plugin for integrating Jira, an issue management system
34 stars 12 forks source link

gh jira cannot be installed #48

Closed maxandersen closed 9 years ago

maxandersen commented 10 years ago

I just tried again. Removed gh jira and reinstalled it. Removed ~/.gh.json and here are what I get when running gh:

➜  jbosstools-website git:(master) gh pr                                                                                                                                   (master⚡)
gh First we need authorization to use GitHub's API. Login with your GitHub account.
[?] Enter your GitHub user: maxandersen
[?] Enter your GitHub password: *********
gh [success] Authentication succeed.
gh [success] Writing GH config data: /Users/max/.gh.json
gh [info] Listing open pull requests on jbosstools/jbosstools-website
gh ➜ jbosstools/jbosstools-website
gh   master (4)
gh     #65 JBIDE-16923 - Improve /download index.html layouts @xcoulon (3 days ago)
gh     #64 JBIDE-16785: Forge N&N, include the connection profile news @koentsje (3 days ago)
gh     #55 reworked fuse tooling page (see JBIDE-16697) @lhein (5 days ago)
gh     #32 initial installation doc @maxandersen (a month ago)
gh

So that works. now run gh jira

➜  jbosstools-website git:(master) gh jira                                                                                                                                 (master⚡)

/usr/local/lib/node_modules/gh-jira/bin/jira.js:222
    options.assignee = options.assignee || jiraConfig.user;
                                                     ^
TypeError: Cannot read property 'user' of undefined
    at Jira.run (/usr/local/lib/node_modules/gh-jira/bin/jira.js:222:54)
    at /usr/local/lib/node_modules/gh/bin/gh.js:183:34
    at Array.forEach (native)
    at /usr/local/lib/node_modules/gh/bin/gh.js:174:25
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:232:13
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:142:25
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:229:17
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:556:34
    at exports.checkVersion (/usr/local/lib/node_modules/gh/lib/base.js:167:21)
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:551:21

Thus yeah, something is assuming jiraConfig exists before jiraConfig is even added.

maxandersen commented 10 years ago

This is still happening ;/

zenorocha commented 9 years ago

@henvic can you investigate this?

henvic commented 9 years ago

Can you please assign this issue to me, @zenorocha?

@maxandersen, meanwhile you can try to add the following key structure to your .gh.json:

{
    ...
    "plugins": {
        "jira": {
            "user": "your-username",
            "password": "hash"
        }
    }
}
maxandersen commented 9 years ago

@henvic your pointers got me a bit further:

Here is what I did, I added:

  "plugins": {
     "jira": {
            "user": "maxandersen",
            "password": "hash"
        }
    },

And yes, I literally wrote hash here since I was not sure what hashing you wanted applied ;)

With that in the file I ran gh jira and got the following output:

% gh jira                                                                                                           ~
[?] Enter your JIRA user: maxandersen
[?] Enter your JIRA password: ********
gh [success] Writing GH config data: /Users/max/.gh.json

and the resulting .gh.json now has:

 "plugins": {
        "jira": {
            "user": "maxandersen",
            "password": "nowwitharealhash"
        }
    },

..and this time I did not paste the real hash :)

Now when I run gh jira I get this though:

% gh jira                                                                                                           ~

/usr/local/lib/node_modules/gh-jira/bin/jira.js:262
.component = options.component || jiraConfig.default_issue_component[options.p
                                                                    ^
TypeError: Cannot read property 'undefined' of undefined
    at instance.searchUserByGithubUsername_.instance.selectUserWithQuestion_.options.assignee (/usr/local/lib/node_modules/gh-jira/bin/jira.js:262:88)
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:551:21
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:227:13
    at iterate (/usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:134:13)
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:145:25
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:229:17
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:556:34
    at /usr/local/lib/node_modules/gh-jira/bin/jira.js:258:17
    at /usr/local/lib/node_modules/gh-jira/bin/jira.js:152:25
    at /usr/local/lib/node_modules/gh-jira/node_modules/async/lib/async.js:232:13

So one step better but things still not working ;/

henvic commented 9 years ago

@maxandersen I've made few changes to the core and maybe this issue doesn't exist anymore (or things can be worse, but we're in the right direction now -- adding unit tests, modularizing, and so on). Can you please update and verify if this is still happening?

Best regards, Henrique.

maxandersen commented 9 years ago

okey - I reinstalled gh jira including updating to require node 0.12.

Now I get this when running 'gh':

/usr/local/lib/node_modules/gh/lib/base.js:31
    host: baseConfig.api.host,
                    ^
TypeError: Cannot read property 'api' of undefined
    at Object.<anonymous> (/usr/local/lib/node_modules/gh/lib/base.js:31:21)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/gh/lib/cmd.js:15:12)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

and when running gh jira

~ ❯❯❯ gh jira
? May gh anonymously report usage statistics to improve the tool over time? Yes
First we need authorization to use GitHub's API. Login with your GitHub account.
? Enter your GitHub user: maxandersen
? Enter your GitHub password: **********
? Enter your two-factor code: 780276
Writing GH config data: /Users/max/.gh.json
Authentication succeed.
/usr/local/lib/node_modules/gh-jira/bin/jira.js:209
    options.assignee = options.assignee || jiraConfig.user;
                                                     ^
TypeError: Cannot read property 'user' of undefined
    at Jira.run (/usr/local/lib/node_modules/gh-jira/bin/jira.js:209:54)
    at /usr/local/lib/node_modules/gh/lib/cmd.js:205:34
    at Array.forEach (native)
    at /usr/local/lib/node_modules/gh/lib/cmd.js:196:25
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:254:17
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:157:25
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:251:21
    at /usr/local/lib/node_modules/gh/node_modules/async/lib/async.js:615:34
    at /usr/local/lib/node_modules/gh/lib/cmds/user.js:192:33
    at /usr/local/lib/node_modules/gh/node_modules/github/api/v3.0.0/authorization.js:141:17

so no, looks like same/worse situation.

maxandersen commented 9 years ago

FYI: I ran 'sudo npm install --force -g gh gh-jira' and still same error.

maxandersen commented 9 years ago

Okey - I think I might have a clue now. I get the above error when running it outside a git repository.

When running inside a git repo I get this instead:

warning: Can't hash jira password.
? Enter your JIRA user: maxandersen
? Enter your JIRA password: ********
Writing GH config data.
fatal: Can't transition. 401: Error while updating
maxandersen commented 9 years ago

now that I got this far - where does one configure the jira server ? it does not say anywhere in the readme. My guess for why I get a 401 is that it does not know what jira server to use ?

maxandersen commented 9 years ago

Figured out to add 'host' manually to ~/.gh.json.

without this or when running outside git repository it just fails hard.

submitted https://github.com/node-gh/gh-jira/pull/51 to update readme.md to let users at least get started.

henvic commented 9 years ago

Thanks for your pull request.