Skip to content

Commit e2ea5bf

Browse files
authored
Fix patch-package (#6583)
* fix patch-package - don't hoist dependencies that are patched, this way we can be assured the path is always correct - put all patches in root postinstall so postinstall-postinstall is guaranteed to work * wip * Revert "fix patch-package" This reverts commit 5583f21. * use per package patches * don't ignor engines or silence * try: make sinon patch devonly * fix socketspec * run full ci on this branch * bump xcode tools to bump mac node version * also run appveyor * Revert "run full ci on this branch" This reverts commit c3e52d0. * Revert "also run appveyor" This reverts commit bfe7b04.
1 parent f1f766d commit e2ea5bf

File tree

11 files changed

+36
-52
lines changed

11 files changed

+36
-52
lines changed

circle.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ executors:
5959
# https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
6060
mac:
6161
macos:
62-
xcode: "10.1.0"
62+
## Node 12.10.0 (yarn 1.17.3)
63+
xcode: "11.0.0"
6364
environment:
6465
PLATFORM: mac
6566

@@ -235,7 +236,7 @@ jobs:
235236
- run: ls $(yarn global bin)/../lib/node_modules
236237

237238
# try several times, because flaky NPM installs ...
238-
- run: yarn --ignore-engines || yarn --ignore-engines
239+
- run: yarn || yarn
239240
- run:
240241
name: Top level packages
241242
command: yarn list --depth=0 || true

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@
218218
"packages": [
219219
"cli",
220220
"packages/*"
221-
],
222-
"nohoist": [
223-
"@packages/driver/*"
224221
]
225222
},
226223
"lint-staged": {

packages/driver/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"clean-deps": "rm -rf node_modules",
77
"cypress:open": "node ../../scripts/cypress open --project ./test",
88
"cypress:run": "node ../../scripts/cypress run --project ./test",
9-
"postinstall": "npx patch-package",
9+
"postinstall": "patch-package",
1010
"start": "$(yarn bin coffee) test/support/server.coffee"
1111
},
1212
"devDependencies": {
@@ -66,6 +66,12 @@
6666
"zone.js": "0.9.0"
6767
},
6868
"files": [
69-
"lib"
70-
]
69+
"lib",
70+
"patches"
71+
],
72+
"workspaces": {
73+
"nohoist": [
74+
"*"
75+
]
76+
}
7177
}

packages/socket/lib/socket.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const fs = require('fs')
22
const server = require('socket.io')
3-
const path = require('path')
4-
const pkg = require('socket.io-client/package.json')
3+
const { version } = require('socket.io-client/package.json')
54
const { client, circularParser } = require('./browser')
6-
const resolvePkg = require('resolve-pkg')
5+
6+
const clientSource = require.resolve('socket.io-client/dist/socket.io.js')
77

