Skip to content

Commit 7a410e3

Browse files
authored
chore(gatsby): remove other services (#35675)
1 parent d2c4d07 commit 7a410e3

File tree

15 files changed

+74
-628
lines changed

15 files changed

+74
-628
lines changed

integration-tests/node-manifest/__tests__/create-node-manifest.test.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,29 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
5454
return urling(`http://localhost:${port}`)
5555
} else if (gatsbyCommandName === `build`) {
5656
// for gatsby build wait for the process to exit
57-
return new Promise(resolve =>
58-
gatsbyProcess.on(`exit`, () => {
59-
gatsbyProcess.kill()
60-
resolve()
61-
})
62-
)
57+
return gatsbyProcess
6358
}
6459
})
6560

66-
afterAll(() => gatsbyProcess.kill())
61+
afterAll(() => {
62+
return new Promise(resolve => {
63+
if (
64+
!gatsbyProcess ||
65+
gatsbyProcess.killed ||
66+
gatsbyProcess.exitCode !== null
67+
) {
68+
return resolve()
69+
}
70+
71+
gatsbyProcess.on(`exit`, () => {
72+
setImmediate(() => {
73+
resolve()
74+
})
75+
})
76+
77+
gatsbyProcess.kill()
78+
})
79+
})
6780

6881
it(`Creates an accurate node manifest when using the ownerNodeId argument in createPage`, async () => {
6982
const manifestFileContents = await getManifestContents(1)
@@ -166,16 +179,29 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
166179
await urling(`http://localhost:${port}`)
167180
} else if (gatsbyCommandName === `build`) {
168181
// for gatsby build wait for the process to exit
169-
return new Promise(resolve => {
170-
gatsbyProcess.on(`exit`, () => {
171-
gatsbyProcess.kill()
182+
return gatsbyProcess
183+
}
184+
})
185+
186+
afterAll(() => {
187+
return new Promise(resolve => {
188+
if (
189+
!gatsbyProcess ||
190+
gatsbyProcess.killed ||
191+
gatsbyProcess.exitCode !== null
192+
) {
193+
return resolve()
194+
}
195+
196+
gatsbyProcess.on(`exit`, () => {
197+
setImmediate(() => {
172198
resolve()
173199
})
174200
})
175-
}
176-
})
177201

178-
afterAll(() => gatsbyProcess.kill())
202+
gatsbyProcess.kill()
203+
})
204+
})
179205

180206
it(`Limits the number of node manifest files written to disk to 500`, async () => {
181207
const nodeManifestFiles = fs.readdirSync(manifestDir)

integration-tests/node-manifest/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A test site for Gatsby's node manifest API",
55
"main": "index.js",
66
"scripts": {
7-
"test": "gatsby clean && GATSBY_COMMAND_NAME=build jest --runInBand && gatsby clean && GATSBY_COMMAND_NAME=develop jest --runInBand"
7+
"test": "cross-env GATSBY_COMMAND_NAME=build jest --runInBand && cross-env GATSBY_COMMAND_NAME=develop jest --runInBand"
88
},
99
"author": "Tyler Barnes <[email protected]>",
1010
"license": "ISC",
@@ -14,9 +14,11 @@
1414
"react-dom": "^17.0.2"
1515
},
1616
"devDependencies": {
17+
"cross-env": "^7.0.3",
18+
"execa": "^5.1.1",
1719
"fs-extra": "^10.0.0",
1820
"jest": "^27.2.1",
1921
"rimraf": "^3.0.2",
2022
"urling": "^1.0.7"
2123
}
22-
}
24+
}
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
const { spawn } = require(`child_process`)
1+
const execa = require(`execa`)
22
const path = require(`path`)
33

4-
const gatsbyBin = path.join(`node_modules`, `.bin`, `gatsby`)
4+
function spawnGatsbyProcess(command = `develop`, env = {}) {
5+
return execa(process.execPath, [`./node_modules/gatsby/cli.js`, command], {
6+
stdio: [`inherit`, `inherit`, `inherit`],
7+
env: {
8+
...process.env,
9+
NODE_ENV: command === `develop` ? `development` : `production`,
10+
...env,
11+
},
12+
})
13+
}
514

