Code Monkey home page Code Monkey logo

npm-utils's Introduction

bahmutov

"npx bahmutov" - to see my info

NPM

Build status semantic-release standard renovate-app badge

Inspired by (and shamelessly copied from) npx marius

Install

Requires Node and NPM with npx utility.

npx bahmutov

   ╭──────────────────────────────────────────────────────────────────────────╮
   │                                                                          │
   │   Gleb Bahmutov, PhD                                                     │
   │   JavaScript ninja, image processing expert, software quality fanatic.   │
   │                                                                          │
   │          Web: https://glebbahmutov.com                                   │
   │         Blog: https://glebbahmutov.com/blog                              │
   │         Work: https://www.cypress.io                                     │
   │       Slides: https://slides.com/bahmutov                                │
   │       GitHub: https://github.com/bahmutov                                │
   │      Twitter: https://twitter.com/bahmutov                               │
   │     LinkedIn: https://linkedin.com/in/bahmutov                           │
   │                                                                          │
   │   Go on, give https://github.com/cypress-io/cypress a star!              │
   │                                                                          │
   ╰──────────────────────────────────────────────────────────────────────────╯

Small print

Author: Gleb Bahmutov <[email protected]> © 2018

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2018 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm-utils's People

Contributors

bahmutov avatar cy6erskunk avatar durandj avatar hutson avatar hypercubed avatar renovate-bot avatar renovate[bot] avatar svnlto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

npm-utils's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: excludePackageNames: excludePackageNames should be inside a packageRule only

HTTPS registry URL not supported

Howdy. I've been using your package to help authenticate a CI publisher tool (sort of like the one you link to from your README). However, I've been running into authentication issues.

When I run npm config get registry with no registry configured in my global ~/.npmrc file, or in a local file, I get: https://registry.npmjs.org/

Taking a look at https://github.com/bahmutov/npm-utils/blob/master/src/set-auth-token.js#L35, it seems only http URLs can be parsed.

Therefore setAuthToken can't remove https, leaving the https in the registry URL in ~/.npmrc.

Therefore my ~/.npmrc file contains https://registry.npmjs.org/:_authToken=${NPM_TOKEN}.

npm does not recognize that line when accessing the registry.npmjs.org registry.

Therefore it does not authenticate.

Use Mocha

Tired of gt test runner, use Mocha

Add set-auth-token-var-name bin script

If the environment has NPM_TOKEN this command should add token to the registry
(maybe default or take name as argument?). Thus anyone who wants to use private modules
from the public registry can do

npm i npm-utils
$(npm bin)/set-auth-token-var-name

which should produce in file .npmrc

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

and then you can do npm install to install all deps

Support Scoped Registries

registry-url.js only retrieves the value of registry, which means that it will always append the _authToken to the value of registry. Therefore, scoped registries in the .npmrc configuration file, such as @company:registry, are not supported.

In my use case I have an .npmrc configuration file with two registries in it:

registry = "internal mirror of public registry"
@company:registry = "private registry"

The project's package.json file has set publishConfig to publish to the scoped, @company, registry. The project's name is @company/something.

In my case, I believe the value of the environment variable NPM_TOKEN needs to be appended to @company:registry instead of registry to allow proper authentication when publishing the project.

If you have access to the project's name, you can call something like registry-url to get the appropriate scoped registry.

An example of how registry-url is used can be seen in package-json.

Do not print to console npm command

Looks weird when printing this for npm.pack for example

spawning test process npm [ 'pack', '/Users/kensho/git/charts-lib/node_modules/express' ]

Auth token is being set for the wrong registry?

Hi Gleb,

I'm not 100% sure, but there is a change that I've faced a small issue in your repo. Please follow the discussion here: https://gitlab.com/hyper-expanse/semantic-release-gitlab/issues/9

To summarise, it seems that npm-utils ignores registry from publishConfig in package.json and authenticates in a wrong repo. This happens when semantic-release-gitlab is trying to publish a release.

How relevant could this be to npm-utils? Or should your lib just be used somehow else in the situation mentioned?

Cheers,
Alex

Update readme

Update readme references to .npmrc. Explain that it now looks for a local file first before defaulting to ~/.npmrc.

Related: #39

registry-url.js

The merge of pull request #27 removes src/registry-url.js but the file is still used in src/index.js

So when I try to use v1.7.0 I get the error:

Error: Cannot find module './registry-url'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (...\node_modules\npm-utils\src\index.js:7:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

`local-or-home-npmrc` Breaks Node 4 For Yarn Users

local-or-home-npmrc sets the value for node in the engines property of their package.json file to node 6.

Yarn will fail during the installation process if the value of the engines property does not match against the version of Node used to run Yarn - yarnpkg/rfcs#69 (comment)

Therefore, npm-utils, version 1.x, was working for Node 4 Yarn users until local-or-home-npmrc was introduced in version 1.13.0, but now npm-utils, though more specifically local-or-home-npmrc, can't be installed.

I ran into this yesterday when I upgraded my Yarn lockfile, and ran my build (which runs against all supported versions of Node, npm, and Yarn) - https://gitlab.com/hyper-expanse/semantic-release-gitlab-notifier/-/jobs/22286197

error [email protected]: The engine "node" is incompatible with this module. Expected version ">=6".
error Found incompatible module

I'll probably consider locking down the npm-utils version in my project's package.json file as a temporary way to work around the issue.

However, as I still support all Node LTS versions, including Node 4, I'll need to consider a longer-term solution (I do want my downstream consumers to benefit from the features you've been adding to npm-utils, but still be able to use Node 4 is that happens to be their current situation)

Do you have any thoughts, or suggestions, on the matter?

npm registry url is determined incorrectly

if the caller has .npmrc file with custom registry, the npm-utils.registryUrl is called from node_modules folder - returning the global NPM url.

Probably should execute in the caller's working dir?

Add version command wrapper

Really powerful command, including git commit, tag, etc. See npm help version.
Can set specific version or increment individual number

npm version [<newversion> | major | minor | patch ...]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.