0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: remove a package, move constants (#2001)

* chore: remove a package, move constants

* chore: remove *
This commit is contained in:
Juan Picado 2020-11-15 11:14:09 +01:00
parent 1153a8d92f
commit 5f3eee5eaf
155 changed files with 589 additions and 998 deletions

View file

@ -2,7 +2,6 @@
'@verdaccio/api': major
'@verdaccio/auth': major
'@verdaccio/cli': major
'@verdaccio/dev-commons': major
'@verdaccio/config': major
'@verdaccio/commons-api': major
'@verdaccio/file-locking': major

View file

@ -2,7 +2,6 @@
'@verdaccio/api': major
'@verdaccio/auth': major
'@verdaccio/cli': major
'@verdaccio/dev-commons': major
'@verdaccio/config': major
'@verdaccio/commons-api': major
'@verdaccio/file-locking': major

View file

@ -2,7 +2,6 @@
'@verdaccio/api': minor
'@verdaccio/auth': minor
'@verdaccio/cli': minor
'@verdaccio/dev-commons': minor
'@verdaccio/config': minor
'@verdaccio/commons-api': minor
'@verdaccio/file-locking': minor

View file

@ -5,7 +5,6 @@
"@verdaccio/api": "5.0.0-alpha.0",
"@verdaccio/auth": "5.0.0-alpha.0",
"@verdaccio/cli": "5.0.0-alpha.0",
"@verdaccio/dev-commons": "5.0.0-alpha.0",
"@verdaccio/config": "5.0.0-alpha.0",
"@verdaccio/commons-api": "10.0.0-beta",
"@verdaccio/file-locking": "10.0.0-beta",

View file

@ -2,7 +2,6 @@
'@verdaccio/api': patch
'@verdaccio/auth': patch
'@verdaccio/cli': patch
'@verdaccio/dev-commons': patch
'@verdaccio/config': patch
'@verdaccio/commons-api': patch
'@verdaccio/file-locking': patch

View file

@ -2,7 +2,6 @@
'@verdaccio/api': patch
'@verdaccio/auth': patch
'@verdaccio/cli': patch
'@verdaccio/dev-commons': patch
'@verdaccio/config': patch
'@verdaccio/commons-api': patch
'@verdaccio/file-locking': patch

View file

@ -283,7 +283,6 @@ Then select the packages you want to include in your changeset navigating throug
@verdaccio/api
@verdaccio/auth
@verdaccio/cli
@verdaccio/dev-commons
@verdaccio/config
@verdaccio/commons-api
```

View file

@ -40,6 +40,7 @@
"@babel/runtime": "7.12.5",
"@changesets/changelog-github": "0.2.7",
"@changesets/cli": "2.11.2",
"@changesets/get-dependents-graph": "^1.1.3",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.2.0",
"@octokit/rest": "17.0.0",
@ -56,7 +57,7 @@
"@types/supertest": "2.0.9",
"@typescript-eslint/eslint-plugin": "4.7.0",
"@typescript-eslint/parser": "4.7.0",
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"@verdaccio/ui-theme": "^1.14.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
@ -96,11 +97,11 @@
"supertest": "4.0.2",
"ts-node": "^9.0.0",
"typescript": "^4.0.5",
"verdaccio": "workspace:*",
"verdaccio-audit": "workspace:*",
"verdaccio-auth-memory": "workspace:*",
"verdaccio-htpasswd": "workspace:*",
"verdaccio-memory": "workspace:*"
"verdaccio": "workspace:5.0.0-alpha.0",
"verdaccio-audit": "workspace:10.0.0-beta",
"verdaccio-auth-memory": "workspace:10.0.0-beta",
"verdaccio-htpasswd": "workspace:10.0.0-beta",
"verdaccio-memory": "workspace:10.0.0-beta"
},
"scripts": {
"dev": "cross-env BABEL_ENV=registry babel-node --extensions \".ts,.tsx\" packages/cli/src",

View file

@ -24,13 +24,13 @@
"license": "MIT",
"dependencies": {
"@verdaccio/auth": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/hooks": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/middleware": "workspace:5.0.0-alpha.0",
"@verdaccio/store": "workspace:5.0.0-alpha.0",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"cookies": "0.8.0",
"debug": "^4.1.1",
"express": "4.17.1",
@ -39,9 +39,8 @@
"semver": "7.3.2"
},
"devDependencies": {
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/server": "workspace:5.0.0-alpha.0",
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"body-parser": "1.19.0",
"lodash": "^4.17.20",
"supertest": "next"

View file

@ -3,8 +3,7 @@ import _ from 'lodash';
import { Router } from 'express';
import { media, allow } from '@verdaccio/middleware';
import { API_MESSAGE, HTTP_STATUS, DIST_TAGS } from '@verdaccio/dev-commons';
import { VerdaccioError } from '@verdaccio/commons-api';
import { API_MESSAGE, HTTP_STATUS, DIST_TAGS, VerdaccioError } from '@verdaccio/commons-api';
import { Package } from '@verdaccio/types';
import { IStorageHandler } from '@verdaccio/store';
import { IAuth } from '@verdaccio/auth';

View file

@ -4,7 +4,7 @@ import buildDebug from 'debug';
import { allow } from '@verdaccio/middleware';
import { convertDistRemoteToLocalTarballUrls, getVersion, ErrorCode } from '@verdaccio/utils';
import { HEADERS, DIST_TAGS, API_ERROR } from '@verdaccio/dev-commons';
import { HEADERS, DIST_TAGS, API_ERROR } from '@verdaccio/commons-api';
import { Config, Package } from '@verdaccio/types';
import { IAuth } from '@verdaccio/auth';
import { IStorageHandler } from '@verdaccio/store';

View file

@ -4,7 +4,7 @@ import mime from 'mime';
import { Router } from 'express';
import buildDebug from 'debug';
import { API_MESSAGE, HEADERS, DIST_TAGS, API_ERROR, HTTP_STATUS } from '@verdaccio/dev-commons';
import { API_MESSAGE, HEADERS, DIST_TAGS, API_ERROR, HTTP_STATUS } from '@verdaccio/commons-api';
import {
validateMetadata,
isObject,

View file

@ -1,4 +1,4 @@
import { HEADERS } from '@verdaccio/dev-commons';
import { HEADERS } from '@verdaccio/commons-api';
export default function (route, auth, storage): void {
// searching packages

View file

@ -1,4 +1,4 @@
import { USERS, HTTP_STATUS } from '@verdaccio/dev-commons';
import { USERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { Response } from 'express';
import _ from 'lodash';
import buildDebug from 'debug';

View file

@ -1,7 +1,7 @@
import _ from 'lodash';
import { Response, Router } from 'express';
import { USERS, HTTP_STATUS } from '@verdaccio/dev-commons';
import { USERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { Package } from '@verdaccio/types';
import { IStorageHandler } from '@verdaccio/store';

View file

@ -2,18 +2,14 @@ import _ from 'lodash';
import { Response, Router } from 'express';
import buildDebug from 'debug';
import {
createRemoteUser,
getAuthenticatedMessage,
validatePassword,
ErrorCode,
} from '@verdaccio/utils';
import { getAuthenticatedMessage, validatePassword, ErrorCode } from '@verdaccio/utils';
import { getApiToken } from '@verdaccio/auth';
import { logger } from '@verdaccio/logger';
import { createRemoteUser } from '@verdaccio/config';
import { Config, RemoteUser } from '@verdaccio/types';
import { IAuth } from '@verdaccio/auth';
import { API_ERROR, API_MESSAGE, HTTP_STATUS } from '@verdaccio/dev-commons';
import { API_ERROR, API_MESSAGE, HTTP_STATUS } from '@verdaccio/commons-api';
import { $RequestExtend, $NextFunctionVer } from '../types/custom';
const debug = buildDebug('verdaccio:api:user');

View file

@ -1,7 +1,7 @@
import _ from 'lodash';
import { Response, Router } from 'express';
import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/dev-commons';
import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/commons-api';
import { ErrorCode, validatePassword } from '@verdaccio/utils';
import { IAuth } from '@verdaccio/auth';
import { $RequestExtend, $NextFunctionVer } from '../../types/custom';

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import { HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/dev-commons';
import { HTTP_STATUS, SUPPORT_ERRORS, getInternalError } from '@verdaccio/commons-api';
import { ErrorCode, stringToMD5, mask } from '@verdaccio/utils';
import { getApiToken } from '@verdaccio/auth';
import { logger } from '@verdaccio/logger';
@ -8,7 +8,6 @@ import { Response, Router } from 'express';
import { Config, RemoteUser, Token } from '@verdaccio/types';
import { IAuth } from '@verdaccio/auth';
import { IStorageHandler } from '@verdaccio/store';
import { getInternalError } from '@verdaccio/commons-api';
import { $RequestExtend, $NextFunctionVer } from '../../types/custom';
export type NormalizeToken = Token & {

View file

@ -7,8 +7,7 @@ import { Config, parseConfigFile } from '@verdaccio/config';
import { Storage } from '@verdaccio/store';
import { final, handleError, errorReportingMiddleware } from '@verdaccio/middleware';
import { Auth, IAuth } from '@verdaccio/auth';
import { HEADER_TYPE, HTTP_STATUS, generatePackageMetadata } from '@verdaccio/dev-commons';
import { HEADERS } from '@verdaccio/commons-api';
import { HEADERS, HEADER_TYPE, HTTP_STATUS, generatePackageMetadata } from '@verdaccio/commons-api';
import apiEndpoints from '../../src';
const getConf = (conf) => {

View file

@ -1,7 +1,6 @@
import supertest from 'supertest';
import { HTTP_STATUS } from '@verdaccio/commons-api';
import { HEADER_TYPE, HEADERS } from '@verdaccio/dev-commons';
import { HEADER_TYPE, HEADERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { $ResponseExtend, $RequestExtend } from '../../types/custom';
import { initializeServer, publishTaggedVersion, publishVersion } from './_helper';

View file

@ -1,7 +1,6 @@
import supertest from 'supertest';
import { HTTP_STATUS } from '@verdaccio/commons-api';
import { HEADER_TYPE, HEADERS } from '@verdaccio/dev-commons';
import { HEADER_TYPE, HEADERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { initializeServer } from './_helper';
describe('ping', () => {

View file

@ -6,7 +6,7 @@ import {
generatePackageMetadata,
HEADER_TYPE,
HEADERS,
} from '@verdaccio/dev-commons';
} from '@verdaccio/commons-api';
import { $ResponseExtend, $RequestExtend } from '../../types/custom';
import { initializeServer, publishVersion } from './_helper';

View file

@ -1,9 +1,17 @@
import supertest from 'supertest';
import _ from 'lodash';
import { HTTP_STATUS, API_ERROR } from '@verdaccio/commons-api';
import { HEADERS, HEADER_TYPE, API_MESSAGE } from '@verdaccio/dev-commons';
import { getBadRequest, getConflict, getUnauthorized } from '@verdaccio/commons-api';
import {
getBadRequest,
getConflict,
getUnauthorized,
HEADERS,
HEADER_TYPE,
API_MESSAGE,
HTTP_STATUS,
API_ERROR,
} from '@verdaccio/commons-api';
import { $RequestExtend, $ResponseExtend } from '../../types/custom';
import { initializeServer } from './_helper';

View file

@ -1,7 +1,6 @@
import supertest from 'supertest';
import { HTTP_STATUS } from '@verdaccio/commons-api';
import { HEADERS } from '@verdaccio/dev-commons';
import { HEADERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { $RequestExtend, $ResponseExtend } from '../../types/custom';
import { initializeServer } from './_helper';

View file

@ -1,4 +1,4 @@
import { HTTP_STATUS, API_ERROR } from '@verdaccio/dev-commons';
import { HTTP_STATUS, API_ERROR } from '@verdaccio/commons-api';
import {
addVersion,
uploadPackageTarball,

View file

@ -23,8 +23,7 @@
},
"license": "MIT",
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/loaders": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/auth": "workspace:5.0.0-alpha.0",
@ -37,7 +36,7 @@
},
"devDependencies": {
"@verdaccio/mock": "workspace:5.0.0-alpha.0",
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"gitHead": "7c246ede52ff717707fcae66dd63fc4abd536982"
}

View file

@ -3,12 +3,15 @@ import { NextFunction, Request, Response } from 'express';
import buildDebug from 'debug';
import {
API_ERROR,
SUPPORT_ERRORS,
TOKEN_BASIC,
TOKEN_BEARER,
VerdaccioError,
getBadRequest,
getInternalError,
getForbidden,
} from '@verdaccio/commons-api';
import { API_ERROR, SUPPORT_ERRORS, TOKEN_BASIC, TOKEN_BEARER } from '@verdaccio/dev-commons';
import { loadPlugin } from '@verdaccio/loaders';
import {
@ -24,14 +27,12 @@ import {
PackageAccess,
} from '@verdaccio/types';
import { isNil, isFunction, convertPayloadToBase64 } from '@verdaccio/utils';
import {
isNil,
isFunction,
getMatchedPackagesSpec,
createAnonymousRemoteUser,
convertPayloadToBase64,
createRemoteUser,
} from '@verdaccio/utils';
import { getMatchedPackagesSpec } from '@verdaccio/config';
} from '@verdaccio/config';
import {
getMiddlewareCredentials,

View file

@ -8,15 +8,18 @@ import {
Security,
AuthPackageAllow,
} from '@verdaccio/types';
import { HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER, API_ERROR } from '@verdaccio/dev-commons';
import { getForbidden, getUnauthorized, getConflict, getCode } from '@verdaccio/commons-api';
import {
AllowAction,
AllowActionCallback,
convertPayloadToBase64,
createAnonymousRemoteUser,
} from '@verdaccio/utils';
HTTP_STATUS,
TOKEN_BASIC,
TOKEN_BEARER,
API_ERROR,
getForbidden,
getUnauthorized,
getConflict,
getCode,
} from '@verdaccio/commons-api';
import { createAnonymousRemoteUser } from '@verdaccio/config';
import { AllowAction, AllowActionCallback, convertPayloadToBase64 } from '@verdaccio/utils';
import { TokenEncryption, AESPayload } from './auth';
import { aesDecrypt } from './legacy-token';
import { verifyPayload } from './jwt-token';

View file

@ -1,22 +1,27 @@
import path from 'path';
import _ from 'lodash';
import { CHARACTER_ENCODING, TOKEN_BEARER, ROLES, API_ERROR } from '@verdaccio/dev-commons';
import { CHARACTER_ENCODING, TOKEN_BEARER, API_ERROR } from '@verdaccio/commons-api';
import { configExample } from '@verdaccio/mock';
import { Config as AppConfig, parseConfigFile } from '@verdaccio/config';
import { setup } from '@verdaccio/logger';
import {
Config as AppConfig,
parseConfigFile,
ROLES,
createRemoteUser,
createAnonymousRemoteUser,
} from '@verdaccio/config';
import {
getAuthenticatedMessage,
buildToken,
createAnonymousRemoteUser,
createRemoteUser,
AllowActionCallbackResponse,
buildUserBuffer,
} from '@verdaccio/utils';
import { Config, Security, RemoteUser } from '@verdaccio/types';
import { VerdaccioError, getForbidden } from '@verdaccio/commons-api';
import { setup } from '@verdaccio/logger';
import {
IAuth,
Auth,

View file

@ -1,9 +1,8 @@
import _ from 'lodash';
import { Config as AppConfig } from '@verdaccio/config';
import { ROLES, Config as AppConfig } from '@verdaccio/config';
import { setup } from '@verdaccio/logger';
import { IAuth } from '@verdaccio/auth';
import { Config } from '@verdaccio/types';
import { ROLES } from '@verdaccio/dev-commons';
import { getInternalError } from '@verdaccio/commons-api';
import { Auth } from '../src';

View file

@ -30,7 +30,6 @@
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/node-api": "workspace:5.0.0-alpha.0",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"commander": "6.2.0",
"envinfo": "7.4.0",
"kleur": "3.0.3",

View file

@ -1,3 +0,0 @@
{
"extends": "../../.babelrc"
}

View file

@ -1,27 +0,0 @@
{
"name": "@verdaccio/dev-commons",
"version": "5.0.0-alpha.0",
"description": "commons utilities",
"main": "./build/index.js",
"types": "build/index.d.ts",
"author": {
"name": "Juan Picado",
"email": "juanpicado19@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/verdaccio/verdaccio"
},
"homepage": "https://verdaccio.org",
"license": "MIT",
"devDependencies": {
"@verdaccio/types": "workspace:*"
},
"scripts": {
"clean": "rimraf ./build",
"type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"build": "pnpm run build:js && pnpm run build:types"
}
}

View file

@ -1,169 +0,0 @@
export const DEFAULT_PORT = '4873';
export const DEFAULT_PROTOCOL = 'http';
export const DEFAULT_DOMAIN = 'localhost';
export const TIME_EXPIRATION_24H = '24h';
export const TIME_EXPIRATION_7D = '7d';
export const DIST_TAGS = 'dist-tags';
export const LATEST = 'latest';
export const USERS = 'users';
export const DEFAULT_MIN_LIMIT_PASSWORD = 3;
export const DEFAULT_USER = 'Anonymous';
export const keyPem = 'verdaccio-key.pem';
export const certPem = 'verdaccio-cert.pem';
export const csrPem = 'verdaccio-csr.pem';
export const HEADERS = {
ACCEPT: 'Accept',
ACCEPT_ENCODING: 'Accept-Encoding',
USER_AGENT: 'User-Agent',
JSON: 'application/json',
CONTENT_TYPE: 'Content-type',
CONTENT_LENGTH: 'content-length',
TEXT_PLAIN: 'text/plain',
TEXT_HTML: 'text/html',
AUTHORIZATION: 'authorization',
FORWARDED_PROTO: 'X-Forwarded-Proto',
FRAMES_OPTIONS: 'X-Frame-Options',
CSP: 'Content-Security-Policy',
CTO: 'X-Content-Type-Options',
XSS: 'X-XSS-Protection',
ETAG: 'ETag',
JSON_CHARSET: 'application/json; charset=utf-8',
OCTET_STREAM: 'application/octet-stream; charset=utf-8',
TEXT_CHARSET: 'text/plain; charset=utf-8',
WWW_AUTH: 'WWW-Authenticate',
GZIP: 'gzip'
};
export const CHARACTER_ENCODING = {
UTF8: 'utf8'
};
export const HEADER_TYPE = {
CONTENT_ENCODING: 'content-encoding',
CONTENT_TYPE: 'content-type',
CONTENT_LENGTH: 'content-length',
ACCEPT_ENCODING: 'accept-encoding'
};
export const ERROR_CODE = {
token_required: 'token is required'
};
export const TOKEN_BASIC = 'Basic';
export const TOKEN_BEARER = 'Bearer';
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
export const DEFAULT_UPLINK = 'npmjs';
export const ROLES = {
$ALL: '$all',
ALL: 'all',
$AUTH: '$authenticated',
$ANONYMOUS: '$anonymous',
DEPRECATED_ALL: '@all',
DEPRECATED_AUTH: '@authenticated',
DEPRECATED_ANONYMOUS: '@anonymous'
};
export const HTTP_STATUS = {
OK: 200,
CREATED: 201,
MULTIPLE_CHOICES: 300,
NOT_MODIFIED: 304,
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
FORBIDDEN: 403,
NOT_FOUND: 404,
CONFLICT: 409,
UNSUPPORTED_MEDIA: 415,
BAD_DATA: 422,
INTERNAL_ERROR: 500,
NOT_IMPLEMENTED: 501,
SERVICE_UNAVAILABLE: 503,
LOOP_DETECTED: 508
};
export const API_MESSAGE = {
PKG_CREATED: 'created new package',
PKG_CHANGED: 'package changed',
PKG_REMOVED: 'package removed',
PKG_PUBLISHED: 'package published',
TARBALL_UPLOADED: 'tarball uploaded successfully',
TARBALL_REMOVED: 'tarball removed',
TAG_UPDATED: 'tags updated',
TAG_REMOVED: 'tag removed',
TAG_ADDED: 'package tagged',
LOGGED_OUT: 'Logged out'
};
export const SUPPORT_ERRORS = {
PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
TFA_DISABLED: 'the two-factor authentication is not yet supported',
STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
PARAMETERS_NOT_VALID: 'the parameters are not valid'
};
export const API_ERROR = {
PASSWORD_SHORT: (passLength: number = DEFAULT_MIN_LIMIT_PASSWORD) =>
`The provided password is too short. Please pick a password` +
` longer than ${passLength} characters.`,
MUST_BE_LOGGED: 'You must be logged in to publish packages.',
PLUGIN_ERROR: 'bug in the auth plugin system',
CONFIG_BAD_FORMAT: 'config file must be an object',
BAD_USERNAME_PASSWORD: 'bad username/password, access denied',
NO_PACKAGE: 'no such package available',
PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added',
BAD_DATA: 'bad data',
NOT_ALLOWED: 'not allowed to access package',
NOT_ALLOWED_PUBLISH: 'not allowed to publish package',
INTERNAL_SERVER_ERROR: 'internal server error',
UNKNOWN_ERROR: 'unknown error',
NOT_PACKAGE_UPLINK: 'package does not exist on uplink',
UPLINK_OFFLINE_PUBLISH: 'one of the uplinks is down, refuse to publish',
UPLINK_OFFLINE: 'uplink is offline',
CONTENT_MISMATCH: 'content length mismatch',
NOT_FILE_UPLINK: "file doesn't exist on uplink",
MAX_USERS_REACHED: 'maximum amount of users reached',
VERSION_NOT_EXIST: "this version doesn't exist",
FILE_NOT_FOUND: 'File not found',
UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',
BAD_STATUS_CODE: 'bad status code',
PACKAGE_EXIST: 'this package is already present',
BAD_AUTH_HEADER: 'bad authorization header',
WEB_DISABLED: 'Web interface is disabled in the config file',
DEPRECATED_BASIC_HEADER: 'basic authentication is disabled, please use Bearer tokens instead',
BAD_FORMAT_USER_GROUP: 'user groups is different than an array',
RESOURCE_UNAVAILABLE: 'resource unavailable',
BAD_PACKAGE_DATA: 'bad incoming package data',
USERNAME_PASSWORD_REQUIRED: 'username and password is required',
USERNAME_ALREADY_REGISTERED: 'username is already registered'
};
export const APP_ERROR = {
CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',
PROFILE_ERROR: 'profile unexpected error',
PASSWORD_VALIDATION: 'not valid password'
};
export const DEFAULT_NO_README = 'ERROR: No README data found!';
export const MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';
export const WEB_TITLE = 'Verdaccio';
export const PACKAGE_ACCESS = {
SCOPE: '@*/*',
ALL: '**'
};
export const STORAGE = {
PACKAGE_FILE_NAME: 'package.json',
FILE_EXIST_ERROR: 'EEXISTS',
NO_SUCH_FILE_ERROR: 'ENOENT',
DEFAULT_REVISION: '0-0000000000000000'
};
export const LOG_STATUS_MESSAGE =
"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
export const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
export const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;

View file

@ -1,2 +0,0 @@
export * from './constants';
export * from './helpers/pkg';

View file

@ -1,9 +0,0 @@
{
"extends": "../../tsconfig.base",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.test.ts"]
}

View file

@ -1,9 +0,0 @@
{
"extends": "../../tsconfig.reference.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.test.ts"]
}

View file

@ -23,7 +23,7 @@
"build": "pnpm run build:js && pnpm run build:types"
},
"dependencies": {
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"debug": "^4.2.0",
"js-yaml": "3.14.0",

View file

@ -6,7 +6,7 @@ import mkdirp from 'mkdirp';
import buildDebug from 'debug';
import { folderExists, fileExists } from '@verdaccio/utils';
import { CHARACTER_ENCODING } from '@verdaccio/dev-commons';
import { CHARACTER_ENCODING } from '@verdaccio/commons-api';
const CONFIG_FILE = 'config.yaml';
const XDG = 'xdg';

View file

@ -3,7 +3,7 @@ import _ from 'lodash';
import buildDebug from 'debug';
import { generateRandomHexString, isObject } from '@verdaccio/utils';
import { APP_ERROR } from '@verdaccio/dev-commons';
import { APP_ERROR } from '@verdaccio/commons-api';
import {
PackageList,
Config as AppConfig,
@ -26,6 +26,8 @@ export type MatchedPackage = PackageAccess | void;
const debug = buildDebug('verdaccio:config');
export const WEB_TITLE = 'Verdaccio';
/**
* Coordinates the application configuration
*/

View file

@ -5,3 +5,4 @@ export * from './package-access';
export * from './parse';
export * from './uplinks';
export * from './security';
export * from './user';

View file

@ -10,6 +10,21 @@ export interface LegacyPackageList {
[key: string]: PackageAccess;
}
export const ROLES = {
$ALL: '$all',
ALL: 'all',
$AUTH: '$authenticated',
$ANONYMOUS: '$anonymous',
DEPRECATED_ALL: '@all',
DEPRECATED_AUTH: '@authenticated',
DEPRECATED_ANONYMOUS: '@anonymous',
};
export const PACKAGE_ACCESS = {
SCOPE: '@*/*',
ALL: '**',
};
export function normalizeUserList(groupsList: any): any {
const result: any[] = [];
if (_.isNil(groupsList)) {

View file

@ -1,6 +1,6 @@
import fs from 'fs';
import YAML from 'js-yaml';
import { APP_ERROR } from '@verdaccio/dev-commons';
import { APP_ERROR } from '@verdaccio/commons-api';
import { ConfigRuntime, ConfigYaml } from '@verdaccio/types';
export function parseConfigFile(configPath: string): ConfigRuntime {

View file

@ -5,6 +5,9 @@ import _ from 'lodash';
import { getMatchedPackagesSpec } from './package-access';
import { MatchedPackage } from './config';
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
export const DEFAULT_UPLINK = 'npmjs';
const BLACKLIST = {
all: true,
anonymous: true,

View file

@ -0,0 +1,51 @@
import { RemoteUser } from '@verdaccio/types';
import { ROLES } from './package-access';
/**
* All logged users will have by default the group $all and $authenticate
*/
export const defaultLoggedUserRoles = [
ROLES.$ALL,
ROLES.$AUTH,
ROLES.DEPRECATED_ALL,
ROLES.DEPRECATED_AUTH,
ROLES.ALL,
];
/**
*
*/
export const defaultNonLoggedUserRoles = [
ROLES.$ALL,
ROLES.$ANONYMOUS,
// groups without '$' are going to be deprecated eventually
ROLES.DEPRECATED_ALL,
ROLES.DEPRECATED_ANONYMOUS,
];
/**
* Create a RemoteUser object
* @return {Object} { name: xx, pluginGroups: [], real_groups: [] }
*/
export function createRemoteUser(name: string, pluginGroups: string[]): RemoteUser {
const isGroupValid: boolean = Array.isArray(pluginGroups);
const groups = (isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles]);
return {
name,
groups,
real_groups: pluginGroups,
};
}
/**
* Builds an anonymous remote user in case none is logged in.
* @return {Object} { name: xx, groups: [], real_groups: [] }
*/
export function createAnonymousRemoteUser(): RemoteUser {
return {
name: undefined,
groups: [...defaultNonLoggedUserRoles],
real_groups: [],
};
}

View file

@ -1,9 +1,15 @@
import path from 'path';
import _ from 'lodash';
import { DEFAULT_REGISTRY, DEFAULT_UPLINK, ROLES, WEB_TITLE } from '@verdaccio/dev-commons';
import { Config, defaultSecurity, parseConfigFile } from '../src';
import {
Config,
DEFAULT_REGISTRY,
DEFAULT_UPLINK,
defaultSecurity,
parseConfigFile,
ROLES,
WEB_TITLE,
} from '../src';
const resolveConf = (conf) => {
const { name, ext } = path.parse(conf);

View file

@ -1,9 +1,11 @@
import path from 'path';
import _ from 'lodash';
import { PACKAGE_ACCESS } from '@verdaccio/dev-commons';
import { getMatchedPackagesSpec, normalisePackageAccess } from '../src/package-access';
import {
getMatchedPackagesSpec,
normalisePackageAccess,
PACKAGE_ACCESS,
} from '../src/package-access';
import { parseConfigFile } from '../src';
describe('Package access utilities', () => {

View file

@ -1,4 +1,5 @@
import { spliceURL } from '../src/string';
import { createAnonymousRemoteUser, createRemoteUser, ROLES } from '../src';
describe('spliceURL', () => {
test('should splice two strings and generate a url', () => {
@ -12,4 +13,30 @@ describe('spliceURL', () => {
expect(url).toMatch('/-/static/logo.png');
});
describe('createRemoteUser and createAnonymousRemoteUser', () => {
test('should create a remote user with default groups', () => {
expect(createRemoteUser('12345', ['foo', 'bar'])).toEqual({
groups: [
'foo',
'bar',
ROLES.$ALL,
ROLES.$AUTH,
ROLES.DEPRECATED_ALL,
ROLES.DEPRECATED_AUTH,
ROLES.ALL,
],
name: '12345',
real_groups: ['foo', 'bar'],
});
});
test('should create a anonymous remote user with default groups', () => {
expect(createAnonymousRemoteUser()).toEqual({
groups: [ROLES.$ALL, ROLES.$ANONYMOUS, ROLES.DEPRECATED_ALL, ROLES.DEPRECATED_ANONYMOUS],
name: undefined,
real_groups: [],
});
});
});
});

View file

@ -11,7 +11,7 @@
"path": "../utils"
},
{
"path": "../commons"
"path": "../core/commons-api"
},
{
"path": "../logger"

View file

@ -3,6 +3,13 @@ import httpCodes from 'http-status-codes';
export const DEFAULT_MIN_LIMIT_PASSWORD = 3;
export const HEADER_TYPE = {
CONTENT_ENCODING: 'content-encoding',
CONTENT_TYPE: 'content-type',
CONTENT_LENGTH: 'content-length',
ACCEPT_ENCODING: 'accept-encoding',
};
export const HTTP_STATUS = {
OK: httpCodes.OK,
CREATED: httpCodes.CREATED,
@ -13,6 +20,7 @@ export const HTTP_STATUS = {
FORBIDDEN: httpCodes.FORBIDDEN,
NOT_FOUND: httpCodes.NOT_FOUND,
CONFLICT: httpCodes.CONFLICT,
NOT_IMPLEMENTED: httpCodes.NOT_IMPLEMENTED,
UNSUPPORTED_MEDIA: httpCodes.UNSUPPORTED_MEDIA_TYPE,
BAD_DATA: httpCodes.UNPROCESSABLE_ENTITY,
INTERNAL_ERROR: httpCodes.INTERNAL_SERVER_ERROR,
@ -20,6 +28,17 @@ export const HTTP_STATUS = {
LOOP_DETECTED: 508,
};
export const CHARACTER_ENCODING = {
UTF8: 'utf8',
};
export const ERROR_CODE = {
token_required: 'token is required',
};
export const TOKEN_BASIC = 'Basic';
export const TOKEN_BEARER = 'Bearer';
export const HEADERS = {
ACCEPT: 'Accept',
ACCEPT_ENCODING: 'Accept-Encoding',
@ -56,6 +75,13 @@ export const API_MESSAGE = {
LOGGED_OUT: 'Logged out',
};
export const SUPPORT_ERRORS = {
PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
TFA_DISABLED: 'the two-factor authentication is not yet supported',
STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
PARAMETERS_NOT_VALID: 'the parameters are not valid',
};
export const API_ERROR = {
PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>
`The provided password is too short. Please pick a password longer than ` +
@ -78,6 +104,7 @@ export const API_ERROR = {
NOT_FILE_UPLINK: "file doesn't exist on uplink",
MAX_USERS_REACHED: 'maximum amount of users reached',
VERSION_NOT_EXIST: "this version doesn't exist",
UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',
FILE_NOT_FOUND: 'File not found',
BAD_STATUS_CODE: 'bad status code',
PACKAGE_EXIST: 'this package is already present',
@ -91,6 +118,12 @@ export const API_ERROR = {
USERNAME_ALREADY_REGISTERED: 'username is already registered',
};
export const APP_ERROR = {
CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',
PROFILE_ERROR: 'profile unexpected error',
PASSWORD_VALIDATION: 'not valid password',
};
export type VerdaccioError = HttpError & { code: number };
function getError(code: number, message: string): VerdaccioError {
@ -140,3 +173,17 @@ export function getNotFound(customMessage?: string): VerdaccioError {
export function getCode(statusCode: number, customMessage: string): VerdaccioError {
return getError(statusCode, customMessage);
}
export const TIME_EXPIRATION_24H = '24h';
export const TIME_EXPIRATION_7D = '7d';
export const DIST_TAGS = 'dist-tags';
export const LATEST = 'latest';
export const USERS = 'users';
export const DEFAULT_USER = 'Anonymous';
export const LOG_STATUS_MESSAGE =
"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
export const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
export const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
export * from './helpers/pkg';

View file

@ -30,7 +30,7 @@
"lockfile": "1.0.4"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -28,7 +28,7 @@
"node": ">=10"
},
"dependencies": {
"@verdaccio/file-locking": "workspace:*",
"@verdaccio/file-locking": "workspace:10.0.0-beta",
"apache-md5": "1.1.2",
"bcryptjs": "2.4.3",
"http-errors": "1.8.0",
@ -36,7 +36,7 @@
},
"devDependencies": {
"@types/bcryptjs": "^2.4.2",
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -31,9 +31,9 @@
"node": ">=10"
},
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/file-locking": "workspace:*",
"@verdaccio/streams": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/file-locking": "workspace:10.0.0-beta",
"@verdaccio/streams": "workspace:10.0.0-beta",
"async": "^3.2.0",
"debug": "^4.1.1",
"level": "5.0.1",
@ -42,7 +42,7 @@
},
"devDependencies": {
"@types/minimatch": "^3.0.3",
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"minimatch": "^3.0.4",
"rmdir-sync": "^1.0.1"
},

View file

@ -35,7 +35,7 @@
"marked": "1.1.1"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -23,7 +23,7 @@
"access": "public"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -16,7 +16,7 @@
"homepage": "https://verdaccio.org",
"dependencies": {
"debug": "^4.2.0",
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"handlebars": "4.5.3",
"request": "2.87.0",
@ -25,9 +25,8 @@
"devDependencies": {
"@verdaccio/auth": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/types": "workspace:*",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/types": "workspace:10.0.0-beta",
"nock": "^13.0.4"
},
"scripts": {

View file

@ -1,7 +1,6 @@
import nock from 'nock';
import { createRemoteUser } from '@verdaccio/utils';
import { Config } from '@verdaccio/types';
import { parseConfigFile } from '@verdaccio/config';
import { parseConfigFile, createRemoteUser } from '@verdaccio/config';
import { notify } from '../src/notify';
import { parseConfigurationFile } from './__helper';

View file

@ -19,9 +19,6 @@
{
"path": "../logger"
},
{
"path": "../utils"
},
{
"path": "../core/commons-api"
}

View file

@ -13,7 +13,6 @@
"url": "git://github.com/verdaccio/verdaccio"
},
"dependencies": {
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"lodash": "4.17.15",
"debug": "^4.1.1"
@ -21,8 +20,8 @@
"devDependencies": {
"@verdaccio/mock": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/types": "workspace:*"
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/types": "workspace:10.0.0-beta"
},
"homepage": "https://verdaccio.org",
"license": "MIT",

View file

@ -4,10 +4,11 @@ import buildDebug from 'debug';
import { logger } from '@verdaccio/logger';
import { Config, IPlugin } from '@verdaccio/types';
import { MODULE_NOT_FOUND } from '@verdaccio/dev-commons';
const debug = buildDebug('verdaccio:plugin:loader');
export const MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';
/**
* Requires a module.
* @param {*} path the module's path

View file

@ -21,9 +21,6 @@
},
{
"path": "../core/commons-api"
},
{
"path": "../common"
}
]
}

View file

@ -23,8 +23,7 @@
"build": "pnpm run build:js && pnpm run build:types"
},
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"dayjs": "1.8.36",
"fast-safe-stringify": "2.0.7",
"kleur": "3.0.3",

View file

@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/pino": "^6.3.3",
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"gitHead": "7c246ede52ff717707fcae66dd63fc4abd536982"
}

View file

@ -22,8 +22,7 @@
"build": "pnpm run build:js && pnpm run build:types"
},
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"@verdaccio/auth": "workspace:5.0.0-alpha.0",

View file

@ -8,6 +8,12 @@ import {
stringToMD5,
ErrorCode,
} from '@verdaccio/utils';
import { NextFunction, Request, Response } from 'express';
import { Config, Package, RemoteUser, Logger } from '@verdaccio/types';
import { logger } from '@verdaccio/logger';
import { IAuth } from '@verdaccio/auth';
import {
API_ERROR,
HEADER_TYPE,
@ -15,14 +21,8 @@ import {
HTTP_STATUS,
TOKEN_BASIC,
TOKEN_BEARER,
} from '@verdaccio/dev-commons';
import { NextFunction, Request, Response } from 'express';
import { Config, Package, RemoteUser, Logger } from '@verdaccio/types';
import { logger } from '@verdaccio/logger';
import { IAuth } from '@verdaccio/auth';
import { VerdaccioError } from '@verdaccio/commons-api';
VerdaccioError,
} from '@verdaccio/commons-api';
import { HttpError } from 'http-errors';
export type $RequestExtend = Request & { remote_user?: RemoteUser; log: Logger };

View file

@ -23,7 +23,7 @@
"build": "pnpm run build:js && pnpm run build:types"
},
"dependencies": {
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"fs-extra": "^8.1.0",
@ -34,7 +34,6 @@
"verdaccio": "^4.8.1"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
},
"gitHead": "7c246ede52ff717707fcae66dd63fc4abd536982"
"@verdaccio/types": "workspace:10.0.0-beta"
}
}

View file

@ -8,7 +8,7 @@ import {
HEADERS,
HTTP_STATUS,
TOKEN_BEARER,
} from '@verdaccio/dev-commons';
} from '@verdaccio/commons-api';
import { buildToken, encodeScopedUri } from '@verdaccio/utils';
import { generateRandomHexString } from '@verdaccio/utils';
import { Package } from '@verdaccio/types';

View file

@ -2,7 +2,7 @@ import assert from 'assert';
import _ from 'lodash';
import buildDebug from 'debug';
import { API_MESSAGE, HEADERS, HTTP_STATUS, TOKEN_BASIC } from '@verdaccio/dev-commons';
import { API_MESSAGE, HEADERS, HTTP_STATUS, TOKEN_BASIC } from '@verdaccio/commons-api';
import { buildToken } from '@verdaccio/utils';
import smartRequest, { PromiseAssert } from './request';

View file

@ -1,7 +1,7 @@
import assert from 'assert';
import { fork } from 'child_process';
import { HTTP_STATUS } from '@verdaccio/dev-commons';
import { HTTP_STATUS } from '@verdaccio/commons-api';
import { CREDENTIALS } from './constants';
import { IVerdaccioConfig, IServerProcess } from './types';

View file

@ -1,6 +1,5 @@
import _ from 'lodash';
import { HTTP_STATUS } from '@verdaccio/dev-commons';
import { VerdaccioError } from '@verdaccio/commons-api';
import { HTTP_STATUS, VerdaccioError } from '@verdaccio/commons-api';
import smartRequest, { PromiseAssert } from '../src/request';
import { mockServer } from '../src/mock';

View file

@ -8,7 +8,7 @@
"exclude": ["src/**/*.test.ts"],
"references": [
{
"path": "../commons"
"path": "../core/commons-api"
},
{
"path": "../utils"

View file

@ -1,5 +1,5 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
collectCoverage: true,
collectCoverage: false,
});

View file

@ -23,11 +23,10 @@
},
"license": "MIT",
"dependencies": {
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/server": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"lodash": "^4.17.20",
"debug": "^4.2.0",
"core-js": "^3.6.5",
@ -35,7 +34,7 @@
},
"devDependencies": {
"@verdaccio/mock": "workspace:5.0.0-alpha.0",
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"publishConfig": {
"access": "public"

View file

@ -14,10 +14,14 @@ import {
HttpsConfKeyCert,
HttpsConfPfx,
} from '@verdaccio/types';
import { API_ERROR, certPem, csrPem, keyPem } from '@verdaccio/dev-commons';
import { API_ERROR } from '@verdaccio/commons-api';
import server from '@verdaccio/server';
import { logger } from '@verdaccio/logger';
export const keyPem = 'verdaccio-key.pem';
export const certPem = 'verdaccio-cert.pem';
export const csrPem = 'verdaccio-csr.pem';
import { getListListenAddresses, resolveConfigPath } from './cli-utils';
import { displayExperimentsInfoBox } from './experiments';

View file

@ -1,11 +1,52 @@
import path from 'path';
import semver from 'semver';
import { parseAddress } from '@verdaccio/utils';
import { DEFAULT_PORT } from '@verdaccio/dev-commons';
const logger = require('@verdaccio/logger');
export const DEFAULT_PORT = '4873';
export const DEFAULT_PROTOCOL = 'http';
export const DEFAULT_DOMAIN = 'localhost';
/**
* Parse an internet address
* Allow:
- https:localhost:1234 - protocol + host + port
- localhost:1234 - host + port
- 1234 - port
- http::1234 - protocol + port
- https://localhost:443/ - full url + https
- http://[::1]:443/ - ipv6
- unix:/tmp/http.sock - unix sockets
- https://unix:/tmp/http.sock - unix sockets (https)
* @param {*} urlAddress the internet address definition
* @return {Object|Null} literal object that represent the address parsed
*/
export function parseAddress(urlAddress: any): any {
//
// TODO: refactor it to something more reasonable?
//
// protocol : // ( host )|( ipv6 ): port /
let urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
if (urlPattern) {
return {
proto: urlPattern[2] || DEFAULT_PROTOCOL,
host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,
port: urlPattern[8] || DEFAULT_PORT,
};
}
urlPattern = /^((https?):(\/\/)?)?unix:(.*)$/.exec(urlAddress);
if (urlPattern) {
return {
proto: urlPattern[2] || DEFAULT_PROTOCOL,
path: urlPattern[4],
};
}
return null;
}
export const resolveConfigPath = function (storageLocation: string, file: string) {
return path.resolve(path.dirname(storageLocation), file);
};

View file

@ -1,6 +1,5 @@
import { certPem, csrPem, keyPem } from '@verdaccio/dev-commons';
import { resolveConfigPath } from './cli-utils';
import { certPem, csrPem, keyPem } from './bootstrap';
const logger = require('@verdaccio/logger');

View file

@ -4,12 +4,12 @@ import fs from 'fs';
import selfsigned from 'selfsigned';
import { configExample } from '@verdaccio/mock';
import { DEFAULT_DOMAIN, DEFAULT_PROTOCOL } from '@verdaccio/dev-commons';
import { parseConfigFile } from '@verdaccio/config';
import { logger } from '@verdaccio/logger';
import { startVerdaccio } from '../src';
import { DEFAULT_DOMAIN, DEFAULT_PROTOCOL } from '../src/cli-utils';
jest.mock('@verdaccio/logger', () => ({
setup: jest.fn(),

View file

@ -1,6 +1,10 @@
import _ from 'lodash';
import { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '@verdaccio/dev-commons';
import { getListListenAddresses } from '../src/cli-utils';
import {
DEFAULT_DOMAIN,
DEFAULT_PORT,
DEFAULT_PROTOCOL,
getListListenAddresses,
} from '../src/cli-utils';
jest.mock('@verdaccio/logger', () => ({
setup: jest.fn(),

View file

@ -1,7 +1,5 @@
import _ from 'lodash';
import { DEFAULT_DOMAIN, DEFAULT_PORT } from '@verdaccio/dev-commons';
import { parseAddress as parse } from '../src/utils';
import { DEFAULT_DOMAIN, DEFAULT_PORT, parseAddress } from '../src/cli-utils';
describe('Parse listen address', () => {
const useCases: any[] = [];
@ -32,7 +30,7 @@ describe('Parse listen address', () => {
addTest('unix:1234', 'http', 'unix', '1234'); // not unix socket
test.each(useCases)(`should parse (%s - %s - %s - %s)`, (uri, proto, host, port) => {
const parsed = parse(uri);
const parsed = parseAddress(uri);
if (_.isNull(proto)) {
expect(parsed).toBeNull();

View file

@ -8,7 +8,7 @@
"exclude": ["src/**/*.test.ts"],
"references": [
{
"path": "../commons"
"path": "../core/commons-api"
},
{
"path": "../logger"

View file

@ -25,12 +25,12 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"activedirectory2": "^1.3.0"
},
"devDependencies": {
"@types/activedirectory2": "^1.2.1",
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -27,7 +27,7 @@
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"nock": "^12.0.3",
"body-parser": "^1.19.0",
"supertest": "^4.0.2"

View file

@ -22,10 +22,10 @@
"main": "build/index.js",
"types": "build/src/index.d.ts",
"dependencies": {
"@verdaccio/commons-api": "workspace:*"
"@verdaccio/commons-api": "workspace:10.0.0-beta"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -22,12 +22,12 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/streams": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/streams": "workspace:10.0.0-beta",
"aws-sdk": "^2.607.0"
},
"devDependencies": {
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"recursive-readdir": "2.2.2"
},
"scripts": {

View file

@ -26,10 +26,10 @@
"@google-cloud/datastore": "^6.2.0",
"@google-cloud/storage": "^5.3.0",
"@verdaccio/commons-api": "^9.7.1",
"@verdaccio/streams": "workspace:*"
"@verdaccio/streams": "workspace:10.0.0-beta"
},
"devDependencies": {
"@verdaccio/types": "workspace:*",
"@verdaccio/types": "workspace:10.0.0-beta",
"memory-fs": "0.5.0"
},
"optionalDependencies": {

View file

@ -22,12 +22,12 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/streams": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/streams": "workspace:10.0.0-beta",
"memory-fs": "^0.5.0"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
"@verdaccio/types": "workspace:10.0.0-beta"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -23,17 +23,17 @@
"build": "pnpm run build:js && pnpm run build:types"
},
"dependencies": {
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/local-storage": "workspace:*",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/local-storage": "workspace:10.0.0-beta",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/streams": "workspace:*",
"@verdaccio/streams": "workspace:10.0.0-beta",
"@verdaccio/utils": "workspace:5.0.0-alpha.0",
"JSONStream": "1.3.5",
"lodash": "^4.17.20",
"request": "2.87.0"
},
"devDependencies": {
"@verdaccio/types": "workspace:*"
},
"gitHead": "7c246ede52ff717707fcae66dd63fc4abd536982"
"@verdaccio/types": "workspace:10.0.0-beta"
}
}

View file

@ -15,7 +15,7 @@ import {
API_ERROR,
HEADER_TYPE,
CHARACTER_ENCODING,
} from '@verdaccio/dev-commons';
} from '@verdaccio/commons-api';
import {
Config,
Callback,

View file

@ -1,13 +1,8 @@
import { buildToken } from '@verdaccio/utils';
import {
ERROR_CODE,
TOKEN_BASIC,
TOKEN_BEARER,
DEFAULT_REGISTRY,
HEADERS,
} from '@verdaccio/dev-commons';
import { ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, HEADERS } from '@verdaccio/commons-api';
import { setup } from '@verdaccio/logger';
import { DEFAULT_REGISTRY } from '@verdaccio/config';
import { ProxyStorage } from '../src/up-storage';

View file

@ -14,11 +14,14 @@
"path": "../core/streams"
},
{
"path": "../commons"
"path": "../core/commons-api"
},
{
"path": "../logger"
},
{
"path": "../config"
},
{
"path": "../utils"
}

View file

@ -18,7 +18,7 @@
"@verdaccio/api": "workspace:5.0.0-alpha.0",
"@verdaccio/auth": "workspace:5.0.0-alpha.0",
"@verdaccio/config": "workspace:5.0.0-alpha.0",
"@verdaccio/dev-commons": "workspace:5.0.0-alpha.0",
"@verdaccio/commons-api": "workspace:10.0.0-beta",
"@verdaccio/loaders": "workspace:5.0.0-alpha.0",
"@verdaccio/logger": "workspace:5.0.0-alpha.0",
"@verdaccio/middleware": "workspace:5.0.0-alpha.0",
@ -31,12 +31,11 @@
"lodash": "4.17.15"
},
"devDependencies": {
"@verdaccio/commons-api": "workspace:*",
"@verdaccio/mock": "workspace:5.0.0-alpha.0",
"@verdaccio/proxy": "workspace:5.0.0-alpha.0",
"http-errors": "1.7.3",
"request": "2.87.0",
"verdaccio": "~4.4.4"
"verdaccio": "4.8.1"
},
"scripts": {
"clean": "rimraf ./build",

View file

@ -9,7 +9,7 @@ import { loadPlugin } from '@verdaccio/loaders';
import { Auth } from '@verdaccio/auth';
import apiEndpoint from '@verdaccio/api';
import { ErrorCode } from '@verdaccio/utils';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/dev-commons';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/commons-api';
import { Config as AppConfig } from '@verdaccio/config';
import { webAPI, renderWebMiddleware } from '@verdaccio/web';

View file

@ -8,7 +8,7 @@ import {
HEADER_TYPE,
API_MESSAGE,
TOKEN_BEARER,
} from '@verdaccio/dev-commons';
} from '@verdaccio/commons-api';
import { buildToken, encodeScopedUri } from '@verdaccio/utils';
import { setup, logger } from '@verdaccio/logger';

View file

@ -2,7 +2,7 @@ import path from 'path';
import express from 'express';
import request from 'request';
import { API_ERROR } from '@verdaccio/dev-commons';
import { API_ERROR } from '@verdaccio/commons-api';
import { parseConfigFile } from '@verdaccio/config';
import { setup } from '@verdaccio/logger';

View file

@ -8,7 +8,7 @@ import {
TOKEN_BEARER,
TOKEN_BASIC,
API_ERROR,
} from '@verdaccio/dev-commons';
} from '@verdaccio/commons-api';
import { mockServer, generateRamdonStorage } from '@verdaccio/mock';
import { buildUserBuffer, buildToken } from '@verdaccio/utils';
import {

View file

@ -5,7 +5,7 @@ import { setup, logger } from '@verdaccio/logger';
setup([]);
import { HEADERS, HTTP_STATUS } from '@verdaccio/dev-commons';
import { HEADERS, HTTP_STATUS } from '@verdaccio/commons-api';
import { generateRamdonStorage, mockServer, configExample, DOMAIN_SERVERS } from '@verdaccio/mock';
import endPointAPI from '../../src';

View file

@ -2,7 +2,7 @@ import path from 'path';
import request from 'supertest';
import { mockServer } from '@verdaccio/mock';
import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/dev-commons';
import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/commons-api';
import { setup, logger } from '@verdaccio/logger';
import {

View file

@ -5,7 +5,7 @@ import { Config as AppConfig } from '@verdaccio/config';
import { Config, UpLinkConf } from '@verdaccio/types';
import { VerdaccioError } from '@verdaccio/commons-api';
import { IProxy } from '@verdaccio/proxy';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/dev-commons';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/commons-api';
import { mockServer, configExample, DOMAIN_SERVERS } from '@verdaccio/mock';
import { ProxyStorage } from '@verdaccio/proxy';
import { setup, logger } from '@verdaccio/logger';

View file

@ -6,7 +6,7 @@ import { Storage } from '@verdaccio/store';
import { IStorageHandler } from '@verdaccio/store';
import { Config } from '@verdaccio/types';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/dev-commons';
import { API_ERROR, HTTP_STATUS } from '@verdaccio/commons-api';
import { mockServer, configExample, DOMAIN_SERVERS, generateRamdonStorage } from '@verdaccio/mock';
import { setup, logger } from '@verdaccio/logger';

Some files were not shown because too many files have changed in this diff Show more