rooibos-roku 5.13.0 → 5.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js ADDED
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const roku_debug_1 = require("roku-debug");
5
+ const brighterscript_1 = require("brighterscript");
6
+ const yargs = require("yargs");
7
+ const roku_deploy_1 = require("roku-deploy");
8
+ const fs = require("fs");
9
+ let options = yargs
10
+ .usage('$0', 'Rooibos: a simple, flexible, fun Brightscript test framework for Roku Scenegraph apps')
11
+ .help('help', 'View help information about this tool.')
12
+ .option('project', { type: 'string', description: 'Path to a bsconfig.json project file.' })
13
+ .option('host', { type: 'string', description: 'Host of the Roku device to connect to. Overrides value in bsconfig file.' })
14
+ .option('password', { type: 'string', description: 'Password of the Roku device to connect to. Overrides value in bsconfig file.' })
15
+ .option('log-level', { type: 'string', defaultDescription: '"log"', description: 'The log level. Value can be "error", "warn", "log", "info", "debug".' })
16
+ .check((argv) => {
17
+ if (!argv.host) {
18
+ return new Error('You must provide a host. (--host)');
19
+ }
20
+ if (!argv.password) {
21
+ return new Error('You must provide a password. (--password)');
22
+ }
23
+ if (!argv.project) {
24
+ console.log('No project file specified. Using "./bsconfig.json"');
25
+ }
26
+ let bsconfigPath = argv.project || './bsconfig.json';
27
+ if (!fs.existsSync(bsconfigPath)) {
28
+ return new Error(`Unable to load ${bsconfigPath}`);
29
+ }
30
+ return true;
31
+ })
32
+ .argv;
33
+ async function main() {
34
+ var _a, _b, _c, _d;
35
+ let currentErrorCode = 0;
36
+ let bsconfigPath = (_a = options.project) !== null && _a !== void 0 ? _a : 'bsconfig.json';
37
+ console.log(`Using bsconfig: ${bsconfigPath}`);
38
+ const rawConfig = brighterscript_1.util.loadConfigFile(bsconfigPath);
39
+ const bsConfig = brighterscript_1.util.normalizeConfig(rawConfig);
40
+ const host = (_b = options.host) !== null && _b !== void 0 ? _b : bsConfig.host;
41
+ const password = (_c = options.password) !== null && _c !== void 0 ? _c : bsConfig.password;
42
+ const logLevel = (_d = brighterscript_1.LogLevel[options['log-level']]) !== null && _d !== void 0 ? _d : bsConfig.logLevel;
43
+ const builder = new brighterscript_1.ProgramBuilder();
44
+ builder.logger.logLevel = logLevel;
45
+ await builder.run(Object.assign(Object.assign({}, options), { retainStagingDir: true, createPackage: true }));
46
+ const rokuDeploy = new roku_deploy_1.RokuDeploy();
47
+ const deviceInfo = await rokuDeploy.getDeviceInfo({ host: host });
48
+ const rendezvousTracker = new roku_debug_1.RendezvousTracker({ softwareVersion: deviceInfo['software-version'] }, { host: host, remotePort: 8085 });
49
+ const telnet = new roku_debug_1.TelnetAdapter({ host: options.host }, rendezvousTracker);
50
+ telnet.logger.logLevel = logLevel;
51
+ await telnet.activate();
52
+ await telnet.connect();
53
+ const failRegex = /RESULT: Fail/g;
54
+ const endRegex = /\[END TEST REPORT\]/g;
55
+ async function doExit(emitAppExit = false) {
56
+ if (emitAppExit) {
57
+ telnet.beginAppExit();
58
+ }
59
+ await rokuDeploy.pressHomeButton(host); // roku-deploy v4: keyPress({ host: options.host, key: 'home' });
60
+ process.exit(currentErrorCode);
61
+ }
62
+ telnet.on('console-output', (output) => {
63
+ console.log(output);
64
+ //check for Fails or Crashes
65
+ let failMatches = failRegex.exec(output);
66
+ if (failMatches && failMatches.length > 0) {
67
+ currentErrorCode = 1;
68
+ }
69
+ let endMatches = endRegex.exec(output);
70
+ if (endMatches && endMatches.length > 0) {
71
+ doExit(true).catch(e => {
72
+ console.error(e);
73
+ process.exit(1);
74
+ });
75
+ }
76
+ });
77
+ telnet.on('runtime-error', (error) => {
78
+ console.error(`Runtime Error: ${error.errorCode} - ${error.message}`);
79
+ currentErrorCode = 1;
80
+ doExit(true).catch(e => {
81
+ console.error(e);
82
+ process.exit(1);
83
+ });
84
+ });
85
+ telnet.on('app-exit', () => {
86
+ doExit(false).catch(e => {
87
+ console.error(e);
88
+ process.exit(1);
89
+ });
90
+ });
91
+ // Actually start the unit tests
92
+ //deploy a .zip package of your project to a roku device
93
+ async function deployBuiltFiles() {
94
+ const outFile = bsConfig.outFile;
95
+ console.log(`Deploying ${outFile} to ${host}`);
96
+ await rokuDeploy.publish({
97
+ password: password,
98
+ host: host,
99
+ outFile: outFile,
100
+ outDir: process.cwd()
101
+ });
102
+ }
103
+ await deployBuiltFiles();
104
+ }
105
+ main().catch(e => {
106
+ console.error(e);
107
+ process.exit(1);
108
+ });
109
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,2CAA8D;AAE9D,mDAAgE;AAChE,+BAA+B;AAC/B,6CAAyC;AACzC,yBAAyB;AAIzB,IAAI,OAAO,GAAG,KAAK;KACd,KAAK,CAAC,IAAI,EAAE,uFAAuF,CAAC;KACpG,IAAI,CAAC,MAAM,EAAE,wCAAwC,CAAC;KACtD,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;KAC3F,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0EAA0E,EAAE,CAAC;KAC3H,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8EAA8E,EAAE,CAAC;KACnI,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;KACzJ,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;IACZ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACZ,OAAO,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACzD;IACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;QAChB,OAAO,IA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,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE;SACxB,CAAC,CAAC;IACP,CAAC;IAED,MAAM,gBAAgB,EAAE,CAAC;AAC7B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rooibos-roku",
3
- "version": "5.13.0",
3
+ "version": "5.14.0",
4
4
  "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps - roku brighterscript plugin",
