diff --git a/common/logger.ts b/common/logger.ts index 3a1c863..7f0ccc3 100644 --- a/common/logger.ts +++ b/common/logger.ts @@ -68,14 +68,6 @@ function write(value: any) { fn.apply(null, args); } -function withSpaces(value: string): string { - const lines = value.split("\n"); - for (let i = 1; i < lines.length; i++) { - lines[i] = " " + lines[i]; - } - return lines.join("\n"); -} - function filter(value: any) { const keys = Object.keys(value); const result: any = {}; @@ -93,19 +85,6 @@ function asISODate(time: string) { return new Date(time).toISOString(); } -function formatTime(value: any, after?: string) { - after = after || ""; - try { - if (!value || !value.time) { - return ""; - } else { - return "[" + asISODate(value.time) + "]" + after; - } - } catch (_) { - return ""; - } -} - function formatSource(value: any): { str: string, args: any[] } { if (value.source) { return { str: "%c(" + value.source + ") ", args: ["color: #FF00FF"] }; diff --git a/common/sprinklers/SectionRunner.ts b/common/sprinklers/SectionRunner.ts index 3aa8099..21e6be0 100644 --- a/common/sprinklers/SectionRunner.ts +++ b/common/sprinklers/SectionRunner.ts @@ -1,4 +1,4 @@ -import { IObservableArray, observable } from "mobx"; +import { observable } from "mobx"; import { Duration } from "./Duration"; import { SprinklersDevice } from "./SprinklersDevice"; diff --git a/common/sprinklers/SprinklersDevice.ts b/common/sprinklers/SprinklersDevice.ts index dbcf5fa..5247bcc 100644 --- a/common/sprinklers/SprinklersDevice.ts +++ b/common/sprinklers/SprinklersDevice.ts @@ -1,4 +1,4 @@ -import { IObservableArray, observable } from "mobx"; +import { observable } from "mobx"; import { Duration } from "./Duration"; import { Program } from "./Program"; import { Section } from "./Section"; diff --git a/common/sprinklers/index.ts b/common/sprinklers/index.ts index 3424c58..8aad53d 100644 --- a/common/sprinklers/index.ts +++ b/common/sprinklers/index.ts @@ -1,4 +1,3 @@ -import { IObservableArray, observable } from "mobx"; export * from "./Duration"; export * from "./ISprinklersApi"; export * from "./Program"; diff --git a/common/sprinklers/json/index.ts b/common/sprinklers/json/index.ts index 62c8dae..e44503d 100644 --- a/common/sprinklers/json/index.ts +++ b/common/sprinklers/json/index.ts @@ -1,8 +1,6 @@ /* tslint:disable:ordered-imports */ -import { assign, pick } from "lodash"; import { - createSimpleSchema, createModelSchema, primitive, object, date, custom, - ModelSchema, PropSchema, + createSimpleSchema, primitive, object, ModelSchema, PropSchema, } from "serializr"; import list from "./list"; import * as s from ".."; diff --git a/common/sprinklers/mqtt/index.ts b/common/sprinklers/mqtt/index.ts index 317fe75..c2a1de9 100644 --- a/common/sprinklers/mqtt/index.ts +++ b/common/sprinklers/mqtt/index.ts @@ -1,6 +1,5 @@ -import { cloneDeep } from "lodash"; import * as mqtt from "mqtt"; -import { deserialize, update } from "serializr"; +import { update } from "serializr"; import logger from "@common/logger"; import * as s from "@common/sprinklers"; @@ -260,11 +259,6 @@ interface IResponseData { type ResponseCallback = (data: IResponseData) => void; -interface ISectionJSON { - name: string; - pin: number; -} - interface IRunSectionJSON { duration: number; } diff --git a/env.js b/env.js index 36b5e42..c29b7e0 100644 --- a/env.js +++ b/env.js @@ -8,7 +8,7 @@ delete require.cache[require.resolve("./paths")]; const NODE_ENV = process.env.NODE_ENV; if (!NODE_ENV) { throw new Error( - "The NODE_ENV environment variable is required but was not specified." + "The NODE_ENV environment variable is required but was not specified.", ); } @@ -72,7 +72,7 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) { // This should only be used as an escape hatch. Normally you would put // images into the `src` and `import` them in code to get their paths. PUBLIC_URL: publicUrl, - } + }, ); // Stringify all values so we can feed into Webpack DefinePlugin const stringified = { @@ -83,4 +83,4 @@ exports.getClientEnvironment = function getClientEnvironment(publicUrl) { }; return { raw, stringified }; -} +}; diff --git a/paths.js b/paths.js index 31b1ba3..dea0532 100644 --- a/paths.js +++ b/paths.js @@ -5,18 +5,17 @@ const url = require("url"); exports.rootDir = fs.realpathSync(process.cwd()); const resolveRoot = (p) => path.resolve(exports.rootDir, p); -function ensureSlash(path, needsSlash) { - const hasSlash = path.endsWith("/"); +function ensureSlash(p, needsSlash) { + const hasSlash = p.endsWith("/"); if (hasSlash && !needsSlash) { - return path.substr(path, path.length - 1); + return p.substr(p, p.length - 1); } else if (!hasSlash && needsSlash) { - return `${path}/`; + return `${p}/`; } else { - return path; + return p; } } - exports.dotenv = resolveRoot(".env"); exports.nodeModulesDir = resolveRoot("node_modules"); exports.packageJson = resolveRoot("package.json"); @@ -35,4 +34,3 @@ exports.publicDir = exports.appBuildDir; exports.serverDir = resolveRoot("server"); exports.serverBuildDir = resolveRoot("dist"); - diff --git a/server/app/serveApp.ts b/server/app/serveApp.ts index e4c3ae0..872e973 100644 --- a/server/app/serveApp.ts +++ b/server/app/serveApp.ts @@ -1,7 +1,6 @@ import { Express } from "express"; import * as serveStatic from "serve-static"; -import logger from "@common/logger"; import * as paths from "paths"; export default function serveApp(app: Express) {