Skip to content

Commit

Permalink
chore!: remove node 10 support (#3648)
Browse files Browse the repository at this point in the history
* chore!: remove node 10 support

* chore: fix failing tests

* chore: remove old conditions inside the tests

opened up a issuei in the edge handler to drop support netlify-plugin-edge-handlers#660

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
lukasholzer and kodiakhq[bot] authored Nov 18, 2021
1 parent a875fb7 commit 86931c6
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 436 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [10.x, '*']
node-version: [12.x, '*']
exclude:
- os: macOS-latest
node-version: '10.x'
node-version: '12.x'
- os: windows-latest
node-version: '10.x'
node-version: '12.x'
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See the [CLI command line reference](https://cli.netlify.com/commands/) to get s

## Installation

Netlify CLI requires [Node.js](https://nodejs.org) version 10 or above. To install, run the following command from any directory in your terminal:
Netlify CLI requires [Node.js](https://nodejs.org) version 12 or above. To install, run the following command from any directory in your terminal:

```bash
npm install netlify-cli -g
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Bret Comnes <[email protected]> (https://bret.io)"
],
"engines": {
"node": ">=10.18.0"
"node": ">=12.20.0"
},
"files": [
"/bin",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": ">=10.18.0"
"node": ">=12.20.0"
},
"keywords": [
"netlify",
Expand Down
109 changes: 52 additions & 57 deletions tests/command.deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { createLiveTestSite, generateSiteName } = require('./utils/create-live-te
const got = require('./utils/got')
const { withSiteBuilder } = require('./utils/site-builder')

const EDGE_HANDLER_MIN_LENGTH = 50
const SITE_NAME = generateSiteName('netlify-test-deploy-')

const validateContent = async ({ content, path, siteUrl, t }) => {
Expand Down Expand Up @@ -92,70 +93,64 @@ if (process.env.NETLIFY_TEST_DISABLE_LIVE !== 'true') {
})
})

// the edge handlers plugin only works on node >= 10
const version = Number.parseInt(process.version.slice(1).split('.')[0])
const EDGE_HANDLER_MIN_VERSION = 10
const EDGE_HANDLER_MIN_LENGTH = 50
if (version >= EDGE_HANDLER_MIN_VERSION) {
test.serial('should deploy edge handlers when directory exists', async (t) => {
if (!supportsEdgeHandlers(t.context.account)) {
console.warn(`Skipping edge handlers deploy test for account ${t.context.account.slug}`)
return
}
await withSiteBuilder('site-with-public-folder', async (builder) => {
const content = '<h1>⊂◉‿◉つ</h1>'
builder
.withContentFile({
path: 'public/index.html',
content,
})
.withNetlifyToml({
config: {
build: { publish: 'public', command: 'echo "no op"', edge_handlers: 'netlify/edge-handlers' },
},
})
.withEdgeHandlers({
handlers: {
onRequest: (event) => {
console.log(`Incoming request for ${event.request.url}`)
},
test.serial('should deploy edge handlers when directory exists', async (t) => {
if (!supportsEdgeHandlers(t.context.account)) {
console.warn(`Skipping edge handlers deploy test for account ${t.context.account.slug}`)
return
}
await withSiteBuilder('site-with-public-folder', async (builder) => {
const content = '<h1>⊂◉‿◉つ</h1>'
builder
.withContentFile({
path: 'public/index.html',
content,
})
.withNetlifyToml({
config: {
build: { publish: 'public', command: 'echo "no op"', edge_handlers: 'netlify/edge-handlers' },
},
})
.withEdgeHandlers({
handlers: {
onRequest: (event) => {
console.log(`Incoming request for ${event.request.url}`)
},
})
},
})

await builder.buildAsync()
await builder.buildAsync()

const options = {
cwd: builder.directory,
env: { NETLIFY_SITE_ID: t.context.siteId },
}
// build the edge handlers first
await callCli(['build'], options)
const deploy = await callCli(['deploy', '--json'], options).then((output) => JSON.parse(output))

await validateDeploy({ deploy, siteName: SITE_NAME, content, t })

// validate edge handlers
// use this until we can use `netlify api`
const [apiToken] = await getToken()
const { content_length: contentLength, ...rest } = await got(
`https://api.netlify.com/api/v1/deploys/${deploy.deploy_id}/edge_handlers`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${apiToken}`,
},
const options = {
cwd: builder.directory,
env: { NETLIFY_SITE_ID: t.context.siteId },
}
// build the edge handlers first
await callCli(['build'], options)
const deploy = await callCli(['deploy', '--json'], options).then((output) => JSON.parse(output))

await validateDeploy({ deploy, siteName: SITE_NAME, content, t })

// validate edge handlers
// use this until we can use `netlify api`
const [apiToken] = await getToken()
const { content_length: contentLength, ...rest } = await got(
`https://api.netlify.com/api/v1/deploys/${deploy.deploy_id}/edge_handlers`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${apiToken}`,
},
).json()
},
).json()

t.deepEqual(omit(rest, ['created_at', 'sha']), {
content_type: 'application/javascript',
handlers: ['index'],
valid: true,
})
t.is(contentLength > EDGE_HANDLER_MIN_LENGTH, true)
t.deepEqual(omit(rest, ['created_at', 'sha']), {
content_type: 'application/javascript',
handlers: ['index'],
valid: true,
})
t.is(contentLength > EDGE_HANDLER_MIN_LENGTH, true)
})
}
})

test.serial('should run build command before deploy when build flag is passed', async (t) => {
await withSiteBuilder('site-with-public-folder', async (builder) => {
Expand Down
Loading

1 comment on commit 86931c6

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

Package size: 364 MB

Please sign in to comment.