mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 03:19:36 +01:00
chore: eslint config module (#2263)
* build: eslint config as package * chore: fix formatting
This commit is contained in:
parent
d2c65da9c7
commit
f3f00052d8
102
.eslintrc
102
.eslintrc
@ -1,102 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"google",
|
||||
"plugin:react/recommended",
|
||||
"plugin:jest/recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:import/typescript",
|
||||
"plugin:jsx-a11y/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"plugins": ["import", "jest", "jsx-a11y", "react-hooks"],
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"jest": true
|
||||
},
|
||||
"globals": {
|
||||
"__APP_VERSION__": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"allowImportExportEverywhere": true,
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 11,
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true,
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"node": {
|
||||
"extensions": [".js", ".jsx", ".ts", ".tsx"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"rules": {
|
||||
"curly": ["error", "all"],
|
||||
"react/prop-types": 0,
|
||||
"jest/no-export": 0,
|
||||
"jest/no-test-callback": 0,
|
||||
"jest/expect-expect": 0,
|
||||
"jest/no-try-expect": 0,
|
||||
"jest/no-done-callback": "off",
|
||||
"jest/no-conditional-expect": "off",
|
||||
"keyword-spacing": "off",
|
||||
"no-tabs": "off",
|
||||
"no-useless-escape": "off",
|
||||
"padded-blocks": "off",
|
||||
"require-jsdoc": "off",
|
||||
"valid-jsdoc": "off",
|
||||
"import/order": ["error"],
|
||||
"eol-last": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
||||
"no-trailing-spaces": "error",
|
||||
"camelcase": "off",
|
||||
"guard-for-in": "error",
|
||||
"new-cap": "error",
|
||||
"max-len": ["error", 100],
|
||||
"no-console": ["error", { "allow": ["warn"] }],
|
||||
"no-constant-condition": "error",
|
||||
"no-debugger": "error",
|
||||
"no-empty": "error",
|
||||
"no-fallthrough": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-new-require": "error",
|
||||
"no-undef": "error",
|
||||
"no-unreachable": "error",
|
||||
"no-var": "error",
|
||||
"one-var": "error",
|
||||
"prefer-rest-params": "error",
|
||||
"prefer-spread": "error",
|
||||
"handle-callback-err": 0,
|
||||
"prefer-const": 0,
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/ban-ts-ignore": 0,
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/no-inferrable-types": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/no-this-alias": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/array-type": ["error"],
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/indent": 0,
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/ban-types": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
|
||||
// rules to fix
|
||||
"no-unused-vars": ["warn", { "vars": "all", "args": "none" }],
|
||||
"jest/no-identical-title": ["warn"],
|
||||
"prefer-promise-reject-errors": ["warn"],
|
||||
"jest/no-disabled-tests": ["warn"],
|
||||
"jest/no-commented-out-tests": ["warn"],
|
||||
"@typescript-eslint/prefer-optional-chain": ["warn"],
|
||||
"@typescript-eslint/explicit-member-accessibility": ["warn"],
|
||||
"@typescript-eslint/no-unused-vars": ["warn"]
|
||||
}
|
||||
}
|
3
.eslintrc.js
Normal file
3
.eslintrc.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: ['@verdaccio/eslint-config'],
|
||||
};
|
@ -10,7 +10,7 @@ let _localMemory = require('./local-memory');
|
||||
let _localMemory2 = _interopRequireDefault(_localMemory);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : { default: obj };
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
exports.LocalMemory = _localMemory2.default;
|
||||
|
@ -9,7 +9,7 @@ let _memoryHandler = require('./memory-handler');
|
||||
let _memoryHandler2 = _interopRequireDefault(_memoryHandler);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : { default: obj };
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
const DEFAULT_LIMIT = 1000;
|
||||
@ -43,8 +43,8 @@ class LocalMemory {
|
||||
cb(null);
|
||||
} else {
|
||||
this.logger.info(
|
||||
{ limit: this.limit },
|
||||
'Storage memory has reached limit of @{limit} packages'
|
||||
{limit: this.limit},
|
||||
'Storage memory has reached limit of @{limit} packages',
|
||||
);
|
||||
cb(new Error('Storage memory has reached limit of limit packages'));
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ let _memoryFs2 = _interopRequireDefault(_memoryFs);
|
||||
let _streams = require('@verdaccio/streams');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : { default: obj };
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
@ -111,8 +111,8 @@ class MemoryHandler {
|
||||
const uploadStream = new _streams.UploadTarball();
|
||||
const temporalName = `/${name}`;
|
||||
|
||||
process.nextTick(function () {
|
||||
fs.exists(temporalName, function (exists) {
|
||||
process.nextTick(function() {
|
||||
fs.exists(temporalName, function(exists) {
|
||||
if (exists) {
|
||||
return uploadStream.emit('error', fSError(fileExist));
|
||||
}
|
||||
@ -122,7 +122,7 @@ class MemoryHandler {
|
||||
|
||||
uploadStream.pipe(file);
|
||||
|
||||
uploadStream.done = function () {
|
||||
uploadStream.done = function() {
|
||||
const onEnd = function onEnd() {
|
||||
uploadStream.emit('success');
|
||||
};
|
||||
@ -130,7 +130,7 @@ class MemoryHandler {
|
||||
uploadStream.on('end', onEnd);
|
||||
};
|
||||
|
||||
uploadStream.abort = function () {
|
||||
uploadStream.abort = function() {
|
||||
uploadStream.emit('error', fSError('transmision aborted', 400));
|
||||
file.end();
|
||||
};
|
||||
@ -150,8 +150,8 @@ class MemoryHandler {
|
||||
|
||||
const readTarballStream = new _streams.ReadTarball();
|
||||
|
||||
process.nextTick(function () {
|
||||
fs.exists(pathName, function (exists) {
|
||||
process.nextTick(function() {
|
||||
fs.exists(pathName, function(exists) {
|
||||
if (!exists) {
|
||||
readTarballStream.emit('error', noPackageFoundError());
|
||||
} else {
|
||||
@ -164,7 +164,7 @@ class MemoryHandler {
|
||||
readTarballStream.emit('error', error);
|
||||
});
|
||||
|
||||
readTarballStream.abort = function () {
|
||||
readTarballStream.abort = function() {
|
||||
readStream.destroy(fSError('read has been aborted', 400));
|
||||
};
|
||||
}
|
||||
|
24
package.json
24
package.json
@ -39,8 +39,8 @@
|
||||
"@babel/register": "7.13.14",
|
||||
"@babel/runtime": "7.13.10",
|
||||
"@changesets/changelog-github": "^0.2.8",
|
||||
"@changesets/cli": "^2.15.0",
|
||||
"@changesets/get-dependents-graph": "^1.2.0",
|
||||
"@changesets/cli": "^2.16.0",
|
||||
"@changesets/get-dependents-graph": "^1.2.1",
|
||||
"@commitlint/cli": "8.3.5",
|
||||
"@commitlint/config-conventional": "8.2.0",
|
||||
"@octokit/rest": "17.0.0",
|
||||
@ -71,6 +71,7 @@
|
||||
"@typescript-eslint/parser": "4.13.0",
|
||||
"@verdaccio/types": "workspace:*",
|
||||
"@verdaccio/ui-theme": "workspace:*",
|
||||
"@verdaccio/eslint-config": "workspace:*",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-jest": "26.6.3",
|
||||
@ -78,20 +79,21 @@
|
||||
"babel-plugin-emotion": "11.0.0",
|
||||
"codecov": "3.8.1",
|
||||
"concurrently": "^5.3.0",
|
||||
"core-js": "^3.10.1",
|
||||
"core-js": "^3.12.1",
|
||||
"cross-env": "7.0.3",
|
||||
"detect-secrets": "1.0.6",
|
||||
"eslint": "7.19.0",
|
||||
"eslint": "7.26.0",
|
||||
"eslint-config-google": "0.14.0",
|
||||
"eslint-config-prettier": "7.2.0",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-babel": "5.3.1",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"eslint-plugin-jest": "24.1.3",
|
||||
"eslint-plugin-import": "2.23.2",
|
||||
"eslint-plugin-jest": "24.3.6",
|
||||
"eslint-plugin-jsx-a11y": "6.4.1",
|
||||
"eslint-plugin-react": "7.22.0",
|
||||
"eslint-plugin-react": "7.23.2",
|
||||
"eslint-plugin-react-hooks": "4.2.0",
|
||||
"eslint-plugin-simple-import-sort": "7.0.0",
|
||||
"eslint-plugin-verdaccio": "9.6.1",
|
||||
"eslint-plugin-verdaccio": "10.0.0",
|
||||
"eslint-plugin-prettier": "3.4.0",
|
||||
"fs-extra": "9.1.0",
|
||||
"get-stdin": "7.0.0",
|
||||
"husky": "2.7.0",
|
||||
@ -107,14 +109,14 @@
|
||||
"nock": "12.0.3",
|
||||
"nodemon": "^2.0.7",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.2.1",
|
||||
"prettier": "2.3.0",
|
||||
"rimraf": "3.0.2",
|
||||
"selfsigned": "1.10.8",
|
||||
"supertest": "4.0.2",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.2.4",
|
||||
"update-ts-references": "2.3.0",
|
||||
"verdaccio": "^5.0.1",
|
||||
"verdaccio": "^5.0.4",
|
||||
"verdaccio-audit": "workspace:*",
|
||||
"verdaccio-auth-memory": "workspace:*",
|
||||
"verdaccio-htpasswd": "workspace:*",
|
||||
|
@ -41,7 +41,7 @@ export default function (route, auth, storage): void {
|
||||
route.get('/-/v1/search', (req, res) => {
|
||||
// TODO: implement proper result scoring weighted by quality, popularity and
|
||||
// maintenance query parameters
|
||||
let [text, size, from /* , quality, popularity, maintenance */] = [
|
||||
let [text, size, from] = [
|
||||
'text',
|
||||
'size',
|
||||
'from' /* , 'quality', 'popularity', 'maintenance' */,
|
||||
|
@ -5,10 +5,11 @@ import { $ResponseExtend, $RequestExtend } from '../../types/custom';
|
||||
import { initializeServer, publishTaggedVersion, publishVersion } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
|
||||
jest.mock('@verdaccio/auth', () => ({
|
||||
|
@ -11,10 +11,11 @@ import { $ResponseExtend, $RequestExtend } from '../../types/custom';
|
||||
import { initializeServer, publishVersion } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
|
||||
jest.setTimeout(50000000);
|
||||
|
@ -16,10 +16,11 @@ import { $RequestExtend, $ResponseExtend } from '../../types/custom';
|
||||
import { initializeServer } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
|
||||
const mockAuthenticate = jest.fn(() => (_name, _password, callback): void => {
|
||||
@ -53,10 +54,11 @@ describe('user', () => {
|
||||
|
||||
test('should test add a new user', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
|
||||
mockAddUser.mockImplementationOnce(() => (_name, _password, callback): void => {
|
||||
@ -85,10 +87,11 @@ describe('user', () => {
|
||||
|
||||
test('should test fails on add a existing user with login', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
supertest(await initializeServer('user.yaml'))
|
||||
.put('/-/user/org.couchdb.user:jotaNew')
|
||||
@ -124,10 +127,11 @@ describe('user', () => {
|
||||
|
||||
test('should test fails add a new user with missing name', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
mockAddUser.mockImplementationOnce(() => (_name, _password, callback): void => {
|
||||
return callback(getBadRequest(API_ERROR.USERNAME_PASSWORD_REQUIRED));
|
||||
@ -153,10 +157,11 @@ describe('user', () => {
|
||||
|
||||
test('should test fails add a new user with missing password', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: undefined };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
const credentialsShort = _.cloneDeep(credentials);
|
||||
delete credentialsShort.password;
|
||||
@ -181,10 +186,11 @@ describe('user', () => {
|
||||
|
||||
test('should test fails add a new user with wrong password', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test' };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test' };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
mockAuthenticate.mockImplementationOnce(() => (_name, _password, callback): void => {
|
||||
return callback(getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||
@ -210,10 +216,11 @@ describe('user', () => {
|
||||
|
||||
test('should be able to logout an user', async (done) => {
|
||||
mockApiJWTmiddleware.mockImplementationOnce(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test' };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'test' };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
mockAuthenticate.mockImplementationOnce(() => (_name, _password, callback): void => {
|
||||
return callback(getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||
|
@ -6,10 +6,11 @@ import { $RequestExtend, $ResponseExtend } from '../../types/custom';
|
||||
import { initializeServer } from './_helper';
|
||||
|
||||
const mockApiJWTmiddleware = jest.fn(
|
||||
() => (req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
() =>
|
||||
(req: $RequestExtend, res: $ResponseExtend, _next): void => {
|
||||
req.remote_user = { name: 'foo', groups: [], real_groups: [] };
|
||||
_next();
|
||||
}
|
||||
);
|
||||
|
||||
jest.mock('@verdaccio/auth', () => ({
|
||||
|
@ -31,7 +31,7 @@ describe('HTPasswd', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = new HTPasswd(getDefaultConfig(), (stuff as unknown) as VerdaccioConfigApp);
|
||||
wrapper = new HTPasswd(getDefaultConfig(), stuff as unknown as VerdaccioConfigApp);
|
||||
jest.resetModules();
|
||||
|
||||
crypto.randomBytes = jest.fn(() => {
|
||||
|
@ -59,86 +59,84 @@ export function loadPlugin<T extends IPlugin<T>>(
|
||||
sanityCheck: any,
|
||||
prefix: string = 'verdaccio'
|
||||
): any[] {
|
||||
return Object.keys(pluginConfigs).map(
|
||||
(pluginId: string): IPlugin<T> => {
|
||||
let plugin;
|
||||
return Object.keys(pluginConfigs).map((pluginId: string): IPlugin<T> => {
|
||||
let plugin;
|
||||
|
||||
const localPlugin = Path.resolve(__dirname + '/../plugins', pluginId);
|
||||
// try local plugins first
|
||||
plugin = tryLoad(localPlugin);
|
||||
const localPlugin = Path.resolve(__dirname + '/../plugins', pluginId);
|
||||
// try local plugins first
|
||||
plugin = tryLoad(localPlugin);
|
||||
|
||||
// try the external plugin directory
|
||||
if (plugin === null && config.plugins) {
|
||||
const pluginDir = config.plugins;
|
||||
const externalFilePlugin = Path.resolve(pluginDir, pluginId);
|
||||
plugin = tryLoad(externalFilePlugin);
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `${prefix}-${pluginId}`));
|
||||
// compatibility for old sinopia plugins
|
||||
if (!plugin) {
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `sinopia-${pluginId}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
// try the external plugin directory
|
||||
if (plugin === null && config.plugins) {
|
||||
const pluginDir = config.plugins;
|
||||
const externalFilePlugin = Path.resolve(pluginDir, pluginId);
|
||||
plugin = tryLoad(externalFilePlugin);
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
plugin = tryLoad(`${prefix}-${pluginId}`);
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `${prefix}-${pluginId}`));
|
||||
// compatibility for old sinopia plugins
|
||||
if (!plugin) {
|
||||
plugin = tryLoad(`sinopia-${pluginId}`);
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `sinopia-${pluginId}`));
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin === null) {
|
||||
plugin = tryLoad(pluginId);
|
||||
}
|
||||
|
||||
// relative to config path
|
||||
if (plugin === null && pluginId.match(/^\.\.?($|\/)/)) {
|
||||
plugin = tryLoad(Path.resolve(Path.dirname(config.config_path), pluginId));
|
||||
}
|
||||
|
||||
if (plugin === null) {
|
||||
logger.error(
|
||||
{ content: pluginId, prefix },
|
||||
'plugin not found. try npm install @{prefix}-@{content}'
|
||||
);
|
||||
throw Error(`
|
||||
${prefix}-${pluginId} plugin not found. try "npm install ${prefix}-${pluginId}"`);
|
||||
}
|
||||
|
||||
if (!isValid(plugin)) {
|
||||
logger.error(
|
||||
{ content: pluginId },
|
||||
'@{prefix}-@{content} plugin does not have the right code structure'
|
||||
);
|
||||
throw Error(`"${pluginId}" plugin does not have the right code structure`);
|
||||
}
|
||||
|
||||
/* eslint new-cap:off */
|
||||
try {
|
||||
plugin = isES6(plugin)
|
||||
? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params)
|
||||
: plugin(pluginConfigs[pluginId], params);
|
||||
} catch (error) {
|
||||
plugin = null;
|
||||
logger.error({ error, pluginId }, 'error loading a plugin @{pluginId}: @{error}');
|
||||
}
|
||||
/* eslint new-cap:off */
|
||||
|
||||
if (plugin === null || !sanityCheck(plugin)) {
|
||||
logger.error(
|
||||
{ content: pluginId, prefix },
|
||||
"@{prefix}-@{content} doesn't look like a valid plugin"
|
||||
);
|
||||
throw Error(`sanity check has failed, "${pluginId}" is not a valid plugin`);
|
||||
}
|
||||
|
||||
debug('Plugin successfully loaded: %o-%o', pluginId, prefix);
|
||||
return plugin;
|
||||
}
|
||||
);
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
plugin = tryLoad(`${prefix}-${pluginId}`);
|
||||
// compatibility for old sinopia plugins
|
||||
if (!plugin) {
|
||||
plugin = tryLoad(`sinopia-${pluginId}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin === null) {
|
||||
plugin = tryLoad(pluginId);
|
||||
}
|
||||
|
||||
// relative to config path
|
||||
if (plugin === null && pluginId.match(/^\.\.?($|\/)/)) {
|
||||
plugin = tryLoad(Path.resolve(Path.dirname(config.config_path), pluginId));
|
||||
}
|
||||
|
||||
if (plugin === null) {
|
||||
logger.error(
|
||||
{ content: pluginId, prefix },
|
||||
'plugin not found. try npm install @{prefix}-@{content}'
|
||||
);
|
||||
throw Error(`
|
||||
${prefix}-${pluginId} plugin not found. try "npm install ${prefix}-${pluginId}"`);
|
||||
}
|
||||
|
||||
if (!isValid(plugin)) {
|
||||
logger.error(
|
||||
{ content: pluginId },
|
||||
'@{prefix}-@{content} plugin does not have the right code structure'
|
||||
);
|
||||
throw Error(`"${pluginId}" plugin does not have the right code structure`);
|
||||
}
|
||||
|
||||
/* eslint new-cap:off */
|
||||
try {
|
||||
plugin = isES6(plugin)
|
||||
? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params)
|
||||
: plugin(pluginConfigs[pluginId], params);
|
||||
} catch (error) {
|
||||
plugin = null;
|
||||
logger.error({ error, pluginId }, 'error loading a plugin @{pluginId}: @{error}');
|
||||
}
|
||||
/* eslint new-cap:off */
|
||||
|
||||
if (plugin === null || !sanityCheck(plugin)) {
|
||||
logger.error(
|
||||
{ content: pluginId, prefix },
|
||||
"@{prefix}-@{content} doesn't look like a valid plugin"
|
||||
);
|
||||
throw Error(`sanity check has failed, "${pluginId}" is not a valid plugin`);
|
||||
}
|
||||
|
||||
debug('Plugin successfully loaded: %o-%o', pluginId, prefix);
|
||||
return plugin;
|
||||
});
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class ActiveDirectoryPlugin implements IPluginAuth<ActiveDirectoryConfig> {
|
||||
connection.getGroupMembershipForUser(username, (err, groups: object[]): void => {
|
||||
if (err) {
|
||||
this.logger.warn(`AD - Active Directory group check failed with error: ${err}`);
|
||||
return cb(getInternalError((err as unknown) as string));
|
||||
return cb(getInternalError(err as unknown as string));
|
||||
}
|
||||
|
||||
const requestedGroups = Array.isArray(groupName) ? groupName : [groupName];
|
||||
|
@ -83,7 +83,7 @@ describe('Active Directory Plugin', () => {
|
||||
const errorMessage = 'Unknown error retrieving groups';
|
||||
ActiveDirectory.prototype.authenticate = jest.fn((_1, _2, cb) => cb(null, true));
|
||||
ActiveDirectory.prototype.getGroupMembershipForUser = jest.fn((_, cb) =>
|
||||
cb((errorMessage as unknown) as object, null)
|
||||
cb(errorMessage as unknown as object, null)
|
||||
) as jest.Mock;
|
||||
|
||||
adPluginSingleGroup.authenticate('', '', (error, authUser) => {
|
||||
|
@ -29,14 +29,8 @@ export default class S3PackageManager implements ILocalPackageManager {
|
||||
this.config = config;
|
||||
this.packageName = packageName;
|
||||
this.logger = logger;
|
||||
const {
|
||||
endpoint,
|
||||
region,
|
||||
s3ForcePathStyle,
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
sessionToken,
|
||||
} = config;
|
||||
const { endpoint, region, s3ForcePathStyle, accessKeyId, secretAccessKey, sessionToken } =
|
||||
config;
|
||||
|
||||
this.s3 = new S3({
|
||||
endpoint,
|
||||
|
@ -79,7 +79,7 @@ describe.skip('S3 package manager', () => {
|
||||
|
||||
describe('savePackage() group', () => {
|
||||
test('savePackage()', (done) => {
|
||||
const data = ('{data:5}' as unknown) as Package;
|
||||
const data = '{data:5}' as unknown as Package;
|
||||
const packageManager = new S3PackageManager(config, 'first-package', logger);
|
||||
|
||||
packageManager.savePackage('pkg.1.0.0.tar.gz', data, (err) => {
|
||||
|
@ -118,14 +118,12 @@ class GoogleCloudDatabase implements IPluginStorage<VerdaccioConfigGoogleStorage
|
||||
// "{\"secret\":\"181bc38698078f880564be1e4d7ec107ac8a3b344a924c6d86cea4a84a885ae0\"}"
|
||||
return entities.secret;
|
||||
})
|
||||
.catch(
|
||||
(err: Error): Promise<string> => {
|
||||
const error: VerdaccioError = getInternalError(err.message);
|
||||
.catch((err: Error): Promise<string> => {
|
||||
const error: VerdaccioError = getInternalError(err.message);
|
||||
|
||||
this.logger.warn({ error }, 'gcloud: [datastore getSecret] init error @{error}');
|
||||
return Promise.reject(getServiceUnavailable('[getSecret] permissions error'));
|
||||
}
|
||||
);
|
||||
this.logger.warn({ error }, 'gcloud: [datastore getSecret] init error @{error}');
|
||||
return Promise.reject(getServiceUnavailable('[getSecret] permissions error'));
|
||||
});
|
||||
}
|
||||
|
||||
public setSecret(secret: string): Promise<CommitResponse> {
|
||||
@ -194,17 +192,15 @@ class GoogleCloudDatabase implements IPluginStorage<VerdaccioConfigGoogleStorage
|
||||
// };
|
||||
this.helper
|
||||
.getEntities(this.kind)
|
||||
.then(
|
||||
async (entities: any): Promise<void> => {
|
||||
for (const item of entities) {
|
||||
if (item.name === name) {
|
||||
await this._deleteItem(name, item);
|
||||
// deletedItems.push(deletedItem);
|
||||
}
|
||||
.then(async (entities: any): Promise<void> => {
|
||||
for (const item of entities) {
|
||||
if (item.name === name) {
|
||||
await this._deleteItem(name, item);
|
||||
// deletedItems.push(deletedItem);
|
||||
}
|
||||
cb(null);
|
||||
}
|
||||
)
|
||||
cb(null);
|
||||
})
|
||||
.catch((err: Error): void => {
|
||||
cb(getInternalError(err.message));
|
||||
});
|
||||
|
@ -90,16 +90,14 @@ class GoogleCloudStorageHandler implements IPackageStorageManager {
|
||||
onEnd(getInternalError(err.message));
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
(err: Error): Callback => {
|
||||
this.logger.error(
|
||||
{ name, error: err },
|
||||
'gcloud: trying to update @{name} and was not found on storage err: @{error}'
|
||||
);
|
||||
// @ts-ignore
|
||||
return onEnd(getNotFound());
|
||||
}
|
||||
);
|
||||
.catch((err: Error): Callback => {
|
||||
this.logger.error(
|
||||
{ name, error: err },
|
||||
'gcloud: trying to update @{name} and was not found on storage err: @{error}'
|
||||
);
|
||||
// @ts-ignore
|
||||
return onEnd(getNotFound());
|
||||
});
|
||||
}
|
||||
|
||||
public deletePackage(fileName: string, cb: CallbackAction): void {
|
||||
@ -197,28 +195,26 @@ class GoogleCloudStorageHandler implements IPackageStorageManager {
|
||||
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
private _savePackage(name: string, metadata: Package): Promise<null | VerdaccioError> {
|
||||
return new Promise(
|
||||
async (resolve, reject): Promise<void> => {
|
||||
const file = this.helper.buildFilePath(name, pkgFileName);
|
||||
try {
|
||||
await file.save(this._convertToString(metadata), {
|
||||
validation: this.config.validation || defaultValidation,
|
||||
/**
|
||||
* When resumable is `undefined` - it will default to `true`as
|
||||
* per GC Storage documentation:
|
||||
* `Resumable uploads are automatically enabled and must be shut
|
||||
* off explicitly by setting options.resumable to false`
|
||||
* @see
|
||||
* https://cloud.google.com/nodejs/docs/reference/storage/2.5.x/File#createWriteStream
|
||||
*/
|
||||
resumable: this.config.resumable,
|
||||
});
|
||||
resolve(null);
|
||||
} catch (err) {
|
||||
reject(getInternalError(err.message));
|
||||
}
|
||||
return new Promise(async (resolve, reject): Promise<void> => {
|
||||
const file = this.helper.buildFilePath(name, pkgFileName);
|
||||
try {
|
||||
await file.save(this._convertToString(metadata), {
|
||||
validation: this.config.validation || defaultValidation,
|
||||
/**
|
||||
* When resumable is `undefined` - it will default to `true`as
|
||||
* per GC Storage documentation:
|
||||
* `Resumable uploads are automatically enabled and must be shut
|
||||
* off explicitly by setting options.resumable to false`
|
||||
* @see
|
||||
* https://cloud.google.com/nodejs/docs/reference/storage/2.5.x/File#createWriteStream
|
||||
*/
|
||||
resumable: this.config.resumable,
|
||||
});
|
||||
resolve(null);
|
||||
} catch (err) {
|
||||
reject(getInternalError(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
/* eslint-enable no-async-promise-executor */
|
||||
|
||||
@ -244,48 +240,44 @@ class GoogleCloudStorageHandler implements IPackageStorageManager {
|
||||
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
private _fileExist(name: string, fileName: string): Promise<boolean> {
|
||||
return new Promise(
|
||||
async (resolve, reject): Promise<void> => {
|
||||
const file: File = this.helper.buildFilePath(name, fileName);
|
||||
try {
|
||||
// @ts-ignore
|
||||
const data = await file.exists();
|
||||
const exist = data[0];
|
||||
return new Promise(async (resolve, reject): Promise<void> => {
|
||||
const file: File = this.helper.buildFilePath(name, fileName);
|
||||
try {
|
||||
// @ts-ignore
|
||||
const data = await file.exists();
|
||||
const exist = data[0];
|
||||
|
||||
resolve(exist);
|
||||
this.logger.debug(
|
||||
{ name: name, exist },
|
||||
'gcloud: check whether @{name} exist successfully: @{exist}'
|
||||
);
|
||||
} catch (err) {
|
||||
this.logger.error(
|
||||
{ name: file.name, err: err.message },
|
||||
'gcloud: check exist package @{name} has failed, cause: @{err}'
|
||||
);
|
||||
resolve(exist);
|
||||
this.logger.debug(
|
||||
{ name: name, exist },
|
||||
'gcloud: check whether @{name} exist successfully: @{exist}'
|
||||
);
|
||||
} catch (err) {
|
||||
this.logger.error(
|
||||
{ name: file.name, err: err.message },
|
||||
'gcloud: check exist package @{name} has failed, cause: @{err}'
|
||||
);
|
||||
|
||||
reject(getInternalError(err.message));
|
||||
}
|
||||
reject(getInternalError(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private async _readPackage(name: string): Promise<Package> {
|
||||
return new Promise(
|
||||
async (resolve, reject): Promise<void> => {
|
||||
const file = this.helper.buildFilePath(name, pkgFileName);
|
||||
return new Promise(async (resolve, reject): Promise<void> => {
|
||||
const file = this.helper.buildFilePath(name, pkgFileName);
|
||||
|
||||
try {
|
||||
const content: DownloadResponse = await file.download();
|
||||
this.logger.debug({ name: this.name }, 'gcloud: @{name} was found on storage');
|
||||
const response: Package = JSON.parse(content[0].toString('utf8'));
|
||||
try {
|
||||
const content: DownloadResponse = await file.download();
|
||||
this.logger.debug({ name: this.name }, 'gcloud: @{name} was found on storage');
|
||||
const response: Package = JSON.parse(content[0].toString('utf8'));
|
||||
|
||||
resolve(response);
|
||||
} catch (err) {
|
||||
this.logger.debug({ name: this.name }, 'gcloud: @{name} package not found on storage');
|
||||
reject(getNotFound());
|
||||
}
|
||||
resolve(response);
|
||||
} catch (err) {
|
||||
this.logger.debug({ name: this.name }, 'gcloud: @{name} package not found on storage');
|
||||
reject(getNotFound());
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
/* eslint-disable no-async-promise-executor */
|
||||
|
||||
|
@ -21,8 +21,13 @@ export interface FilterOptionsState<Option> {
|
||||
}
|
||||
|
||||
function createFilterOptions(config?: CreateFilterOptionsConfig) {
|
||||
const { ignoreAccents = true, ignoreCase = true, trim = false, limit, matchFrom = 'any' } =
|
||||
config || {};
|
||||
const {
|
||||
ignoreAccents = true,
|
||||
ignoreCase = true,
|
||||
trim = false,
|
||||
limit,
|
||||
matchFrom = 'any',
|
||||
} = config || {};
|
||||
|
||||
return <Option extends {}>(
|
||||
options: Option[],
|
||||
|
@ -6,9 +6,10 @@ import { Theme } from './theme';
|
||||
const resetStyles = makeStyles(({ theme }: { theme?: Theme }) => ({
|
||||
'@global': {
|
||||
// eslint-disable-next-line max-len
|
||||
'html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video': {
|
||||
fontFamily: '"Roboto", Helvetica Neue, Arial, sans-serif',
|
||||
},
|
||||
'html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video':
|
||||
{
|
||||
fontFamily: '"Roboto", Helvetica Neue, Arial, sans-serif',
|
||||
},
|
||||
strong: {
|
||||
fontWeight: theme && theme.fontWeight.semiBold,
|
||||
},
|
||||
|
@ -22,18 +22,8 @@ const cache = new CellMeasurerCache({
|
||||
/* eslint-disable verdaccio/jsx-no-style */
|
||||
const PackageList: React.FC<Props> = ({ packages }) => {
|
||||
const renderRow = ({ index, key, parent, style }: ListRowProps) => {
|
||||
const {
|
||||
name,
|
||||
version,
|
||||
description,
|
||||
time,
|
||||
keywords,
|
||||
dist,
|
||||
homepage,
|
||||
bugs,
|
||||
author,
|
||||
license,
|
||||
} = packages[index];
|
||||
const { name, version, description, time, keywords, dist, homepage, bugs, author, license } =
|
||||
packages[index];
|
||||
// TODO: move format license to API side.
|
||||
const formattedLicense = formatLicense(license);
|
||||
|
||||
|
@ -1,24 +1,24 @@
|
||||
import { SyntheticEvent } from 'react';
|
||||
|
||||
export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLElement>) => void) => (
|
||||
event: SyntheticEvent<HTMLElement>
|
||||
): void => {
|
||||
event.preventDefault();
|
||||
export const copyToClipBoardUtility =
|
||||
(str: string): ((e: SyntheticEvent<HTMLElement>) => void) =>
|
||||
(event: SyntheticEvent<HTMLElement>): void => {
|
||||
event.preventDefault();
|
||||
|
||||
const node = document.createElement('div');
|
||||
node.innerText = str;
|
||||
if (document.body) {
|
||||
document.body.appendChild(node);
|
||||
const node = document.createElement('div');
|
||||
node.innerText = str;
|
||||
if (document.body) {
|
||||
document.body.appendChild(node);
|
||||
|
||||
const range = document.createRange();
|
||||
const selection = window.getSelection() as Selection;
|
||||
range.selectNodeContents(node);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(node);
|
||||
}
|
||||
};
|
||||
const range = document.createRange();
|
||||
const selection = window.getSelection() as Selection;
|
||||
range.selectNodeContents(node);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(node);
|
||||
}
|
||||
};
|
||||
|
||||
export function getCLISetConfigRegistry(
|
||||
command: string,
|
||||
|
@ -41,8 +41,7 @@ const json = {
|
||||
_attachments: {
|
||||
'forbidden-place-1.0.6.tgz': {
|
||||
content_type: 'application/octet-stream',
|
||||
data:
|
||||
'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
length: 512,
|
||||
},
|
||||
},
|
||||
|
@ -41,8 +41,7 @@ const json = {
|
||||
_attachments: {
|
||||
'@scope/pk1-test-1.0.6.tgz': {
|
||||
content_type: 'application/octet-stream',
|
||||
data:
|
||||
'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
length: 512,
|
||||
},
|
||||
},
|
||||
|
20
packages/tools/eslint/package.json
Normal file
20
packages/tools/eslint/package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@verdaccio/eslint-config",
|
||||
"version": "1.0.0",
|
||||
"private": "true",
|
||||
"description": "verdaccio eslint config",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .js"
|
||||
},
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juanpicado19@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "https",
|
||||
"url": "https://github.com/verdaccio/verdaccio"
|
||||
},
|
||||
"homepage": "https://verdaccio.org",
|
||||
"license": "MIT"
|
||||
}
|
27
packages/tools/eslint/src/index.js
Normal file
27
packages/tools/eslint/src/index.js
Normal file
@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
extends: ['./rules/base.js', './rules/prettier.js', './rules/react.js', './rules/jest.js'],
|
||||
env: {
|
||||
es6: true,
|
||||
node: true,
|
||||
},
|
||||
globals: {
|
||||
__APP_VERSION__: true,
|
||||
},
|
||||
parserOptions: {
|
||||
allowImportExportEverywhere: true,
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 11,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
node: {
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
},
|
||||
},
|
||||
},
|
||||
parser: '@typescript-eslint/parser',
|
||||
};
|
64
packages/tools/eslint/src/rules/base.js
Normal file
64
packages/tools/eslint/src/rules/base.js
Normal file
@ -0,0 +1,64 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'google',
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:import/typescript',
|
||||
],
|
||||
plugins: ['import'],
|
||||
rules: {
|
||||
curly: ['error', 'all'],
|
||||
'keyword-spacing': 'off',
|
||||
'no-tabs': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
'padded-blocks': 'off',
|
||||
'require-jsdoc': 'off',
|
||||
'valid-jsdoc': 'off',
|
||||
'import/order': ['error'],
|
||||
'eol-last': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
|
||||
'no-trailing-spaces': 'error',
|
||||
camelcase: 'off',
|
||||
'guard-for-in': 'error',
|
||||
'new-cap': 'error',
|
||||
'max-len': ['error', 100],
|
||||
'no-console': ['error', { allow: ['warn'] }],
|
||||
'no-constant-condition': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-empty': 'error',
|
||||
'no-fallthrough': 'error',
|
||||
'no-invalid-this': 'error',
|
||||
'no-new-require': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-unreachable': 'error',
|
||||
'no-var': 'error',
|
||||
'one-var': 'error',
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'handle-callback-err': 0,
|
||||
'prefer-const': 0,
|
||||
// typescript
|
||||
'@typescript-eslint/camelcase': 0,
|
||||
'@typescript-eslint/ban-ts-ignore': 0,
|
||||
'@typescript-eslint/no-var-requires': 0,
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
'@typescript-eslint/no-empty-function': 0,
|
||||
'@typescript-eslint/no-this-alias': 0,
|
||||
'@typescript-eslint/no-use-before-define': 0,
|
||||
'@typescript-eslint/array-type': ['error'],
|
||||
'@typescript-eslint/no-explicit-any': 0,
|
||||
'@typescript-eslint/indent': 0,
|
||||
'@typescript-eslint/ban-ts-comment': 0,
|
||||
'@typescript-eslint/ban-types': 0,
|
||||
'@typescript-eslint/explicit-module-boundary-types': 0,
|
||||
// rules to fix
|
||||
'no-unused-vars': ['warn', { vars: 'all', args: 'none' }],
|
||||
'prefer-promise-reject-errors': ['warn'],
|
||||
|
||||
'@typescript-eslint/prefer-optional-chain': ['warn'],
|
||||
'@typescript-eslint/explicit-member-accessibility': ['warn'],
|
||||
'@typescript-eslint/no-unused-vars': ['warn'],
|
||||
},
|
||||
};
|
19
packages/tools/eslint/src/rules/jest.js
Normal file
19
packages/tools/eslint/src/rules/jest.js
Normal file
@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
extends: ['plugin:jest/recommended'],
|
||||
plugins: ['jest'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
'jest/no-export': 0,
|
||||
'jest/no-test-callback': 0,
|
||||
'jest/expect-expect': 0,
|
||||
'jest/no-try-expect': 0,
|
||||
'jest/no-done-callback': 'off',
|
||||
'jest/no-conditional-expect': 'off',
|
||||
// rules to fix
|
||||
'jest/no-identical-title': ['warn'],
|
||||
'jest/no-disabled-tests': ['warn'],
|
||||
'jest/no-commented-out-tests': ['warn'],
|
||||
},
|
||||
};
|
4
packages/tools/eslint/src/rules/prettier.js
Normal file
4
packages/tools/eslint/src/rules/prettier.js
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
extends: ['plugin:prettier/recommended'],
|
||||
plugins: ['prettier'],
|
||||
};
|
15
packages/tools/eslint/src/rules/react.js
vendored
Normal file
15
packages/tools/eslint/src/rules/react.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
'plugin:react/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
'plugin:jsx-a11y/recommended',
|
||||
'plugin:jsx-a11y/recommended',
|
||||
],
|
||||
plugins: ['import'],
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
rules: {
|
||||
'react/prop-types': 0,
|
||||
},
|
||||
};
|
@ -41,8 +41,7 @@ const json = {
|
||||
_attachments: {
|
||||
'forbidden-place-1.0.6.tgz': {
|
||||
content_type: 'application/octet-stream',
|
||||
data:
|
||||
'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
length: 512,
|
||||
},
|
||||
},
|
||||
|
@ -15,25 +15,21 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config): void {
|
||||
route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void {
|
||||
const { username, password } = req.body;
|
||||
debug('authenticate %o', username);
|
||||
auth.authenticate(
|
||||
username,
|
||||
password,
|
||||
async (err, user: RemoteUser): Promise<void> => {
|
||||
if (err) {
|
||||
const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;
|
||||
debug('error authenticate %o', errorCode);
|
||||
next(ErrorCode.getCode(errorCode, err.message));
|
||||
} else {
|
||||
req.remote_user = user;
|
||||
const jWTSignOptions: JWTSignOptions = config.security.web.sign;
|
||||
auth.authenticate(username, password, async (err, user: RemoteUser): Promise<void> => {
|
||||
if (err) {
|
||||
const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;
|
||||
debug('error authenticate %o', errorCode);
|
||||
next(ErrorCode.getCode(errorCode, err.message));
|
||||
} else {
|
||||
req.remote_user = user;
|
||||
const jWTSignOptions: JWTSignOptions = config.security.web.sign;
|
||||
|
||||
next({
|
||||
token: await auth.jwtEncrypt(user, jWTSignOptions),
|
||||
username: req.remote_user.name,
|
||||
});
|
||||
}
|
||||
next({
|
||||
token: await auth.jwtEncrypt(user, jWTSignOptions),
|
||||
username: req.remote_user.name,
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
if (config?.flags?.changePassword === true) {
|
||||
|
@ -45,21 +45,19 @@ export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvata
|
||||
|
||||
// for contributors
|
||||
if (_.isEmpty(contributors) === false) {
|
||||
pkgInfoCopy.latest.contributors = contributors.map(
|
||||
(contributor): AuthorAvatar => {
|
||||
if (isObject(contributor)) {
|
||||
contributor.avatar = generateGravatarUrl(contributor.email, online);
|
||||
} else if (_.isString(contributor)) {
|
||||
contributor = {
|
||||
avatar: GENERIC_AVATAR,
|
||||
email: contributor,
|
||||
name: contributor,
|
||||
};
|
||||
}
|
||||
|
||||
return contributor;
|
||||
pkgInfoCopy.latest.contributors = contributors.map((contributor): AuthorAvatar => {
|
||||
if (isObject(contributor)) {
|
||||
contributor.avatar = generateGravatarUrl(contributor.email, online);
|
||||
} else if (_.isString(contributor)) {
|
||||
contributor = {
|
||||
avatar: GENERIC_AVATAR,
|
||||
email: contributor,
|
||||
name: contributor,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return contributor;
|
||||
});
|
||||
}
|
||||
|
||||
// for maintainers
|
||||
|
760
pnpm-lock.yaml
generated
760
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
packages:
|
||||
- packages/*
|
||||
- packages/core/*
|
||||
- packages/tools/*
|
||||
- packages/plugins/*
|
||||
- website
|
||||
- test/e2e-*
|
||||
|
@ -41,8 +41,7 @@ const json = {
|
||||
_attachments: {
|
||||
'protected-pkg-5.0.5.tgz': {
|
||||
content_type: 'application/octet-stream',
|
||||
data:
|
||||
'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
length: 512,
|
||||
},
|
||||
},
|
||||
|
@ -41,8 +41,7 @@ const json = {
|
||||
_attachments: {
|
||||
'@scope/pk1-test-1.0.6.tgz': {
|
||||
content_type: 'application/octet-stream',
|
||||
data:
|
||||
'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=',
|
||||
length: 512,
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user