Skip to content

Commit

Permalink
delete unnecessary commands, fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MilapNaik committed Mar 6, 2024
1 parent fa07787 commit 4344666
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 73 deletions.
40 changes: 20 additions & 20 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1877,43 +1877,43 @@ describe('index', () => {
describe('normalizeFilesArray', () => {
it('catches invalid dest entries', () => {
expect(() => {
rokuDeploy['normalizeFilesArray']([{
util['normalizeFilesArray']([{
src: 'some/path',
dest: <any>true
}]);
}).to.throw();

expect(() => {
rokuDeploy['normalizeFilesArray']([{
util['normalizeFilesArray']([{
src: 'some/path',
dest: <any>false
}]);
}).to.throw();

expect(() => {
rokuDeploy['normalizeFilesArray']([{
util['normalizeFilesArray']([{
src: 'some/path',
dest: <any>/asdf/gi
}]);
}).to.throw();

expect(() => {
rokuDeploy['normalizeFilesArray']([{
util['normalizeFilesArray']([{
src: 'some/path',
dest: <any>{}
}]);
}).to.throw();

expect(() => {
rokuDeploy['normalizeFilesArray']([{
util['normalizeFilesArray']([{
src: 'some/path',
dest: <any>[]
}]);
}).to.throw();
});

it('normalizes directory separators paths', () => {
expect(rokuDeploy['normalizeFilesArray']([{
expect(util['normalizeFilesArray']([{
src: `long/source/path`,
dest: `long/dest/path`
}])).to.eql([{
Expand All @@ -1923,7 +1923,7 @@ describe('index', () => {
});

it('works for simple strings', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
'manifest',
'source/main.brs'
])).to.eql([
Expand All @@ -1933,15 +1933,15 @@ describe('index', () => {
});

it('works for negated strings', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
'!.git'
])).to.eql([
'!.git'
]);
});

it('skips falsey and bogus entries', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
'',
'manifest',
<any>false,
Expand All @@ -1953,7 +1953,7 @@ describe('index', () => {
});

it('works for {src:string} objects', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
{
src: 'manifest'
}
Expand All @@ -1964,7 +1964,7 @@ describe('index', () => {
});

it('works for {src:string[]} objects', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
{
src: [
'manifest',
Expand All @@ -1981,7 +1981,7 @@ describe('index', () => {
});

it('retains dest option', () => {
expect(rokuDeploy['normalizeFilesArray']([
expect(util['normalizeFilesArray']([
{
src: 'source/config.dev.brs',
dest: 'source/config.brs'
Expand All @@ -1993,14 +1993,14 @@ describe('index', () => {
});

it('throws when encountering invalid entries', () => {
expect(() => rokuDeploy['normalizeFilesArray'](<any>[true])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[/asdf/])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[new Date()])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[1])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[{ src: true }])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[{ src: /asdf/ }])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[{ src: new Date() }])).to.throw();
expect(() => rokuDeploy['normalizeFilesArray'](<any>[{ src: 1 }])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[true])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[/asdf/])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[new Date()])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[1])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[{ src: true }])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[{ src: /asdf/ }])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[{ src: new Date() }])).to.throw();
expect(() => util['normalizeFilesArray'](<any>[{ src: 1 }])).to.throw();
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class RokuDeploy {
* Given an already-populated staging folder, create a zip archive of it and copy it to the output folder
* @param options
*/
public async zip(options: ZipPackageOptions) {
public async zip(options: ZipOptions) {
options = this.getOptions(options) as any;

//make sure the output folder exists
Expand Down Expand Up @@ -708,8 +708,8 @@ export class RokuDeploy {
this.logger.logLevel = finalOptions.logLevel; //TODO: Handle logging differently

//fully resolve the folder paths
finalOptions.rootDir = path.resolve(options.cwd, finalOptions.rootDir);
finalOptions.outDir = path.resolve(options.cwd, finalOptions.outDir);
finalOptions.rootDir = path.resolve(finalOptions.cwd, finalOptions.rootDir);
finalOptions.outDir = path.resolve(finalOptions.cwd, finalOptions.outDir);

//stagingDir
if (options.stagingDir) {
Expand Down Expand Up @@ -1003,7 +1003,7 @@ export interface StageOptions {
retainStagingDir?: boolean;
}

export interface ZipPackageOptions {
export interface ZipOptions {
stagingDir?: string;
outDir?: string;
}
Expand Down
5 changes: 5 additions & 0 deletions src/RokuDeployOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { LogLevel } from './Logger';

export interface RokuDeployOptions {
/**
* The working directory where the command should be executed
*/
cwd?: string;

/**
* Path to a bsconfig.json project file
*/
Expand Down
27 changes: 4 additions & 23 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { RekeyDeviceCommand } from './commands/RekeyDeviceCommand';
import { CreateSignedPackageCommand } from './commands/CreateSignedPackageCommand';
import { DeleteDevChannelCommand } from './commands/DeleteDevChannelCommand';
import { TakeScreenshotCommand } from './commands/TakeScreenshotCommand';
import { GetOutputZipFilePathCommand } from './commands/GetOutputZipFilePathCommand';
import { GetOutputPkgFilePathCommand } from './commands/GetOutputPkgFilePathCommand';
import { GetDeviceInfoCommand } from './commands/GetDeviceInfoCommand';
import { GetDevIdCommand } from './commands/GetDevIdCommand';
import { ZipCommand } from './commands/ZipCommand';
Expand Down Expand Up @@ -172,23 +170,6 @@ void yargs
return new TakeScreenshotCommand().run(args);
})

.command('getOutputZipFilePath', 'Centralizes getting output zip file path based on passed in options', (builder) => {
return builder
.option('outFile', { type: 'string', description: 'The output file', demandOption: false })
.option('outDir', { type: 'string', description: 'The output directory', demandOption: false });
return builder;
}, (args: any) => {
return new GetOutputZipFilePathCommand().run(args);
})

.command('getOutputPkgFilePath', 'Centralizes getting output pkg file path based on passed in options', (builder) => {
return builder
.option('outFile', { type: 'string', description: 'The output file', demandOption: false })
.option('outDir', { type: 'string', description: 'The output directory', demandOption: false });
}, (args: any) => {
return new GetOutputPkgFilePathCommand().run(args);
})

.command(['getDeviceInfo', 'deviceinfo'], 'Get the `device-info` response from a Roku device', (builder) => {
return builder
.option('host', { type: 'string', description: 'The IP Address of the host Roku', demandOption: false });
Expand All @@ -203,13 +184,13 @@ void yargs
return new GetDevIdCommand().run(args);
})

.command('zipFolder', 'Given a path to a folder, zip up that folder and all of its contents', (builder) => {
.command('zip', 'Given a path to a folder, zip up that folder and all of its contents', (builder) => {
return builder
.option('srcFolder', { type: 'string', description: 'The folder that should be zipped', demandOption: false })
.option('zipFilePath', { type: 'string', description: 'The path to the zip that will be created. Must be .zip file name', demandOption: false });
.option('stagingDir', { type: 'string', description: 'The folder that should be zipped', demandOption: false })
.option('outDir', { type: 'string', description: 'The path to the zip that will be created. Must be .zip file name', demandOption: false });
}, (args: any) => {
console.log('args', args);
return new ZipFolderCommand().run(args);
return new ZipCommand().run(args);
})

.argv;
13 changes: 0 additions & 13 deletions src/commands/GetOutputPkgFilePathCommand.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/commands/GetOutputZipFilePathCommand.ts

This file was deleted.

0 comments on commit 4344666

Please sign in to comment.