Skip to content

Commit

Permalink
Replace display input by list
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed Jun 28, 2020
1 parent 398246b commit 5a64a69
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
10 changes: 5 additions & 5 deletions packages/cli/src/lib/cmds/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import * as fs from 'fs';
import Color = require('color');
import * as inquirer from 'inquirer';
import {Config, JdkHelper, KeyTool, Log, TwaGenerator, TwaManifest, util} from '@bubblewrap/core';
import {validateColor, validateDisplayMode, validateKeyPassword, validateUrl,
notEmpty} from '../inputHelpers';
import {Config, DISPLAY_MODES, JdkHelper, KeyTool, Log, TwaGenerator, TwaManifest,
util} from '@bubblewrap/core';
import {validateColor, validateKeyPassword, validateUrl, notEmpty} from '../inputHelpers';
import {ParsedArgs} from 'minimist';
import {APP_NAME} from '../constants';

Expand Down Expand Up @@ -52,10 +52,10 @@ async function confirmTwaConfig(twaManifest: TwaManifest): Promise<TwaManifest>
validate: async (input): Promise<boolean> => notEmpty(input, 'Launcher name'),
}, {
name: 'display',
type: 'input',
type: 'list',
message: 'Display mode to be used:',
default: twaManifest.display,
validate: validateDisplayMode,
choices: DISPLAY_MODES,
}, {
name: 'themeColor',
type: 'input',
Expand Down
8 changes: 0 additions & 8 deletions packages/cli/src/lib/inputHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,3 @@ export async function validateUrl(url: string): Promise<boolean> {
}
return true;
}

export async function validateDisplayMode(displayMode: string): Promise<boolean> {
const validModes = ['browser', 'minimal-ui', 'standalone', 'fullscreen'];
if (!validModes.includes(displayMode)) {
throw new Error(`${displayMode} is not a valid display mode (${validModes.join(', ')})`);
}
return true;
}
13 changes: 0 additions & 13 deletions packages/cli/src/spec/inputHelpersSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,4 @@ describe('inputHelpers', () => {
inputHelpers.validateColor('rgb(23, 0 30')).toBeRejectedWithError();
});
});

describe('#validateDisplayMode', () => {
it('returns true for valid colors', async () => {
expect(await inputHelpers.validateDisplayMode('browser'));
expect(await inputHelpers.validateDisplayMode('minimal-ui'));
expect(await inputHelpers.validateDisplayMode('standalone'));
expect(await inputHelpers.validateDisplayMode('fullscreen'));
});

it('throws Error for invalid display modes', async () => {
await expectAsync(inputHelpers.validateColor('bogus')).toBeRejectedWithError();
});
});
});
3 changes: 2 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {GradleWrapper} from './lib/GradleWrapper';
import Log from './lib/Log';
import {JdkHelper} from './lib/jdk/JdkHelper';
import {KeyTool} from './lib/jdk/KeyTool';
import {TwaManifest} from './lib/TwaManifest';
import {TwaManifest, DISPLAY_MODES} from './lib/TwaManifest';
import {TwaGenerator} from './lib/TwaGenerator';
import {DigitalAssetLinks} from './lib/DigitalAssetLinks';
import * as util from './lib/util';
Expand All @@ -34,5 +34,6 @@ export {AndroidSdkTools,
Log,
TwaGenerator,
TwaManifest,
DISPLAY_MODES,
util,
};

0 comments on commit 5a64a69

Please sign in to comment.