Skip to content

Commit d79426f

Browse files
authored
Merge branch 'develop' into zachw/angular-tweaks
2 parents de6a369 + 581b158 commit d79426f

File tree

69 files changed

+2047
-1389
lines changed

Some content is hidden

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

69 files changed

+2047
-1389
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ Here is a list of the npm packages in this repository:
289289
| [eslint-plugin-dev](./npm/eslint-plugin-dev) | `@cypress/eslint-plugin-dev` | Eslint plugin for internal development. |
290290
| [mount-utils](./npm/mount-utils) | `@cypress/mount-utils` | Common functionality for Vue/React/Angular adapters. |
291291
| [react](./npm/react) | `@cypress/react` | Cypress component testing for React. |
292+
| [react18](./npm/react18) | `@cypress/react18` | Cypress component testing for React 18. |
292293
| [vite-dev-server](./npm/vite-dev-server) | `@cypress/vite-dev-server` | Vite powered dev server for Component Testing. |
293294
| [webpack-preprocessor](./npm/webpack-preprocessor) | `@cypress/webpack-preprocessor` | Cypress preprocessor for bundling JavaScript via webpack. |
294295
| [webpack-dev-server](./npm/webpack-dev-server) | `@cypress/webpack-dev-server` | Webpack powered dev server for Component Testing. |
295-
| [vue](./npm/vue) | `@cypress/vue` | Cypress component testing for Vue. |
296+
| [vue](./npm/vue) | `@cypress/vue` | Cypress component testing for Vue 3. |
297+
| [vue2](./npm/vue2) | `@cypress/vue2` | Cypress component testing for Vue 2. |
296298

