chronicled / open-registry-sdk

Apache License 2.0
30 stars 17 forks source link

Shrinkwrap Dependencies #42

Closed orlandoc01 closed 6 years ago

orlandoc01 commented 6 years ago

This PR introduces the following changes:

  1. Adds a shrink wrap file which locks down a specific workable version that should be used for each npm dependency.
  2. Adds a pre-commit hook which ensures that the npm-shrinkwrap file always stays in sync with the package.json file for an easier developer experience. (also adds the lint and test checks in the pre-commit hook.
  3. Removes babel dependencies that are no longer being used.
AllenSH12 commented 6 years ago

I'm not sure postinstall is the time to do this since it's run both when a package has it's dependencies installed and the package itself is installed as a dep. Don't have an alternative suggestion at the moment but here's an example of the error:

# install from master does not report errors
allens-MacBook-Pro:open-registry-sdk allen$ git checkout oc-shrinkwrap

# in a tmp directory that uses open-registry-sdk as a dependency
allens-MacBook-Pro:hooktest allen$ npm install ../../open-registry-sdk/

> sha3@1.2.0 install /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/sha3
> node-gyp rebuild

  CXX(target) Release/obj.target/sha3/src/addon.o
../src/addon.cpp:59:36: warning: 'NewInstance' is deprecated
      [-Wdeprecated-declarations]
                        info.GetReturnValue().Set(cons->NewInstance(argc...
                                                        ^
/Users/allen/.node-gyp/6.11.1/include/node/v8.h:3271:3: note: 'NewInstance' has
      been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version",
  ^
/Users/allen/.node-gyp/6.11.1/include/node/v8config.h:336:29: note: expanded
      from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
1 warning generated.
  CXX(target) Release/obj.target/sha3/src/displayIntermediateValues.o
  CXX(target) Release/obj.target/sha3/src/KeccakF-1600-reference.o
  CXX(target) Release/obj.target/sha3/src/KeccakNISTInterface.o
  CXX(target) Release/obj.target/sha3/src/KeccakSponge.o
  SOLINK_MODULE(target) Release/sha3.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]

> keccak@1.3.0 install /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/keccak
> prebuild-install || node-gyp rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."

prebuild-install info begin Prebuild-install version 2.3.0
prebuild-install info looking for local prebuild @ prebuilds/keccak-v1.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info looking for cached prebuild @ /Users/allen/.npm/_prebuilds/https-github.com-cryptocoinjs-keccak-releases-download-v1.3.0-keccak-v1.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info found cached prebuild 
prebuild-install info unpacking @ /Users/allen/.npm/_prebuilds/https-github.com-cryptocoinjs-keccak-releases-download-v1.3.0-keccak-v1.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info unpack resolved to /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/keccak/build/Release/keccak.node
prebuild-install info unpack required /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/keccak/build/Release/keccak.node successfully
prebuild-install info install Successfully installed prebuilt binary!

> secp256k1@3.3.0 install /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/secp256k1
> prebuild-install || node-gyp rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."

prebuild-install info begin Prebuild-install version 2.3.0
prebuild-install info looking for local prebuild @ prebuilds/secp256k1-v3.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info looking for cached prebuild @ /Users/allen/.npm/_prebuilds/https-github.com-cryptocoinjs-secp256k1-node-releases-download-v3.3.0-secp256k1-v3.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info found cached prebuild 
prebuild-install info unpacking @ /Users/allen/.npm/_prebuilds/https-github.com-cryptocoinjs-secp256k1-node-releases-download-v3.3.0-secp256k1-v3.3.0-node-v48-darwin-x64.tar.gz
prebuild-install info unpack resolved to /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/secp256k1/build/Release/secp256k1.node
prebuild-install info unpack required /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk/node_modules/secp256k1/build/Release/secp256k1.node successfully
prebuild-install info install Successfully installed prebuilt binary!

> open-registry-sdk@0.0.0 postinstall /Users/allen/Projects/tmp/hooktest/node_modules/open-registry-sdk
> ./hooks/setup.sh

fatal: Not a git repository (or any of the parent directories): .git
Setting up pre-commit hook
ln: .git/hooks/pre-commit: No such file or directory
hooktest@1.0.0 /Users/allen/Projects/tmp/hooktest
└── (empty)

npm WARN hooktest@1.0.0 No description
npm WARN hooktest@1.0.0 No repository field.
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "../../open-registry-sdk/"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! open-registry-sdk@0.0.0 postinstall: `./hooks/setup.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the open-registry-sdk@0.0.0 postinstall script './hooks/setup.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the open-registry-sdk package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./hooks/setup.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs open-registry-sdk
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls open-registry-sdk
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/allen/Projects/tmp/hooktest/npm-debug.log
npm ERR! code 1
orlandoc01 commented 6 years ago

Yeah, I realized I missed a few edge cases in that post install step earlier, so I added the do not merge so that people could at least start reviewing the PR while I work on those smaller fixes. I just added a new commit which I believe should address issues when git is not installed, when the sdk folder is not a repo, and when it's installed as part of a dependency to another git repo. Hopefully that should cover all our bases now.

orlandoc01 commented 6 years ago

Hmm maybe not, Circle CI build is still failing. Give me a few more minutes

AllenSH12 commented 6 years ago

Not really seeing a universal way to solve this, best solution seems to be configuring a custom hooks path to the checked in directory:

git config core.hooksPath hooks

https://git-scm.com/docs/git-config#git-config-corehooksPath

orlandoc01 commented 6 years ago

Think that last one fixed it

orlandoc01 commented 6 years ago

Actually looked at the doc page you sent and it might be better to set that custom hookPath instead of making symlinks. Tried that approach in the latest commit