commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.77k stars 551 forks source link

Does not work after npm i and package config #42

Closed maboiteaspam closed 8 years ago

maboiteaspam commented 8 years ago

Hi!

TLDR; IRFM, ran it, then tried to run git cz, it failed with an unfortunate but epic error,

D:\work\MyBlog\C\c2-bin>git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

The longer story

Running windows 7 with node and npm such

D:\work\MyBlog\C\c2-bin>npm -v
2.11.3

D:\work\MyBlog\C\c2-bin>node -v
v0.12.7

I have run D:\work\MyBlog\C\c2-bin>npm install -g commitizen, then D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact

Then i configured my local package.json file to add

  ,"config": {
    "commitizen": {
      "path": "node_modules/cz-conventional-changelog"
    }
  }

Where did i get it wrong ?

Thanks !


D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact
Attempting to initialize using the npm package cz-conventional-changelog
Error: A previous adapter is already configured. Use --force to override

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact --force
Attempting to initialize using the npm package cz-conventional-changelog
npm WARN using --force I sure hope you know what you are doing.
npm WARN package.json c2-bin@1.0.0 No repository field.
npm WARN package.json c2-bin@1.0.0 license should be a valid SPDX license expression
cz-conventional-changelog@1.1.4 node_modules\cz-conventional-changelog
└── word-wrap@1.1.0
{this.config was unexpected at this time.

D:\work\MyBlog\C\c2-bin>  "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\node_modules\.bin\\node.exe"  "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\node
_modules\.bin\\..\json\lib\json.js" -I -f D:\work\MyBlog\C\c2-bin\package.json -e 'if(!this.config) {this.config={};}; if(!this.config.commitizen) { this.config.commitizen={};}
; this.config.commitizen.path="./node_modules/cz-conventional-changelog"'

D:\work\MyBlog\C\c2-bin>git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

D:\work\MyBlog\C\c2-bin>
jimthedev commented 8 years ago

Hi! Sorry to hear you're having trouble. Can you try using a this in your package.json?

  ,"config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
maboiteaspam commented 8 years ago

How about having a console argument for the matter of that value ?

I have a case where i want to run same cz for many instances, i don t feel like i want to duplicate it everywhere. That seems inappropriate to me.

I ve gone through your sources, and find quickly you are not using any helper for that. Any matter here ?

  // Get cli args
  let rawGitArgs = process.argv.slice(2, process.argv.length);

This said, i ran into similar issue on my box too,

maboiteaspam [21:12:08] c2-bin (master) # npm install -g commitizen
npm WARN optional dep failed, continuing fsevents@1.0.2
npm WARN optional dep failed, continuing fsevents@1.0.2
/home/maboiteaspam/bin/git-cz -> /home/maboiteaspam/lib/node_modules/commitizen/bin/git-cz
/home/maboiteaspam/bin/commitizen -> /home/maboiteaspam/lib/node_modules/commitizen/bin/commitizen
commitizen@2.3.0 /home/maboiteaspam/lib/node_modules/commitizen
├── dedent@0.4.0
├── strip-json-comments@1.0.4
├── rimraf@2.4.3
├── node-uuid@1.4.3
├── minimist@1.2.0
├── semver@5.0.3
├── cz-conventional-changelog@1.1.4 (word-wrap@1.1.0)
├── shelljs@0.5.3
├── chalk@1.1.1 (escape-string-regexp@1.0.3, supports-color@2.0.0, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0)
├── json@9.0.3
├── inquirer@0.10.1 (strip-ansi@3.0.0, ansi-regex@2.0.0, ansi-escapes@1.1.0, cli-width@1.1.0, figures@1.4.0, through@2.3.8, rx-lite@3.1.2, lodash@3.10.1, run-async@0.1.0, cli-cursor@1.0.2, readline2@1.0.1)
├── glob@5.0.15 (path-is-absolute@1.0.0, inherits@2.0.1, inflight@1.0.4, once@1.3.2, minimatch@3.0.0)
├── find-node-modules@1.0.1 (merge@1.2.0, findup-sync@0.2.1)
├── nodemon@1.7.3 (undefsafe@0.0.3, es6-promise@3.0.2, minimatch@3.0.0, touch@1.0.0, debug@2.2.0, lodash.defaults@3.1.2, ps-tree@1.0.1, chokidar@1.2.0, update-notifier@0.5.0)
├── gulp-git@1.6.0 (any-shell-escape@0.1.1, require-dir@0.1.0, through2@0.6.5, gulp-util@3.0.7)
├── gulp@3.9.0 (interpret@0.6.6, pretty-hrtime@1.0.1, deprecated@0.0.1, archy@1.0.0, tildify@1.1.2, v8flags@2.0.10, semver@4.3.6, orchestrator@0.3.7, liftoff@2.2.0, vinyl-fs@0.3.14, gulp-util@3.0.7)
└── babel@5.8.23 (path-is-absolute@1.0.0, slash@1.0.0, path-exists@1.0.0, fs-readdir-recursive@0.1.2, convert-source-map@1.1.1, commander@2.9.0, source-map@0.4.4, output-file-sync@1.1.1, lodash@3.10.1, chokidar@1.2.0, babel-core@5.8.29)
maboiteaspam [21:15:12] c2-bin (master) # commitizen init cz-conventional-changelog --save --save-exact
Attempting to initialize using the npm package cz-conventional-changelog
Error: A previous adapter is already configured. Use --force to override
maboiteaspam [21:26:33] c2-bin (master) # git cz
/home/maboiteaspam/lib/node_modules/commitizen/src/commitizen/adapter.js:162
    throw err;
          ^
Error: ENOENT, no such file or directory '/home/maboiteaspam/Bureau/C/c2-bin/node_modules/cz-conventional-changelog'
    at Error (native)
    at Object.fs.lstatSync (fs.js:792:18)
    at resolveAdapterPath (/home/maboiteaspam/lib/node_modules/commitizen/src/commitizen/adapter.js:115:11)
    at getPrompter (/home/maboiteaspam/lib/node_modules/commitizen/src/commitizen/adapter.js:92:29)
    at gitCz (/home/maboiteaspam/lib/node_modules/commitizen/src/cli/strategies/git-cz.js:48:20)
    at Object.bootstrap (/home/maboiteaspam/lib/node_modules/commitizen/src/cli/git-cz.js:24:5)
    at Object.<anonymous> (/home/maboiteaspam/lib/node_modules/commitizen/bin/git-cz.js:3:33)
    at Module._compile (module.js:460:26)
    at normalLoader (/home/maboiteaspam/lib/node_modules/commitizen/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/maboiteaspam/lib/node_modules/commitizen/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
maboiteaspam [21:26:50] c2-bin (master) # npm install -g conventional-changelog^C
maboiteaspam [21:28:03] c2-bin (master) # ^C
maboiteaspam [21:28:03] c2-bin (master) # npm i cz-conventional-changelog
npm WARN package.json c2-bin@1.0.0 No repository field.
npm WARN package.json c2-bin@1.0.0 license should be a valid SPDX license expression
cz-conventional-changelog@1.1.4 node_modules/cz-conventional-changelog
└── word-wrap@1.1.0
maboiteaspam [21:28:19] c2-bin (master) # git cz
Error: No files added to staging! Did you forget to run git add?
maboiteaspam [21:29:46] c2-bin (master) # 

I suggest to improve the README.md to better indicate and suggest about the required first adapter,

npm i cz-conventional-changelog --save-dev --save-exact

I ll check again tomorrow on windows see.

jimthedev commented 8 years ago

Thank you for the feedback on the README. It does need to be updated to be more clear. I have opened #27 to track the documentation changes and will make sure to include our discussion.

Let's take a look at this lines in the error log you posted. This is an important error:

maboiteaspam [21:15:12] c2-bin (master) # commitizen init cz-conventional-changelog --save --save-exact
Attempting to initialize using the npm package cz-conventional-changelog
Error: A previous adapter is already configured. Use --force to override

You had previously configured an adapter but the path was wrong. This error is trying to inform you that commitizen init will not install a new adapter and edit your package.json if you have a path already configured.

In order to tell Commitizen that it is ok to override the previous value, you must re-run the command above with the --force flag. Running with the --force flag overwrites any previous value in the package.json's config.commitizen.path and runs npm install cz-conventional-changelog --save-dev --save-exact so that you do not need to do that manually.

So, the command would be:

commitizen init cz-conventional-changelog --save --save-exact --force

By running this, you should be all set.

maboiteaspam commented 8 years ago

ok, so i cleaned up my env here on windows, re ran,

commitizen init cz-conventional-changelog --save --save-exact

and got expected results. the new package, the new dependency.

So far, git cz, hangs, it s expected,

git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Then update the package file such

{
  "name": "c2-bin",
  "version": "1.0.0",
  "description": "Command and Control binary for C projects.",
  "main": "index.js",
  "bin": {
    "c2-bin": "bin.js"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "maboitespam",
  "prefer": "global",
  "license": "WTF",
  "dependencies": {
    "chokidar": "^1.2.0",
    "findup-sync": "^0.3.0",
    "glob": "^5.0.15",
    "got": "^4.2.0",
    "grunt": "^0.4.5",
    "grunt-cli": "^0.1.13",
    "grunt-open": "^0.2.3",
    "inquirer": "^0.10.1",
    "minimist": "^1.2.0",
    "once": "^1.3.2",
    "resolve": "^1.1.6"
  },
  "devDependencies": {
    "cz-conventional-changelog": "^1.1.4"
  }
,"config": {
  "commitizen": {
    "path": "node_modules/cz-conventional-changelog"
  }
}
}

Still hang.

trying,

    "path": "./node_modules/cz-conventional-changelog"

same.

Also tried,

,"config": {
  "commitizen": {
    "path": ".\\node_modules\\cz-conventional-changelog"
  }

same.

I ve not gone through the source, but i d say it s missing a path.join according to the fact it worked on my linux box and this is about a stupid path resolution issue.

Still, i d like to know how you feel about passing this value as a cli parameter. if you feel not to add this, just let it know.

maboiteaspam commented 8 years ago

before i forget, again i really want to suggest about improving the README. Yesterday I really felt this one was hard to read. I d suggest to get something close to those examples https://github.com/substack/node-browserify https://github.com/rvagg/changelog-maker with some clear identified sections about some clearly identified steps (Install, Usage ect).

jimthedev commented 8 years ago

Did you try commitizen init cz-conventional-changelog --save --save-exact --force?

jimthedev commented 8 years ago

Also can you confirm that you have commitizen version 2.3.0 installed?

jimthedev commented 8 years ago

Hi there. Hope you aren't still having this problem but if you are, please provide some of the info above. If not I'll probably close it in 3 days. Obviously you can always reopen.

maboiteaspam commented 8 years ago

Hi!

Sorry for the lag, i got absorbed into other matters.

Yes! i do have 2.3.0

npm ls commitizen -g --depth=1
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires bower@'~0.3.0' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\bower,
npm WARN unmet dependency which is version 1.4.1
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires clean-css@'~0.3.2' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\clean-css,
npm WARN unmet dependency which is version 3.3.5
C:\Users\d1m\AppData\Roaming\npm
└── commitizen@2.3.0

Running commitizen init cz-conventional-changelog --save --save-exact --force outputs

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact --force
Attempting to initialize using the npm package cz-conventional-changelog
npm WARN using --force I sure hope you know what you are doing.
npm WARN package.json c2-bin@1.0.0 No repository field.
npm WARN package.json c2-bin@1.0.0 license should be a valid SPDX license expression
cz-conventional-changelog@1.1.4 node_modules\cz-conventional-changelog
└── word-wrap@1.1.0
{this.config was unexpected at this time.

D:\work\MyBlog\C\c2-bin>  "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\node_modules\.bin\\node.exe"  "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitize
n\node_modules\.bin\\..\json\lib\json.js" -I -f D:\work\MyBlog\C\c2-bin\package.json -e 'if(!this.config) {this.config={};}; if(!this.config.commitizen) { this.config.com
mitizen={};}; this.config.commitizen.path="./node_modules/cz-conventional-changelog"'

D:\work\MyBlog\C\c2-bin>

Then git cz

D:\work\MyBlog\C\c2-bin>git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

D:\work\MyBlog\C\c2-bin>

Does it help ?

maboiteaspam commented 8 years ago

And my package json is

{
  "name": "c2-bin",
  "version": "1.0.0",
  "description": "Command and Control binary for C projects.",
  "main": "index.js",
  "bin": {
    "c2-bin": "bin.js"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "maboitespam",
  "prefer": "global",
  "license": "WTF",
  "dependencies": {
    "chokidar": "^1.2.0",
    "findup-sync": "^0.3.0",
    "glob": "^5.0.15",
    "got": "^4.2.0",
    "grunt": "^0.4.5",
    "grunt-cli": "^0.1.13",
    "grunt-open": "^0.2.3",
    "inquirer": "^0.10.1",
    "minimist": "^1.2.0",
    "once": "^1.3.2",
    "resolve": "^1.1.6"
  },
  "devDependencies": {
    "cz-conventional-changelog": "^1.1.4"
  },
  "config": {
    "commitizen": {
      "path": ".\\node_modules\\cz-conventional-changelog"
    }
  }
}

BTW! How to do with this commitizen path, which is here windows format, but when i ll get back home, on linux, i will need to use a linux forward slashed path. Can it the path format be lifted whatever is the os to make that work smoothly ?

jimthedev commented 8 years ago

@maboiteaspam I found the problem. All tests are now passing on windows and I swapped out the json editor which seemed to have problems on windows. This is a much simpler method of editing the json and seems to perform much better on windows. If this doesn't fix your problem then please let me know.

maboiteaspam commented 8 years ago

wouav, really cool ! Thanks a lot.

Given the commit, i will test install from the repo directly and let you know if that works fine.

jimthedev commented 8 years ago

Sounds good!

maboiteaspam commented 8 years ago

just in case, and because i have not seen .appveyor.yml file,

http://www.appveyor.com/

i know it s not perfect, but it can help!

testing results

D:\work\MyBlog\C\c2-bin>npm -v
2.11.3
D:\work\MyBlog\C\c2-bin>node -v
v0.12.7
D:\work\MyBlog\C\c2-bin>npm i commitizen/cz-cli -g
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:751:12)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:110:17)
npm WARN addRemoteGit     at maybeClose (child_process.js:1015:16)
npm WARN addRemoteGit     at Socket.<anonymous> (child_process.js:1183:11)
npm WARN addRemoteGit     at Socket.emit (events.js:107:17)
npm WARN addRemoteGit     at Pipe.close (net.js:485:12)
npm WARN addRemoteGit  commitizen/cz-cli resetting remote C:\Users\d1m\AppData\Roaming\npm-cache\_git-remotes\git-github-com-commitizen-cz-cli-git-cb6b9503 because of err
or: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm WARN optional dep failed, continuing fsevents@1.0.5
npm WARN optional dep failed, continuing fsevents@1.0.5
C:\Users\d1m\AppData\Roaming\npm\git-cz -> C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\bin\git-cz
C:\Users\d1m\AppData\Roaming\npm\commitizen -> C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\bin\commitizen
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires bower@'~0.3.0' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\bower,
npm WARN unmet dependency which is version 1.4.1
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires clean-css@'~0.3.2' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\clean-css,
npm WARN unmet dependency which is version 3.3.5
commitizen@0.0.0-semantically-released C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen
├── dedent@0.6.0
├── strip-json-comments@1.0.4
├── rimraf@2.4.3
├── minimist@1.2.0
├── node-uuid@1.4.3
├── semver@5.0.3
├── shelljs@0.5.3
├── cz-conventional-changelog@1.1.4 (word-wrap@1.1.0)
├── chalk@1.1.1 (supports-color@2.0.0, escape-string-regexp@1.0.3, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0)
├── glob@5.0.15 (path-is-absolute@1.0.0, inherits@2.0.1, inflight@1.0.4, once@1.3.2, minimatch@3.0.0)
├── find-node-modules@1.0.1 (merge@1.2.0, findup-sync@0.2.1)
├── inquirer@0.11.0 (strip-ansi@3.0.0, ansi-regex@2.0.0, figures@1.4.0, ansi-escapes@1.1.0, cli-width@1.1.0, through@2.3.8, run-async@0.1.0, rx-lite@3.1.2, cli-cursor@1.0
.2, readline2@1.0.1, lodash@3.10.1)
├── gulp-git@1.6.0 (any-shell-escape@0.1.1, require-dir@0.1.0, through2@0.6.5, gulp-util@3.0.7)
├── gulp@3.9.0 (pretty-hrtime@1.0.1, interpret@0.6.6, deprecated@0.0.1, archy@1.0.0, tildify@1.1.2, v8flags@2.0.10, semver@4.3.6, orchestrator@0.3.7, liftoff@2.2.0, vinyl
-fs@0.3.14, gulp-util@3.0.7)
├── nodemon@1.8.1 (undefsafe@0.0.3, es6-promise@3.0.2, debug@2.2.0, minimatch@3.0.0, touch@1.0.0, lodash.defaults@3.1.2, ps-tree@1.0.1, update-notifier@0.5.0, chokidar@1.
2.0)
└── babel@5.8.29 (slash@1.0.0, path-is-absolute@1.0.0, fs-readdir-recursive@0.1.2, path-exists@1.0.0, convert-source-map@1.1.1, commander@2.9.0, output-file-sync@1.1.1, s
ource-map@0.5.3, lodash@3.10.1, chokidar@1.2.0, babel-core@5.8.33)

D:\work\MyBlog\C\c2-bin>

D:\work\MyBlog\C\c2-bin>git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact
module.js:338
    throw err;
          ^
Error: Cannot find module '../dist/cli/commitizen.js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\bin\commitizen.js:2:1)
    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)

: (

D:\work\MyBlog\C\c2-bin>dir C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\bin\..\
 Volume in drive C has no label.
 Volume Serial Number is D08E-2E0C

 Directory of C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen

11/09/2015  01:04 PM    <DIR>          .
11/09/2015  01:04 PM    <DIR>          ..
11/09/2015  01:04 PM                20 .npmignore
11/09/2015  01:04 PM               656 .travis.yml
11/09/2015  01:04 PM    <DIR>          bin
11/09/2015  01:04 PM               135 jsconfig.json
11/09/2015  01:04 PM             1,063 LICENSE
11/09/2015  01:05 PM    <DIR>          node_modules
11/09/2015  01:04 PM             9,873 package.json
11/09/2015  01:04 PM             7,051 README.md
               6 File(s)         18,798 bytes
               4 Dir(s)  43,178,950,656 bytes free

weird stuff is

D:\work\MyBlog\C\c2-bin>npm ls commitizen -g --depth=1

C:\Users\d1m\AppData\Roaming\npm
└── (empty)

npm ERR! code 1

D:\work\MyBlog\C\c2-bin>

with another package it works nicely

D:\work\MyBlog\C\c2-bin>npm ls showusage -g --depth=1
C:\Users\d1m\AppData\Roaming\npm
└── showusage@0.1.0

: / If i have time, i ll try to dig that, too.

maboiteaspam commented 8 years ago

ok never mind, i ll re do manually, have not seen before : https://github.com/commitizen/cz-cli/blob/master/.npmignore

maboiteaspam commented 8 years ago

nah, i don't know.

I mean, i m not used to es6 stack with babel, and now i m facing weird errors like this

commitizen init cz-conventional-changelog --save --save-exact
C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\dist\cli\commitizen.js:1
(function (exports, require, module, __filename, __dirname) { import { configL
                                                              ^^^^^^
SyntaxError: Unexpected reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    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> (C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\bin\commitizen.js:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

in short,

npm i babel -g
npm i babel-cli -g
cd commitizen
npm i -g

How about appveyor ?

jimthedev commented 8 years ago

Ah, ok. It seems like something is messed up in your environment but I don't know exactly what it is. I would recommend removing your global packages and clearing your npm cache because something is messed up

Can you check to see if you have babel 6 installed by running babel --version. We do not yet support babel 6 so if you have babel 6 installed then you should revert to babel 5 for now.

Unfortunately, I don't know anything about appveyor. Sorry.

The commitizen workflow really should be as simple as the following:

npm install -g commitizen@2.4.4
mkdir my-javascript-project
cd my-javascript-project
git init
npm init --yes
commitizen init cz-conventional-changelog --save-dev
git add .
git cz

If it isn't then something is likely conflicting (eg. babel 6 installed globally) or something is screwed up in your environment.

maboiteaspam commented 8 years ago

Hi !

Thanks for help. Indeed much easier.

I hope you can take a moment to check about appveyor, it s very much like travis, but for windows.

This said i m sorry to report some failures : /

git cz still ain t working, for the same reasons. Also, now, the package json formatting is blown out after the adapter is installed,

see,

D:\work\MyBlog\C\c2-bin>npm install -g commitizen
[lots of things]

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save-dev --force
Attempting to initialize using the npm package cz-conventional-changelog
npm WARN using --force I sure hope you know what you are doing.
npm WARN package.json c2-bin@1.0.0 No repository field.
npm WARN package.json c2-bin@1.0.0 license should be a valid SPDX license expression
cz-conventional-changelog@1.1.4 node_modules\cz-conventional-changelog
└── word-wrap@1.1.0

D:\work\MyBlog\C\c2-bin>git cz
module.js:338
    throw err;
          ^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

D:\work\MyBlog\C\c2-bin>npm ls commitizen -g --depth=1
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires bower@'~0.3.0' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\bower,
npm WARN unmet dependency which is version 1.4.1
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\yeoman requires clean-css@'~0.3.2' but will load
npm WARN unmet dependency C:\Users\d1m\AppData\Roaming\npm\node_modules\clean-css,
npm WARN unmet dependency which is version 3.3.5
C:\Users\d1m\AppData\Roaming\npm
└── commitizen@2.4.4

And the package json looks likes this now : (

{"name":"c2-bin","version":"1.0.0","description":"Command and Control binary for C projects.","main":"index.js","bin":{"c2-bin":"bin.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"maboitespam","prefer":"global","license":"WTF","dependencies":{"chokidar":"^1.2.0","findup-sync":"^0.3.0","glob":"^5.0.15","got":"^4.2.0","grunt":"^0.4.5","grunt-cli":"^0.1.13","grunt-open":"^0.2.3","inquirer":"^0.10.1","minimist":"^1.2.0","once":"^1.3.2","resolve":"^1.1.6"},"devDependencies":{"cz-conventional-changelog":"^1.1.4"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}
maboiteaspam commented 8 years ago

Note also i un-built babel 6 prior those steps.

and commitizen has brought in babel 5.8.29

└── babel@5.8.29 (slash@1.0.0, path-is-absolute@1.0.0, path-exists@1.0.0, fs-readdir-recursive@0.1.2, convert-source-map@1.1.1, source-map@0.5.3, commander@2.9.0, output-
file-sync@1.1.1, chokidar@1.2.0, babel-core@5.8.33)

For the records,

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save-dev
Attempting to initialize using the npm package cz-conventional-changelog
Error: A previous adapter is already configured. Use --force to override

D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save-dev --force
Attempting to initialize using the npm package cz-conventional-changelog
npm WARN using --force I sure hope you know what you are doing.
npm WARN package.json c2-bin@1.0.0 No repository field.
npm WARN package.json c2-bin@1.0.0 license should be a valid SPDX license expression
cz-conventional-changelog@1.1.4 node_modules\cz-conventional-changelog
└── word-wrap@1.1.0
jimthedev commented 8 years ago

@maboiteaspam I haven't been able to replicate this, but in an effort to make sure that our test coverage includes Windows I'm working on getting our tests running on appveyor.

maboiteaspam commented 8 years ago

I wont promise, but if i can free some time at office i ll seriously dig it too.

thanks again !

afirdousi commented 8 years ago

Do you guys have something on this uptil now?

Here is my simple package.json

{ "name": "enterprise-config", "description": "This is a sample Node JS Module for showing how to setup travis ci with git for enterprise Node JS modules", "main": "src/index.js", "scripts": { "commit":"git-cz", "test": "karma start", "semantic-release": "semantic-release pre && npm publish && semantic-release post" }, "repository": { "type": "git", "url": "https://github.com/afirdousi/node-npm-travis-git-integration-sample.git" }, "keywords": [ "NodeJS", "Travic", "CI", "Git", "JavaScript", "Module", "Sample" ], "author": "'Anas 'anas.firdousi@gmail.com'", "license": "'MIT'", "bugs": { "url": "https://github.com/afirdousi/node-npm-travis-git-integration-sample/issues" }, "homepage": "https://github.com/afirdousi/node-npm-travis-git-integration-sample", "devDependencies": { "commitizen": "^2.4.4", "cz-conventional-changelog": "^1.1.4", "karma": "^0.13.15", "karma-browserify": "^4.4.0", "karma-chrome-launcher": "^0.2.1", "karma-jasmine": "^0.3.6", "semantic-release": "^6.0.3" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } }

}

When i try to do npm run commit

I get the following:

enterprise-config@ commit D:\git\node-npm-travis-git-integration-sample git-cz

npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "commit" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! file C:\WINDOWS\system32\cmd.exe; npm ERR! path C:\WINDOWS\system32\cmd.exe; npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn C:\WINDOWS\system32\cmd.exe; npm ERR! enterprise-config@ commit: git-cz npm ERR! spawn C:\WINDOWS\system32\cmd.exe; ENOENT npm ERR! npm ERR! Failed at the enterprise-config@ commit script 'git-cz'. npm ERR! This is most likely a problem with the enterprise-config package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! git-cz npm ERR! You can get their info via: npm ERR! npm owner ls enterprise-config npm ERR! There is likely additional logging output above. npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "commit" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! code ELIFECYCLE

npm ERR! enterprise-config@ commit: git-cz npm ERR! Exit status -4058 npm ERR! npm ERR! Failed at the enterprise-config@ commit script 'git-cz'. npm ERR! This is most likely a problem with the enterprise-config package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! git-cz npm ERR! You can get their info via: npm ERR! npm owner ls enterprise-config npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\git\node-npm-travis-git-integration-sample\npm-debug.log

I am also attaching my log file here npm-semantic-cli-issues.txt

My environement:

Windows 8.1 Node : v0.12.0 NPM : 2.5.1 Commitizen : 2.4.4 cz-conventional-changelog : 1.1.4

What am I doing wrong here? Can anyone help please?

jimthedev commented 8 years ago

@afirdousi That is odd. Unfortunately, I don't have a Windows 8.1 machine but would you mind trying to run these in powershell to see if it makes any difference?

maboiteaspam commented 8 years ago

hi,

I ll just drop that link here, to not forget about it, until i can free time, https://github.com/Microsoft/nodejs-guidelines

i believe it may be helpful : )

jimthedev commented 8 years ago

Sounds good. I have appveyor tests running on Windows 2012 R2. The only one failing is the multi line commit one which is due to the way git on Windows formats its output. On Mon, Nov 16, 2015 at 7:34 PM maboiteaspam notifications@github.com wrote:

hi,

I ll just drop that link here, to not forget about it, until i can free time, https://github.com/Microsoft/nodejs-guidelines

i believe it may be helpful : )

— Reply to this email directly or view it on GitHub https://github.com/commitizen/cz-cli/issues/42#issuecomment-157233067.

jimthedev commented 8 years ago

Ok all Windows tests are now passing on appveyor. Next I will have to try to figure out if it has something to do with how we're recommending that people configure their package.json's commit script. Thanks for hanging in there.

maboiteaspam commented 8 years ago

Hi @jimthedev ,

amazing, i can make it work now : ) Happy.

But i need to report about something i found weird.

git cz will not work, git-cz does work here.

The steps i followed

npm rm babel-cli babel -g # just in case
npm i commitizen@latest -g --force 
npm ls commitizen -g --depth=1 # to check
commitizen init cz-conventional-changelog --save --save-exact --force

et voila : )

Will dig about adapters now !!

Thanks again.

jimthedev commented 8 years ago

Hooray! Thanks for the feedback! On Wed, Nov 18, 2015 at 12:33 AM maboiteaspam notifications@github.com wrote:

Hi @jimthedev https://github.com/jimthedev ,

amazing, i can make it work now : ) Happy.

But i need to report about something i found weird.

git cz will not work, git-cz does work here.

The steps i followed

npm rm babel-cli babel -g # just in case npm i commitizen@latest -g --force npm ls commitizen -g --depth=1 # to check commitizen init cz-conventional-changelog --save --save-exact --force

et voila : )

Will dig about adapters now !!

Thanks again.

— Reply to this email directly or view it on GitHub https://github.com/commitizen/cz-cli/issues/42#issuecomment-157618580.

maboiteaspam commented 8 years ago

kind of forgotten to close, sorry : )