Reynicke / Jimai

A Jira > Kimai connector
7 stars 0 forks source link

npm install throws errors #1

Open nlenzDE opened 3 years ago

nlenzDE commented 3 years ago

Hi,

when doing npm install, this results in the following messages:

[nlenz@localhost Jimai]$ npm install npm WARN deprecated request@2.74.0: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@2.0.6: this library is no longer supported npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues. npm WARN deprecated node-uuid@1.4.8: Use uuid module instead npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance with the hapi support policy > \1. npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance with the hapi support policy > \1. npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy > \1. npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues. npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN jimai@1.0.0 No repository field.

added 137 packages from 79 contributors and audited 137 packages in 5.366s

1 package is looking for funding run npm fund for details

found 9 vulnerabilities > \1 run npm audit fix to fix them, or npm audit for details

I ran npm audit fix --force

npm WARN using --force I sure hope you know what you are doing. npm WARN jimai@1.0.0 No repository field.

  • yargs@16.2.0 added 5 packages from 5 contributors, removed 46 packages and updated 10 packages in 2.469s

4 packages are looking for funding run npm fund for details

fixed 1 of 1 vulnerability in 112 scanned packages 1 package update for 1 vulnerability involved breaking changes (installed due to --force option)

I then tried to start the script:

[nlenz@localhost Jimai]$ ./jimai.sh internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module './config.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/nlenz/other/Jimai/src/index.js:2:16) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

What do I need to solve that? I maybe npm install not enough?

Reynicke commented 3 years ago

Hi! I am glad someone else than my colleagues and me use this :D

The dependency vulnerabilities are not nice but should not interfere. You fixed them, so everything should be alright. What's missing is the src/config.js file. You can use src/config.example.js as template.

Jira: I addition to your Jira username and email, you will need a token: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/ These data will be used to query your worklogs from Jira.

Kimai: URL to Kimai and your credentials are needed.

Mapping: Here Jira worklogs get assigned to Kimai tasks. To find the Kimai projectId and taskId you could check the kimai database, I guess. I always look into the kimai website: With the dev tools inspect the radio buttons where you usually choose the project or task. The ids are easily found in the DOM.

If you need any further help, please let me know!

nlenzDE commented 3 years ago

Hi, thanks for the quick response. Yes, there was this issue with the config file that was not available.

Now being equipped with one I started over again:

[xxx@localhost Jimai]$ bash -x jimai.sh

  • node ./src/index.js Date: 2021-04-29 (node:1587) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'join' of undefined at Promise (/home/xxx/other/Jimai/src/jira.js:11:103) at new Promise () at Object.getWorklogs (/home/xxx/other/Jimai/src/jira.js:9:10) at Object. (/home/xxx/other/Jimai/src/index.js:14:6) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) (node:1587) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:1587) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here is the config.js file that has been used:

module.exports = { jira: { userName: '>>MYJIRAUSERNAME<<', email: '>>my@email.com<<', projects: ['>>OURJIRAPROJECT<<'], jiraAuth: { user: '>>MYJIRAUSERNAME<<', pass: '>>MYJIRATOKEN<<', sendImmediately: true } },

kimai: { api: 'https://<>/json.php', auth: ['>>MYKIMAIUSERNAME<<', '>>MYKIMAITOKEN<<'] } }

Another question about https://github.com/Reynicke/Jimai/blob/master/src/jira.js, line 11: const url = 'https://winedock.atlassian.net/rest/api/latest/search?expand=' + config.customFields.join(','); -> shouldn't that be an individual URL as well?

Regards

Reynicke commented 3 years ago

Good catch with the jira URL! I'll add that to the config. Like I said, I hacked it together for my collegues.

Last thing missing in your config is the mapping.

Reynicke commented 3 years ago

You can now configure the Jira URL. Pull the new version and have a look in the config example.