Skip to content

Commit a4defbb

Browse files
committed
Merge remote-tracking branch 'origin/10.0-release' into lmiller1990/UNIFY-1402
2 parents f54860c + 9ec9739 commit a4defbb

File tree

64 files changed

+682
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+682
-214
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ system-tests/projects/config-with-ts-syntax-error/**
3737
# cli/types is linted by tslint/dtslint
3838
cli/types
3939

40+
# cli/react, cli/vue, and cli/mount-utils are all copied from dist'd builds
41+
cli/react
42+
cli/vue
43+
cli/mount-utils
44+
4045
# packages/example is not linted (think about changing this)
4146
packages/example
4247

browser-versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"chrome:beta": "100.0.4896.60",
3-
"chrome:stable": "100.0.4896.60"
2+
"chrome:beta": "101.0.4951.15",
3+
"chrome:stable": "100.0.4896.75"
44
}

circle.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mainBuildFilters: &mainBuildFilters
2929
only:
3030
- develop
3131
- 10.0-release
32-
- 10.0-use-contexts
32+
- marktnoonan/merg-develop-2022-4-5
3333

3434
# usually we don't build Mac app - it takes a long time
3535
# but sometimes we want to really confirm we are doing the right thing
@@ -39,7 +39,7 @@ macWorkflowFilters: &mac-workflow-filters
3939
or:
4040
- equal: [ develop, << pipeline.git.branch >> ]
4141
- equal: [ '10.0-release', << pipeline.git.branch >> ]
42-
- equal: [ 10.0-use-contexts, << pipeline.git.branch >> ]
42+
- equal: [ marktnoonan/merg-develop-2022-4-5, << pipeline.git.branch >> ]
4343
- matches:
4444
pattern: "-release$"
4545
value: << pipeline.git.branch >>
@@ -49,7 +49,7 @@ windowsWorkflowFilters: &windows-workflow-filters
4949
or:
5050
- equal: [ develop, << pipeline.git.branch >> ]
5151
- equal: [ '10.0-release', << pipeline.git.branch >> ]
52-
- equal: [ 10.0-use-contexts, << pipeline.git.branch >> ]
52+
- equal: [ marktnoonan/merg-develop-2022-4-5, << pipeline.git.branch >> ]
5353
- matches:
5454
pattern: "-release$"
5555
value: << pipeline.git.branch >>
@@ -948,9 +948,16 @@ commands:
948948
- run:
949949
name: Build NPM package
950950
command: yarn build --scope cypress
951+
- run:
952+
name: Copy Re-exported NPM Packages
953+
command: node ./scripts/post-build.js
954+
working_directory: cli
951955
- run:
952956
command: ls -la types
953957
working_directory: cli/build
958+
- run:
959+
command: ls -la vue mount-utils react
960+
working_directory: cli/build
954961
- unless:
955962
condition:
956963
equal: [ *windows-executor, << parameters.executor >> ]
@@ -1704,7 +1711,7 @@ jobs:
17041711
- run:
17051712
name: Check current branch to persist artifacts
17061713
command: |
1707-
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "10.0-use-contexts" && "$CIRCLE_BRANCH" != "10.0-release" ]]; then
1714+
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "marktnoonan/merg-develop-2022-4-5" && "$CIRCLE_BRANCH" != "10.0-release" ]]; then
17081715
echo "Not uploading artifacts or posting install comment for this branch."
17091716
circleci-agent step halt
17101717
fi

cli/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ types/sinon-chai
1212
types/net-stubbing.ts
1313
# ignore CLI output build folder
1414
build
15+
16+
# ignore packages synced at build-time via
17+
# the sync-exported-npm-with-cli.js script
18+
vue
19+
react
20+
mount-utils

cli/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,47 @@ yarn add ~/{your-dirs}/cypress/cli/build/cypress-3.3.1.tgz --ignore-scripts
6060

6161
Which installs the `tgz` file we have just built from folder `Users/jane-lane/{your-dirs}/cypress/cli/build`.
6262

63+
#### Sub-package API
64+
65+
> How do deep imports from cypress/* get resolved?
66+
67+
The cypress npm package comes pre-assembled with mounting libraries for major front-end frameworks. These mounting libraries are the first examples of Cypress providing re-exported sub-packages. These sub-packages follow the same naming convention they do when they're published on **npm**, but without a leading **`@`** sign. For example:
68+
69+
##### An example of a sub-package: @cypress/vue, @cypress/react, @cypress/mount-utils
70+
71+
**Let's discuss the Vue mounting library that Cypress ships.**
72+
73+
If you'd installed the `@cypress/vue` package from NPM, you could write the following code.
74+
75+
This would be necessary when trying to use a version of Vue, React, or other library that may be newer or older than the current version of cypress itself.
76+
77+
```js
78+
import { mount } from '@cypress/vue'
79+
```
80+
81+
Now, with the sub-package API, you're able to import the latest APIs directly from Cypress without needing to install a separate dependency.
82+
83+
```js
84+
import { mount } from 'cypress/vue'
85+
```
86+
87+
The only difference is the import name, and if you still need to use a specific version of one of our external sub-packages, you may install it and import it directly.
88+
89+
##### Adding a new sub-package
90+
91+
There are a few steps when adding a new sub-package.
92+
93+
1. Make sure the sub-package's rollup build is _self-contained_ or that any dependencies are also declared in the CLI's **`package.json`**.
94+
2. Now, in the **`postbuild`** script for the sub-package you'd like to embed, invoke `node ./scripts/sync-exported-npm-with-cli.js` (relative to the sub-package, see **`npm/vue`** for an example).
95+
3. Add the sub-package's name to the following locations:
96+
- **`cli/.gitignore`**
97+
- **`cli/scripts/post-build.js`**
98+
- **`.eslintignore`** (under cli/sub-package)
99+
4. DO NOT manually update the **package.json** file. Running `yarn build` will automate this process.
100+
5. Commit the changed files.
101+
102+
[Here is an example Pull Request](https://github.com/cypress-io/cypress/pull/20930/files#diff-21b1fe66043572c76c549a4fc5f186e9a69c330b186fc91116b9b70a4d047902)
103+
63104
#### Module API
64105

65106
The module API can be tested locally using something like:

cli/package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@
103103
"index.js",
104104
"index.mjs",
105105
"types/**/*.d.ts",
106-
"types/net-stubbing.ts"
106+
"types/net-stubbing.ts",
107+
"mount-utils",
108+
"vue",
109+
"react"
107110
],
108111
"bin": {
109112
"cypress": "bin/cypress"
@@ -117,9 +120,20 @@
117120
"import": "./index.mjs",
118121
"require": "./index.js"
119122
},
123+
"./vue": {
124+
"import": "./vue/dist/cypress-vue.esm-bundler.js",
125+
"require": "./vue/dist/cypress-vue.cjs.js"
126+
},
120127
"./package.json": {
121128
"import": "./package.json",
122129
"require": "./package.json"
130+
},
131+
"./react": {
132+
"import": "./react/dist/cypress-react.esm-bundler.js",
133+
"require": "./react/dist/cypress-react.cjs.js"
134+
},
135+
"./mount-utils": {
136+
"require": "./mount-utils/dist/index.js"
123137
}
124138
}
125139
}

