1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00
verdaccio/packages/config
Marc Bernard 6e764e3c49
feat: add support for npm owner (#4582)
* feat: add support for npm owner

* Revert debug msg

* Finish feature and add test cases

* Fix remote user name and more tests

* Simplify passing remote user

* Update version metadata with owners

* Add test for validateUserName

* Add comment for "change owner"

* add config option

* add check to removePackage, removeTarball

* typo

* check access when write=true

* Add to config, fix undefined user

* Update docs

* Update docs

* Update readme
2024-06-13 12:06:01 +02:00
..
src feat: add support for npm owner (#4582) 2024-06-13 12:06:01 +02:00
test feat: add migrateToSecureLegacySignature property (#4621) 2024-05-05 16:53:28 +02:00
.babelrc fix: build targets for 5x modules (#3576) 2023-01-28 12:12:14 +01:00
CHANGELOG.md chore: update versions (next-7) (#4658) 2024-06-02 21:52:46 +02:00
jest.config.js chore(config): increase test coverage (#4382) 2024-01-06 11:31:32 +01:00
package.json chore: update versions (next-7) (#4658) 2024-06-02 21:52:46 +02:00
README.md fix config builder erroring when passed partial config (#4552) 2024-03-23 12:19:41 +01:00
tsconfig.build.json feat: add typescript project references settings (#1933) 2021-04-09 17:54:19 +02:00
tsconfig.json feat: add forceEnhancedLegacySignature (#3655) 2023-02-26 22:24:00 +01:00

@verdaccio/config

Overview

The @verdaccio/config package provides a powerful configuration builder constructor for programmatically creating configuration objects for Verdaccio, a lightweight private npm proxy registry. With this package, users can easily manage various configuration aspects such as package access, uplinks, security settings, authentication, logging, and storage options.

Installation

You can install via npm:

npm install @verdaccio/config

Usage

To start using @verdaccio/config, import the ConfigBuilder class and begin constructing your configuration object:

ConfigBuilder constructor

The ConfigBuilder class is a helper configuration builder constructor used to programmatically create configuration objects for testing or other purposes.


import { ConfigBuilder } from '@verdaccio/config';

// Create a new configuration builder instance
const config = ConfigBuilder.build({ security: { api: { legacy: false } } });

// Add package access configuration
configBuilder.addPackageAccess('@scope/*', { access: 'read', publish: 'write' });

// Add an uplink configuration
configBuilder.addUplink('npmjs', { url: 'https://registry.npmjs.org/' });

// Add security configuration
configBuilder.addSecurity({ allow_offline: true });

// Get the configuration object
const config = configBuilder.getConfig();

// Get the configuration yaml text
const config = configBuilder.getAsYaml();

Methods

  • addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml): Adds package access configuration.
  • addUplink(id: string, uplink: UpLinkConf): Adds an uplink configuration.
  • addSecurity(security: Partial<Security>): Adds security configuration.
  • addAuth(auth: Partial<AuthConf>): Adds authentication configuration.
  • addLogger(log: LoggerConfItem): Adds logger configuration.
  • addStorage(storage: string | object): Adds storage configuration.
  • getConfig(): ConfigYaml: Retrieves the configuration object.
  • getAsYaml(): string: Retrieves the configuration object as YAML format.

getDefaultConfig

This method is available in the package's index and retrieves the default configuration object.

import { getDefaultConfig } from '@verdaccio/config';

const defaultConfig = getDefaultConfig();

Other Methods

  • fromJStoYAML(config: ConfigYaml): string: Converts a JavaScript configuration object to YAML format.
  • parseConfigFile(filePath: string): ConfigYaml: Parses a configuration file from the specified path and returns the configuration object.

License

Verdaccio is MIT licensed

The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch) files within the /assets folder) is Creative Commons licensed.