From 16ae1bcc9a721a4ac6d23d34e21c538b959f99c8 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Thu, 16 Nov 2017 23:54:10 -0200 Subject: [PATCH] release: 0.3.0-alpha.2 --- CHANGELOG.md | 8 ++ cli/__tests__/init-test.js | 90 ++++++++++--------- cli/__tests__/to-run-successfully-matcher.js | 15 ++-- cli/bootstrap/custom-app/package.json | 2 +- cli/shared/index.js | 4 +- examples/benchmark/package.json | 2 +- examples/clock-app-with-react-tv/package.json | 2 +- examples/keyboard-navigation/package.json | 2 +- package.json | 2 +- 9 files changed, 70 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eafce38..2361305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 0.3.0-alpha.2 + +- CLI: `react-tv init` +- CLI: `react-tv init ` +- add tests for CLI behavior +- add .npmignore +- add `jest:ci` job + # 0.3.0-alpha.1 - migrate to react-reconciler 0.6.0 diff --git a/cli/__tests__/init-test.js b/cli/__tests__/init-test.js index f0e1b33..42ad96b 100644 --- a/cli/__tests__/init-test.js +++ b/cli/__tests__/init-test.js @@ -1,62 +1,64 @@ -const { spawnSync } = require('child_process') -const path = require('path') -const rimraf = require('rimraf') +const {spawnSync} = require('child_process'); +const path = require('path'); +const rimraf = require('rimraf'); -const scriptPath = path.resolve(__dirname, '../index.js') -const packagePath = path.resolve(__dirname, '../__fixtures__/package') -const emptyPackagePath = path.resolve(__dirname, '../__fixtures__/emptyPackage') +const scriptPath = path.resolve(__dirname, '../index.js'); +const packagePath = path.resolve(__dirname, '../__fixtures__/package'); +const fixturesPath = path.resolve(__dirname, '../__fixtures__'); -require('./to-run-successfully-matcher') +require('./to-run-successfully-matcher'); describe('[CLI] init', () => { describe('react-tv init', () => { - let slug = 'react-tv' + let slug = 'react-tv'; - beforeEach((done) => rimraf(path.resolve(packagePath, slug), done)) - afterEach((done) => rimraf(path.resolve(packagePath, slug), done)) + beforeEach(done => rimraf(path.resolve(packagePath, slug), done)); + afterEach(done => rimraf(path.resolve(packagePath, slug), done)); it('should create react-tv folder', () => { - const subject = spawnSync('node', [ - scriptPath, - 'init' - ], { cwd: packagePath }) + const subject = spawnSync('node', [scriptPath, 'init'], { + cwd: packagePath, + }); - const createdAppPath = path.resolve(packagePath, slug) - const appInfo = require(path.resolve(createdAppPath, 'webos/appinfo.json')) + const createdAppPath = path.resolve(packagePath, slug); + const appInfo = require(path.resolve( + createdAppPath, + 'webos/appinfo.json' + )); - expect(appInfo.id).toEqual('react.tv.app') - expect(appInfo.title).toEqual('package') - expect(subject).toRunSuccessfully() - }) + expect(appInfo.id).toEqual('react.tv.app'); + expect(appInfo.title).toEqual('package'); + expect(subject).toRunSuccessfully(); + }); it('should fail when package.json not exists', () => { - const subject = spawnSync('node', [ - scriptPath, - 'init' - ], { cwd: emptyPackagePath }) + const subject = spawnSync('node', [scriptPath, 'init'], { + cwd: fixturesPath, + }); - expect(subject).not.toRunSuccessfully() - }) - }) + expect(subject).not.toRunSuccessfully(); + }); + }); describe('react-tv init ', () => { - const appName = 'russell-crowe' + const appName = 'russell-crowe'; - beforeEach((done) => rimraf(path.resolve(emptyPackagePath, appName), done)) - afterEach((done) => rimraf(path.resolve(emptyPackagePath, appName), done)) + beforeEach(done => rimraf(path.resolve(fixturesPath, appName), done)); + afterEach(done => rimraf(path.resolve(fixturesPath, appName), done)); it('should create custom app', () => { - const subject = spawnSync('node', [ - scriptPath, - 'init', - appName - ], { cwd: emptyPackagePath }) - - const createdAppPath = path.resolve(emptyPackagePath, appName) - const createdPackageJson = require(path.resolve(createdAppPath, 'package.json')) - - expect(subject).toRunSuccessfully() - expect(createdPackageJson.name).toEqual('russell-crowe') - }) - }) -}) + const subject = spawnSync('node', [scriptPath, 'init', appName], { + cwd: fixturesPath, + }); + + const createdAppPath = path.resolve(fixturesPath, appName); + const createdPackageJson = require(path.resolve( + createdAppPath, + 'package.json' + )); + + expect(subject).toRunSuccessfully(); + expect(createdPackageJson.name).toEqual('russell-crowe'); + }); + }); +}); diff --git a/cli/__tests__/to-run-successfully-matcher.js b/cli/__tests__/to-run-successfully-matcher.js index 385215f..4e98744 100644 --- a/cli/__tests__/to-run-successfully-matcher.js +++ b/cli/__tests__/to-run-successfully-matcher.js @@ -1,17 +1,20 @@ expect.extend({ toRunSuccessfully(received) { - const pass = received.status === 0 + const pass = received.status === 0; if (pass) { return { message: () => `expected exit code not to be 0`, pass: true, - } + }; } else { return { - message: () => `expected exit code to be 0, was ${received.status} with error: \n${received.output}`, + message: () => + `expected exit code to be 0, was ${received.status} with error: \n${ + received.output + }`, pass: false, - } + }; } - } -}) + }, +}); diff --git a/cli/bootstrap/custom-app/package.json b/cli/bootstrap/custom-app/package.json index 0e3fe28..efcaaca 100644 --- a/cli/bootstrap/custom-app/package.json +++ b/cli/bootstrap/custom-app/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "react": "^16.0.0", - "react-tv": "^0.3.0-alpha.1" + "react-tv": "^0.3.0-alpha.2" }, "devDependencies": { "babel-core": "^6.4.5", diff --git a/cli/shared/index.js b/cli/shared/index.js index 270a700..4af0b4a 100644 --- a/cli/shared/index.js +++ b/cli/shared/index.js @@ -40,7 +40,7 @@ function createReactTVApp(appName) { recursive: true, silent: true, }); - } catch(e) { + } catch (e) { return process.exit(1); } @@ -71,7 +71,7 @@ function createReactTVApp(appName) { recursive: true, silent: true, }); - } catch(e) { + } catch (e) { return process.exit(1); } diff --git a/examples/benchmark/package.json b/examples/benchmark/package.json index 956e556..36f11ad 100644 --- a/examples/benchmark/package.json +++ b/examples/benchmark/package.json @@ -18,7 +18,7 @@ "dependencies": { "react": "^16.0.0", "react-dom": "^16.0.0", - "react-tv": "0.3.0-alpha.1" + "react-tv": "0.3.0-alpha.2" }, "devDependencies": { "babel-core": "^6.4.5", diff --git a/examples/clock-app-with-react-tv/package.json b/examples/clock-app-with-react-tv/package.json index d7b537c..4c3f232 100644 --- a/examples/clock-app-with-react-tv/package.json +++ b/examples/clock-app-with-react-tv/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "react": "^16.0.0", - "react-tv": "0.3.0-alpha.1" + "react-tv": "0.3.0-alpha.2" }, "devDependencies": { "babel-core": "^6.4.5", diff --git a/examples/keyboard-navigation/package.json b/examples/keyboard-navigation/package.json index ac10220..2340486 100644 --- a/examples/keyboard-navigation/package.json +++ b/examples/keyboard-navigation/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "react": "^16.0.0", - "react-tv": "0.3.0-alpha.1" + "react-tv": "0.3.0-alpha.2" }, "devDependencies": { "babel-core": "^6.4.5", diff --git a/package.json b/package.json index 9c843f9..78f4ed3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-tv", - "version": "0.3.0-alpha.1", + "version": "0.3.0-alpha.2", "description": "React renderer for low memory applications and Packager for TVs (WebOS, Tizen, Orsay)", "main": "dist/react-tv.umd.js", "bin": {