0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00
verdaccio/test/functional/lib/verdaccio-server.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

// @flow
import _ from 'lodash';
2017-11-27 07:15:09 +01:00
import VerdaccioProcess from './server_process';
import type {IVerdaccioConfig, IServerProcess} from './types';
export class VerdaccioConfig implements IVerdaccioConfig {
storagePath: string;
configPath: string;
domainPath: string;
constructor(storagePath: string, configPath: string, domainPath: string) {
this.storagePath = storagePath;
this.configPath = configPath;
this.domainPath = domainPath;
}
}
export class VerdaccioServer {
serverProcess: IServerProcess;
pid: number;
constructor(config: IVerdaccioConfig) {
2017-11-27 07:15:09 +01:00
console.log("*************VerdaccioServer****************");
this.serverProcess = new VerdaccioProcess(config);
2017-11-27 07:15:09 +01:00
console.log("*************VerdaccioServer****************");
}
start(): Promise<any> {
2017-11-27 07:15:09 +01:00
console.log("*************VerdaccioServer******start**********");
return this.serverProcess.init().then(this.debugCheck);
}
2017-11-27 07:15:09 +01:00
debugCheck = (): Promise<any> => {
console.log("*************VerdaccioServer******debugCheck**********");
return new Promise((resolve, reject) => {
this.serverProcess.getBridge().debug().status(200).then((body) => {
if (_.isNil(body.pid)) {
reject();
}
2017-11-27 07:15:09 +01:00
console.log("*************body.pid;******debugCheck**********", body.pid);
this.pid = body.pid;
2017-11-27 07:15:09 +01:00
console.log("************authTestUser***");
return this.authTestUser().catch(function(reason: any) {
2017-11-27 07:15:09 +01:00
console.log("************authTestUser**reason*", reason);
reject(reason);
});
}).catch(function(reason: any) {
reject(reason);
});
});
}
authTestUser(): Promise<any> {
return this.serverProcess.getBridge().auth('test', 'test')
.status(201)
.body_ok(/'test'/);
}
stop() {
}
notify() {
}
}