Typings added; code style improved

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 9376803f40
commit c54d004d72
  1. 6
      BuildServer/app.ts
  2. 2
      BuildServer/lib/builder.ts
  3. 44
      BuildServer/lib/report-processor.ts
  4. 4
      BuildServer/lib/tasks/zip.ts
  5. 122
      BuildServer/package.json
  6. 4
      BuildServer/routes/release.ts
  7. 4
      BuildServer/tsconfig.json

@ -1,9 +1,9 @@
"use strict";
import * as realFs from "fs";
import * as fs from "graceful-fs";
import * as fs from "fs";
import { gracefulify } from "graceful-fs";
fs.gracefulify(realFs);
gracefulify(fs);
import * as express from "express";
import * as routes from "./routes";

@ -74,7 +74,7 @@ export const build = (options, buildCallback) => {
const tmp = join(options.app.get("tmpcodepath"), rev.substr(0, maxTmpcodepathLength));
const exported = tmp + codePostfix;
const release = join(options.app.get("releasepath"), owner, reponame, branch, rev);
const statusQueue = queue((task, queueCallback) => task(queueCallback), 1);
const statusQueue = queue((task: (callback: any) => void, queueCallback) => task(queueCallback), 1);
const actualGitLoader = wrapGitLoader(skipGitLoader);
const date = new Date();
const versionMajor = date.getFullYear();

@ -8,6 +8,40 @@ import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
import * as _ from "underscore";
import * as JSONParse from "json-parse-safe";
interface Message {
message: string;
prefix: string;
};
interface PartialMessagesLeaf {
$messages: string[];
};
interface PartialMessagesRecursive {
[propName: string]: Messages;
};
interface PartialMessagesRoot {
$allMessages: Message[];
};
type Messages = PartialMessagesLeaf & PartialMessagesRecursive;
type MessagesRoot = PartialMessagesLeaf & PartialMessagesRecursive & PartialMessagesRoot;
interface ReportResult {
errors: MessagesRoot;
warns: MessagesRoot;
infos: MessagesRoot;
messages: MessagesRoot;
};
interface Report {
date: number;
err?: string;
result?: ReportResult;
};
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
const attemptsTimeout = 30000;
@ -20,11 +54,11 @@ const readableStreamBufferOptions = {
"frequency": 1
};
const getAllErrors = (report) => ((report.result || {}).errors || {}).$allMessages || [];
const getAllWarns = (report) => ((report.result || {}).warns || {}).$allMessages || [];
const getAllInfos = (report) => ((report.result || {}).infos || {}).$allMessages || [];
const getAllErrors = (report: Report): Message[] => (report.result && report.result.errors && report.result.errors.$allMessages) || [];
const getAllWarns = (report: Report): Message[] => (report.result && report.result.warns && report.result.errors.$allMessages) || [];
const getAllInfos = (report: Report): Message[] => (report.result && report.result.infos && report.result.errors.$allMessages) || [];
export const writeReport = (releaseDir, err, result, callback) => {
export const writeReport = (releaseDir, err, result: ReportResult, callback) => {
const data = JSON.stringify({
"date": Date.now(),
err,
@ -67,7 +101,7 @@ export const readReport = (releaseDir, callback) => {
return callback("ReportFileNotFound");
}
const { error, value } = JSONParse(data);
const { error, value }: { error: any, value?: Report } = JSONParse(data);
if (error) {
return callback("ReportFileMalformed");
}

@ -2,7 +2,7 @@
import { createWriteStream } from "fs";
import { join, normalize } from "path";
import * as Archiver from "archiver";
import { create as createArchiver } from "archiver";
export default (params, processor) => ({
"process": () => {
@ -12,7 +12,7 @@ export default (params, processor) => ({
processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
const output = createWriteStream(targetArchivePath);
const archive = new Archiver("zip");
const archive = createArchiver("zip");
output.on("close", () => processor.done());

@ -4,8 +4,9 @@
"private": true,
"scripts": {
"start": "forever -c node app.js",
"test": "./node_modules/.bin/eslint .",
"tslint": "./node_modules/.bin/tslint --project tsconfig.json --type-check --force"
"build": "./node_modules/.bin/tsc -p .",
"pretest": "./node_modules/.bin/tsc -p . --noEmit",
"test": "./node_modules/.bin/tslint --project tsconfig.json --type-check"
},
"dependencies": {
"archiver": "^1.3.0",
@ -16,7 +17,7 @@
"eslint": "^3.12.2",
"express": "4.14.0",
"fs-extra": "^1.0.0",
"github": "~7.1.0",
"github": "~9.0.0",
"glob": "~7.1.1",
"graceful-fs": "^4.1.11",
"jade": "*",
@ -25,7 +26,6 @@
"morgan": "^1.7.0",
"mustache": "~2.3.0",
"nodegit": "~0.16.0",
"nodemailer": "~2.7.0",
"recursive-tree-copy": "0.0.1",
"serve-favicon": "^2.3.2",
"serve-static": "^1.11.1",
@ -33,106 +33,24 @@
"uglify-js": "^2.7.5",
"underscore": "^1.8.3"
},
"eslintConfig": {
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 6
},
"plugins": [
"fp"
],
"extends": [
"eslint:all",
"plugin:fp/recommended"
],
"rules": {
"fp/no-unused-expression": "off",
"fp/no-nil": "off",
"fp/no-mutation": [
"error",
{
"commonjs": true
}
],
"prefer-destructuring": "off",
"quotes": [
"warn",
"double"
],
"require-jsdoc": "off",
"func-names": [
"warn",
"never"
],
"max-len": [
"warn",
{
"code": 140
}
],
"operator-linebreak": [
"warn",
"before"
],
"padded-blocks": [
"warn",
"never"
],
"dot-notation": [
"warn",
{
"allowPattern": "^[a-z]+(_[a-z]+)+$"
}
],
"linebreak-style": [
"warn",
"windows"
],
"no-console": "off",
"dot-location": [
"warn",
"property"
],
"object-curly-spacing": [
"warn",
"always"
],
"one-var": [
"warn",
{
"initialized": "never"
}
],
"no-magic-numbers": [
"warn",
{
"ignore": [
0,
1
]
}
],
"id-length": [
"warn",
{
"exceptions": [
"_"
]
}
],
"no-extra-parens": [
"warn",
"all",
{
"nestedBinaryExpressions": false
}
]
}
},
"devDependencies": {
"@types/archiver": "^0.15.37",
"@types/async": "^2.0.38",
"@types/body-parser": "0.0.34",
"@types/errorhandler": "0.0.30",
"@types/express": "^4.0.35",
"@types/fs-extra": "0.0.37",
"@types/github": "0.0.0",
"@types/glob": "^5.0.30",
"@types/jade": "0.0.30",
"@types/method-override": "0.0.29",
"@types/morgan": "^1.7.32",
"@types/mustache": "^0.8.29",
"@types/node": "^7.0.5",
"@types/serve-favicon": "^2.2.28",
"@types/serve-static": "^1.7.31",
"@types/uglify-js": "^2.6.28",
"@types/underscore": "^1.7.36",
"tslint": "^4.4.2",
"typescript": "^2.2.1"
}

@ -1,7 +1,7 @@
"use strict";
import { join } from "path";
import * as Archiver from "archiver";
import { create as createArchiver } from "archiver";
import { readReport } from "../lib/report-processor";
@ -39,7 +39,7 @@ export default (req, res, next) => {
return next(err);
}
const archive = new Archiver("zip");
const archive = createArchiver("zip");
archive.on("error", next);
res.attachment(`${options.reponame}.${getDatePart(report)}.${options.rev}.zip`, ".");

@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"sourceMap": false,
"typeRoots": [
"node_modules/@types"
]
@ -11,5 +12,8 @@
"settings.ts",
"lib/**/*.ts",
"routes/**/*.ts"
],
"exclude": [
"node_modules/**/*.ts"
]
}

Loading…
Cancel
Save