From 207183e5314ef76d483f063794d6e9303ebce3e0 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 27 May 2019 13:35:07 +0200 Subject: [PATCH] fix(core): update --- package-lock.json | 14 ++++++------ package.json | 4 ++-- test/test.ts | 19 ++++++++++++---- ts/index.ts | 55 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8466f0b..65577dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,9 +61,9 @@ } }, "@gitzone/tstest": { - "version": "1.0.21", - "resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.21.tgz", - "integrity": "sha512-bYdU0+H2ZZZtIq5mxM6wql2E/kP33x9okNjU0SVuGi/NuyKLpM04MnGH3n0VaaC+kU2bEz80DL1AkmDMrYCK/w==", + "version": "1.0.22", + "resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.22.tgz", + "integrity": "sha512-S3Gcyml+Fr4+QYinRcUmedvR8E+MfPik6P7Om4cwI1DyrNvBt0BgCricfxIKrqI8qleY1mtAbJWm8d3BO/ZSww==", "dev": true, "requires": { "@gitzone/tsrun": "^1.2.6", @@ -71,7 +71,7 @@ "@pushrocks/smartfile": "^7.0.2", "@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartpromise": "^3.0.2", - "@pushrocks/smartshell": "^2.0.16", + "@pushrocks/smartshell": "^2.0.17", "@types/figures": "^3.0.1", "figures": "^3.0.0" } @@ -391,9 +391,9 @@ "dev": true }, "@types/node": { - "version": "10.14.7", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-10.14.7.tgz", - "integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A==", + "version": "12.0.2", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.0.2.tgz", + "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==", "dev": true }, "@types/vinyl": { diff --git a/package.json b/package.json index d44f398..83ed42b 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,9 @@ }, "devDependencies": { "@gitzone/tsbuild": "^2.0.22", - "@gitzone/tstest": "^1.0.15", + "@gitzone/tstest": "^1.0.22", "@pushrocks/tapbundle": "^3.0.7", - "@types/node": "^10.11.7", + "@types/node": "^12.0.2", "tslint": "^5.11.0", "tslint-config-prettier": "^1.15.0" }, diff --git a/test/test.ts b/test/test.ts index f522af8..5903a0d 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,8 +1,19 @@ import { expect, tap } from '@pushrocks/tapbundle'; -import * as smartmanifest from '../ts/index' +import * as smartmanifest from '../ts/index'; + +let testSmartManifest: smartmanifest.SmartManifest; tap.test('first test', async () => { - console.log(smartmanifest.standardExport) -}) + testSmartManifest = new smartmanifest.SmartManifest({ + name: 'test app', + short_name: 'app' + }); + expect(testSmartManifest).to.be.instanceOf(smartmanifest.SmartManifest); +}); -tap.start() +tap.test('should produce a web app manifest', async () => { + const testData = testSmartManifest.getData(); + console.log(testData); +}); + +tap.start(); diff --git a/ts/index.ts b/ts/index.ts index bac341e..8d8aec2 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,3 +1,56 @@ import * as plugins from './smartmanifest.plugins'; -export let standardExport = 'Hi there! :) This is an exported string'; +export interface ISmartManifestConstructorOptions { + name: string; + short_name: string; + start_url?: '/'; + display?: string; + orientation?: string; + background_color?: string; + theme_color?: string; + icons?: [ + { + src: string; + type: string; + sizes: string; + } + ]; +} + +const defaultConstructorOptions: ISmartManifestConstructorOptions = { + name: 'UNNAMED APP', + short_name: 'UNNAMED', + start_url: '/', + display: 'standalone', + orientation: 'any', + background_color: '#fff', + theme_color: '#f78f21', + icons: [ + { + src: '/assets/icon-large.png', + type: 'image/png', + sizes: '1024x1024', + } + ] +} + +export class SmartManifest { + public options: ISmartManifestConstructorOptions; + constructor(optionsArg: ISmartManifestConstructorOptions) { + this.options = { + ...defaultConstructorOptions, + ...optionsArg + }; + } + + public jsonString(): string { + return JSON.stringify(this.options); + } + + /** + * get the manifest data as javascriptObject + */ + public getData() { + return JSON.parse(JSON.stringify(this.options)); + } +}