0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

refactor: move specific flow types into the project

This commit is contained in:
Juan Picado @jotadeveloper 2018-02-26 21:28:09 +01:00
parent b23cc1bc8b
commit 0167de508c
No known key found for this signature in database
GPG key ID: 18AC54485952D158
11 changed files with 118 additions and 19 deletions

View file

@ -52,7 +52,7 @@
"@commitlint/cli": "6.1.0", "@commitlint/cli": "6.1.0",
"@commitlint/config-conventional": "6.1.0", "@commitlint/config-conventional": "6.1.0",
"@commitlint/travis-cli": "6.1.0", "@commitlint/travis-cli": "6.1.0",
"@verdaccio/types": "1.0.4", "@verdaccio/types": "2.0.0",
"axios": "0.17.1", "axios": "0.17.1",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-core": "6.26.0", "babel-core": "6.26.0",

View file

@ -19,7 +19,6 @@ import {loadPlugin} from '../lib/plugin-loader';
import LocalDatabase from '@verdaccio/local-storage'; import LocalDatabase from '@verdaccio/local-storage';
import {UploadTarball, ReadTarball} from '@verdaccio/streams'; import {UploadTarball, ReadTarball} from '@verdaccio/streams';
import type { import type {
IStorage,
Package, Package,
Config, Config,
MergeTags, MergeTags,
@ -32,11 +31,11 @@ import type {
ILocalData, ILocalData,
IPackageStorage, IPackageStorage,
} from '@verdaccio/local-storage'; } from '@verdaccio/local-storage';
import type { import type {
IUploadTarball, IUploadTarball,
IReadTarball, IReadTarball,
} from '@verdaccio/streams'; } from '@verdaccio/streams';
import type {IStorage} from '../../types';
/** /**
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js). * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).

View file

@ -1,8 +1,8 @@
// @flow // @flow
import lunr from 'lunr'; import lunr from 'lunr';
import type {IStorageHandler, Version, IWebSearch} from '@verdaccio/types'; import type {Version} from '@verdaccio/types';
import type {IStorageHandler, IWebSearch} from '../../types';
/** /**
* Handle the search Indexer. * Handle the search Indexer.
*/ */

View file

@ -12,13 +12,9 @@ import LocalStorage from './local-storage';
import {ReadTarball} from '@verdaccio/streams'; import {ReadTarball} from '@verdaccio/streams';
import ProxyStorage from './up-storage'; import ProxyStorage from './up-storage';
import * as Utils from './utils'; import * as Utils from './utils';
import type {IStorage, IProxy, IStorageHandler, ProxyList} from '../../types';
import type { import type {
IStorage,
IProxy,
IStorageHandler,
Versions, Versions,
ProxyList,
Package, Package,
Config, Config,
MergeTags, MergeTags,
@ -27,7 +23,6 @@ import type {
Callback, Callback,
Logger, Logger,
} from '@verdaccio/types'; } from '@verdaccio/types';
import type {IReadTarball, IUploadTarball} from '@verdaccio/streams'; import type {IReadTarball, IUploadTarball} from '@verdaccio/streams';
const LoggerApi = require('../lib/logger'); const LoggerApi = require('../lib/logger');

View file

@ -11,15 +11,13 @@ import {parseInterval, isObject, ErrorCode} from './utils';
import {ReadTarball} from '@verdaccio/streams'; import {ReadTarball} from '@verdaccio/streams';
import type { import type {
IProxy,
Config, Config,
UpLinkConf, UpLinkConf,
Callback, Callback,
Headers, Headers,
Logger, Logger,
} from '@verdaccio/types'; } from '@verdaccio/types';
import type {IProxy} from '../../types';
// import type {IUploadTarball, IReadTarball} from '@verdaccio/streams';
const LoggerApi = require('./logger'); const LoggerApi = require('./logger');
const encode = function(thing) { const encode = function(thing) {

View file

@ -7,8 +7,8 @@ import configExample from './partials/config';
import AppConfig from '../../src/lib/config'; import AppConfig from '../../src/lib/config';
import {setup} from '../../src/lib/logger'; import {setup} from '../../src/lib/logger';
import type {IAuth} from '../../types';
import type {IAuth, Config} from '@verdaccio/types'; import type {Config} from '@verdaccio/types';
setup(configExample.logs); setup(configExample.logs);

View file

@ -10,7 +10,8 @@ import {readFile} from '../functional/lib/test.utils';
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`); const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
import type {IStorage, Config} from '@verdaccio/types'; import type {Config} from '@verdaccio/types';
import type {IStorage} from '../../types';
setup([]); setup([]);

View file

@ -8,7 +8,8 @@ import AppConfig from '../../src/lib/config';
import Storage from '../../src/lib/storage'; import Storage from '../../src/lib/storage';
import {setup} from '../../src/lib/logger'; import {setup} from '../../src/lib/logger';
import type {IStorageHandler, Config} from '@verdaccio/types'; import type {Config} from '@verdaccio/types';
import type {IStorageHandler} from '../../types';
setup(configExample.logs); setup(configExample.logs);

View file

@ -5,7 +5,8 @@ import _ from 'lodash';
// $FlowFixMe // $FlowFixMe
import configExample from './partials/config'; import configExample from './partials/config';
import {setup} from '../../src/lib/logger'; import {setup} from '../../src/lib/logger';
import type {Config, IProxy, UpLinkConf} from '@verdaccio/types'; import type {Config, UpLinkConf} from '@verdaccio/types';
import type {IProxy} from '../../types';
setup([]); setup([]);

104
types/index.js Normal file
View file

@ -0,0 +1,104 @@
// @flow
import type {
UpLinkConf,
Callback,
Versions,
Version,
MergeTags,
Config,
Logger,
Package} from '@verdaccio/types';
import type {
IUploadTarball,
IReadTarball,
} from '@verdaccio/streams';
import type {ILocalData} from '@verdaccio/local-storage';
export interface IAuth {
config: Config;
logger: Logger;
secret: string;
plugins: Array<any>;
}
export interface IWebSearch {
index: any;
storage: IStorageHandler;
query(query: string): any;
add(pkg: Version): void;
remove(name: string): void;
reindex(): void;
configureStorage(storage: IStorageHandler): void;
}
export interface IProxy {
config: UpLinkConf;
failed_requests: number;
userAgent: string;
ca?: string | void;
logger: Logger;
server_id: string;
url: any;
maxage: number;
timeout: number;
max_fails: number;
fail_timeout: number;
upname: string;
fetchTarball(url: string): IReadTarball;
isUplinkValid(url: string): boolean;
}
export type ProxyList = {
[key: string]: IProxy | null;
}
export type Utils = {
ErrorCode: any;
getLatestVersion: Callback;
isObject: (value: any) => boolean;
validate_name: (value: any) => boolean;
tag_version: (value: any, version: string, tag: string) => void;
normalize_dist_tags: (pkg: Package) => void;
semverSort: (keys: Array<string>) => Array<string>;
}
export interface IStorageHandler {
config: Config;
localStorage: IStorage;
logger: Logger;
uplinks: ProxyList;
addPackage(name: string, metadata: any, callback: Function): void;
addVersion(name: string, version: string, metadata: Version, tag: string, callback: Callback): void;
mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
replace_tags(name: string, tagHash: MergeTags, callback: Callback): void;
change_package(name: string, metadata: Package, revision: string, callback: Callback): void;
remove_package(name: string, callback: Callback): void;
remove_tarball(name: string, filename: string, revision: string, callback: Callback): void;
add_tarball(name: string, filename: string): IUploadTarball;
get_tarball(name: string, filename: string): IReadTarball;
getPackage(options: any): void;
search(startkey: string, options: any): void;
getLocalDatabase(callback: Callback): void;
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
_setupUpLinks(config: Config): void;
}
export interface IStorage {
config: Config;
localData: ILocalData;
logger: Logger;
addPackage(name: string, info: Package, callback: Callback): void;
removePackage(name: string, callback: Callback): void;
updateVersions(name: string, packageInfo: Package, callback: Callback): void;
addVersion(name: string, version: string, metadata: Version, tag: string, callback: Callback): void;
mergeTags(name: string, tags: MergeTags, callback: Callback): void;
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
addTarball(name: string, filename: string): IUploadTarball;
getTarball(name: string, filename: string): IReadTarball;
getPackageMetadata(name: string, callback: Callback): void;
search(startKey: string, options: any): IUploadTarball;
}

BIN
yarn.lock

Binary file not shown.