cli/scripts/post-build.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const shell = require('shelljs')
2+
const { resolve } = require('path')
3+
4+
shell.set('-v') // verbose
5+
shell.set('-e') // any error is fatal
6+
7+
// For each npm package that is re-published via cypress/*
8+
// make sure that it is also copied into the build directory
9+
const npmModulesToCopy = [
10+
'mount-utils',
11+
'react',
12+
'vue',
13+
]
14+
15+
npmModulesToCopy.forEach((folder) => {
16+
// cli/mount-utils => cli/build/mount-utils
17+
const from = resolve(`${__dirname}/../${folder}`)
18+
const to = resolve(`${__dirname}/../build/${folder}`)
19+
20+
shell.cp('-R', from, to)
21+
})

cli/scripts/start-build.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ includeTypes.forEach((folder) => {
2222
shell.cp('-R', source, 'build/types')
2323
})
2424

25+
// TODO: Add a typescript or rollup build step
26+
// The only reason start-build.js exists
27+
// is because the cli package does not have an actual
28+
// build process to compile index.js and lib
2529
shell.exec('babel lib -d build/lib')
2630
shell.exec('babel index.js -o build/index.js')
2731
shell.cp('index.mjs', 'build/index.mjs')

cli/types/cypress.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ declare namespace Cypress {
23412341
type Agent<T extends sinon.SinonSpy> = SinonSpyAgent<T> & T
23422342

23432343
interface CookieDefaults {
2344-
preserve: string | string[] | RegExp | ((cookie: any) => boolean)
2344+
preserve: string | string[] | RegExp | ((cookie: Cookie) => boolean)
23452345
}
23462346

23472347
interface Failable {

npm/mount-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "tsc || echo 'built, with type errors'",
8-
"build-prod": "tsc || echo 'built, with type errors'",
8+
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
9+
"build-prod": "yarn build",
910
"check-ts": "tsc --noEmit",
1011
"watch": "tsc -w"
1112
},

0 commit comments

Comments
 (0)