npm-registry-sync

1.1.0 • Public • Published

npm-registry-sync

A daemon to sync packages across npm registries.

About

npm-registry-sync is a daemon (background process) that synchronizes packages across multiple npm registries.

It's useful in scenarios where there are multiple private npm registries (eg. Enterprise Artifactory) with different packages.

For example, given two private npm registries A & B, where A is currently reachable but B is not (eg. behind firewall), npm-registry-sync will download all versions of the specified packages from A. When B is finally reachable, it will publish all versions of the specified package to registry B.

Usage

  1. Setup a directory with a configuration file:

    npm-registry-sync.config.json:

    {
        "registries": {
            "registry-id-a": {
                "name": "Registry name A",
                "url": "https://registry-url-a/",
                "npmrc": "~/npmrc/file", // (Optional)
                "strictSSL": false, // (Optional)
    
                // These packages will be downloaded and published to the other registries
                "packages": [
                    "package-name-a",
                    "package-name-b",
                    "package-name-c",
                    // ....
                ]
            },
    
            "registry-id-b": {
                "url": "https://registry-url-b/",
                // ...
            },
            // ...
        },
    
        // Registry polling interval in seconds
        "pollingInterval": 60
    }

    Tip: Use npmrc to manage configurations for multiple npm registries.

    You can then reference the appropriate configuration in ~/.npmrcs/.

  2. Make sure npm is authenticated to the registries:

    npm whoami --registry <registry url>
  3. Start npm-registries-sync:

    npx npm-registries-sync

    Or run it in the background using screen:

    screen npx npm-registries-sync

Config schema

export type Config = {
    registries: Record<string, {

        // Name of the registry (used for logging)
        name: string

        // URL of the registry
        url: string

        // Optional `.npmrc` file
        // Compatible with https://www.npmjs.com/package/npmrc
        npmrc?: string

        // Whether to disable SSL when interacting with registry
        strictSSL?: boolean

        // Array of package names to download
        // and publish to other registries
        packages?: string[]
    }>

    // Frequency to poll the registries in seconds
    // Default: 60
    pollingInterval: number
}

/npm-registry-sync/

    Package Sidebar

    Install

    npm i npm-registry-sync

    Weekly Downloads

    0

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    51.1 kB

    Total Files

    3

    Last publish

    Collaborators

    • hirokiosame