-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: embedding mount into the cypress binary (real dependency) (#20930)
- Loading branch information
1 parent
1ef7ffb
commit 3fe5f50
Showing
14 changed files
with
183 additions
and
9 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
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,21 @@ | ||
const shell = require('shelljs') | ||
const { resolve } = require('path') | ||
|
||
shell.set('-v') // verbose | ||
shell.set('-e') // any error is fatal | ||
|
||
// For each npm package that is re-published via cypress/* | ||
// make sure that it is also copied into the build directory | ||
const npmModulesToCopy = [ | ||
'mount-utils', | ||
'react', | ||
'vue', | ||
] | ||
|
||
npmModulesToCopy.forEach((folder) => { | ||
// cli/mount-utils => cli/build/mount-utils | ||
const from = resolve(`${__dirname}/../${folder}`) | ||
const to = resolve(`${__dirname}/../build/${folder}`) | ||
|
||
shell.cp('-R', from, to) | ||
}) |
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
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,78 @@ | ||
/** | ||
* This script is used to re-export packages that Cypress publishes on its own. | ||
* It is executed individually in a postbuild step by individual npm/* packages. | ||
* For example, usually, Cypress will publish the `npm/react` directory as a `@cypress/react` package. | ||
* However, the Cypress binary will also ship an export for `cypress/react` that's guaranteed to work | ||
* with this version of the binary | ||
*/ | ||
const shell = require('shelljs') | ||
const path = require('path') | ||
const packlist = require('npm-packlist') | ||
const fs = require('fs') | ||
|
||
shell.set('-v') // verbose | ||
shell.set('-e') // any error is fatal | ||
|
||
// This script will be run in a postbuild task for each npm package | ||
// that will be re-exported by Cypress | ||
const currentPackageDir = process.cwd() | ||
|
||
// 1. We'll run npm's own "packlist" against the npm package to be published (@cypress/react, etc) | ||
// to make sure we don't miss any files when we copy them over to the CLI package | ||
// The files that will be returned here are the ones from @cypress/react's package.json['files'] key. | ||
packlist({ path: currentPackageDir }) | ||
.then((files) => { | ||
// 2. Move all of the files that would be published under @cypress/react | ||
// to be copied under cli/react (drop the @cypress namespace) | ||
const cliPath = path.join(__dirname, '..', 'cli') | ||
|
||
// Typically, these packages are independently published as @cypress/package-name | ||
// e.g. @cypress/vue => import whatever from 'cypress/vue' | ||
// The files will wind up at cypress/cli/vue/* | ||
const currentPackageConfig = require(path.join(process.cwd(), 'package.json')) | ||
const exportName = currentPackageConfig.name.replace('@cypress/', '') | ||
const outDir = path.join(cliPath, exportName) | ||
|
||
// 3. For each file, mkdir if not exists, and then copy the dist'd assets over | ||
// Shell is synchronous by default, but we don't actually need to await for the results | ||
// to write to the `cliPackageConfig` at the end | ||
files.forEach((f) => { | ||
// mkdir if not exists | ||
const { dir } = path.parse(f) | ||
|
||
if (dir) { | ||
shell.mkdir('-p', path.join(outDir, dir)) | ||
} | ||
|
||
shell.cp(path.join(currentPackageDir, f), path.join(outDir, f)) | ||
}) | ||
|
||
// After everything is copied, let's update the Cypress cli package.json['exports'] map. | ||
const isModule = currentPackageConfig.type === 'module' | ||
|
||
const cliPackageConfig = require(path.join(cliPath, 'package.json')) | ||
|
||
const subPackageExports = cliPackageConfig.exports[`./${exportName}`] = {} | ||
const esmEntry = isModule ? currentPackageConfig.main : currentPackageConfig.module | ||
|
||
if (esmEntry) { | ||
// ./react/dist/cypress-react-esm.js, etc | ||
subPackageExports.import = `./${exportName}/${esmEntry}` | ||
} | ||
|
||
if (!isModule) { | ||
// ./react/dist/cypress-react-cjs.js, etc | ||
subPackageExports.require = `./${exportName}/${currentPackageConfig.main}` | ||
} | ||
|
||
if (!cliPackageConfig.files.includes(exportName)) { | ||
cliPackageConfig.files.push(exportName) | ||
} | ||
|
||
const output = `${JSON.stringify(cliPackageConfig, null, 2) }\n` | ||
|
||
// eslint-disable-next-line no-console | ||
console.log('Writing to CLI package.json for', exportName) | ||
|
||
fs.writeFileSync(path.join(cliPath, 'package.json'), output, 'utf-8') | ||
}) |
3fe5f50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: