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:
parent
b23cc1bc8b
commit
0167de508c
11 changed files with 118 additions and 19 deletions
|
@ -52,7 +52,7 @@
|
|||
"@commitlint/cli": "6.1.0",
|
||||
"@commitlint/config-conventional": "6.1.0",
|
||||
"@commitlint/travis-cli": "6.1.0",
|
||||
"@verdaccio/types": "1.0.4",
|
||||
"@verdaccio/types": "2.0.0",
|
||||
"axios": "0.17.1",
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-core": "6.26.0",
|
||||
|
|
|
@ -19,7 +19,6 @@ import {loadPlugin} from '../lib/plugin-loader';
|
|||
import LocalDatabase from '@verdaccio/local-storage';
|
||||
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
||||
import type {
|
||||
IStorage,
|
||||
Package,
|
||||
Config,
|
||||
MergeTags,
|
||||
|
@ -32,11 +31,11 @@ import type {
|
|||
ILocalData,
|
||||
IPackageStorage,
|
||||
} from '@verdaccio/local-storage';
|
||||
|
||||
import type {
|
||||
IUploadTarball,
|
||||
IReadTarball,
|
||||
} from '@verdaccio/streams';
|
||||
import type {IStorage} from '../../types';
|
||||
|
||||
/**
|
||||
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -12,13 +12,9 @@ import LocalStorage from './local-storage';
|
|||
import {ReadTarball} from '@verdaccio/streams';
|
||||
import ProxyStorage from './up-storage';
|
||||
import * as Utils from './utils';
|
||||
|
||||
import type {IStorage, IProxy, IStorageHandler, ProxyList} from '../../types';
|
||||
import type {
|
||||
IStorage,
|
||||
IProxy,
|
||||
IStorageHandler,
|
||||
Versions,
|
||||
ProxyList,
|
||||
Package,
|
||||
Config,
|
||||
MergeTags,
|
||||
|
@ -27,7 +23,6 @@ import type {
|
|||
Callback,
|
||||
Logger,
|
||||
} from '@verdaccio/types';
|
||||
|
||||
import type {IReadTarball, IUploadTarball} from '@verdaccio/streams';
|
||||
|
||||
const LoggerApi = require('../lib/logger');
|
||||
|
|
|
@ -11,15 +11,13 @@ import {parseInterval, isObject, ErrorCode} from './utils';
|
|||
import {ReadTarball} from '@verdaccio/streams';
|
||||
|
||||
import type {
|
||||
IProxy,
|
||||
Config,
|
||||
UpLinkConf,
|
||||
Callback,
|
||||
Headers,
|
||||
Logger,
|
||||
} from '@verdaccio/types';
|
||||
|
||||
// import type {IUploadTarball, IReadTarball} from '@verdaccio/streams';
|
||||
import type {IProxy} from '../../types';
|
||||
|
||||
const LoggerApi = require('./logger');
|
||||
const encode = function(thing) {
|
||||
|
|
|
@ -7,8 +7,8 @@ import configExample from './partials/config';
|
|||
import AppConfig from '../../src/lib/config';
|
||||
import {setup} from '../../src/lib/logger';
|
||||
|
||||
|
||||
import type {IAuth, Config} from '@verdaccio/types';
|
||||
import type {IAuth} from '../../types';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
|
||||
setup(configExample.logs);
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ import {readFile} from '../functional/lib/test.utils';
|
|||
|
||||
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([]);
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import AppConfig from '../../src/lib/config';
|
|||
import Storage from '../../src/lib/storage';
|
||||
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);
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ import _ from 'lodash';
|
|||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
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([]);
|
||||
|
||||
|
|
104
types/index.js
Normal file
104
types/index.js
Normal 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
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue