-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
17 changed files
with
272 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Cypress CLI source | ||
|
||
This folder is used to build Cypress NPM module. | ||
|
||
## Building | ||
|
||
See `scripts/build.js`. Note that the built NPM package will include [NPM_README.md](NPM_README.md) as its public README file. | ||
|
||
## Testing | ||
|
||
To build and test an NPM package: | ||
|
||
- `npm install` | ||
- `npm run build` | ||
|
||
This creates `build` folder. | ||
|
||
- `cd build; npm pack` | ||
|
||
This creates an archive, usually named `cypress-<version>.tgz`. You can install this archive from other projects, but because there is no corresponding binary yet (probably), skip binary download. For example from inside `cypress-example-kitchensink` folder | ||
|
||
```shell | ||
npm i ~/git/cypress/cli/build/cypress-3.1.5.tgz --ignore-scripts | ||
``` | ||
|
||
Which installs the `tgz` file we have just built from folder `~/git/cypress/cli/build`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env node | ||
|
||
const { includeTypes } = require('./utils') | ||
const shell = require('shelljs') | ||
const { join } = require('path') | ||
|
||
shell.set('-v') // verbose | ||
shell.set('-e') // any error is fatal | ||
|
||
// we include the TypeScript definitions for the bundled 3rd party tools | ||
// thus we need to copy them from "dev" dependencies into our types folder | ||
includeTypes.forEach((folder) => { | ||
const source = join('node_modules', '@types', folder) | ||
|
||
shell.cp('-R', source, 'types') | ||
}) | ||
|
||
// fix paths to Chai, jQuery and other types to be relative | ||
shell.sed( | ||
'-i', | ||
'<reference types="chai" />', | ||
'<reference path="../chai/index.d.ts" />', | ||
join('types', 'chai-jquery', 'index.d.ts') | ||
) | ||
shell.sed( | ||
'-i', | ||
'<reference types="jquery" />', | ||
'<reference path="../jquery/index.d.ts" />', | ||
join('types', 'chai-jquery', 'index.d.ts') | ||
) | ||
shell.sed( | ||
'-i', | ||
'<reference types="chai" />', | ||
'<reference path="../chai/index.d.ts" />', | ||
join('types', 'sinon-chai', 'index.d.ts') | ||
) | ||
shell.sed( | ||
'-i', | ||
'<reference types="sinon" />', | ||
'<reference types="../sinon" />', | ||
join('types', 'sinon-chai', 'index.d.ts') | ||
) | ||
// also use relative import for sinon-chai | ||
shell.sed( | ||
'-i', | ||
'from \'sinon\';', | ||
'from \'../sinon\';', | ||
join('types', 'sinon-chai', 'index.d.ts') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Folder names in "node_modules/@types" that we should include | ||
* when we bundle Cypress NPM package. These folder have ".d.ts" | ||
* definition files that we will need to include with our NPM package. | ||
*/ | ||
const includeTypes = [ | ||
'blob-util', | ||
'bluebird', | ||
'lodash', | ||
'mocha', | ||
'minimatch', | ||
'sinon', | ||
'sinon-chai', | ||
'chai', | ||
'chai-jquery', | ||
'jquery', | ||
] | ||
|
||
module.exports = { includeTypes } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// I was trying to avoid relying on "import" of actual module from "minimatch" | ||
// because it would not work in test project, and the only reliable way | ||
// to get around type errors finally was to copy the minimal minimatch function | ||
// definition from "minimatch/index.d.ts" here and just keep it in our code | ||
|
||
export = Minimatch | ||
export as namespace Minimatch | ||
|
||
interface MinimatchOptions { | ||
/** | ||
* Dump a ton of stuff to stderr. | ||
* | ||
* @default false | ||
*/ | ||
debug?: boolean | ||
|
||
/** | ||
* Do not expand {a,b} and {1..3} brace sets. | ||
* | ||
* @default false | ||
*/ | ||
nobrace?: boolean | ||
|
||
/** | ||
* Disable ** matching against multiple folder names. | ||
* | ||
* @default false | ||
*/ | ||
noglobstar?: boolean | ||
|
||
/** | ||
* Allow patterns to match filenames starting with a period, | ||
* even if the pattern does not explicitly have a period in that spot. | ||
* | ||
* @default false | ||
*/ | ||
dot?: boolean | ||
|
||
/** | ||
* Disable "extglob" style patterns like +(a|b). | ||
* | ||
* @default false | ||
*/ | ||
noext?: boolean | ||
|
||
/** | ||
* Perform a case-insensitive match. | ||
* | ||
* @default false | ||
*/ | ||
nocase?: boolean | ||
|
||
/** | ||
* When a match is not found by minimatch.match, | ||
* return a list containing the pattern itself if this option is set. | ||
* Otherwise, an empty list is returned if there are no matches. | ||
* | ||
* @default false | ||
*/ | ||
nonull?: boolean | ||
|
||
/** | ||
* If set, then patterns without slashes will be matched against | ||
* the basename of the path if it contains slashes. | ||
* | ||
* @default false | ||
*/ | ||
matchBase?: boolean | ||
|
||
/** | ||
* Suppress the behavior of treating # | ||
* at the start of a pattern as a comment. | ||
* | ||
* @default false | ||
*/ | ||
nocomment?: boolean | ||
|
||
/** | ||
* Suppress the behavior of treating a leading ! character as negation. | ||
* | ||
* @default false | ||
*/ | ||
nonegate?: boolean | ||
|
||
/** | ||
* Returns from negate expressions the same as if they were not negated. | ||
* (Ie, true on a hit, false on a miss.) | ||
* | ||
* @default false | ||
*/ | ||
flipNegate?: boolean | ||
} | ||
|
||
declare namespace Minimatch { | ||
function minimatch(target: string, pattern: string, options?: MinimatchOptions): boolean | ||
} |
File renamed without changes.
Oops, something went wrong.
This should be deleted