Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console warnings if a shortcut has been skipped. #122

Merged
merged 4 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion packages/core/src/lib/TwaManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as fs from 'fs';
import fetch from 'node-fetch';
import {findSuitableIcon, generatePackageId} from './util';
import Color = require('color');
import Log from './Log';
import {WebManifestIcon, WebManifestJson} from './types/WebManifest';

// The minimum size needed for the app icon.
Expand Down Expand Up @@ -100,6 +101,8 @@ export class TwaManifest {
generatorApp: string;
webManifestUrl?: URL;

private static log: Log = new Log('twa-manifest');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I've been passing a log object in the constructor, but initialising with a default value. This helps with tests so those don't pollute the console. But I'm ok to keep like this too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being used from within a static function though. I could make it a module-level constant but that won't help with the pollution issue.


constructor(data: TwaManifestJson) {
this.packageId = data.packageId;
this.host = data.host;
Expand Down Expand Up @@ -188,13 +191,17 @@ export class TwaManifest {

const shortcuts: ShortcutInfo[] = [];

for (const s of webManifest.shortcuts || []) {
for (let i = 0; i < (webManifest.shortcuts || []).length; i++) {
const s = webManifest.shortcuts![i];

if (!s.icons || !s.url || (!s.name && !s.short_name)) {
TwaManifest.log.warn(`Skipping shortcut[${i}] for missing metadata.`);
continue;
}

const suitableIcon = findSuitableIcon(s.icons, 'any');
if (!suitableIcon) {
TwaManifest.log.warn(`Skipping shortcut[${i}] for not finding a suitable icon.`);
continue;
}

Expand Down