Merge branch 'develop' into elevatebart/chore/merge-develop

This commit is contained in:
ElevateBart
2021-12-07 10:39:29 -06:00
65 changed files with 1356 additions and 1428 deletions

View File

@@ -68,25 +68,34 @@ export async function buildCypressApp (options: BuildCypressAppOpts) {
// Copy Packages: We want to copy the package.json, files, and output
log('#copyAllToDist')
await packages.copyAllToDist(DIST_DIR)
fs.copySync(path.join(CY_ROOT_DIR, 'patches'), path.join(DIST_DIR, 'patches'))
const jsonRoot = fs.readJSONSync(path.join(CY_ROOT_DIR, 'package.json'))
fs.writeJsonSync(meta.distDir('package.json'), _.omit(jsonRoot, [
'scripts',
const packageJsonContents = _.omit(jsonRoot, [
'devDependencies',
'lint-staged',
'engines',
]), { spaces: 2 })
'scripts',
])
fs.writeJsonSync(meta.distDir('package.json'), {
...packageJsonContents,
scripts: {
postinstall: 'patch-package',
},
}, { spaces: 2 })
// Copy the yarn.lock file so we have a consistent install
fs.copySync(path.join(CY_ROOT_DIR, 'yarn.lock'), meta.distDir('yarn.lock'))
// replaceLocalNpmVersions
log('#replace local npm versions')
const dirsSeen = await packages.replaceLocalNpmVersions(DIST_DIR)
// remove local npm dirs that aren't needed
log('#remove local npm dirs that are not needed')
await packages.removeLocalNpmDirs(DIST_DIR, dirsSeen)
log('#install production dependencies')
execSync('yarn --production', {
cwd: DIST_DIR,
stdio: 'inherit',
@@ -152,7 +161,7 @@ require('./packages/server')\
log(`#testVersion ${meta.distDir()}`)
await testVersion(meta.distDir(), version)
// testBuiltStaticAssets
log('#testStaticAssets')
await testStaticAssets(meta.distDir())
log('#removeCyAndBinFolders')

View File

@@ -13,14 +13,6 @@ let car = null
// all the projects to trigger / run / change environment variables for
const _PROVIDERS = {
appVeyor: {
main: 'cypress-io/cypress',
win32: [
'cypress-io/cypress-test-tiny',
'cypress-io/cypress-test-example-repos',
],
},
circle: {
main: 'cypress-io/cypress',
linux: [
@@ -35,6 +27,10 @@ const _PROVIDERS = {
'cypress-io/cypress-test-tiny',
'cypress-io/cypress-test-example-repos',
],
win32: [
'cypress-io/cypress-test-tiny',
'cypress-io/cypress-test-example-repos',
],
},
}
@@ -105,12 +101,6 @@ const awaitEachProjectAndProvider = function (projects, fn, filter = (val) => va
}
}
if (check.unemptyString(creds.appVeyorToken)) {
providers.appVeyor = {
appVeyorToken: creds.appVeyorToken,
}
}
const providerNames = Object.keys(providers)
console.log('configured providers', providerNames)
@@ -133,7 +123,6 @@ const awaitEachProjectAndProvider = function (projects, fn, filter = (val) => va
}
// do not trigger all projects if there is specific provider
// for example appVeyor should be used for Windows testing
const getFilterByProvider = function (providerName, platformName) {
return (val) => {
if (providerName && val.provider !== providerName) {
@@ -226,14 +215,6 @@ Testing new Cypress version ${version}
message += '\n'
message += `Circle CI build url ${process.env.CIRCLE_BUILD_URL}`
}
if (process.env.APPVEYOR) {
const slug = process.env.APPVEYOR_PROJECT_SLUG
const build = process.env.APPVEYOR_BUILD_ID
message += '\n'
message += `AppVeyor CI ${slug} ${build}`
}
}
const defaultOptions = {

View File

@@ -1,6 +0,0 @@
// but globby supports multiple wildcard search patterns 👏
const globby = require('globby')
module.exports = {
globby,
}

View File

@@ -1,16 +1,17 @@
import _ from 'lodash'
import fs from 'fs-extra'
import util from 'util'
import path from 'path'
// we wrap glob to handle EMFILE error
import glob from 'glob'
import la from 'lazy-ass'
import check from 'check-more-types'
import execa from 'execa'
import debugLib from 'debug'
import externalUtils, { globby } from './3rd-party'
const debug = debugLib('cypress:binary')
const globAsync = util.promisify(glob)
const pathToPackageJson = function (packageFolder) {
la(check.unemptyString(packageFolder), 'expected package path', packageFolder)
@@ -41,17 +42,13 @@ const createCLIExecutable = (command) => {
const yarn = createCLIExecutable('yarn')
export const runAllBuild = _.partial(yarn, ['lerna', 'run', 'build-prod', '--ignore', 'cli'])
export const runAllCleanJs = _.partial(yarn, ['lerna', 'run', 'clean-js', '--ignore', 'cli'])
export async function copyAllToDist (distDir: string) {
await fs.ensureDir(distDir)
const started = new Date().valueOf()
const globbed = await externalUtils.globby(['./packages/*', './npm/*'], {
onlyFiles: false,
})
const globbed = await globAsync('./{packages,npm}/*')
for (const pkg of globbed) {
// copies the package to dist
@@ -74,11 +71,17 @@ export async function copyAllToDist (distDir: string) {
const pkgFileMasks = [].concat(json.files || []).concat(json.main || [])
debug('for pkg %s have the following file masks %o', pkg, pkgFileMasks)
const foundFileRelativeToPackageFolder = await externalUtils.globby(pkgFileMasks, {
cwd: pkg, // search in the package folder
absolute: false, // and return relative file paths
followSymbolicLinks: false, // do not follow symlinks
})
let foundFileRelativeToPackageFolder = []
if (pkgFileMasks.length > 0) {
const pattern = pkgFileMasks.length > 1 ? `{${pkgFileMasks.join(',')}}` : pkgFileMasks[0]
foundFileRelativeToPackageFolder = await globAsync(pattern, {
cwd: pkg, // search in the package folder
absolute: false, // and return relative file paths
follow: false, // do not follow symlinks
})
}
console.log(`Copying ${pkg} to ${path.join(distDir, pkg)}`)
@@ -101,7 +104,6 @@ export async function copyAllToDist (distDir: string) {
try {
// Strip out dev-dependencies & scripts for everything in /packages so we can yarn install in there
await fs.writeJson(path.join(distDir, pkg, 'package.json'), _.omit(json, [
'scripts',
'devDependencies',
'lint-staged',
'engines',
@@ -123,12 +125,13 @@ export async function copyAllToDist (distDir: string) {
export const replaceLocalNpmVersions = async function (basePath: string) {
const visited = new Set<string>()
const pkgPaths = await globby('./packages/*/package.json', { cwd: basePath })
const pkgPaths = await globAsync('./packages/*/', { cwd: basePath })
async function updatePackageJson (pkg: string) {
const pkgJsonPath = path.join(basePath, pkg)
const pkgPath = path.join(basePath, pkg)
const pkgJsonPath = path.join(basePath, pkg, 'package.json')
visited.add(pkg)
visited.add(pkgPath)
const json = await fs.readJson(pkgJsonPath)
const { dependencies } = json
@@ -154,6 +157,7 @@ export const replaceLocalNpmVersions = async function (basePath: string) {
shouldWriteFile = true
}
if (shouldWriteFile) {
await fs.writeJson(pkgJsonPath, json, { spaces: 2 })
}
@@ -166,9 +170,8 @@ export const replaceLocalNpmVersions = async function (basePath: string) {
}
export async function removeLocalNpmDirs (distPath: string, except: string[]) {
const toRemove = await globby(`${distPath}/npm/*`, {
ignore: except.map((e) => path.join(distPath, e).replace('/package.json', '')),
onlyDirectories: true,
const toRemove = await globAsync(`${distPath}/npm/*/`, {
ignore: except,
})
for (const dir of toRemove) {

View File

@@ -47,6 +47,49 @@ const testStaticAssets = async (buildResourcePath) => {
['-ms-', 20],
],
}),
testPackageStaticAssets({
assetGlob: `${buildResourcePath}/packages/desktop-gui/dist/index.html`,
goodStrings: [
// make sure webpack is run with NODE_ENV=production
`window.env = 'production'`,
],
}),
testPackageStaticAssets({
assetGlob: `${buildResourcePath}/packages/desktop-gui/dist/app.js`,
goodStrings: [
// make sure webpack is run with NODE_ENV=production
'react.production.min.js',
],
}),
testPackageStaticAssets({
assetGlob: `${buildResourcePath}/packages/socket/node_modules/socket.io-parser/dist/binary.js`,
badStrings: [
'pack.data = _deconstructPacket(packetData, buffers);',
],
goodStrings: [
'pack.data = _deconstructPacket(packetData, buffers, [], new WeakMap());',
],
}),
testPackageStaticAssets({
assetGlob: `${buildResourcePath}/packages/socket/node_modules/engine.io-parser/lib/encodePacket.browser.js`,
badStrings: [
'return callback(data instanceof ArrayBuffer ? data : data.buffer);',
],
goodStrings: [
'This extra check is made because the "instanceof ArrayBuffer" check does not work',
'return callback((data instanceof ArrayBuffer || isArrayBuffer(data)) ? data : data.buffer);',
],
}),
testPackageStaticAssets({
assetGlob: `${buildResourcePath}/node_modules/winston/lib/winston/common.js`,
badStrings: [
`if (target.padLevels) {`,
],
goodStrings: [
`if (target.hasOwnProperty('padLevels') && target.padLevels) {`,
],
}),
])
}

View File

@@ -29,10 +29,6 @@ const formHashFromEnvironment = function () {
return `circle-${env.CIRCLE_BRANCH}-${env.CIRCLE_SHA1}`
}
if (env.APPVEYOR) {
return `appveyor-${env.APPVEYOR_REPO_BRANCH}-${env.APPVEYOR_REPO_COMMIT}`
}
throw new Error('Do not know how to form unique build hash on this CI')
}