Skip to content

Commit

Permalink
Merge branch 'master' into monorepo-docs
Browse files Browse the repository at this point in the history
* master:
  Fix typo (#379)
  kyt-cli version bump (#376)
  updates the kyt-cli version (#370)
  fixes cli starter kyt path bug (#369)
  Adds prep for 0.4.0 release candidate (#368)
  Adding identity object property; fixing preprocessor bug (#367)
  Adds yarn support with npm fallback (#270)
  Fix typo (#366)
  Match imports by file ext in Jest test config (#363)
  • Loading branch information
delambo committed Feb 7, 2017
2 parents 366a2de + 5161eac commit 5f2ecf2
Show file tree
Hide file tree
Showing 40 changed files with 12,013 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- 6.0
script: npm run update && npm run lint && npm test && npm run e2e
- 6
script: yarn run update && yarn run lint && yarn test && yarn run e2e
37 changes: 22 additions & 15 deletions e2e_tests/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ const path = require('path');
const fs = require('fs');
const shell = require('shelljs');
const kill = require('../utils/psKill');
const ypm = require('../../packages/kyt-cli/utils/yarnOrNpm')();

const pkgJsonPath = path.join(__dirname, './../pkg.json');

describe('KYT CLI', () => {
beforeAll(() => {
shell.rm('-rf', 'cli-test');
shell.rm('-rf', 'test-packages');
});
it('installs kyt', () => {
// create test packages
shell.mkdir('test-packages');
shell.exec('cp -r ./packages/kyt-utils ./test-packages');
shell.exec('cp -r ./packages/kyt-core ./test-packages/');
shell.exec('cp -r ./packages/kyt-core ./test-packages');
shell.exec('cp -r ./packages/kyt-cli ./test-packages');
shell.exec('rm -rf ./test-packages/kyt-utils/node_modules/');
shell.exec('rm -rf ./test-packages/kyt-core/node_modules/');
shell.exec('rm -rf ./test-packages/kyt-cli/node_modules/');
// Update package Json to point to local kyt-utils
const utilsPath = 'file:../kyt-utils';
const cliPkgPath = './test-packages/kyt-cli/package.json';
Expand All @@ -33,16 +41,16 @@ describe('KYT CLI', () => {
shell.mkdir('cli-test');
shell.cd('cli-test');
shell.cp(pkgJsonPath, 'package.json');
const output = shell.exec('npm install');
const output = shell.exec(`${ypm} install`);
if (output.code !== 0) {
process.exit();
process.exit(output.code);
}
expect(shell.test('-f', 'package.json')).toBe(true);
expect(shell.test('-d', 'node_modules')).toBe(true);
});
it('sets up a starter-kyt', () => {
const setupURL = 'https://github.com/NYTimes/kyt-starter-test.git';
const output = shell.exec(`node_modules/.bin/kyt-cli setup -r ${setupURL}`);
const output = shell.exec(`node_modules/.bin/kyt-cli setup -r ${setupURL} -p ${ypm}`);
expect(output.code).toBe(0);
const setupArr = output.stdout.split('\n');
expect(setupArr.includes('🔥 Setting up your new kyt project...')).toBe(true);
Expand Down Expand Up @@ -83,27 +91,26 @@ describe('KYT CLI', () => {
});

it('runs the lint command', () => {
expect(true).toBe(true);
const output = shell.exec('npm run lint-script');
const output = shell.exec(`${ypm} run lint-script`);
expect(output.code).toBe(0);
const outputArr = output.stdout.split('\n');
expect(outputArr.includes('✅ Your JS looks great ✨')).toBe(true);
});

it('runs the lint-style command', () => {
const output = shell.exec('node_modules/.bin/kyt lint-style');
const output = shell.exec(`${ypm} run lint-style`);
expect(output.code).toBe(0);
const outputArr = output.stdout.split('\n');
expect(outputArr.includes('✅ Your styles look good! ✨')).toBe(true);
});

it('runs the tests command', () => {
const output = shell.exec('npm run test');
const output = shell.exec(`${ypm} run test`);
expect(output.code).toBe(0);
});

it('runs the build command', () => {
const output = shell.exec('npm run build');
const output = shell.exec(`${ypm} run build`);
expect(output.code).toBe(0);
expect(shell.test('-d', 'build')).toBe(true);
expect(shell.test('-d', 'build/server')).toBe(true);
Expand All @@ -115,7 +122,7 @@ describe('KYT CLI', () => {
const exec = new Promise((resolve, reject) => {
let sentKill = false;
let finishedBuild = false;
const child = shell.exec('npm run build', () => {
const child = shell.exec(`${ypm} run build`, () => {
resolve(finishedBuild);
});
child.stdout.on('data', (data) => {
Expand All @@ -136,7 +143,7 @@ describe('KYT CLI', () => {
const exec = new Promise((resolve, reject) => {
let sentKill = false;
let finishedBuild = false;
const child = shell.exec('npm run dev', () => {
const child = shell.exec(`${ypm} run dev`, () => {
resolve(finishedBuild);
});
child.stdout.on('data', (data) => {
Expand All @@ -157,9 +164,9 @@ describe('KYT CLI', () => {

it('starts the app', () => {
let testPass;
shell.exec('npm run build');
shell.exec(`${ypm} run build`);
const exec = new Promise((resolve) => {
const child = shell.exec('npm run start', () => {
const child = shell.exec(`${ypm} run start`, () => {
resolve(testPass);
});
child.stdout.on('data', (data) => {
Expand All @@ -178,7 +185,7 @@ describe('KYT CLI', () => {
it('dev', () => {
let testPass;
const exec = new Promise((resolve) => {
const child = shell.exec('npm run dev', () => {
const child = shell.exec(`${ypm} run dev`, () => {
resolve(testPass);
});
child.stdout.on('data', (data) => {
Expand All @@ -196,7 +203,7 @@ describe('KYT CLI', () => {
it('proto', () => {
const exec = new Promise((resolve) => {
let testPass;
const child = shell.exec('npm run proto', () => {
const child = shell.exec(`${ypm} run proto`, () => {
resolve(testPass);
});
let stillAlive = true;
Expand Down
8 changes: 4 additions & 4 deletions e2e_tests/utils/psKill.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const psTree = require('ps-tree');

// Loops through processes and kills them
module.exports = (pid, signal, callback) => {
signal = signal || 'SIGKILL';
callback = callback || function noop() {};
module.exports = (pid, signal = 'SIGKILL', callback) => {
psTree(pid, (err, children) => {
let arr = [pid].concat(
children.map(p => p.PID)
Expand All @@ -17,6 +15,8 @@ module.exports = (pid, signal, callback) => {
logger.log('Could not kill process', tpid, ex);
}
});
callback();
if (callback) {
callback();
}
});
};
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
"jest": {
"testPathIgnorePatterns": [
"<rootDir>/packages/starter-kyts",
"<rootDir>/packages/kyt-core/cli/actions/test.js",
"<rootDir>/e2e_tests"
],
"collectCoverageFrom": ["**/*.js"],
"collectCoverageFrom": [
"**/*.js"
],
"coveragePathIgnorePatterns": [
"<rootDir>/node_modules",
"<rootDir>/packages/*/node_modules",
Expand All @@ -28,15 +31,16 @@
"scripts": {
"bootstrap": "./scripts/bootstrap.sh",
"update": "./scripts/install-modules.sh",
"yarn-update": "./scripts/yarn-install-modules.sh",
"test": "jest",
"test-watch": "jest --watch",
"test-coverage": "jest --coverage",
"e2e": "jest --config ./e2e_tests/jest.config.json --verbose --no-cache",
"lint": "packages/eslint-config-kyt/node_modules/.bin/eslint ./"
},
"dependencies": {
"jest": "18.1.0",
"ps-tree": "1.1.0",
"shelljs": "0.7.5",
"jest": "16.0.1"
"shelljs": "0.7.5"
}
}
2 changes: 1 addition & 1 deletion packages/babel-presets/babel-preset-kyt-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-kyt-core",
"version": "0.1.0-alpha.1",
"version": "0.1.0",
"description": "An opinionated babel preset, best used with kyt",
"main": "lib/index.js",
"author": "NYTimes",
Expand Down
Loading

0 comments on commit 5f2ecf2

Please sign in to comment.