build(aio): upgrade all preview server dependencies

This commit is contained in:
George Kalpakas 2017-09-23 15:24:04 +03:00 committed by Victor Berchet
parent adb0b761f1
commit 620407720c
10 changed files with 383 additions and 921 deletions

View File

@ -18,7 +18,7 @@ const TEST_AIO_UPLOAD_PORT = +getEnvVar('TEST_AIO_UPLOAD_PORT');
const WWW_USER = getEnvVar('AIO_WWW_USER'); const WWW_USER = getEnvVar('AIO_WWW_USER');
// Interfaces - Types // Interfaces - Types
export interface CmdResult { success: boolean; err: Error; stdout: string; stderr: string; } export interface CmdResult { success: boolean; err: Error | null; stdout: string; stderr: string; }
export interface FileSpecs { content?: string; size?: number; } export interface FileSpecs { content?: string; size?: number; }
export type CleanUpFn = () => void; export type CleanUpFn = () => void;
@ -143,7 +143,7 @@ class Helper {
statusText = status[1]; statusText = status[1];
} else { } else {
statusCode = status; statusCode = status;
statusText = http.STATUS_CODES[statusCode]; statusText = http.STATUS_CODES[statusCode] || 'UNKNOWN_STATUS_CODE';
} }
return (result: CmdResult) => { return (result: CmdResult) => {
@ -196,7 +196,7 @@ class Helper {
} }
// Methods - Protected // Methods - Protected
protected createCleanUpFn(fn: Function): CleanUpFn { protected createCleanUpFn(fn: () => void): CleanUpFn {
const cleanUpFn = () => { const cleanUpFn = () => {
const idx = this.cleanUpFns.indexOf(cleanUpFn); const idx = this.cleanUpFns.indexOf(cleanUpFn);
if (idx !== -1) { if (idx !== -1) {

View File

@ -8,7 +8,7 @@
"scripts": { "scripts": {
"prebuild": "yarn clean-dist", "prebuild": "yarn clean-dist",
"build": "tsc", "build": "tsc",
"build-watch": "yarn tsc -- --watch", "build-watch": "yarn tsc --watch",
"clean-dist": "node --eval \"require('shelljs').rm('-rf', 'dist')\"", "clean-dist": "node --eval \"require('shelljs').rm('-rf', 'dist')\"",
"dev": "concurrently --kill-others --raw --success first \"yarn build-watch\" \"yarn test-watch\"", "dev": "concurrently --kill-others --raw --success first \"yarn build-watch\" \"yarn test-watch\"",
"lint": "tslint --project tsconfig.json", "lint": "tslint --project tsconfig.json",
@ -20,26 +20,26 @@
"test-watch": "nodemon --exec \"yarn ~~test-only\" --watch dist" "test-watch": "nodemon --exec \"yarn ~~test-only\" --watch dist"
}, },
"dependencies": { "dependencies": {
"body-parser": "^1.17.2", "body-parser": "^1.18.2",
"express": "^4.14.1", "express": "^4.15.4",
"jasmine": "^2.5.3", "jasmine": "^2.8.0",
"jsonwebtoken": "^7.3.0", "jsonwebtoken": "^8.0.1",
"shelljs": "^0.7.6" "shelljs": "^0.7.8",
"tslib": "^1.7.1"
}, },
"devDependencies": { "devDependencies": {
"@types/body-parser": "^1.16.4", "@types/body-parser": "^1.16.5",
"@types/express": "^4.0.35", "@types/express": "^4.0.37",
"@types/jasmine": "^2.5.43", "@types/jasmine": "^2.6.0",
"@types/jsonwebtoken": "^7.2.0", "@types/jsonwebtoken": "^7.2.3",
"@types/node": "^7.0.5", "@types/node": "^8.0.30",
"@types/shelljs": "^0.7.0", "@types/shelljs": "^0.7.4",
"@types/supertest": "^2.0.0", "@types/supertest": "^2.0.3",
"concurrently": "^3.3.0", "concurrently": "^3.5.0",
"eslint": "^3.15.0", "nodemon": "^1.12.1",
"eslint-plugin-jasmine": "^2.2.0",
"nodemon": "^1.11.0",
"supertest": "^3.0.0", "supertest": "^3.0.0",
"tslint": "^4.4.2", "tslint": "^5.7.0",
"typescript": "^2.1.6" "tslint-jasmine-noSkipOrFocus": "^1.0.8",
"typescript": "^2.5.2"
} }
} }

View File

@ -39,8 +39,8 @@ describe('BuildCleaner', () => {
let cleanerGetExistingBuildNumbersSpy: jasmine.Spy; let cleanerGetExistingBuildNumbersSpy: jasmine.Spy;
let cleanerGetOpenPrNumbersSpy: jasmine.Spy; let cleanerGetOpenPrNumbersSpy: jasmine.Spy;
let cleanerRemoveUnnecessaryBuildsSpy: jasmine.Spy; let cleanerRemoveUnnecessaryBuildsSpy: jasmine.Spy;
let existingBuildsDeferred: {resolve: Function, reject: Function}; let existingBuildsDeferred: {resolve: (v?: any) => void, reject: (e?: any) => void};
let openPrsDeferred: {resolve: Function, reject: Function}; let openPrsDeferred: {resolve: (v?: any) => void, reject: (e?: any) => void};
let promise: Promise<void>; let promise: Promise<void>;
beforeEach(() => { beforeEach(() => {
@ -195,7 +195,7 @@ describe('BuildCleaner', () => {
describe('getOpenPrNumbers()', () => { describe('getOpenPrNumbers()', () => {
let prDeferred: {resolve: Function, reject: Function}; let prDeferred: {resolve: (v: any) => void, reject: (v: any) => void};
let promise: Promise<number[]>; let promise: Promise<number[]>;
beforeEach(() => { beforeEach(() => {
@ -277,7 +277,10 @@ describe('BuildCleaner', () => {
it('should catch errors and log them', () => { it('should catch errors and log them', () => {
const consoleErrorSpy = spyOn(console, 'error'); const consoleErrorSpy = spyOn(console, 'error');
shellRmSpy.and.callFake(() => { throw 'Test'; }); shellRmSpy.and.callFake(() => {
// tslint:disable-next-line: no-string-throw
throw 'Test';
});
(cleaner as any).removeDir('/foo/bar'); (cleaner as any).removeDir('/foo/bar');

View File

@ -56,7 +56,7 @@ describe('GithubApi', () => {
it('should not pass data to \'request()\'', () => { it('should not pass data to \'request()\'', () => {
(api.get as Function)('foo', {}, {}); (api.get as any)('foo', {}, {});
expect(apiRequestSpy).toHaveBeenCalled(); expect(apiRequestSpy).toHaveBeenCalled();
expect(apiRequestSpy.calls.argsFor(0)[2]).toBeUndefined(); expect(apiRequestSpy.calls.argsFor(0)[2]).toBeUndefined();
@ -144,7 +144,7 @@ describe('GithubApi', () => {
describe('getPaginated()', () => { describe('getPaginated()', () => {
let deferreds: {resolve: Function, reject: Function}[]; let deferreds: {resolve: (v: any) => void, reject: (v: any) => void}[];
beforeEach(() => { beforeEach(() => {
deferreds = []; deferreds = [];
@ -292,7 +292,7 @@ describe('GithubApi', () => {
describe('onResponse', () => { describe('onResponse', () => {
let promise: Promise<Object>; let promise: Promise<object>;
let respond: (statusCode: number) => IncomingMessage; let respond: (statusCode: number) => IncomingMessage;
beforeEach(() => { beforeEach(() => {

View File

@ -22,7 +22,7 @@ describe('GithubPullRequests', () => {
describe('addComment()', () => { describe('addComment()', () => {
let prs: GithubPullRequests; let prs: GithubPullRequests;
let deferred: {resolve: Function, reject: Function}; let deferred: {resolve: (v: any) => void, reject: (v: any) => void};
beforeEach(() => { beforeEach(() => {
prs = new GithubPullRequests('12345', 'foo/bar'); prs = new GithubPullRequests('12345', 'foo/bar');

View File

@ -223,6 +223,7 @@ describe('BuildCreator', () => {
it('should reject with an UploadError', done => { it('should reject with an UploadError', done => {
// tslint:disable-next-line: no-string-throw
shellMkdirSpy.and.callFake(() => { throw 'Test'; }); shellMkdirSpy.and.callFake(() => { throw 'Test'; });
bc.create(pr, sha, archive, isPublic).catch(err => { bc.create(pr, sha, archive, isPublic).catch(err => {
expectToBeUploadError(err, 500, `Error while uploading to directory: ${shaDir}\nTest`); expectToBeUploadError(err, 500, `Error while uploading to directory: ${shaDir}\nTest`);
@ -407,6 +408,7 @@ describe('BuildCreator', () => {
it('should reject with an UploadError', done => { it('should reject with an UploadError', done => {
// tslint:disable-next-line: no-string-throw
shellMvSpy.and.callFake(() => { throw 'Test'; }); shellMvSpy.and.callFake(() => { throw 'Test'; });
bc.updatePrVisibility(pr, makePublic).catch(err => { bc.updatePrVisibility(pr, makePublic).catch(err => {
expectToBeUploadError(err, 500, `Error while making PR ${pr} ${makePublic ? 'public' : 'hidden'}.\nTest`); expectToBeUploadError(err, 500, `Error while making PR ${pr} ${makePublic ? 'public' : 'hidden'}.\nTest`);
@ -434,11 +436,11 @@ describe('BuildCreator', () => {
describe('exists()', () => { describe('exists()', () => {
let fsAccessSpy: jasmine.Spy; let fsAccessSpy: jasmine.Spy;
let fsAccessCbs: Function[]; let fsAccessCbs: ((v?: any) => void)[];
beforeEach(() => { beforeEach(() => {
fsAccessCbs = []; fsAccessCbs = [];
fsAccessSpy = spyOn(fs, 'access').and.callFake((_: string, cb: Function) => fsAccessCbs.push(cb)); fsAccessSpy = spyOn(fs, 'access').and.callFake((_: string, cb: (v?: any) => void) => fsAccessCbs.push(cb));
}); });
@ -482,7 +484,7 @@ describe('BuildCreator', () => {
let shellChmodSpy: jasmine.Spy; let shellChmodSpy: jasmine.Spy;
let shellRmSpy: jasmine.Spy; let shellRmSpy: jasmine.Spy;
let cpExecSpy: jasmine.Spy; let cpExecSpy: jasmine.Spy;
let cpExecCbs: Function[]; let cpExecCbs: ((...args: any[]) => void)[];
beforeEach(() => { beforeEach(() => {
cpExecCbs = []; cpExecCbs = [];
@ -490,7 +492,7 @@ describe('BuildCreator', () => {
consoleWarnSpy = spyOn(console, 'warn'); consoleWarnSpy = spyOn(console, 'warn');
shellChmodSpy = spyOn(shell, 'chmod'); shellChmodSpy = spyOn(shell, 'chmod');
shellRmSpy = spyOn(shell, 'rm'); shellRmSpy = spyOn(shell, 'rm');
cpExecSpy = spyOn(cp, 'exec').and.callFake((_: string, cb: Function) => cpExecCbs.push(cb)); cpExecSpy = spyOn(cp, 'exec').and.callFake((_: string, cb: (...args: any[]) => void) => cpExecCbs.push(cb));
}); });
@ -556,7 +558,11 @@ describe('BuildCreator', () => {
done(); done();
}); });
shellChmodSpy.and.callFake(() => { throw 'Test'; }); shellChmodSpy.and.callFake(() => {
// tslint:disable-next-line: no-string-throw
throw 'Test';
});
cpExecCbs[0](); cpExecCbs[0]();
}); });
@ -569,7 +575,11 @@ describe('BuildCreator', () => {
done(); done();
}); });
shellRmSpy.and.callFake(() => { throw 'Test'; }); shellRmSpy.and.callFake(() => {
// tslint:disable-next-line: no-string-throw
throw 'Test';
});
cpExecCbs[0](); cpExecCbs[0]();
}); });

View File

@ -116,7 +116,7 @@ describe('uploadServerFactory', () => {
it('should log the server address info on \'listening\'', () => { it('should log the server address info on \'listening\'', () => {
const consoleInfoSpy = spyOn(console, 'info'); const consoleInfoSpy = spyOn(console, 'info');
const server = createUploadServer('builds/dir'); const server = createUploadServer();
server.address = () => ({address: 'foo', family: '', port: 1337}); server.address = () => ({address: 'foo', family: '', port: 1337});
expect(consoleInfoSpy).not.toHaveBeenCalled(); expect(consoleInfoSpy).not.toHaveBeenCalled();

View File

@ -1,25 +1,66 @@
{ {
"compilerOptions": { "compilerOptions": {
"alwaysStrict": true, /* Basic Options */
"forceConsistentCasingInFileNames": true, "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"inlineSourceMap": true, "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [ "lib": [
"es2016" "es2015",
], "es2016.array.include"
"noImplicitAny": true, ], /* Specify library files to be included in the compilation: */
"noImplicitReturns": true, // "allowJs": true, /* Allow javascript files to be compiled. */
"noImplicitThis": true, // "checkJs": true, /* Report errors in .js files. */
"noUnusedLocals": true, // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"noUnusedParameters": true, // "declaration": true, /* Generates corresponding '.d.ts' file. */
"outDir": "dist", // "sourceMap": true, /* Generates corresponding '.map' file. */
"pretty": true, // "outFile": "./", /* Concatenate and emit output to single file. */
"rootDir": ".", "outDir": "dist", /* Redirect output structure to the directory. */
"skipLibCheck": true, // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strictNullChecks": true, // "removeComments": true, /* Do not emit comments to output. */
"target": "es5", // "noEmit": true, /* Do not emit outputs. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
] ], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Other */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"newLine": "LF", /* Use the specified end of line sequence to be used when emitting files: "crlf" (windows) or "lf" (unix). */
"pretty": true, /* Stylize errors and messages using color and context. */
"skipLibCheck": true /* Skip type checking of all declaration files (*.d.ts). */
}, },
"include": [ "include": [
"lib/**/*", "lib/**/*",

View File

@ -1,5 +1,9 @@
{ {
"extends": "tslint:recommended", "defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": { "rules": {
"array-type": [true, "array"], "array-type": [true, "array"],
"arrow-parens": [true, "ban-single-arg-parens"], "arrow-parens": [true, "ban-single-arg-parens"],
@ -7,9 +11,14 @@
"max-classes-per-file": [true, 4], "max-classes-per-file": [true, 4],
"no-consecutive-blank-lines": [true, 2], "no-consecutive-blank-lines": [true, 2],
"no-console": [false], "no-console": [false],
"no-focused-test": true,
"no-namespace": [true, "allow-declarations"], "no-namespace": [true, "allow-declarations"],
"no-skipped-test": true,
"no-string-literal": false, "no-string-literal": false,
"quotemark": [true, "single"], "quotemark": [true, "single"],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"] "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
} },
"rulesDirectory": [
"node_modules/tslint-jasmine-noSkipOrFocus"
]
} }

File diff suppressed because it is too large Load Diff