Files
cypress/cli/scripts/build.js
Gleb Bahmutov f81dc7a6b2 move 3rd party types to dev dependencies in CLI NPM package (#3425)
* wip: move lodash types to dev dependencies

* move blob-util types

* move types for minimatch

* do not lint types from minimatch

* move types sinon to dev dependencies

* move sinon-chai types to dev dependencies

* update tslint

* move types bluebird to dev dependencies

* move mocha types

* move jquery types to dev dependencies

* rename moment local wrapper

* move chai and chai-jquery

* refactor code for building CLI and dealing with folders

* linting

* include types subfolders

* replace types with relative paths

* transform sinon path to relative

* linting

* do not delete d.ts files

* linting

* chore: build npm package from this branch

* add minimatch relative reference

* work around minimatch

* set sinon to be relative load

* add readme to CLI

* linting readme
2019-03-05 12:49:42 -05:00

73 lines
1.6 KiB
JavaScript

const _ = require('lodash')
const path = require('path')
const fs = require('../lib/fs')
// grab the current version and a few other properties
// from the root package.json
const {
version,
description,
author,
homepage,
license,
bugs,
repository,
keywords,
} = require('@packages/root')
// the rest of properties should come from the package.json in CLI folder
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']
// no need to include "nyc" code coverage settings
delete json.nyc
_.extend(json, {
version,
description,
author,
homepage,
license,
bugs,
repository,
keywords,
types: 'types', // typescript types
scripts: {
postinstall: 'node index.js --exec install',
size: 't=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";',
},
})
return json
}
function makeUserPackageFile () {
return fs.readJsonAsync(packageJsonSrc)
.then(preparePackageForNpmRelease)
.then((json) => {
return fs.outputJsonAsync(packageJsonDest, json, {
spaces: 2,
})
.return(json) // returning package json object makes it easy to test
})
}
module.exports = makeUserPackageFile
if (!module.parent) {
makeUserPackageFile()
.catch((err) => {
/* eslint-disable no-console */
console.error('Could not write user package file')
console.error(err)
/* eslint-enable no-console */
process.exit(-1)
})
}