297299
We try to tag all issues with a `pkg/` or `npm/` tag describing the appropriate package the work is required in. For public packages, we use their qualified package name: For example, issues relating to the webpack preprocessor are tagged under [`npm: @cypress/webpack-preprocessor`](https://github.com/cypress-io/cypress/labels/npm%3A%20%40cypress%2Fwebpack-preprocessor) label and issues related to the `driver` package are tagged with the [`pkg/driver`](https://github.com/cypress-io/cypress/labels/pkg%2Fdriver) label.
298300

@@ -513,7 +515,7 @@ The repository is setup with two main (protected) branches.
513515
- `master` is the code already published, both for the main Cypress app and independent npm packages.
514516
- `develop` is the current latest "pre-release" code. This branch is set as the default branch, and all pull requests that update the main Cypress binary should be made against this branch.
515517

516-
In general, we want to publish our standalone npm packages continuously as new features are added. Therefore, any pull requests that only change independent `@cypress/` packages in the [`npm`](./npm) directory should be made directly off the `master` branch. We use [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/) to automatically publish these packages to npm when a PR is merged directly into master.
518+
In general, we want to publish our [standalone npm packages](./npm) continuously as new features are added. Therefore, any pull requests that only change independent `@cypress/` packages in the [`npm`](./npm) directory should be made directly off the `master` branch. We use [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/) to automatically publish these packages to npm when a PR is merged directly into master.
517519

518520
When updating the main Cypress app, pull requests should be made against the `develop` branch. We do not continuously deploy the Cypress binary, so `develop` contains all of the new features and fixes that are staged to go out in the next update of the main Cypress app. In addition, if you make changes to an npm package that can't be published until the binary is also updated, you should make a pull request against the `develop` branch.
519521

npm/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# npm
2+
3+
This directory contains packages that are both used internally inside the Cypress monorepo [`packages`](../packages) and also published independently on npm under the Cypress organization using the `@cypress` prefix. For example, `vite-dev-server` is published as `@cypress/vite-dev-server`.
4+
5+
These are automatically released based on [Semantic Version](https://semver.org) commit message prefixes (`feat`, `chore` etc). A package is automatically released when changes are merged into master. You can read more about this process in [`CONTRIBUTING`](../CONTRIBUTING.md#committing-code).
6+

npm/react/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"@vitejs/plugin-react": "1.3.1",
2222
"axios": "0.21.2",
2323
"cypress": "0.0.0-development",
24-
"cypress-plugin-snapshots": "1.4.4",
2524
"prop-types": "15.7.2",
2625
"react": "16.8.6",
2726
"react-dom": "16.8.6",
@@ -30,7 +29,7 @@
3029
"rollup": "^2.38.5",
3130
"rollup-plugin-typescript2": "^0.29.0",
3231
"typescript": "^4.2.3",
33-
"vite": "2.9.5",
32+
"vite": "3.0.3",
3433
"vite-plugin-require-transform": "1.0.3"
3534
},
3635
"peerDependencies": {

npm/react/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "es6",
44
"module": "esnext",
55
"moduleResolution": "node",
66
"lib": [

npm/vite-dev-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"debug": "4.3.3",
1919
"find-up": "6.3.0",
2020
"local-pkg": "0.4.1",
21+
"node-html-parser": "5.3.3",
2122
"pathe": "0.2.0"
2223
},
2324
"devDependencies": {
@@ -26,7 +27,7 @@
2627
"mocha": "^9.2.2",
2728
"sinon": "^13.0.1",
2829
"ts-node": "^10.2.1",
29-
"vite": "2.9.0-beta.3",
30+
"vite": "3.0.3",
3031
"vite-plugin-inspect": "0.4.3"
3132
},
3233
"files": [

npm/vite-dev-server/src/plugins/cypress.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import debugFn from 'debug'
22
import { resolve } from 'pathe'
33
import type { ModuleNode, Plugin, ViteDevServer } from 'vite'
44
import type { Vite } from '../getVite'
5+
import { parse, HTMLElement } from 'node-html-parser'
56
import fs from 'fs'
67

78
import type { ViteDevServerConfig } from '../devServer'
@@ -52,21 +53,44 @@ export const Cypress = (
5253
configResolved (config) {
5354
base = config.base
5455
},
55-
async transformIndexHtml () {
56+
async transformIndexHtml (html) {
57+
// it's possibe other plugins have modified the HTML
58+
// before we get to. For example vitejs/plugin-react will
59+
// add a preamble. We do our best to look at the HTML we
60+
// receive and inject it.
61+
// For now we just grab any `<script>` tags and inject them to <head>.
62+
// We will add more handling as we learn the use cases.
63+
const root = parse(html)
64+
65+
const scriptTagsToInject = root.childNodes.filter((node) => {
66+
return node instanceof HTMLElement && node.rawTagName === 'script'
67+
})
68+
5669
const indexHtmlPath = resolve(projectRoot, indexHtmlFile)
5770

5871
debug('resolved the indexHtmlPath as', indexHtmlPath, 'from', indexHtmlFile)
59-
const indexHtmlContent = await fs.promises.readFile(indexHtmlPath, { encoding: 'utf8' })
72+
73+
let indexHtmlContent = await fs.promises.readFile(indexHtmlPath, { encoding: 'utf8' })
74+
75+
// Inject the script tags
76+
indexHtmlContent = indexHtmlContent.replace(
77+
'<head>',
78+
`<head>
79+
${scriptTagsToInject.map((script) => script.toString())}
80+
`,
81+
)
82+
6083
// find </body> last index
6184
const endOfBody = indexHtmlContent.lastIndexOf('</body>')
6285

6386
// insert the script in the end of the body
64-
return `${indexHtmlContent.substring(0, endOfBody)
65-
}<script>
66-
${loader}
67-
</script>${
68-
indexHtmlContent.substring(endOfBody)
69-
}`
87+
const newHtml = `
88+
${indexHtmlContent.substring(0, endOfBody)}
89+
<script>${loader}</script>
90+
${indexHtmlContent.substring(endOfBody)}
91+
`
92+
93+
return newHtml
7094
},
7195
configureServer: async (server: ViteDevServer) => {
7296
server.middlewares.use(`${base}index.html`, async (req, res) => {

npm/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"rollup-plugin-typescript2": "^0.29.0",
3232
"tailwindcss": "1.1.4",
3333
"typescript": "^4.2.3",
34-
"vite": "2.9.5",
34+
"vite": "3.0.3",
3535
"vue": "3.2.31",
3636
"vue-i18n": "9.0.0-rc.6",
3737
"vue-router": "^4.0.0",

0 commit comments

Comments
 (0)