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 cli commands and rename roku-deploy functions, reorganize functions #142

Merged
merged 68 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
c6d2536
Make change to assume dest folder. Delete 2 old tests that looked for…
MilapNaik Jan 2, 2024
2ba8eca
Sort files
MilapNaik Jan 2, 2024
cc92e04
Update src/RokuDeploy.ts
MilapNaik Jan 16, 2024
9bbd579
Removed redundant entry.dest is null situation
MilapNaik Jan 17, 2024
460cbf6
Added a few commands, not all are working correctly
MilapNaik Jan 19, 2024
de269ed
Merge branch 'v4' into add-cli-commands
MilapNaik Jan 19, 2024
7b9ee29
Merge branch 'fix-src-dest-handling' into add-cli-commands
MilapNaik Jan 19, 2024
6db962a
Move commands to their own file
MilapNaik Jan 31, 2024
20eb21f
More command files
MilapNaik Feb 1, 2024
4e4b66a
Change commands to help with tests
MilapNaik Feb 1, 2024
2b809e6
Add testing suite for all cli (2 tests are not working)
MilapNaik Feb 2, 2024
13f2ca4
Updated cli file after adding in commands and tests
MilapNaik Feb 2, 2024
2d13441
Fixed a few test cases
MilapNaik Feb 2, 2024
09a275f
Change name and input of table helper
MilapNaik Feb 2, 2024
e34ac97
Totally broken code, but have the right names
TwitchBronBron Feb 2, 2024
52b1bc0
Changed name of toTable
MilapNaik Feb 6, 2024
f3a0c56
Make test for objectToTable
MilapNaik Feb 6, 2024
b5f41ca
add yargs to pacjage.json
MilapNaik Feb 6, 2024
4b95943
add package-lock.json
MilapNaik Feb 6, 2024
b6c6223
add new line at eof
MilapNaik Feb 6, 2024
f15f295
Add test for coverage, also remove an unncessary '?'
MilapNaik Feb 6, 2024
08a587e
Merge branch 'add-cli-commands' into rename
MilapNaik Feb 6, 2024
6941e86
tweaks
TwitchBronBron Feb 6, 2024
ea49342
tweaks
TwitchBronBron Feb 6, 2024
616ff23
get from json stuff
TwitchBronBron Feb 6, 2024
e2f3f80
Merge branch 'v4' into rename
MilapNaik Feb 6, 2024
190a2f1
Merge branch 'v4' into rename
MilapNaik Feb 6, 2024
cacf433
Correct imports
MilapNaik Feb 7, 2024
cbd6417
Last of the fsExtra changes
MilapNaik Feb 7, 2024
ebab568
Create a load from json util, clean up cli.ts file with fleshing out …
MilapNaik Feb 21, 2024
46fe129
Adding cli tests
MilapNaik Feb 22, 2024
36502e1
Delete deployAndSignPackage tests, a deleted function in rokudeploy
MilapNaik Feb 22, 2024
c058dd6
Add defaultsFromJson tests
MilapNaik Feb 22, 2024
5859f91
Move some tests to utils test file, re add other functions that might…
MilapNaik Feb 29, 2024
8ae9ace
Change signExistingPackage to CreateSignedPackage
MilapNaik Feb 29, 2024
cc0f4b8
Delete retrieveSignedPackage
MilapNaik Feb 29, 2024
cbfcaed
Move getFilePaths
MilapNaik Feb 29, 2024
c74ef8e
Random changes I forgot to put in the other pushes
MilapNaik Feb 29, 2024
583d960
Change to different notation since getOutputZipFilePath and getOutput…
MilapNaik Feb 29, 2024
6d874a6
Change notation for normalizeDeviceInfoFieldValue since it was made p…
MilapNaik Feb 29, 2024
f5ba839
Change notation for parsedManifestFromString and ParseManifest since …
MilapNaik Feb 29, 2024
2858dd6
Change deleteInstalledChannel to deleteDevChannel, other small changes
MilapNaik Feb 29, 2024
3186e88
Add stagingDir, fix zip/deleteDevChannel/captureScreenshot function c…
MilapNaik Mar 4, 2024
55ce426
Fix commands
MilapNaik Mar 4, 2024
8d4e537
change defaults from json function, fix some tests
MilapNaik Mar 5, 2024
1d75b10
fix index, fix makezip, getfilepaths, sideload
MilapNaik Mar 5, 2024
48d07d9
Add options from json ability to each command to each command
MilapNaik Mar 5, 2024
053a3f4
remove bsconfig, fix cli file with key press commands, fix key press …
MilapNaik Mar 5, 2024
fa07787
fix getoptionsfromjson
MilapNaik Mar 5, 2024
4344666
delete unnecessary commands, fix some tests
MilapNaik Mar 6, 2024
7d9e56e
change to captureScreenshot
MilapNaik Mar 6, 2024
ebb3d22
Fix a bunch of tests
MilapNaik Mar 8, 2024
243bbdd
Fix up the last few tests and cli commands
MilapNaik Mar 11, 2024
b485ea4
Changing coverage check to false
MilapNaik Mar 11, 2024
7ad7ff0
Fix failing tests on windows
TwitchBronBron Mar 11, 2024
fad56b9
Delete comment
MilapNaik Mar 11, 2024
b51c3fc
Change publish to sideload everywhere else
MilapNaik Mar 15, 2024
0da4110
Move deploy tests to test exec command
MilapNaik Mar 18, 2024
2ad743a
Throw new error for wrong device id, and add test to test for it
MilapNaik Mar 18, 2024
e6d8752
Delete creating variable options since it was unused
MilapNaik Mar 18, 2024
200e537
Add function description
MilapNaik Mar 18, 2024
a669ee3
Inline exec command options
MilapNaik Mar 18, 2024
906856e
Remove retainsStagingDir, zipCallBackInfo, incrementBuildNumber, and …
MilapNaik Mar 19, 2024
d065bd5
Delete convertToSquashfs, move deployAndSignPackage tests to cli, mov…
MilapNaik Mar 19, 2024
0f17569
Change prepublishToStaging to stage
MilapNaik Mar 20, 2024
94fa701
Change the way close channel works
MilapNaik Mar 20, 2024
f64ab5d
Update src/RokuDeploy.ts
MilapNaik Mar 20, 2024
4ffc8f7
Add outFile to Zip, delete zipPackage
MilapNaik Mar 20, 2024
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
],
"sourceMap": true,
"instrument": true,
"check-coverage": true,
"check-coverage": false,
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll re-enable this once most of v4 is finished. No need to chase 100% right now

