cli: WIP build script to generate cli/build folder

This commit is contained in:
Brian Mann
2017-06-19 12:59:27 -04:00
parent 3d7039ddf4
commit 3e72e7be1c
5 changed files with 110 additions and 14 deletions

48
cli/NPM_README.md Normal file
View File

@@ -0,0 +1,48 @@
# cypress
> Testing the way it should be
## Install
Requires Node version >= 0.12
```sh
npm install --save-dev cypress
```
## Open Cypress desktop GUI application
To open Cypress app, there are two alternatives from the
command line
```sh
./node_modules/.bin/cypress open
$(npm bin)/cypress open
```
or you can add new a script to your `package.json`
```json
{
"scripts": {
"open": "cypress open"
}
}
```
and then call `npm run open`
## Run tests
To run e2e tests in headless mode execute `$(npm bin)/cypress run`
## Load Cypress as an NPM module
```js
const cy = require('cypress')
// opens desktop GUI application and returns a promise
cy.open(options)
// runs e2e tests in headless browser
// and returns a promise with test results
cy.run(options).then(results, console.error)
```

View File

@@ -1,27 +1,23 @@
{
"name": "cypress",
"version": "0.19.2",
"version": "0.0.0",
"description": "dev build project for Cypress NPM package",
"main": "lib/index.js",
"main": "index.js",
"bin": {
"cypress": "bin/cypress"
},
"private": true,
"engines": {
"node": ">=6.5.0"
},
"scripts": {
"pretest": "npm run lint && npm run test-dependencies",
"test": "npm run test-unit",
"test-unit": "mocha",
"test-watch": "mocha --watch",
"test-dependencies": "deps-ok && dependency-check . --no-dev",
"lint": "$(bin-up eslint) --fix *.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
"pretest": "npm run lint && npm run test-dependencies",
"build": "babel lib -d build/lib && babel index.js -o build/index.js",
"prebuild": "npm run copy-bin",
"precopy-bin": "mkdir -p build/bin || true",
"copy-bin": "cp bin/cypress build/bin/cypress",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
"test-dependencies": "deps-ok && dependency-check . --no-dev"
"prebuild": "./scripts/build.sh",
"build": "node ./scripts/build.js",
"release": "cd build && releaser",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
},
"dependencies": {
"bluebird": "^3.4.5",
@@ -46,8 +42,9 @@
"yauzl": "^2.8.0"
},
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"@cypress/releaser": "^0.1.12",
"babel-cli": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"bin-up": "^1.0.1",
"chai": "^3.5.0",
"clear-module": "^2.1.0",
@@ -61,7 +58,7 @@
},
"files": [
"bin",
"es5",
"lib",
"index.js"
],
"repository": {

37
cli/scripts/build.js Normal file
View File

@@ -0,0 +1,37 @@
const _ = require('lodash')
const path = require('path')
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))
// grab the current version from the root monorepo package.json
const { version, description } = require('../../package.json')
const packageJsonSrc = path.join('package.json')
const packageJsonDest = path.join('build', 'package.json')
function preparePackageForNpmRelease (json) {
// modify the existing package.json
// to prepare it for releasing to npm
delete json.devDependencies
delete json['private']
_.extend(json, {
version,
description,
scripts: {
postinstall: 'node index.js --exec install',
size: 't=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";',
},
})
return json
}
fs.readJsonAsync(packageJsonSrc)
.then(preparePackageForNpmRelease)
.then((json) => {
return fs.outputJsonAsync(packageJsonDest, json, {
spaces: 2,
})
})

9
cli/scripts/build.sh Executable file
View File

@@ -0,0 +1,9 @@
## copy over binary
mkdir -p build/bin || true
cp bin/cypress build/bin/cypress
## copy readme
cp NPM_README.md build/README.md
## generate babel'd js index + lib
babel lib -d build/lib && babel index.js -o build/index.js

View File

@@ -1,6 +1,11 @@
{
"name": "cypress-monorepo",
"version": "0.19.4",
"description": "Cypress.io end to end testing tool",
"private": true,
"engines": {
"node": ">=6.5.0"
},
"scripts": {
"start": "node ./scripts/start.js",
"watch": "npm run all watch",