mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
chore: update flow to 0.75.0
This commit is contained in:
parent
eecc98f671
commit
7ce6abf3b2
11 changed files with 106 additions and 31 deletions
33
flow-typed/npm/express_v4.16.x.js
vendored
33
flow-typed/npm/express_v4.16.x.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
// flow-typed signature: 41a220e96fcef89a09244ac3797039e8
|
// flow-typed signature: cc24a4e737d9dfb8e1381c3bd4ebaa65
|
||||||
// flow-typed version: 9f7cf2ab0c/express_v4.16.x/flow_>=v0.32.x
|
// flow-typed version: d11eab7bb5/express_v4.16.x/flow_>=v0.32.x
|
||||||
|
|
||||||
import type { Server } from "http";
|
import type { Server } from "http";
|
||||||
import type { Socket } from "net";
|
import type { Socket } from "net";
|
||||||
|
@ -195,13 +195,11 @@ declare class express$Router extends express$Route {
|
||||||
id: string
|
id: string
|
||||||
) => mixed
|
) => mixed
|
||||||
): void;
|
): void;
|
||||||
|
(
|
||||||
// Can't use regular callable signature syntax due to https://github.com/facebook/flow/issues/3084
|
|
||||||
$call: (
|
|
||||||
req: http$IncomingMessage,
|
req: http$IncomingMessage,
|
||||||
res: http$ServerResponse,
|
res: http$ServerResponse,
|
||||||
next?: ?express$NextFunction
|
next?: ?express$NextFunction
|
||||||
) => void;
|
): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -250,6 +248,12 @@ declare class express$Application extends express$Router mixins events$EventEmit
|
||||||
res: http$ServerResponse,
|
res: http$ServerResponse,
|
||||||
next?: ?express$NextFunction
|
next?: ?express$NextFunction
|
||||||
): void;
|
): void;
|
||||||
|
// callable signature is not inherited
|
||||||
|
(
|
||||||
|
req: http$IncomingMessage,
|
||||||
|
res: http$ServerResponse,
|
||||||
|
next?: ?express$NextFunction
|
||||||
|
): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type JsonOptions = {
|
declare type JsonOptions = {
|
||||||
|
@ -266,6 +270,20 @@ declare type JsonOptions = {
|
||||||
) => mixed
|
) => mixed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare type express$UrlEncodedOptions = {
|
||||||
|
extended?: boolean,
|
||||||
|
inflate?: boolean,
|
||||||
|
limit?: string | number,
|
||||||
|
parameterLimit?: number,
|
||||||
|
type?: string | Array<string> | ((req: express$Request) => boolean),
|
||||||
|
verify?: (
|
||||||
|
req: express$Request,
|
||||||
|
res: express$Response,
|
||||||
|
buf: Buffer,
|
||||||
|
encoding: string
|
||||||
|
) => mixed,
|
||||||
|
}
|
||||||
|
|
||||||
declare module "express" {
|
declare module "express" {
|
||||||
declare export type RouterOptions = express$RouterOptions;
|
declare export type RouterOptions = express$RouterOptions;
|
||||||
declare export type CookieOptions = express$CookieOptions;
|
declare export type CookieOptions = express$CookieOptions;
|
||||||
|
@ -280,6 +298,7 @@ declare module "express" {
|
||||||
(): express$Application, // If you try to call like a function, it will use this signature
|
(): express$Application, // If you try to call like a function, it will use this signature
|
||||||
json: (opts: ?JsonOptions) => express$Middleware,
|
json: (opts: ?JsonOptions) => express$Middleware,
|
||||||
static: (root: string, options?: Object) => express$Middleware, // `static` property on the function
|
static: (root: string, options?: Object) => express$Middleware, // `static` property on the function
|
||||||
Router: typeof express$Router // `Router` property on the function
|
Router: typeof express$Router, // `Router` property on the function
|
||||||
|
urlencoded: (opts: ?express$UrlEncodedOptions) => express$Middleware,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "6.1.3",
|
"@commitlint/cli": "6.1.3",
|
||||||
"@commitlint/config-conventional": "6.1.3",
|
"@commitlint/config-conventional": "6.1.3",
|
||||||
"@verdaccio/types": "3.0.1",
|
"@verdaccio/types": "3.1.0",
|
||||||
"babel-cli": "6.26.0",
|
"babel-cli": "6.26.0",
|
||||||
"babel-core": "6.26.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-eslint": "8.2.2",
|
"babel-eslint": "8.2.2",
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
"eslint-plugin-jest": "21.17.0",
|
"eslint-plugin-jest": "21.17.0",
|
||||||
"eslint-plugin-react": "7.10.0",
|
"eslint-plugin-react": "7.10.0",
|
||||||
"file-loader": "1.1.11",
|
"file-loader": "1.1.11",
|
||||||
"flow-bin": "0.69.0",
|
"flow-bin": "0.75.0",
|
||||||
"flow-runtime": "0.17.0",
|
"flow-runtime": "0.17.0",
|
||||||
"friendly-errors-webpack-plugin": "1.7.0",
|
"friendly-errors-webpack-plugin": "1.7.0",
|
||||||
"github-markdown-css": "2.10.0",
|
"github-markdown-css": "2.10.0",
|
||||||
|
|
|
@ -396,8 +396,8 @@ class LocalStorage implements IStorage {
|
||||||
const _transform = uploadStream._transform;
|
const _transform = uploadStream._transform;
|
||||||
const storage = this._getLocalStorage(name);
|
const storage = this._getLocalStorage(name);
|
||||||
|
|
||||||
uploadStream.abort = function() {};
|
(uploadStream: any).abort = function() {};
|
||||||
uploadStream.done = function() {};
|
(uploadStream: any).done = function() {};
|
||||||
|
|
||||||
uploadStream._transform = function(data) {
|
uploadStream._transform = function(data) {
|
||||||
shaOneHash.update(data);
|
shaOneHash.update(data);
|
||||||
|
@ -459,11 +459,11 @@ class LocalStorage implements IStorage {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadStream.abort = function() {
|
(uploadStream: any).abort = function() {
|
||||||
writeStream.abort();
|
writeStream.abort();
|
||||||
};
|
};
|
||||||
|
|
||||||
uploadStream.done = function() {
|
(uploadStream: any).done = function() {
|
||||||
if (!length) {
|
if (!length) {
|
||||||
uploadStream.emit('error', ErrorCode.getBadData('refusing to accept zero-length file'));
|
uploadStream.emit('error', ErrorCode.getBadData('refusing to accept zero-length file'));
|
||||||
writeStream.abort();
|
writeStream.abort();
|
||||||
|
@ -521,7 +521,7 @@ class LocalStorage implements IStorage {
|
||||||
const readTarballStream = storage.readTarball(filename);
|
const readTarballStream = storage.readTarball(filename);
|
||||||
const e404 = ErrorCode.getNotFound;
|
const e404 = ErrorCode.getNotFound;
|
||||||
|
|
||||||
stream.abort = function() {
|
(stream: any).abort = function() {
|
||||||
if (_.isNil(readTarballStream) === false) {
|
if (_.isNil(readTarballStream) === false) {
|
||||||
readTarballStream.abort();
|
readTarballStream.abort();
|
||||||
}
|
}
|
||||||
|
@ -800,7 +800,7 @@ class LocalStorage implements IStorage {
|
||||||
return this.localData.setSecret(config.checkSecretKey(secretKey));
|
return this.localData.setSecret(config.checkSecretKey(secretKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadStorage(config: Config, logger: Logger) {
|
_loadStorage(config: Config, logger: Logger): ILocalData {
|
||||||
const Storage = this._loadStorePlugin();
|
const Storage = this._loadStorePlugin();
|
||||||
|
|
||||||
if (_.isNil(Storage)) {
|
if (_.isNil(Storage)) {
|
||||||
|
@ -811,13 +811,13 @@ class LocalStorage implements IStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadStorePlugin() {
|
_loadStorePlugin(): ILocalData {
|
||||||
const plugin_params = {
|
const plugin_params = {
|
||||||
config: this.config,
|
config: this.config,
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
};
|
};
|
||||||
|
|
||||||
return _.head(loadPlugin(this.config, this.config.store, plugin_params, function(plugin) {
|
return _.head(loadPlugin(this.config, this.config.store, plugin_params, (plugin) => {
|
||||||
return plugin.getPackageStorage;
|
return plugin.getPackageStorage;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,12 @@ function isES6(plugin) {
|
||||||
* @param {*} sanityCheck callback that check the shape that should fulfill the plugin
|
* @param {*} sanityCheck callback that check the shape that should fulfill the plugin
|
||||||
* @return {Array} list of plugins
|
* @return {Array} list of plugins
|
||||||
*/
|
*/
|
||||||
function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck: Function) {
|
function loadPlugin<T>(
|
||||||
return Object.keys(pluginConfigs || {}).map(function(pluginId) {
|
config: Config,
|
||||||
|
pluginConfigs: any = {},
|
||||||
|
params: any,
|
||||||
|
sanityCheck: Function): T[] {
|
||||||
|
return Object.keys(pluginConfigs).map((pluginId: string) => {
|
||||||
let plugin;
|
let plugin;
|
||||||
|
|
||||||
// try local plugins first
|
// try local plugins first
|
||||||
|
@ -79,7 +83,9 @@ function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck
|
||||||
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
||||||
}
|
}
|
||||||
/* eslint new-cap:off */
|
/* eslint new-cap:off */
|
||||||
plugin = isES6(plugin) ? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params) : plugin(pluginConfigs[pluginId], params);
|
plugin = isES6(plugin)
|
||||||
|
? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params)
|
||||||
|
: plugin(pluginConfigs[pluginId], params);
|
||||||
/* eslint new-cap:off */
|
/* eslint new-cap:off */
|
||||||
|
|
||||||
if (plugin === null || !sanityCheck(plugin)) {
|
if (plugin === null || !sanityCheck(plugin)) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ class Storage implements IStorageHandler {
|
||||||
*/
|
*/
|
||||||
getTarball(name: string, filename: string) {
|
getTarball(name: string, filename: string) {
|
||||||
let readStream = new ReadTarball();
|
let readStream = new ReadTarball();
|
||||||
readStream.abort = function() {};
|
(readStream: any).abort = function() {};
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ class ProxyStorage implements IProxy {
|
||||||
let current_length = 0;
|
let current_length = 0;
|
||||||
let expected_length;
|
let expected_length;
|
||||||
|
|
||||||
stream.abort = () => {};
|
(stream: any).abort = () => {};
|
||||||
const readStream = this.request({
|
const readStream = this.request({
|
||||||
uri_full: url,
|
uri_full: url,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
|
|
|
@ -253,7 +253,7 @@ function parse_address(urlAddress: any) {
|
||||||
* Function filters out bad semver versions and sorts the array.
|
* Function filters out bad semver versions and sorts the array.
|
||||||
* @return {Array} sorted Array
|
* @return {Array} sorted Array
|
||||||
*/
|
*/
|
||||||
function semverSort(listVersions: Array<string>) {
|
function semverSort(listVersions: Array<string>): string[] {
|
||||||
return listVersions.filter(function(x) {
|
return listVersions.filter(function(x) {
|
||||||
if (!semver.parse(x, true)) {
|
if (!semver.parse(x, true)) {
|
||||||
Logger.logger.warn( {ver: x}, 'ignoring bad version @{ver}' );
|
Logger.logger.warn( {ver: x}, 'ignoring bad version @{ver}' );
|
||||||
|
@ -409,7 +409,7 @@ function fileExists(path: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByName(packages: Array<any>) {
|
function sortByName(packages: Array<any>): string[] {
|
||||||
return packages.sort(function(a, b) {
|
return packages.sort(function(a, b) {
|
||||||
if (a.name < b.name) {
|
if (a.name < b.name) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
50
test/flow/plugins/auth/complete.js
Normal file
50
test/flow/plugins/auth/complete.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import Config from '../../../../src/lib/config';
|
||||||
|
import LoggerApi from '../../../../src/lib/logger';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AuthPlugin,
|
||||||
|
Config as AppConfig,
|
||||||
|
IAuthPlugin,
|
||||||
|
Logger,
|
||||||
|
PluginOptions
|
||||||
|
} from '@verdaccio/types';
|
||||||
|
|
||||||
|
|
||||||
|
// this class is not aim to be tested, just to check flow definitions
|
||||||
|
class ExampleAuthPlugin implements IAuthPlugin {
|
||||||
|
config: AppConfig;
|
||||||
|
logger: Logger;
|
||||||
|
|
||||||
|
constructor(config: AppConfig, options: PluginOptions) {
|
||||||
|
this.config = config;
|
||||||
|
this.logger = options.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_access(packageName: string, user: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_publish(packageName: string, user: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const config1: AppConfig = new Config({
|
||||||
|
storage: './storage',
|
||||||
|
self_path: '/home/sotrage'
|
||||||
|
});
|
||||||
|
|
||||||
|
const options: PluginOptions = {
|
||||||
|
config: config1,
|
||||||
|
logger: LoggerApi.logger.child()
|
||||||
|
}
|
||||||
|
|
||||||
|
// $FlowFixMe
|
||||||
|
const instance1: AuthPlugin = new ExampleAuthPlugin(config1, options);
|
||||||
|
console.log(instance1);
|
0
test/flow/plugins/partials/config.example.js
Normal file
0
test/flow/plugins/partials/config.example.js
Normal file
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
module.exports = function ( ) {
|
module.exports = function ( ) {
|
||||||
return {
|
return {
|
||||||
authenticate ( user, pass, callback ) {
|
authenticate( user, pass, callback ) {
|
||||||
/* user and pass are used here to forward errors
|
/* user and pass are used here to forward errors
|
||||||
and success types respectively for testing purposes */
|
and success types respectively for testing purposes */
|
||||||
callback(user, pass);
|
callback(user, pass);
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -234,9 +234,9 @@
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
|
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
|
||||||
|
|
||||||
"@verdaccio/types@3.0.1":
|
"@verdaccio/types@3.1.0":
|
||||||
version "3.0.1"
|
version "3.1.0"
|
||||||
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.0.1.tgz#8cdfd74a8a070ad797a056652f257f9ead3717f9"
|
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.1.0.tgz#b4b376c80e787aa9ab59794fbbabf81fedb9cdba"
|
||||||
|
|
||||||
"@webassemblyjs/ast@1.5.9":
|
"@webassemblyjs/ast@1.5.9":
|
||||||
version "1.5.9"
|
version "1.5.9"
|
||||||
|
@ -3833,9 +3833,9 @@ flatten@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
resolved "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
||||||
|
|
||||||
flow-bin@0.69.0:
|
flow-bin@0.75.0:
|
||||||
version "0.69.0"
|
version "0.75.0"
|
||||||
resolved "https://registry.npmjs.org/flow-bin/-/flow-bin-0.69.0.tgz#053159a684a6051fcbf0b71a2eb19a9679082da6"
|
resolved "https://registry.npmjs.org/flow-bin/-/flow-bin-0.75.0.tgz#b96d1ee99d3b446a3226be66b4013224ce9df260"
|
||||||
|
|
||||||
flow-config-parser@^0.3.0:
|
flow-config-parser@^0.3.0:
|
||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue