speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Cannot install through git url #201

Open davidabrahams opened 6 years ago

davidabrahams commented 6 years ago

I'm trying to use the code on branch version-1.1.0, but it seems like installing from the git repository doesn't work for babel-plugin-rewire.

Our package.json:

{
  "name": "tagprobot",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "http-server",
    "lint": "eslint 'src/**/*.js' 'test/**/*.js'",
    "lint:fix": "eslint 'src/**/*.js' 'test/**/*.js' --fix",
    "test": "babel-tape-runner test/**/*.js | faucet",
    "build": "webpack --watch",
    "build:once": "webpack"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/altodyte/tagprobot.git"
  },
  "author": "chauncy",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/altodyte/tagprobot/issues"
  },
  "homepage": "https://github.com/altodyte/tagprobot#readme",
  "devDependencies": {
    "babel-cli": "^6.24.1",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-lodash": "^3.2.11",
    "babel-plugin-rewire": "^1.1.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-tape-runner": "^2.0.1",
    "eslint": "^4.1.1",
    "eslint-config-airbnb-base": "^11.3.2",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-import": "^2.7.0",
    "tap-webpack-plugin": "^2.0.0",
    "tape": "^4.7.0",
    "sinon": "^2.4.1",
    "webpack": "^3.1.0"
  },
  "dependencies": {
    "@tyriar/fibonacci-heap": "^1.0.10",
    "faucet": "0.0.1",
    "lodash": "^4.17.4"
  }
}

Our .babelrc:

{
  "plugins": ["lodash", "babel-plugin-rewire"],
  "presets": ["es2015"]
}

Running our unit tests:

➜  tagprobot git:(129-improved-tests) test

> tagprobot@1.0.0 test /home/david/Repos/tagprobot
> babel-tape-runner test/**/*.js | faucet

✓ updatePath
✓ checks isVisualMode
✓ calls removeChild on each existing sprite
✓ adds a new sprite for each item in path to the renderer
✓ clearSprites
....
✓ assertGridInBounds: does not throw errors when inputs are in bounds
✓ assertGridInBounds: throws errors when inputs are not in bounds
# tests 195
# pass  195
✓ ok

Reinstall babel-plugin-rewire through the git repository:

➜  tagprobot git:(129-improved-tests) npm install speedskater/babel-plugin-rewire#version-1.1.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ babel-plugin-rewire@1.1.0
added 115 packages and updated 1 package in 3.692s

Running tests again:

➜  tagprobot git:(129-improved-tests) ✗ test

> tagprobot@1.0.0 test /home/david/Repos/tagprobot
> babel-tape-runner test/**/*.js | faucet

/home/david/Repos/tagprobot/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180
          throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
          ^

ReferenceError: Unknown plugin "babel-plugin-rewire" specified in "/home/david/Repos/tagprobot/.babelrc" at 1, attempted to resolve relative to "/home/david/Repos/tagprobot"
    at /home/david/Repos/tagprobot/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/home/david/Repos/tagprobot/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/home/david/Repos/tagprobot/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at OptionManager.init (/home/david/Repos/tagprobot/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/home/david/Repos/tagprobot/node_modules/babel-register/lib/node.js:103:45)
    at loader (/home/david/Repos/tagprobot/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/home/david/Repos/tagprobot/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
not ok 1 no plan found
not ok 2 no assertions found
⨯ fail  2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tagprobot@1.0.0 test: `babel-tape-runner test/**/*.js | faucet`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tagprobot@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/david/.npm/_logs/2017-09-02T21_42_54_573Z-debug.log
clayreimann commented 5 years ago

@speedskater Are you using npm version [patch|minor|major] if so you can resolve this by issuing git push --tags. Otherwise this can be resolved by adding tags of vX.Y.Z corresponding to each release.