88
module.exports = {
99
server,
@@ -13,17 +13,11 @@ module.exports = {
1313
circularParser,
1414

1515
getPathToClientSource () {
16-
const clientSource = resolvePkg('socket.io-client/dist/socket.io.js', { cwd: path.join(__dirname, '..', '..', '..') })
17-
18-
if (fs.existsSync(clientSource)) {
19-
return clientSource
20-
}
21-
22-
return require.resolve('socket.io-client/dist/socket.io.js')
16+
return clientSource
2317
},
2418

2519
getClientVersion () {
26-
return pkg.version
20+
return version
2721
},
2822

2923
getClientSource () {

packages/socket/package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@
55
"main": "index.js",
66
"scripts": {
77
"clean-deps": "rm -rf node_modules",
8+
"postinstall": "patch-package",
89
"test": "yarn test-unit",
910
"test-debug": "yarn test-unit --inspect-brk=5566",
1011
"test-unit": "cross-env NODE_ENV=test mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
1112
"test-watch": "cross-env NODE_ENV=test mocha --watch"
1213
},
1314
"dependencies": {
14-
"resolve-pkg": "2.0.0",
1515
"socket.io": "2.3.0",
16-
"socket.io-circular-parser": "cypress-io/socket.io-circular-parser#4d3076af68ea8192c2e53f9d185eaa166359b4c5",
16+
"socket.io-circular-parser": "cypress-io/socket.io-circular-parser#unpatched-has-binary-2",
1717
"socket.io-client": "2.3.0"
1818
},
1919
"devDependencies": {
2020
"chai": "3.5.0",
2121
"cross-env": "6.0.3",
22-
"mocha": "3.5.3"
22+
"mocha": "3.5.3",
23+
"resolve-pkg": "2.0.0"
2324
},
2425
"files": [
25-
"lib"
26-
]
26+
"lib",
27+
"patches"
28+
],
29+
"workspaces": {
30+
"nohoist": [
31+
"**"
32+
]
33+
}
2734
}
File renamed without changes.

packages/socket/test/socket_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Socket', function () {
1818

1919
context('.getPathToClientSource', function () {
2020
it('returns path to socket.io.js', function () {
21-
const clientPath = path.join(resolvePkg('socket.io-client', { cwd: path.join(__dirname, '..', '..', '..') }), 'dist', 'socket.io.js')
21+
const clientPath = path.join(resolvePkg('socket.io-client'), 'dist', 'socket.io.js')
2222

2323
expect(lib.getPathToClientSource()).to.eq(clientPath)
2424
})
@@ -36,7 +36,7 @@ describe('Socket', function () {
3636

3737
context('.getClientSource', function () {
3838
it('returns client source as a string', function (done) {
39-
const clientPath = path.join(resolvePkg('socket.io-client', { cwd: path.join(__dirname, '..', '..', '..') }), 'dist', 'socket.io.js')
39+
const clientPath = path.join(resolvePkg('socket.io-client'), 'dist', 'socket.io.js')
4040

4141
fs.readFile(clientPath, 'utf8', function (err, str) {
4242
if (err) done(err)

scripts/binary/build.coffee

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,6 @@ buildCypressApp = (platform, version, options = {}) ->
121121

122122
packages.copyAllToDist(distDir())
123123

124-
copyPatches = ->
125-
log("#copyPatches")
126-
127-
patchesPath = path.join(__dirname, '..', '..', 'patches')
128-
destPatchesPath = path.join(distDir(), 'patches')
129-
130-
fs.mkdirSync(destPatchesPath)
131-
fs.readdirSync(patchesPath)
132-
.map((patchFileName) -> [
133-
path.join(patchesPath, patchFileName),
134-
path.join(destPatchesPath, patchFileName)
135-
])
136-
.forEach(([src, dest]) -> fs.copyFileSync(src, dest))
137-
138124
transformSymlinkRequires = ->
139125
log("#transformSymlinkRequires")
140126

@@ -355,7 +341,6 @@ buildCypressApp = (platform, version, options = {}) ->
355341
.then(cleanupPlatform)
356342
.then(buildPackages)
357343
.then(copyPackages)
358-
.then(copyPatches)
359344
.then(npmInstallPackages)
360345
.then(createRootPackage)
361346
.then(convertCoffeeToJs)

scripts/binary/util/packages.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ forceNpmInstall = (packagePath, packageToInstall) ->
106106
console.log("Force installing %s", packageToInstall)
107107
console.log("in %s", packagePath)
108108
la(check.unemptyString(packageToInstall), "missing package to install")
109-
yarn(["install", "--force", "--ignore-engines", packageToInstall], packagePath)
109+
yarn(["install", "--force", packageToInstall], packagePath)
110110

111111
removeDevDependencies = (packageFolder) ->
112112
packagePath = pathToPackageJson(packageFolder)
@@ -141,7 +141,7 @@ npmInstallAll = (pathToPackages) ->
141141

142142
# force installing only PRODUCTION dependencies
143143
# https://docs.npmjs.com/cli/install
144-
npmInstall = _.partial(yarn, ["install", "--production", "--silent", "--ignore-engines"])
144+
npmInstall = _.partial(yarn, ["install", "--production"])
145145

146146
npmInstall(pkg, {NODE_ENV: "production"})
147147
.catch {code: "EMFILE"}, ->

0 commit comments

Comments
 (0)