5
5
  "scripts": {
6
6
  "preversion": "npm run build && npm run lint && npm run test",
@@ -15,7 +15,8 @@
15
15
  "publish-npm": "npm run test && npm publish",
16
16
  "publish-npm:beta": "npm run test && npm publish --tag=beta",
17
17
  "local": "ts-node scripts/install-local.js",
18
- "remote": "ts-node scripts/install-npm.js"
18
+ "remote": "ts-node scripts/install-npm.js",
19
+ "cli": "ts-node src/cli.ts"
19
20
  },
20
21
  "repository": {
21
22
  "type": "git",
@@ -25,14 +26,20 @@
25
26
  "dist/**/!(*.spec.*)*"
26
27
  ],
27
28
  "main": "dist/plugin.js",
29
+ "bin": {
30
+ "rooibos": "dist/cli.js"
31
+ },
28
32
  "directories": {
29
33
  "test": "test"
30
34
  },
31
35
  "dependencies": {
36
+ "roku-debug": "^0.21.10",
37
+ "roku-deploy": "^3.12.1",
32
38
  "source-map": "^0.7.3",
33
39
  "undent": "^0.1.0",
34
40
  "vscode-languageserver": "~6.1.1",
35
- "vscode-languageserver-protocol": "~3.15.3"
41
+ "vscode-languageserver-protocol": "~3.17.5",
42
+ "yargs": "^16.2.0"
36
43
  },
37
44
  "devDependencies": {
38
45
  "@types/chai": "^4.1.2",
@@ -40,9 +47,10 @@
40
47
  "@types/fs-extra": "^5.0.1",
41
48
  "@types/mocha": "^9.1.1",
42
49
  "@types/node": "^14.18.41",
50
+ "@types/yargs": "^15.0.5",
43
51
  "@typescript-eslint/eslint-plugin": "^5.27.0",
44
52
  "@typescript-eslint/parser": "^5.27.0",
45
- "brighterscript": "^0.65.22",
53
+ "brighterscript": "^0.67.4",
46
54
  "chai": "^4.2.0",
47
55
  "chai-subset": "^1.6.0",
48
56
  "coveralls": "^3.0.0",
@@ -53,7 +61,7 @@
53
61
  "minimatch": "^3.0.4",
54
62
  "mocha": "^9.1.3",
55
63
  "nyc": "^15.1.0",
56
- "release-it": "^15.10.3",
64
+ "release-it": "^17.6.0",
57
65
  "source-map-support": "^0.5.13",
58
66
  "trim-whitespace": "^1.3.3",
59
67
  "ts-node": "^9.0.0",