Giter Site home page Giter Site logo

npm-migrate's Introduction

npm-migrate

Migrate all versions of a selected package from a registry to another one.

Usage

const migrate = require('npm-migrate')

const moduleName = 'my-private-module'
const from = 'http://your-old.private-registry.com:8080'
const to = 'http://nice-new.private-registry.org:8080'

// optional
const options = {
    debug: false // default
}

migrate(moduleName, from, to, options)
    .then((migrated) => console.log(migrated)) // list of migrated packages
    .catch((err) => console.error(err))

What it does

  1. Fetches all versions (or just those not already migrated) as tarballs from old registry
  2. Extracts & updates package.json: the publishConfig.registry field to the new registry url
  3. Publishes each version to the new registry
  4. Cleans up after itself

Known issues

  • The dates of every version published will be reset to the date and time you run this script
  • The migrating user will be added as maintainer

Changelog

  • v1.2.0 - Work with scoped packages
  • v1.3.0 - Compare both registries and migrate only the remaining versions not in the new registry

npm-migrate's People

Contributors

bblackwo avatar necccc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

npm-migrate's Issues

graceful-fs needs a version update.

graceful-fs needs to be updated to v4.2.4 or above to get fixes for isaacs/node-graceful-fs#158.

Right now, if I use the current version of npm-migrate, I get the error:

/Users/<USERNAME>/Library/code/projectOne/node_modules/npm/node_modules/graceful-fs/polyfills.js:287
      if (cb) cb.apply(this, arguments)
                 ^

TypeError: cb.apply is not a function
    at /Users/<USERNAME>/Library/code/projectOne/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (node:fs:209:5)

Node.js v18.16.0

[question] reasons for updating `publishConfig.registry`

Hi!
Thanks for making available this library. It's a huge time saver!

I have a question, though:

What is the reason for updating publishConfig.registry property in previously published packages? Is it a special valued used somehow by the registry itself?

I asked because mutating the package content produces a new checksum hash on the new registry which I fear might lead to some unexpected issues in the future.

Thanks again. Cheers!

[Question] How do I authenticate my private registry?

I've been trying to use this script to migrate my npm packages from Azure to Nexus but both of them has authentication on them so it keeps giving me 401. Can I still use this script to migrate or do I need to think of some other way around? Thanks.

Error {code: "ENOTDIR"} when trying to migrate packages between verdaccios

When trying to migrate some packages from a remote verdaccio to my local verdaccio, I get the error ENOTDIR.

user-agent: npm/6.4.1 node/v8.12.0 win32 x64

error:

code:"ENOTDIR"
__proto__:Error: ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'
code:"ENOENT"
errno:-4058
message:"ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'"
path:"C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json"
stack:"Error: ENOENT: no such file or directory, open 'C:\Users\admin\AppData\Local\Temp\npm-1892-57af5724\unpack-f25ee458\package.json'"
syscall:"open"

The error is emitted when executing npm.commands.publish in the function publishAsync in npm_utils.js. Before the error is emitted, packages are successfully downloaded and repacked.

If I manually run npm publish /path/to/tgz --registry http://localhost:4873, everything works fine.

Can't only migrate remaining versions

The script died on me 1/2 way through migration and then I couldn't run it a 2nd time to only migrate the missing versions.

Would be good to change this so it fails gracefully on some versions already being migrated instead of throwing this error:

npm ERR! publish Failed PUT 403
{ Error: Forbidden The feed already contains the package 'my-module' at version '0.1.2': _packaging
    at makeError (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/npm-registry-client/lib/request.js:304:12)
    at CachingRegistryClient.<anonymous> (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/npm-registry-client/lib/request.js:292:14)
    at Request._callback (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/npm-registry-client/lib/request.js:212:14)
    at Request.self.callback (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/request/request.js:1081:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/Users/bblackwo/dev/node/npm-migrate/node_modules/npm/node_modules/request/request.js:1001:12) pkgid: '_packaging', statusCode: 403, code: 'E403' }

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.