Comparing version 0.0.3 to 0.0.4
@@ -1,9 +0,6 @@ | ||
import { Config } from "./config"; | ||
import { Template } from "./template"; | ||
import { Config } from './config'; | ||
export declare class Airhorn { | ||
config: Config; | ||
templates: Template[]; | ||
constructor(); | ||
getTemplate(name: string): Promise<Template>; | ||
} | ||
//# sourceMappingURL=airhorn.d.ts.map |
@@ -24,3 +24,2 @@ "use strict"; | ||
const config_1 = require("./config"); | ||
const template_1 = require("./template"); | ||
const Logger = __importStar(require("./logger")); | ||
@@ -31,12 +30,6 @@ const logger = Logger.create(); | ||
this.config = new config_1.Config(); | ||
this.templates = new Array(); | ||
logger.error("This is an init project. DO NOT USE. Please follow along at https://github.com/jaredwray/airhorn"); | ||
logger.error('This is an init project. DO NOT USE. Please follow along at https://github.com/jaredwray/airhorn'); | ||
} | ||
//templates | ||
async getTemplate(name) { | ||
let result = new template_1.Template(); | ||
return result; | ||
} | ||
} | ||
exports.Airhorn = Airhorn; | ||
//# sourceMappingURL=airhorn.js.map |
export declare class Config { | ||
templatePath: string; | ||
defaultTemplateLanguage: string; | ||
constructor(opts?: any); | ||
parse(opts: any): void; | ||
environment: string; | ||
constructor(options?: any); | ||
parse(options: any): void; | ||
} | ||
//# sourceMappingURL=config.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Config = void 0; | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable node/prefer-global/process */ | ||
class Config { | ||
constructor(opts) { | ||
this.templatePath = "./templates"; | ||
this.defaultTemplateLanguage = "en"; | ||
if (opts) { | ||
this.parse(opts); | ||
constructor(options) { | ||
this.templatePath = './templates'; | ||
this.defaultTemplateLanguage = 'en'; | ||
this.environment = 'development'; | ||
if (options) { | ||
this.parse(options); | ||
} | ||
/* Set the node environment */ | ||
if (process.env.NODE_ENV !== undefined) { | ||
this.environment = process.env.NODE_ENV; | ||
} | ||
} | ||
parse(opts) { | ||
if (opts.templatePath) { | ||
this.templatePath = opts.templatePath.toString(); | ||
parse(options) { | ||
if (options.templatePath) { | ||
this.templatePath = options.templatePath.toString(); | ||
} | ||
if (opts.defaultTemplateLanguage) { | ||
this.defaultTemplateLanguage = opts.defaultTemplateLanguage.toString(); | ||
if (options.defaultTemplateLanguage) { | ||
this.defaultTemplateLanguage = options.defaultTemplateLanguage.toString(); | ||
} | ||
@@ -19,0 +27,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import * as winston from "winston"; | ||
import * as winston from 'winston'; | ||
export declare function create(): winston.Logger; | ||
//# sourceMappingURL=logger.d.ts.map |
@@ -24,5 +24,7 @@ "use strict"; | ||
const winston = __importStar(require("winston")); | ||
const config_1 = require("./config"); | ||
function create() { | ||
let log = winston.createLogger({ transports: [new winston.transports.Console()] }); | ||
if (process.env.NODE_ENV === "test") { | ||
const log = winston.createLogger({ transports: [new winston.transports.Console()] }); | ||
const config = new config_1.Config(); | ||
if (config.environment === 'test') { | ||
log.silent = true; | ||
@@ -29,0 +31,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const airhorn_1 = require("../src/airhorn"); | ||
const template_1 = require("../src/template"); | ||
test("Test Init Error", () => { | ||
test('Test Init Error', () => { | ||
expect(new airhorn_1.Airhorn()).toEqual(new airhorn_1.Airhorn()); | ||
}); | ||
test("get template", async () => { | ||
let airhorn = new airhorn_1.Airhorn(); | ||
let template = await airhorn.getTemplate('foo'); | ||
expect(template).toEqual(new template_1.Template()); | ||
}); | ||
//# sourceMappingURL=airhorn.test.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const config_1 = require("../src/config"); | ||
test("Config - init", () => { | ||
test('Config - init', () => { | ||
expect(new config_1.Config()).toEqual(new config_1.Config()); | ||
}); | ||
test("Config - default settings", () => { | ||
let config = new config_1.Config(); | ||
expect(config.templatePath).toEqual("./templates"); | ||
expect(config.defaultTemplateLanguage).toEqual("en"); | ||
test('Config - default settings', () => { | ||
const config = new config_1.Config(); | ||
expect(config.templatePath).toEqual('./templates'); | ||
expect(config.defaultTemplateLanguage).toEqual('en'); | ||
}); | ||
test("Config - settings on constructor", () => { | ||
let obj = { | ||
templatePath: "./foo", | ||
defaultTemplateLanguage: "es" | ||
test('Config - settings on constructor', () => { | ||
const object = { | ||
templatePath: './foo', | ||
defaultTemplateLanguage: 'es', | ||
}; | ||
let config = new config_1.Config(obj); | ||
expect(config.templatePath).toEqual(obj.templatePath); | ||
const config = new config_1.Config(object); | ||
expect(config.templatePath).toEqual(object.templatePath); | ||
}); | ||
test("Config - parse with object", () => { | ||
let obj = { | ||
templatePath: "./foo", | ||
defaultTemplateLanguage: "es" | ||
test('Config - parse with object', () => { | ||
const object = { | ||
templatePath: './foo', | ||
defaultTemplateLanguage: 'es', | ||
}; | ||
let config = new config_1.Config(); | ||
config.parse(obj); | ||
expect(config.templatePath).toEqual(obj.templatePath); | ||
const config = new config_1.Config(); | ||
config.parse(object); | ||
expect(config.templatePath).toEqual(object.templatePath); | ||
}); | ||
test("Config - defaultTemplateLanguage Should Not Be Default en", () => { | ||
let obj = { | ||
templatePath: "./foo" | ||
test('Config - defaultTemplateLanguage Should Not Be Default en', () => { | ||
const object = { | ||
templatePath: './foo', | ||
}; | ||
let config = new config_1.Config(); | ||
config.parse(obj); | ||
expect(config.defaultTemplateLanguage).toEqual("en"); | ||
const config = new config_1.Config(); | ||
config.parse(object); | ||
expect(config.defaultTemplateLanguage).toEqual('en'); | ||
}); | ||
test("Config - settings on constructor", () => { | ||
let obj = { | ||
defaultTemplateLanguage: "es" | ||
test('Config - settings on constructor', () => { | ||
const object = { | ||
defaultTemplateLanguage: 'es', | ||
}; | ||
let config = new config_1.Config(); | ||
config.parse(obj); | ||
expect(config.defaultTemplateLanguage).toEqual(obj.defaultTemplateLanguage); | ||
const config = new config_1.Config(); | ||
config.parse(object); | ||
expect(config.defaultTemplateLanguage).toEqual(object.defaultTemplateLanguage); | ||
}); | ||
//# sourceMappingURL=config.test.js.map |
@@ -22,8 +22,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable node/prefer-global/process */ | ||
const Logger = __importStar(require("../src/logger")); | ||
test("Logger - silence", () => { | ||
process.env.NODE_ENV = "foo"; | ||
let logger = Logger.create(); | ||
test('Logger - silence', () => { | ||
process.env.NODE_ENV = 'foo'; | ||
const logger = Logger.create(); | ||
expect(logger.silent).toEqual(undefined); | ||
}); | ||
//# sourceMappingURL=logger.test.js.map |
{ | ||
"name": "airhorn", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Cloud Notification Library", | ||
@@ -12,3 +12,3 @@ "main": "./dist/airhorn", | ||
"scripts": { | ||
"test": "jest --coverage", | ||
"test": "xo && jest --coverage", | ||
"build": "tsc" | ||
@@ -21,3 +21,4 @@ }, | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^4.4.4" | ||
"typescript": "^4.4.4", | ||
"xo": "^0.45.0" | ||
}, | ||
@@ -31,3 +32,21 @@ "dependencies": { | ||
"dist" | ||
] | ||
], | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"tsconfig": "tsconfig.json" | ||
} | ||
}, | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js" | ||
], | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"testMatch": [ | ||
"**/test/**/*.test.(ts)" | ||
], | ||
"testEnvironment": "node" | ||
} | ||
} |
@@ -5,4 +5,4 @@  | ||
 | ||
 | ||
[](https://github.com/jaredwray/airhorn/actions/workflows/build.yaml) | ||
 | ||
[](https://codecov.io/gh/jaredwray/airhorn) | ||
@@ -9,0 +9,0 @@ [](https://github.com/jaredwray/airhorn/blob/master/LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
0
16345
6
27
189