From 37ceee7e99db2806ff123c0c93e21b5a69318ba3 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 13:33:15 -0200 Subject: [PATCH 01/15] initial samsung tizen support --- cli/bootstrap/react-tv/tizen/config.xml | 12 +++ cli/index.js | 6 +- cli/scripts/index.js | 1 + cli/scripts/tizen/run.js | 100 ++++++++++++++++++++++++ cli/shared/index.js | 14 ++++ examples/benchmark/package.json | 7 +- 6 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 cli/bootstrap/react-tv/tizen/config.xml create mode 100644 cli/scripts/tizen/run.js diff --git a/cli/bootstrap/react-tv/tizen/config.xml b/cli/bootstrap/react-tv/tizen/config.xml new file mode 100644 index 0000000..cc7264a --- /dev/null +++ b/cli/bootstrap/react-tv/tizen/config.xml @@ -0,0 +1,12 @@ + + + + {{REACTTVAPP}} + + + + + + + + diff --git a/cli/index.js b/cli/index.js index 5048611..07adb9a 100755 --- a/cli/index.js +++ b/cli/index.js @@ -3,7 +3,7 @@ const argv = process.argv; const path = require('path'); const {help, debug, createReactTVApp} = require('./shared'); -const {runWebOS} = require('./scripts'); +const {runWebOS, runTizen} = require('./scripts'); if (argv.length < 2) { return help(); @@ -24,6 +24,10 @@ switch (command) { runWebOS(process.cwd()); break; + case 'run-tizen': + runTizen(process.cwd()); + break; + default: help(); } diff --git a/cli/scripts/index.js b/cli/scripts/index.js index 9684334..450e332 100644 --- a/cli/scripts/index.js +++ b/cli/scripts/index.js @@ -1,3 +1,4 @@ module.exports = { runWebOS: require('./webos/run'), + runTizen: require('./tizen/run'), }; diff --git a/cli/scripts/tizen/run.js b/cli/scripts/tizen/run.js new file mode 100644 index 0000000..523dbbd --- /dev/null +++ b/cli/scripts/tizen/run.js @@ -0,0 +1,100 @@ +const path = require('path'); +const fs = require('fs'); +const chalk = require('chalk'); +const execSync = require('child_process').execSync; + +function copy(from, to) { + fs.writeFileSync(to, fs.readFileSync(from)); +} + +function defaultCLIEnv() { + //return '/opt/tizen/tools/ide/bin'; + return 'E:/Ferramentas/tizen/tools/ide/bin'; +} + +function isReactTVTizenProject(root) { + const appinfo = path.resolve(root, 'react-tv/tizen/config.xml'); + if (fs.existsSync(appinfo)) { + return true; + } + return false; +} + +function runTizen(root) { + let tizen_CLI_ENV = process.env['TIZEN_CLI'] || false; + if (!tizen_CLI_ENV) { + tizen_CLI_ENV = defaultCLIEnv(); + } + + process.env['PATH'] = `${tizen_CLI_ENV}:${process.env['PATH']}`; + + if (!isReactTVTizenProject(root)) { + const msg = `This project isn\'t a React-TV WebOS Project: + Just run "react-tv init"`; + return console.log(chalk.dim('[react-tv]'), msg); + } + + const packageJson = require(path.resolve(root, 'package.json')); + const ReactTVConfig = packageJson['react-tv']; + if (!ReactTVConfig) { + return console.log( + chalk.dim('[react-tv]'), + 'You should set react-tv properties on package.json' + ); + } + + if (!ReactTVConfig.files || !ReactTVConfig.files.length) { + return console.log(chalk.dim('[react-tv]'), 'You should add files'); + } + + // TODO: option to create/select profiles? + const securityProfiles = execSync(`${tizen_CLI_ENV}/tizen security-profiles list`).toString().trim().split("\n"); + if (!securityProfiles) { + return console.log(chalk.dim('[react-tv]'), 'No tizen security profiles found'); + } + + // Select the last profile + const selectedProfile = securityProfiles[securityProfiles.length - 1]; + + const tizenPath = path.resolve(root, 'react-tv/tizen'); + try { + copy(`${root}/react-tv/icon.png`, `${tizenPath}/icon.png`); + + ReactTVConfig.files.forEach(file => { + const filePath = path.resolve(root, file); + copy(`${filePath}`, `${tizenPath}/${file}`); + }); + } catch (e) { + return console.log('FAIL TO MOUNT', e.toString()); + } + + console.log(''); + console.log(chalk.dim('Up Emulator...')); + + const vms = execSync( + `${tizen_CLI_ENV}/../../emulator/bin/em-cli list-vm` + ).toString(); + + if (vms.indexOf('react-tv-tizen') < 0) { + execSync( + `${tizen_CLI_ENV}/../../emulator/bin/em-cli create -n react-tv-tizen` + ); + } + + execSync( + `${tizen_CLI_ENV}/../../emulator/bin/em-cli launch -n react-tv-tizen` + ); + + console.log(chalk.yellow(' Tizen Emulator successful running')); + + console.log(chalk.dim('Packing...')); + execSync(`cd ${tizenPath} && ${tizen_CLI_ENV}/tizen package -t wgt -s ${selectedProfile}`); + console.log(chalk.yellow(` succefull pack from ${root}`)); + + console.log(chalk.dim('Running...')); + console.log(packageJson['name']); + execSync(`cd ${tizenPath} && ${tizen_CLI_ENV}/tizen install -n ${packageJson['name']}.wgt -t react-tv-tizen`); + console.log(chalk.yellow(` done`)); +} + +module.exports = runTizen; diff --git a/cli/shared/index.js b/cli/shared/index.js index 4af0b4a..34fffa5 100644 --- a/cli/shared/index.js +++ b/cli/shared/index.js @@ -17,6 +17,10 @@ function help() { chalk.bgBlueBright(' run-webos '), chalk.blueBright(' pack, build and runs webos simulator') ); + console.log( + chalk.bgBlueBright(' run-tizen '), + chalk.blueBright(' pack, build and runs tizen emulator') + ); console.log( chalk.bgRed(' help '), chalk.red(' output react-tv cli commands') @@ -71,6 +75,16 @@ function createReactTVApp(appName) { recursive: true, silent: true, }); + + var randomstring = require("randomstring"); + + replace({ + regex: '{{PACKAGE}}', + replacement: randomstring.generate(10), + paths: ['./react-tv'], + recursive: true, + silent: true, + }); } catch (e) { return process.exit(1); } diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index 36f11ad..74917ce 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -1,5 +1,5 @@ { - "name": "benchmark-react-tv", + "name": "benchmark", "version": "1.0.0", "author": "Raphael Amorim", "license": "MIT", @@ -12,13 +12,14 @@ }, "scripts": { "build": "webpack", - "start": "yarn build && react-tv run-webos", + "start-webos": "yarn build && react-tv run-webos", + "start-tizen": "yarn build && react-tv run-tizen", "start-dev": "webpack-dev-server --progress --colors" }, "dependencies": { "react": "^16.0.0", "react-dom": "^16.0.0", - "react-tv": "0.3.0-alpha.2" + "react-tv": "../../" }, "devDependencies": { "babel-core": "^6.4.5", From 89e88d5d30f8726bb12b52bf9f2a3499c7d1e8af Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 14:06:21 -0200 Subject: [PATCH 02/15] minor fixes --- cli/scripts/tizen/run.js | 2 +- examples/benchmark/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/scripts/tizen/run.js b/cli/scripts/tizen/run.js index 523dbbd..6d975c7 100644 --- a/cli/scripts/tizen/run.js +++ b/cli/scripts/tizen/run.js @@ -29,7 +29,7 @@ function runTizen(root) { process.env['PATH'] = `${tizen_CLI_ENV}:${process.env['PATH']}`; if (!isReactTVTizenProject(root)) { - const msg = `This project isn\'t a React-TV WebOS Project: + const msg = `This project isn\'t a React-TV Tizen Project: Just run "react-tv init"`; return console.log(chalk.dim('[react-tv]'), msg); } diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index 74917ce..5b31091 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -19,7 +19,7 @@ "dependencies": { "react": "^16.0.0", "react-dom": "^16.0.0", - "react-tv": "../../" + "react-tv": "0.3.0-alpha.2" }, "devDependencies": { "babel-core": "^6.4.5", From c8d4b4ce4116ad8672c5bdddf9fa775a872b9ac2 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 21:24:20 -0200 Subject: [PATCH 03/15] add cross-env --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 78f4ed3..84ba6ce 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "scripts": { "build": "node scripts/rollup/build.js", - "build:all": "NODE_ENV=PROD node scripts/rollup/build.js", + "build:all": "cross-env NODE_ENV=PROD node scripts/rollup/build.js", "prepublishOnly": "yarn test && yarn build:all", "prettier:stat": "node ./scripts/prettier/index", "test": "yarn prettier:stat && yarn flow && yarn jest:ci", @@ -38,6 +38,7 @@ "babel-preset-react": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "commitplease": "^3.1.0", + "cross-env": "^5.1.1", "flow-bin": "^0.57.3", "jest": "20.1.0-delta.1", "prettier": "^1.5.3", From 5508e5384ce4e9b4a6e97d7eb456387f2eca3161 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 21:36:33 -0200 Subject: [PATCH 04/15] Run application --- cli/scripts/tizen/run.js | 104 +++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 14 deletions(-) diff --git a/cli/scripts/tizen/run.js b/cli/scripts/tizen/run.js index 6d975c7..569f4c8 100644 --- a/cli/scripts/tizen/run.js +++ b/cli/scripts/tizen/run.js @@ -12,6 +12,20 @@ function defaultCLIEnv() { return 'E:/Ferramentas/tizen/tools/ide/bin'; } +function getPackageId(root) { + const appinfo = path.resolve(root, 'react-tv/tizen/config.xml'); + const content = fs.readFileSync(appinfo, {encoding: 'utf-8'}); + + const re = new RegExp(/tizen:application id="(.*?)"/); + const matches = content.match(re); + + if (!matches) { + return null; + } + + return matches[1]; +} + function isReactTVTizenProject(root) { const appinfo = path.resolve(root, 'react-tv/tizen/config.xml'); if (fs.existsSync(appinfo)) { @@ -48,13 +62,23 @@ function runTizen(root) { } // TODO: option to create/select profiles? - const securityProfiles = execSync(`${tizen_CLI_ENV}/tizen security-profiles list`).toString().trim().split("\n"); + const securityProfiles = execSync( + `${tizen_CLI_ENV}/tizen security-profiles list` + ) + .toString() + .trim() + .split('\n'); if (!securityProfiles) { - return console.log(chalk.dim('[react-tv]'), 'No tizen security profiles found'); + return console.log( + chalk.dim('[react-tv]'), + 'No tizen security profiles found' + ); } // Select the last profile - const selectedProfile = securityProfiles[securityProfiles.length - 1]; + const selectedProfile = securityProfiles[securityProfiles.length - 1] + .split(' ', 1)[0] + .trim(); const tizenPath = path.resolve(root, 'react-tv/tizen'); try { @@ -69,7 +93,7 @@ function runTizen(root) { } console.log(''); - console.log(chalk.dim('Up Emulator...')); + console.log(chalk.dim('Setting up Emulator...')); const vms = execSync( `${tizen_CLI_ENV}/../../emulator/bin/em-cli list-vm` @@ -77,24 +101,76 @@ function runTizen(root) { if (vms.indexOf('react-tv-tizen') < 0) { execSync( - `${tizen_CLI_ENV}/../../emulator/bin/em-cli create -n react-tv-tizen` + `${ + tizen_CLI_ENV + }/../../emulator/bin/em-cli create -n react-tv-tizen -p tv-samsung-3.0-x86` ); } - execSync( - `${tizen_CLI_ENV}/../../emulator/bin/em-cli launch -n react-tv-tizen` - ); + const runningVms = execSync( + `${tizen_CLI_ENV}/../../sdb devices` + ).toString(); - console.log(chalk.yellow(' Tizen Emulator successful running')); + if (runningVms.indexOf('react-tv-tizen') < 0) { + console.log(chalk.dim('Running Emulator...')); + execSync( + `${tizen_CLI_ENV}/../../emulator/bin/em-cli launch -n react-tv-tizen` + ); + console.log(chalk.yellow(' Tizen Emulator successful running')); + } + else { + console.log(chalk.yellow(' already running.')); + } console.log(chalk.dim('Packing...')); - execSync(`cd ${tizenPath} && ${tizen_CLI_ENV}/tizen package -t wgt -s ${selectedProfile}`); + execSync( + `cd ${tizenPath} && ${tizen_CLI_ENV}/tizen package -t wgt -s ${ + selectedProfile + }` + ); console.log(chalk.yellow(` succefull pack from ${root}`)); - console.log(chalk.dim('Running...')); - console.log(packageJson['name']); - execSync(`cd ${tizenPath} && ${tizen_CLI_ENV}/tizen install -n ${packageJson['name']}.wgt -t react-tv-tizen`); - console.log(chalk.yellow(` done`)); + console.log(chalk.dim('Running App...')); + + let attemps = 0; + const task = setInterval(function() { + if (attemps > 15) { + console.log('FAILED TO UP Tizen emulator'); + clearInterval(task); + } + + try { + execSync( + `${tizen_CLI_ENV}/../../sdb devices` + ).toString(); + + execSync( + `cd ${tizenPath} && ${tizen_CLI_ENV}/tizen install -n ${ + packageJson['name'] + }.wgt -t react-tv-tizen` + ); + } + catch (error) { + if (error.stdout.toString().indexOf('install completed') < 0) { + attemps += 1; + return false; + } + } + + clearInterval(task); + + const packageId = getPackageId(root); + + if (!packageId) { + return console.log('Invalid package id!'); + } + + execSync( + `cd ${tizenPath} && ${tizen_CLI_ENV}/tizen run -p ${ + packageId + } -t react-tv-tizen` + ); + }, 500); } module.exports = runTizen; From 7312aa3d6721a35642293ae5bfe4f9cb0e5ebf36 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:14:37 -0200 Subject: [PATCH 05/15] Custom tizen app name --- cli/bootstrap/react-tv/tizen/config.xml | 2 +- cli/shared/index.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cli/bootstrap/react-tv/tizen/config.xml b/cli/bootstrap/react-tv/tizen/config.xml index cc7264a..8ab5884 100644 --- a/cli/bootstrap/react-tv/tizen/config.xml +++ b/cli/bootstrap/react-tv/tizen/config.xml @@ -1,6 +1,6 @@ - + {{REACTTVAPP}} diff --git a/cli/shared/index.js b/cli/shared/index.js index 34fffa5..6cc60ca 100644 --- a/cli/shared/index.js +++ b/cli/shared/index.js @@ -79,9 +79,17 @@ function createReactTVApp(appName) { var randomstring = require("randomstring"); replace({ - regex: '{{PACKAGE}}', + regex: '{{TIZEN_PACKAGE}}', replacement: randomstring.generate(10), - paths: ['./react-tv'], + paths: ['./react-tv/tizen'], + recursive: true, + silent: true, + }); + + replace({ + regex: '{{TIZEN_REACTTVAPP}}', + replacement: appName.replace(/-/g, "").replace(/\./g, ""), + paths: ['./react-tv/tizen'], recursive: true, silent: true, }); From 18e333860b7b72bfe2e61844655b0a9778c86808 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:14:56 -0200 Subject: [PATCH 06/15] add start tizen to clock example --- examples/clock-app-with-react-tv/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/clock-app-with-react-tv/package.json b/examples/clock-app-with-react-tv/package.json index 4c3f232..53ccca4 100644 --- a/examples/clock-app-with-react-tv/package.json +++ b/examples/clock-app-with-react-tv/package.json @@ -13,6 +13,7 @@ "scripts": { "build": "webpack", "start": "yarn build && react-tv run-webos", + "start-tizen": "yarn build && react-tv run-tizen", "start-dev": "webpack-dev-server --progress --colors" }, "dependencies": { From 8504d368293793e104270d93a0db6fd0ee267036 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:15:40 -0200 Subject: [PATCH 07/15] benchmark package name to original one --- examples/benchmark/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index 5b31091..f04cec3 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -1,5 +1,5 @@ { - "name": "benchmark", + "name": "benchmark-react-tv", "version": "1.0.0", "author": "Raphael Amorim", "license": "MIT", From c86428e3bbd03c524f45b476bb7a34dd9767fbaf Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:29:16 -0200 Subject: [PATCH 08/15] add tizen to platform --- src/modules/Platform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Platform.js b/src/modules/Platform.js index de57b6a..7a461e0 100644 --- a/src/modules/Platform.js +++ b/src/modules/Platform.js @@ -12,7 +12,7 @@ function isLGWebOS() { } function isSamsungTizen() { - return false; + return tizen ? true : false; } function isSamsungOrsay() { From 3cb9fb4c3016385ee325383388665966068c254c Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:29:27 -0200 Subject: [PATCH 09/15] add tizen to clock example --- examples/clock-app-with-react-tv/src/App.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/clock-app-with-react-tv/src/App.js b/examples/clock-app-with-react-tv/src/App.js index 37bdb3c..40aec12 100644 --- a/examples/clock-app-with-react-tv/src/App.js +++ b/examples/clock-app-with-react-tv/src/App.js @@ -16,6 +16,9 @@ class Clock extends React.Component { if (Platform('webos')) currentPlatform = 'LG WebOS' + if (Platform('tizen')) + currentPlatform = 'Samsung Tizen' + return (
From 7d0ed23096cbad10a07d028b67a4fb7300d92157 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 17 Nov 2017 22:30:59 -0200 Subject: [PATCH 10/15] prettier code --- cli/scripts/tizen/run.js | 14 ++++---------- cli/shared/index.js | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cli/scripts/tizen/run.js b/cli/scripts/tizen/run.js index 569f4c8..5920fbe 100644 --- a/cli/scripts/tizen/run.js +++ b/cli/scripts/tizen/run.js @@ -107,9 +107,7 @@ function runTizen(root) { ); } - const runningVms = execSync( - `${tizen_CLI_ENV}/../../sdb devices` - ).toString(); + const runningVms = execSync(`${tizen_CLI_ENV}/../../sdb devices`).toString(); if (runningVms.indexOf('react-tv-tizen') < 0) { console.log(chalk.dim('Running Emulator...')); @@ -117,8 +115,7 @@ function runTizen(root) { `${tizen_CLI_ENV}/../../emulator/bin/em-cli launch -n react-tv-tizen` ); console.log(chalk.yellow(' Tizen Emulator successful running')); - } - else { + } else { console.log(chalk.yellow(' already running.')); } @@ -140,17 +137,14 @@ function runTizen(root) { } try { - execSync( - `${tizen_CLI_ENV}/../../sdb devices` - ).toString(); + execSync(`${tizen_CLI_ENV}/../../sdb devices`).toString(); execSync( `cd ${tizenPath} && ${tizen_CLI_ENV}/tizen install -n ${ packageJson['name'] }.wgt -t react-tv-tizen` ); - } - catch (error) { + } catch (error) { if (error.stdout.toString().indexOf('install completed') < 0) { attemps += 1; return false; diff --git a/cli/shared/index.js b/cli/shared/index.js index 6cc60ca..314e5d2 100644 --- a/cli/shared/index.js +++ b/cli/shared/index.js @@ -76,7 +76,7 @@ function createReactTVApp(appName) { silent: true, }); - var randomstring = require("randomstring"); + var randomstring = require('randomstring'); replace({ regex: '{{TIZEN_PACKAGE}}', @@ -88,7 +88,7 @@ function createReactTVApp(appName) { replace({ regex: '{{TIZEN_REACTTVAPP}}', - replacement: appName.replace(/-/g, "").replace(/\./g, ""), + replacement: appName.replace(/-/g, '').replace(/\./g, ''), paths: ['./react-tv/tizen'], recursive: true, silent: true, From e1e5da69a96d1a5a3147d17855d43857e5b47fdd Mon Sep 17 00:00:00 2001 From: Gustavo Date: Sat, 18 Nov 2017 02:00:10 -0200 Subject: [PATCH 11/15] Move randomstring require to top --- cli/shared/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/shared/index.js b/cli/shared/index.js index 314e5d2..03429e8 100644 --- a/cli/shared/index.js +++ b/cli/shared/index.js @@ -2,6 +2,7 @@ const fs = require('fs-extra'); const path = require('path'); const chalk = require('chalk'); const replace = require('node-replace'); +const randomstring = require('randomstring'); function debug(msg) { console.log(chalk.dim('[react-tv]'), msg); @@ -76,8 +77,6 @@ function createReactTVApp(appName) { silent: true, }); - var randomstring = require('randomstring'); - replace({ regex: '{{TIZEN_PACKAGE}}', replacement: randomstring.generate(10), From 64b747b653051a9e66272c8230e80dc169e3f1b8 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Sat, 18 Nov 2017 02:01:19 -0200 Subject: [PATCH 12/15] Update README --- README.md | 50 ++++++++++++++-------- examples/benchmark/README.md | 8 +++- examples/clock-app-with-react-tv/README.md | 7 +++ 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index df9f3d3..41dd0af 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ ReactTV.render(, document.getElementById('root')) - [Clock TV App rendering with React-TV](#clock-tv-app-rendering-with-react-tv) - [Supported Televisions](#supported-televisions) - [LG WebOS](#lg-webos) + - [Samsung Tizen](#samsung-tizen) - [References for Study](#references) - [WebOS](#webos) - [Videos](#videos) @@ -110,29 +111,23 @@ $ yarn add react-tv ## Using CLI -### React-TV CLI for WebOS - -#### 1: Install globally React-TV +#### Install globally React-TV ```bash $ yarn add --global react-tv ``` -#### 2: Setup WebOS Environment - -[Setup WebOS Enviroment](docs/setup-webos-environment.md) - -#### 3: Setting Up +#### Setting Up -3.1: If you doesn't have a project and want to start from nothing. If is your situation: jump to topic 3 (Running It!). +If you doesn't have a project and want to start from nothing. If is your situation: jump to next topic (Running It!). ```bash $ react-tv init ``` -3.2: If you already have some source code. Just run `react-tv init` on project root. +If you already have some source code. Just run `react-tv init` on project root. -3.3: Add the files related to app on a React-TV entry on `package.json`: +Add the files related to app on a React-TV entry on `package.json`: ```json { @@ -147,14 +142,26 @@ $ react-tv init } ``` -#### 4: Running It! +#### Running (WebOS) + +First you need to [setup the WebOS environment](https://github.com/raphamorim/react-tv/blob/master/docs/setup-webos-environment.md) Run emulator and devices (should pack, build and run on emulator): -``` +```bash $ react-tv run-webos ``` +#### Running (Tizen) + +First you need to [setup the Tizen environment](https://github.com/raphamorim/react-tv/blob/master/docs/setup-tizen-environment.md) + +Run emulator and devices (should pack, build and run on emulator): + +```bash +$ react-tv run-tizen +``` + ## Using Module ### Platform @@ -233,7 +240,7 @@ WebOS, also known as Open WebOS or LG WebOS, (previously known as HP WebOS and P ### Samsung Tizen -[Work in Progress] +**Target Version: 3.0** ### Samsung Orsay @@ -250,6 +257,16 @@ WebOS, also known as Open WebOS or LG WebOS, (previously known as HP WebOS and P - http://webostv.developer.lge.com/develop/app-test/ - http://webostv.developer.lge.com/api/web-api/supported-standard-web-api/ +### Tizen + +- http://developer.samsung.com/tv/develop/tools/tizen-studio +- http://developer.samsung.com/tv/develop/getting-started/setting-up-sdk/installing-tv-sdk +- http://developer.samsung.com/tv/develop/getting-started/setting-up-sdk/creating-certificates +- http://developer.samsung.com/tv/develop/getting-started/creating-tv-applications +- http://developer.samsung.com/tv/design/design-principles +- http://developer.samsung.com/tv/develop/specifications/general-specifications +- http://developer.samsung.com/tv/develop/specifications/web-engine-specifications + #### Videos ##### Windows @@ -262,7 +279,6 @@ WebOS, also known as Open WebOS or LG WebOS, (previously known as HP WebOS and P ### Essentials to beginner -- http://developer.samsung.com/tv/develop/getting-started/setup-sdk/installing-tv-sdk/ - http://developer.samsung.com/tv/develop/getting-started/using-sdk/tv-simulator - http://developer.samsung.com/tv/develop/getting-started/essentials-for-beginner @@ -300,7 +316,7 @@ Implement essential functionality needed for daily use by early adopters. - [ ] Support render to Canvas instead DOM using `React.CanvasComponent` - [ ] `run-webos` support TV device as param -- [ ] Start CLI for Tizen +- [x] Start CLI for Tizen - [ ] Develop helpers for WebOS debbug (e.g: Log System). - [ ] Support Cross Platform - [ ] Check executable bin path for Windows, OSX and Linux @@ -317,7 +333,7 @@ Add additional features users expect from a Renderer. Then fix bugs and stabiliz - [ ] Reactive Renderer - [ ] Testing and stability ----------------------------------------------------- +---------------------------------------------------- See ReactTV's [Changelog](https://github.com/raphamorim/react-tv/blob/master/CHANGELOG.md). diff --git a/examples/benchmark/README.md b/examples/benchmark/README.md index 8c315a3..93406a1 100644 --- a/examples/benchmark/README.md +++ b/examples/benchmark/README.md @@ -20,6 +20,12 @@ yarn To run it: +WebOS: ```shell -yarn start +yarn start-webos +``` + +Tizen: +```shell +yarn start-tizen ``` diff --git a/examples/clock-app-with-react-tv/README.md b/examples/clock-app-with-react-tv/README.md index 1963c4e..a20ab62 100644 --- a/examples/clock-app-with-react-tv/README.md +++ b/examples/clock-app-with-react-tv/README.md @@ -20,8 +20,15 @@ yarn To run it: +WebOS: ```shell yarn start ``` +Tizen: +```shell +yarn start-tizen +``` + + ![Screenshot](screenshot.png) From 7e40059ac1600c600611277b7e10cba8c7660d5d Mon Sep 17 00:00:00 2001 From: Gustavo Date: Sat, 18 Nov 2017 02:04:23 -0200 Subject: [PATCH 13/15] add setup tizen doc --- docs/setup-tizen-environment.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/setup-tizen-environment.md diff --git a/docs/setup-tizen-environment.md b/docs/setup-tizen-environment.md new file mode 100644 index 0000000..1f98574 --- /dev/null +++ b/docs/setup-tizen-environment.md @@ -0,0 +1,7 @@ +# Setup Tizen Environment + +[Install the Tizen Studio](http://developer.samsung.com/tv/develop/tools/tizen-studio) + +[Install the TV SDK](http://developer.samsung.com/tv/develop/getting-started/setting-up-sdk/installing-tv-sdk/) + +Using the Package Manager install the Web CLI, Native CLI and Baseline SDK packages under the Tizen SDK Tools From 845cb434035c9c3832773c148d3493f3b5436b09 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Sat, 18 Nov 2017 03:51:50 -0200 Subject: [PATCH 14/15] add randomstring to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 84ba6ce..49c4385 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "chalk": "^2.1.0", "fbjs": "^0.8.4", "fs-extra": "^4.0.1", - "node-replace": "^0.3.1" + "node-replace": "^0.3.1", + "randomstring": "^1.1.5" }, "devDependencies": { "babel-jest": "20.1.0-delta.1", From b482e4b7618f30293689e311ec2c7934307ab56e Mon Sep 17 00:00:00 2001 From: Gustavo Date: Tue, 19 Dec 2017 02:19:11 -0200 Subject: [PATCH 15/15] fix stuff after rebase --- examples/navigation/package.json | 3 +- packages/react-tv-cli/index.js | 8 +++++ packages/react-tv-cli/scripts/tizen/index.js | 5 ++++ packages/react-tv-cli/scripts/tizen/run.js | 31 ++++++++++++++------ packages/react-tv-cli/shared/index.js | 17 +++++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 packages/react-tv-cli/scripts/tizen/index.js diff --git a/examples/navigation/package.json b/examples/navigation/package.json index e6e65bc..c61757a 100644 --- a/examples/navigation/package.json +++ b/examples/navigation/package.json @@ -13,7 +13,7 @@ }, "scripts": { "build": "webpack", - "build-prod": "NODE_ENV=production yarn build", + "build-prod": "cross-env NODE_ENV=production yarn build", "react-tv-cli": "react-tv-cli", "start-webos": "yarn build-prod && react-tv-cli run-webos", "start-tizen": "yarn build-prod && react-tv-cli run-tizen", @@ -29,6 +29,7 @@ "babel-loader": "^6.2.1", "babel-polyfill": "^6.26.0", "babel-preset-react": "^6.3.13", + "cross-env": "^5.1.1", "webpack": "^1.12.12", "webpack-dev-server": "^1.12.1" } diff --git a/packages/react-tv-cli/index.js b/packages/react-tv-cli/index.js index 3639f22..a8845c5 100755 --- a/packages/react-tv-cli/index.js +++ b/packages/react-tv-cli/index.js @@ -41,6 +41,14 @@ switch (command) { WebOS.getKey(device); break; + case 'run-tizen': + if (argv.length > 3) { + device = argv[3]; + } + + Tizen.run(process.cwd()); + break; + case '--version': version(); break; diff --git a/packages/react-tv-cli/scripts/tizen/index.js b/packages/react-tv-cli/scripts/tizen/index.js new file mode 100644 index 0000000..c6f3ada --- /dev/null +++ b/packages/react-tv-cli/scripts/tizen/index.js @@ -0,0 +1,5 @@ +const run = require('./run'); + +module.exports = { + run +}; diff --git a/packages/react-tv-cli/scripts/tizen/run.js b/packages/react-tv-cli/scripts/tizen/run.js index 5920fbe..dc3cf30 100644 --- a/packages/react-tv-cli/scripts/tizen/run.js +++ b/packages/react-tv-cli/scripts/tizen/run.js @@ -1,12 +1,8 @@ const path = require('path'); -const fs = require('fs'); +const fs = require('fs-extra'); const chalk = require('chalk'); const execSync = require('child_process').execSync; -function copy(from, to) { - fs.writeFileSync(to, fs.readFileSync(from)); -} - function defaultCLIEnv() { //return '/opt/tizen/tools/ide/bin'; return 'E:/Ferramentas/tizen/tools/ide/bin'; @@ -34,7 +30,7 @@ function isReactTVTizenProject(root) { return false; } -function runTizen(root) { +function run(root) { let tizen_CLI_ENV = process.env['TIZEN_CLI'] || false; if (!tizen_CLI_ENV) { tizen_CLI_ENV = defaultCLIEnv(); @@ -81,12 +77,29 @@ function runTizen(root) { .trim(); const tizenPath = path.resolve(root, 'react-tv/tizen'); + + process.on('exit', cleanup); + process.on('SIGINT', cleanup); + process.on('SIGUSR1', cleanup); + process.on('SIGUSR2', cleanup); + process.on('uncaughtException', cleanup); + + function cleanup() { + fs.removeSync(`${tizenPath}/icon.png`); + ReactTVConfig.files.forEach(file => { + fs.removeSync(`${tizenPath}/${file}`); + }); + } + try { - copy(`${root}/react-tv/icon.png`, `${tizenPath}/icon.png`); + cleanup(); + fs.copySync(`${root}/react-tv/icon-large.png`, `${tizenPath}/icon.png`); ReactTVConfig.files.forEach(file => { const filePath = path.resolve(root, file); - copy(`${filePath}`, `${tizenPath}/${file}`); + const toFile = path.resolve(tizenPath, file); + fs.ensureDirSync(path.dirname(toFile)); + fs.copySync(`${filePath}`, `${toFile}`); }); } catch (e) { return console.log('FAIL TO MOUNT', e.toString()); @@ -167,4 +180,4 @@ function runTizen(root) { }, 500); } -module.exports = runTizen; +module.exports = run; diff --git a/packages/react-tv-cli/shared/index.js b/packages/react-tv-cli/shared/index.js index 815749f..ac08b9d 100644 --- a/packages/react-tv-cli/shared/index.js +++ b/packages/react-tv-cli/shared/index.js @@ -37,6 +37,7 @@ function help() { } function createReactTVApp(appName) { + console.log('tizen'); let appPath = process.cwd(); const packageJson = path.resolve(appPath, 'package.json'); @@ -55,6 +56,22 @@ function createReactTVApp(appName) { recursive: true, silent: true, }); + + replace({ + regex: '{{TIZEN_PACKAGE}}', + replacement: randomstring.generate(10), + paths: [appName], + recursive: true, + silent: true, + }); + + replace({ + regex: '{{TIZEN_REACTTVAPP}}', + replacement: appName.replace(/-/g, '').replace(/\./g, ''), + paths: [appName], + recursive: true, + silent: true, + }); } catch (e) { return process.exit(1); }