"lines": 100,
"statements": 100,
"functions": 100,
Expand Down
1,082 changes: 182 additions & 900 deletions src/RokuDeploy.spec.ts

Large diffs are not rendered by default.

753 changes: 236 additions & 517 deletions src/RokuDeploy.ts

Large diffs are not rendered by default.

13 changes: 6 additions & 7 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 Expand Up @@ -49,12 +54,6 @@ export interface RokuDeployOptions {
*/
retainDeploymentArchive?: boolean;

/**
* The path where roku-deploy should stage all of the files right before being zipped. defaults to ${outDir}/.roku-deploy-staging
* @deprecated since 3.9.0. use `stagingDir` instead
*/
stagingFolderPath?: string;

/**
* The path where roku-deploy should stage all of the files right before being zipped. defaults to ${outDir}/.roku-deploy-staging
*/
Expand Down Expand Up @@ -150,7 +149,7 @@ export interface RokuDeployOptions {
/**
* If true, the previously installed dev channel will be deleted before installing the new one
*/
deleteInstalledChannel?: boolean;
deleteDevChannel?: boolean;
}

export type FileEntry = (string | { src: string | string[]; dest?: string });
98 changes: 19 additions & 79 deletions src/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import * as childProcess from 'child_process';
import { cwd, expectPathExists, rootDir, stagingDir, tempDir, outDir } from './testUtils.spec';
import * as fsExtra from 'fs-extra';
import { expect } from 'chai';
import * as path from 'path';
import { createSandbox } from 'sinon';
import { rokuDeploy } from './index';
import { PublishCommand } from './commands/PublishCommand';
import { ConvertToSquashfsCommand } from './commands/ConvertToSquashfsCommand';
import { RekeyDeviceCommand } from './commands/RekeyDeviceCommand';
import { SignExistingPackageCommand } from './commands/SignExistingPackageCommand';
import { DeployCommand } from './commands/DeployCommand';
import { DeleteInstalledChannelCommand } from './commands/DeleteInstalledChannelCommand';
import { TakeScreenshotCommand } from './commands/TakeScreenshotCommand';
import { CreateSignedPackageCommand } from './commands/CreateSignedPackageCommand';
import { DeleteDevChannelCommand } from './commands/DeleteDevChannelCommand';
import { CaptureScreenshotCommand } from './commands/CaptureScreenshotCommand';
import { GetDeviceInfoCommand } from './commands/GetDeviceInfoCommand';
import { GetDevIdCommand } from './commands/GetDevIdCommand';
import { RetrieveSignedPackageCommand } from './commands/RetrieveSignedPackageCommand';

const sinon = createSandbox();

Expand All @@ -39,6 +36,11 @@ describe('cli', () => {
sinon.restore();
});

it('Successfully bundles an app', () => {
execSync(`node ${cwd}/dist/cli.js bundle --rootDir ${rootDir} --outDir ${outDir}`);
expectPathExists(`${outDir}/roku-deploy.zip`);
});

it('Successfully runs prepublishToStaging', () => {
//make the files
fsExtra.outputFileSync(`${rootDir}/source/main.brs`, '');
Expand All @@ -63,13 +65,8 @@ describe('cli', () => {
expectPathExists(`${outDir}/roku-deploy.zip`);
});

it('Successfully uses createPackage to create .pkg', () => {
execSync(`node ${cwd}/dist/cli.js createPackage --stagingDir ${stagingDir} --rootDir ${rootDir} --outDir ${outDir}`);
expectPathExists(`${outDir}/roku-deploy.zip`);
});

it('Publish passes proper options', async () => {
const stub = sinon.stub(rokuDeploy, 'publish').callsFake(async () => {
const stub = sinon.stub(rokuDeploy, 'sideload').callsFake(async () => {
return Promise.resolve({
message: 'Publish successful',
results: {}
Expand Down Expand Up @@ -141,11 +138,11 @@ describe('cli', () => {
});

it('Signs an existing package', async () => {
const stub = sinon.stub(rokuDeploy, 'signExistingPackage').callsFake(async () => {
const stub = sinon.stub(rokuDeploy, 'createSignedPackage').callsFake(async () => {
return Promise.resolve('');
});

const command = new SignExistingPackageCommand();
const command = new CreateSignedPackageCommand();
await command.run({
host: '1.2.3.4',
password: '5536',
Expand All @@ -163,58 +160,12 @@ describe('cli', () => {
});
});

it('Retrieves a signed package', async () => {
MilapNaik marked this conversation as resolved.
Show resolved Hide resolved
const stub = sinon.stub(rokuDeploy, 'retrieveSignedPackage').callsFake(async () => {
return Promise.resolve('');
});

const command = new RetrieveSignedPackageCommand();
await command.run({
pathToPkg: 'path_to_pkg',
host: '1.2.3.4',
password: '5536',
outFile: 'roku-deploy-test'
});

expect(
stub.getCall(0).args
).to.eql(['path_to_pkg', {
host: '1.2.3.4',
password: '5536',
outFile: 'roku-deploy-test'
}]);
});

it('Deploys a package', async () => {
const stub = sinon.stub(rokuDeploy, 'deploy').callsFake(async () => {
return Promise.resolve({
message: 'Convert successful',
results: {}
});
});

const command = new DeployCommand();
await command.run({
host: '1.2.3.4',
password: '5536',
rootDir: rootDir
});

expect(
stub.getCall(0).args[0]
).to.eql({
host: '1.2.3.4',
password: '5536',
rootDir: rootDir
});
});

it('Deletes an installed channel', async () => {
const stub = sinon.stub(rokuDeploy, 'deleteInstalledChannel').callsFake(async () => {
const stub = sinon.stub(rokuDeploy, 'deleteDevChannel').callsFake(async () => {
return Promise.resolve({ response: {}, body: {} });
});

const command = new DeleteInstalledChannelCommand();
const command = new DeleteDevChannelCommand();
await command.run({
host: '1.2.3.4',
password: '5536'
Expand All @@ -229,11 +180,11 @@ describe('cli', () => {
});

it('Takes a screenshot', async () => {
const stub = sinon.stub(rokuDeploy, 'takeScreenshot').callsFake(async () => {
const stub = sinon.stub(rokuDeploy, 'captureScreenshot').callsFake(async () => {
return Promise.resolve('');
});

const command = new TakeScreenshotCommand();
const command = new CaptureScreenshotCommand();
await command.run({
host: '1.2.3.4',
password: '5536'
Expand All @@ -247,18 +198,6 @@ describe('cli', () => {
});
});

it('Gets output zip file path', () => {
let zipFilePath = execSync(`node ${cwd}/dist/cli.js getOutputZipFilePath --outFile "roku-deploy" --outDir ${outDir}`).toString();

expect(zipFilePath.trim()).to.equal(path.join(path.resolve(outDir), 'roku-deploy.zip'));
});

it('Gets output pkg file path', () => {
let pkgFilePath = execSync(`node ${cwd}/dist/cli.js getOutputPkgFilePath --outFile "roku-deploy" --outDir ${outDir}`).toString();

expect(pkgFilePath.trim()).to.equal(path.join(path.resolve(outDir), 'roku-deploy.pkg'));
});

it('Device info arguments are correct', async () => {
const stub = sinon.stub(rokuDeploy, 'getDeviceInfo').callsFake(async () => {
return Promise.resolve({
Expand Down Expand Up @@ -319,13 +258,14 @@ describe('cli', () => {
expect(
stub.getCall(0).args[0]
).to.eql({
host: '1.2.3.4'
host: '1.2.3.4',
password: '5536'
});
});

it('Zips a folder', () => {
execSync(`node ${cwd}/dist/cli.js zipFolder --srcFolder ${rootDir} --zipFilePath "roku-deploy.zip"`);
execSync(`node ${cwd}/dist/cli.js zip --stagingDir ${rootDir} --outDir ${outDir}`);

expectPathExists(`${tempDir}/roku-deploy.zip`);
expectPathExists(`${outDir}/roku-deploy.zip`);
});
});
Loading