Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby): remove other services #35675

Merged
merged 7 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,29 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
return urling(`http://localhost:${port}`)
} else if (gatsbyCommandName === `build`) {
// for gatsby build wait for the process to exit
return new Promise(resolve =>
gatsbyProcess.on(`exit`, () => {
gatsbyProcess.kill()
resolve()
})
)
return gatsbyProcess
}
})

afterAll(() => gatsbyProcess.kill())
afterAll(() => {
return new Promise(resolve => {
if (
!gatsbyProcess ||
gatsbyProcess.killed ||
gatsbyProcess.exitCode !== null
) {
return resolve()
}

gatsbyProcess.on(`exit`, () => {
setImmediate(() => {
resolve()
})
})

gatsbyProcess.kill()
})
})

it(`Creates an accurate node manifest when using the ownerNodeId argument in createPage`, async () => {
const manifestFileContents = await getManifestContents(1)
Expand Down Expand Up @@ -166,16 +179,29 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
await urling(`http://localhost:${port}`)
} else if (gatsbyCommandName === `build`) {
// for gatsby build wait for the process to exit
return new Promise(resolve => {
gatsbyProcess.on(`exit`, () => {
gatsbyProcess.kill()
return gatsbyProcess
}
})

afterAll(() => {
return new Promise(resolve => {
if (
!gatsbyProcess ||
gatsbyProcess.killed ||
gatsbyProcess.exitCode !== null
) {
return resolve()
}

gatsbyProcess.on(`exit`, () => {
setImmediate(() => {
resolve()
})
})
}
})

afterAll(() => gatsbyProcess.kill())
gatsbyProcess.kill()
})
})

it(`Limits the number of node manifest files written to disk to 500`, async () => {
const nodeManifestFiles = fs.readdirSync(manifestDir)
Expand Down
6 changes: 4 additions & 2 deletions integration-tests/node-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A test site for Gatsby's node manifest API",
"main": "index.js",
"scripts": {
"test": "gatsby clean && GATSBY_COMMAND_NAME=build jest --runInBand && gatsby clean && GATSBY_COMMAND_NAME=develop jest --runInBand"
"test": "cross-env GATSBY_COMMAND_NAME=build jest --runInBand && cross-env GATSBY_COMMAND_NAME=develop jest --runInBand"
},
"author": "Tyler Barnes <[email protected]>",
"license": "ISC",
Expand All @@ -14,9 +14,11 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"cross-env": "^7.0.3",
"execa": "^5.1.1",
"fs-extra": "^10.0.0",
"jest": "^27.2.1",
"rimraf": "^3.0.2",
"urling": "^1.0.7"
}
}
}
38 changes: 13 additions & 25 deletions integration-tests/node-manifest/utils/get-gatsby-process.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
const { spawn } = require(`child_process`)
const execa = require(`execa`)
const path = require(`path`)

const gatsbyBin = path.join(`node_modules`, `.bin`, `gatsby`)
function spawnGatsbyProcess(command = `develop`, env = {}) {
return execa(process.execPath, [`./node_modules/gatsby/cli.js`, command], {
stdio: [`inherit`, `inherit`, `inherit`],
env: {
...process.env,
NODE_ENV: command === `develop` ? `development` : `production`,
...env,
},
})
}

exports.spawnGatsbyProcess = (command = `develop`, env = {}) =>
spawn(
gatsbyBin,
[command, ...(command === `develop` ? ["-H", "localhost"] : [])],
{
stdio: [`inherit`, `inherit`, `inherit`, `inherit`],
env: {
...process.env,
NODE_ENV: command === `develop` ? `development` : `production`,
...env,
},
}
)

exports.runGatsbyClean = () =>
spawn(
gatsbyBin,
['clean'],
{
stdio: [`inherit`, `inherit`, `inherit`, `inherit`],
env: { ...process.env },
},
)
exports.spawnGatsbyProcess = spawnGatsbyProcess

exports.runGatsbyClean = () => spawnGatsbyProcess("clean")
1 change: 1 addition & 0 deletions packages/gatsby-plugin-netlify-cms/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ exports.onCreateWebpackConfig = (
new FriendlyErrorsPlugin({
clearConsole: false,
compilationSuccessInfo: {
// TODO(v5): change proxyPort back in port
messages: [
`Netlify CMS is running at ${
program.https ? `https://` : `http://`
Expand Down
48 changes: 0 additions & 48 deletions packages/gatsby/cache-dir/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global HAS_REACT_18 */
import React from "react"
import ReactDOM from "react-dom"
import io from "socket.io-client"

import socketIo from "./socketIo"
import emitter from "./emitter"
Expand Down Expand Up @@ -93,53 +92,6 @@ apiRunnerAsync(`onClientEntry`).then(() => {
})
}

fetch(`/___services`)
.then(res => res.json())
.then(services => {
if (services.developstatusserver) {
let isRestarting = false
const parentSocket = io(
`${window.location.protocol}//${window.location.hostname}:${services.developstatusserver.port}`
)

parentSocket.on(`structured-log`, msg => {
if (
!isRestarting &&
msg.type === `LOG_ACTION` &&
msg.action.type === `DEVELOP` &&
msg.action.payload === `RESTART_REQUIRED` &&
window.confirm(
`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?`
)
) {
isRestarting = true
parentSocket.emit(`develop:restart`, () => {
window.location.reload()
})
}

if (
isRestarting &&
msg.type === `LOG_ACTION` &&
msg.action.type === `SET_STATUS` &&
msg.action.payload === `SUCCESS`
) {
isRestarting = false
window.location.reload()
}
})

// Prevents certain browsers spamming XHR 'ERR_CONNECTION_REFUSED'
// errors within the console, such as when exiting the develop process.
parentSocket.on(`disconnect`, () => {
console.warn(
`[socket.io] Disconnected. Unable to perform health-check.`
)
parentSocket.close()
})
}
})

/**
* Service Workers are persistent by nature. They stick around,
* serving a cached version of the site if they aren't removed.
Expand Down
2 changes: 0 additions & 2 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"babel-preset-gatsby": "^2.19.0-next.2",
"better-opn": "^2.1.1",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
"browserslist": "^4.17.5",
"cache-manager": "^2.11.1",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -109,7 +108,6 @@
"graphql-compose": "^9.0.7",
"graphql-playground-middleware-express": "^1.7.22",
"hasha": "^5.2.2",
"http-proxy": "^1.18.1",
"invariant": "^2.2.4",
"is-relative": "^1.0.0",
"is-relative-url": "^3.0.0",
Expand Down
Loading