Skip to content

Commit

Permalink
fix: patch-package is not applied in dist'ed build (#19239)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Dec 3, 2021
1 parent 11e99fc commit 8262f80
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 25 deletions.
4 changes: 3 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ macWorkflowFilters: &mac-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ tgriesser/fix/patch-resolutions, << pipeline.git.branch >> ]
- equal: [ renovate/cypress-request-2.x, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
Expand All @@ -47,6 +48,7 @@ windowsWorkflowFilters: &windows-workflow-filters
or:
- equal: [ master, << pipeline.git.branch >> ]
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ tgriesser/fix/patch-resolutions, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -1586,7 +1588,7 @@ jobs:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "tgriesser/fix/patch-resolutions" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"trash": "5.2.0",
"tree-kill": "1.2.2",
"ts-node": "8.5.4",
"tsconfig-paths": "3.10.1",
"tslib": "2.3.0",
"underscore.string": "3.3.5",
"url-parse": "1.5.2",
Expand Down Expand Up @@ -184,7 +185,6 @@
"supertest-session": "4.0.0",
"through2": "2.0.5",
"ts-loader": "7.0.4",
"tsconfig-paths": "3.10.1",
"webpack": "4.43.0",
"ws": "5.2.3",
"xvfb": "cypress-io/node-xvfb#22e3783c31d81ebe64d8c0df491ea00cdc74726a",
Expand Down
4 changes: 4 additions & 0 deletions packages/socket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
},
"dependencies": {
"circular-json": "0.5.9",
"engine.io": "5.0.0",
"engine.io-parser": "4.0.2",
"socket.io": "4.0.1",
"socket.io-client": "4.0.1"
},
Expand All @@ -30,6 +32,8 @@
],
"workspaces": {
"nohoist": [
"engine.io",
"engine.io-parser",
"socket.io",
"socket.io/socket.io-parser",
"socket.io-client",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 12 additions & 4 deletions scripts/binary/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,23 @@ 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'))
Expand Down Expand Up @@ -153,7 +161,7 @@ require('./packages/server')\
log(`#testVersion ${meta.distDir()}`)
await testVersion(meta.distDir(), version)

// testBuiltStaticAssets
log('#testStaticAssets')
await testStaticAssets(meta.distDir())

log('#removeCyAndBinFolders')
Expand Down
1 change: 0 additions & 1 deletion scripts/binary/util/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,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',
Expand Down
28 changes: 28 additions & 0 deletions scripts/binary/util/testStaticAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ const testStaticAssets = async (buildResourcePath) => {
'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) {`,
],
}),
])
}

Expand Down
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17601,6 +17601,13 @@ engine.io-client@~5.0.0:
ws "~7.4.2"
yeast "0.1.2"

engine.io-parser@4.0.2, engine.io-parser@~4.0.0, engine.io-parser@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-4.0.2.tgz#e41d0b3fb66f7bf4a3671d2038a154024edb501e"
integrity sha512-sHfEQv6nmtJrq6TKuIz5kyEKH/qSdK56H/A+7DnAuUPWosnIZAS2NHNcPLmyjtY3cGS/MqJdZbUjW97JU72iYg==
dependencies:
base64-arraybuffer "0.1.4"

engine.io-parser@~2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.2.1.tgz#57ce5611d9370ee94f99641b589f94c97e4f5da7"
Expand All @@ -17612,12 +17619,18 @@ engine.io-parser@~2.2.0:
blob "0.0.5"
has-binary2 "~1.0.2"

engine.io-parser@~4.0.0, engine.io-parser@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-4.0.2.tgz#e41d0b3fb66f7bf4a3671d2038a154024edb501e"
integrity sha512-sHfEQv6nmtJrq6TKuIz5kyEKH/qSdK56H/A+7DnAuUPWosnIZAS2NHNcPLmyjtY3cGS/MqJdZbUjW97JU72iYg==
engine.io@5.0.0, engine.io@~5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/engine.io/-/engine.io-5.0.0.tgz#470dc94a8a4907fa4d2cd1fa6611426afcee61bf"
integrity sha512-BATIdDV3H1SrE9/u2BAotvsmjJg0t1P4+vGedImSs1lkFAtQdvk4Ev1y4LDiPF7BPWgXWEG+NDY+nLvW3UrMWw==
dependencies:
base64-arraybuffer "0.1.4"
accepts "~1.3.4"
base64id "2.0.0"
cookie "~0.4.1"
cors "~2.8.5"
debug "~4.3.1"
engine.io-parser "~4.0.0"
ws "~7.4.2"

engine.io@~3.5.0:
version "3.5.0"
Expand All @@ -17631,19 +17644,6 @@ engine.io@~3.5.0:
engine.io-parser "~2.2.0"
ws "~7.4.2"

engine.io@~5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/engine.io/-/engine.io-5.0.0.tgz#470dc94a8a4907fa4d2cd1fa6611426afcee61bf"
integrity sha512-BATIdDV3H1SrE9/u2BAotvsmjJg0t1P4+vGedImSs1lkFAtQdvk4Ev1y4LDiPF7BPWgXWEG+NDY+nLvW3UrMWw==
dependencies:
accepts "~1.3.4"
base64id "2.0.0"
cookie "~0.4.1"
cors "~2.8.5"
debug "~4.3.1"
engine.io-parser "~4.0.0"
ws "~7.4.2"

enhanced-resolve@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f"
Expand Down

3 comments on commit 8262f80

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8262f80 Dec 3, 2021

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:

npm install https://cdn.cypress.io/beta/npm/9.1.1/circle-develop-8262f80d1f8ca72ef4317fc191811f6a46497184/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8262f80 Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 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:

npm install https://cdn.cypress.io/beta/npm/9.1.1/circle-develop-8262f80d1f8ca72ef4317fc191811f6a46497184/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8262f80 Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin 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:

npm install https://cdn.cypress.io/beta/npm/9.1.1/circle-develop-8262f80d1f8ca72ef4317fc191811f6a46497184/cypress.tgz

Please sign in to comment.