6-
exports.spawnGatsbyProcess = (command = `develop`, env = {}) =>
7-
spawn(
8-
gatsbyBin,
9-
[command, ...(command === `develop` ? ["-H", "localhost"] : [])],
10-
{
11-
stdio: [`inherit`, `inherit`, `inherit`, `inherit`],
12-
env: {
13-
...process.env,
14-
NODE_ENV: command === `develop` ? `development` : `production`,
15-
...env,
16-
},
17-
}
18-
)
19-
20-
exports.runGatsbyClean = () =>
21-
spawn(
22-
gatsbyBin,
23-
['clean'],
24-
{
25-
stdio: [`inherit`, `inherit`, `inherit`, `inherit`],
26-
env: { ...process.env },
27-
},
28-
)
15+
exports.spawnGatsbyProcess = spawnGatsbyProcess
2916

17+
exports.runGatsbyClean = () => spawnGatsbyProcess("clean")

packages/gatsby-plugin-netlify-cms/src/gatsby-node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ exports.onCreateWebpackConfig = (
170170
new FriendlyErrorsPlugin({
171171
clearConsole: false,
172172
compilationSuccessInfo: {
173+
// TODO(v5): change proxyPort back in port
173174
messages: [
174175
`Netlify CMS is running at ${
175176
program.https ? `https://` : `http://`

packages/gatsby/cache-dir/app.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* global HAS_REACT_18 */
22
import React from "react"
33
import ReactDOM from "react-dom"
4-
import io from "socket.io-client"
54

65
import socketIo from "./socketIo"
76
import emitter from "./emitter"
@@ -93,53 +92,6 @@ apiRunnerAsync(`onClientEntry`).then(() => {
9392
})
9493
}
9594

96-
fetch(`/___services`)
97-
.then(res => res.json())
98-
.then(services => {
99-
if (services.developstatusserver) {
100-
let isRestarting = false
101-
const parentSocket = io(
102-
`${window.location.protocol}//${window.location.hostname}:${services.developstatusserver.port}`
103-
)
104-
105-
parentSocket.on(`structured-log`, msg => {
106-
if (
107-
!isRestarting &&
108-
msg.type === `LOG_ACTION` &&
109-
msg.action.type === `DEVELOP` &&
110-
msg.action.payload === `RESTART_REQUIRED` &&
111-
window.confirm(
112-
`The develop process needs to be restarted for the changes to ${msg.action.dirtyFile} to be applied.\nDo you want to restart the develop process now?`
113-
)
114-
) {
115-
isRestarting = true
116-
parentSocket.emit(`develop:restart`, () => {
117-
window.location.reload()
118-
})
119-
}
120-
121-
if (
122-
isRestarting &&
123-
msg.type === `LOG_ACTION` &&
124-
msg.action.type === `SET_STATUS` &&
125-
msg.action.payload === `SUCCESS`
126-
) {
127-
isRestarting = false
128-
window.location.reload()
129-
}
130-
})
131-
132-
// Prevents certain browsers spamming XHR 'ERR_CONNECTION_REFUSED'
133-
// errors within the console, such as when exiting the develop process.
134-
parentSocket.on(`disconnect`, () => {
135-
console.warn(
136-
`[socket.io] Disconnected. Unable to perform health-check.`
137-
)
138-
parentSocket.close()
139-
})
140-
}
141-
})
142-
14395
/**
14496
* Service Workers are persistent by nature. They stick around,
14597
* serving a cached version of the site if they aren't removed.

packages/gatsby/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"babel-preset-gatsby": "^2.19.0-next.2",
4949
"better-opn": "^2.1.1",
5050
"bluebird": "^3.7.2",
51-
"body-parser": "^1.19.0",
5251
"browserslist": "^4.17.5",
5352
"cache-manager": "^2.11.1",
5453
"chalk": "^4.1.2",
@@ -109,7 +108,6 @@
109108
"graphql-compose": "^9.0.7",
110109
"graphql-playground-middleware-express": "^1.7.22",
111110
"hasha": "^5.2.2",
112-
"http-proxy": "^1.18.1",
113111
"invariant": "^2.2.4",
114112
"is-relative": "^1.0.0",
115113
"is-relative-url": "^3.0.0",

0 commit comments

Comments
 (0)