Skip to content

Commit 0e9d88a

Browse files
committed
Fix Node.js version
1 parent e5464b0 commit 0e9d88a

File tree

8 files changed

+7838
-5072
lines changed

8 files changed

+7838
-5072
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
13+
- 24
1414
steps:
1515
- uses: actions/checkout@v2
1616
- uses: actions/setup-node@v2

lib/load-user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {fileURLToPath} from 'node:url'
2-
import path, {dirname} from 'node:path'
2+
import path from 'node:path'
33
import {loadJsonFile} from 'load-json-file'
44

5-
const directoryName = dirname(fileURLToPath(import.meta.url))
5+
const directoryName = path.dirname(fileURLToPath(import.meta.url))
66

77
const loadUser = async hostname => {
88
const [id] = hostname.split('.')

package-lock.json

Lines changed: 7801 additions & 5013 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "git@github.com:remy/mit-license.git"
1111
},
1212
"engines": {
13-
"node": "14.x"
13+
"node": "24.x"
1414
},
1515
"author": "Remy Sharp <remy@leftlogic.com> (http://remysharp.com/)",
1616
"scripts": {
@@ -47,26 +47,15 @@
4747
"yn": "^5.0.0"
4848
},
4949
"devDependencies": {
50-
"@babel/eslint-parser": "^7.15.7",
51-
"@babel/plugin-syntax-top-level-await": "^7.14.5",
5250
"css": "^3.0.0",
5351
"file-ext": "^1.0.0",
5452
"has-flag": "^5.0.1",
5553
"nodemon": "^2.0.12",
5654
"path-extra": "^4.3.0",
57-
"xo": "^0.44.0"
55+
"xo": "^1.2.1"
5856
},
5957
"xo": {
6058
"space": 2,
61-
"semicolon": false,
62-
"parser": "@babel/eslint-parser",
63-
"parserOptions": {
64-
"requireConfigFile": false,
65-
"babelOptions": {
66-
"plugins": [
67-
"@babel/plugin-syntax-top-level-await"
68-
]
69-
}
70-
}
59+
"semicolon": false
7160
}
7261
}

routes/get.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import {fileURLToPath} from 'node:url'
2-
import path, {dirname} from 'node:path'
2+
import path from 'node:path'
33
import {htmlEscape, htmlUnescape} from 'escape-goat'
44
import stripHtml from 'html-text'
55
import is from '@sindresorhus/is'
66
import getGravatarUrl from 'gravatar-url'
77
import createHtmlElement from 'create-html-element'
88
import {renderFile} from 'ejs'
9-
109
import loadUser from '../lib/load-user.js'
1110
import loadOptions from '../lib/load-options.js'
1211

13-
const directoryName = dirname(fileURLToPath(import.meta.url))
12+
const directoryName = path.dirname(fileURLToPath(import.meta.url))
1413

1514
function getCopyrightName(user, isPlainText) {
1615
if (is.string(user)) {
@@ -24,13 +23,15 @@ function getCopyrightName(user, isPlainText) {
2423

2524
function getCopyrightHtml(user, isPlainText) {
2625
const name = getCopyrightName(user, isPlainText)
27-
let html = user.url ? createHtmlElement({
28-
name: 'a',
29-
attributes: {
30-
href: user.url,
31-
},
32-
text: name,
33-
}) : name
26+
let html = user.url
27+
? createHtmlElement({
28+
name: 'a',
29+
attributes: {
30+
href: user.url,
31+
},
32+
text: name,
33+
})
34+
: name
3435

3536
if (user.email) {
3637
html += ` &lt;${createHtmlElement({
@@ -71,6 +72,7 @@ export default async function getRoute(request, response) {
7172
}
7273

7374
const options = loadOptions(request.url)
75+
// eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
7476
const year = options.pinnedYear
7577
? options.pinnedYear
7678
: removeFalsy([options.startYear, options.endYear]).join('-')

routes/post.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path, {dirname} from 'node:path'
1+
import path from 'node:path'
22
import {fileURLToPath} from 'node:url'
33
import process from 'node:process'
44
import toBase64 from 'btoa'
@@ -11,7 +11,7 @@ import yn from 'yn'
1111
import is from '@sindresorhus/is'
1212
import isDomainId from '../utils/is-domain-id.js'
1313

14-
const directoryName = dirname(fileURLToPath(import.meta.url))
14+
const directoryName = path.dirname(fileURLToPath(import.meta.url))
1515

1616
const {version} = await readPackage()
1717

@@ -59,9 +59,7 @@ export default async function postRoute(request, response) {
5959
// Return a vague error intentionally
6060
response
6161
.status(400)
62-
.send(
63-
'User already exists - to update values, please send a pull request on https://github.com/remy/mit-license',
64-
)
62+
.send('User already exists - to update values, please send a pull request on https://github.com/remy/mit-license')
6563

6664
return
6765
}
@@ -70,9 +68,7 @@ export default async function postRoute(request, response) {
7068
if (await pathExists(path.join(directoryName, '..', 'users', `${id}.json`))) {
7169
response
7270
.status(409)
73-
.send(
74-
'User already exists - to update values, please send a pull request on https://github.com/remy/mit-license',
75-
)
71+
.send('User already exists - to update values, please send a pull request on https://github.com/remy/mit-license')
7672
return
7773
}
7874

@@ -82,9 +78,7 @@ export default async function postRoute(request, response) {
8278
if (is.undefined(userData.gravatar)) {
8379
response
8480
.status(400)
85-
.send(
86-
'The "gravatar" JSON property must be a boolean.',
87-
)
81+
.send('The "gravatar" JSON property must be a boolean.')
8882
return
8983
}
9084
}
@@ -116,8 +110,6 @@ export default async function postRoute(request, response) {
116110
} catch {
117111
response
118112
.status(500)
119-
.send(
120-
'Unable to create new user - please send a pull request on https://github.com/remy/mit-license',
121-
)
113+
.send('Unable to create new user - please send a pull request on https://github.com/remy/mit-license')
122114
}
123115
}

server.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// IMPORTANT: Set the `github_token` environment variable to a personal access token with at least the `public_repo` scope for the API.
22
// The `PORT` environment variable can also be set to control the port the server should be hosted on.
3-
import path, {dirname} from 'node:path'
3+
import path from 'node:path'
44
import {fileURLToPath} from 'node:url'
55
import process from 'node:process'
66
import express from 'express'
@@ -10,22 +10,19 @@ import postcssMiddleware from 'postcss-middleware'
1010
import tempDirectory from 'temp-dir'
1111
import postcssPresetEnv from 'postcss-preset-env'
1212
import cors from 'cors'
13-
1413
import postRoute from './routes/post.js'
1514
import getRoute from './routes/get.js'
1615

1716
// Server
1817
const PORT = process.env.PORT || 8080
1918

20-
const directoryName = dirname(fileURLToPath(import.meta.url))
19+
const directoryName = path.dirname(fileURLToPath(import.meta.url))
2120

2221
// Prepare application
2322
const app = express()
24-
app.use(
25-
minify({
26-
cache: tempDirectory,
27-
}),
28-
)
23+
app.use(minify({
24+
cache: tempDirectory,
25+
}))
2926
app.use(favicon(path.join(directoryName, 'favicon.ico')))
3027
app.set('views', path.join(directoryName, '/licenses'))
3128

@@ -52,11 +49,9 @@ app.use(
5249
// CORS
5350
app.use(cors())
5451
// Parse URL-encoded bodies (as sent by HTML forms)
55-
app.use(
56-
express.urlencoded({
57-
extended: true,
58-
}),
59-
)
52+
app.use(express.urlencoded({
53+
extended: true,
54+
}))
6055
// Parse JSON bodies (as sent by API clients)
6156
app.use(express.json())
6257

test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ for await (const user of users) {
3737
const parsedData = JSON.parse(data)
3838

3939
if (!parsedData.locked && !parsedData.copyright) {
40-
report(`Copyright not specified in ${user}`)
40+
await report(`Copyright not specified in ${user}`)
4141
}
4242

4343
if (parsedData.version) {
@@ -55,10 +55,10 @@ for await (const user of users) {
5555
})
5656
}
5757
} catch ({message}) {
58-
report(`Invalid JSON in ${user} (${message})`)
58+
await report(`Invalid JSON in ${user} (${message})`)
5959
}
6060
} catch ({message}) {
61-
report(`Unable to read ${user} (${message})`)
61+
await report(`Unable to read ${user} (${message})`)
6262
}
6363
}
6464

@@ -71,10 +71,10 @@ for await (const theme of themes) {
7171
try {
7272
parseCSS(cssData)
7373
} catch ({message}) {
74-
report(`Invalid CSS in ${theme} (${message})`)
74+
await report(`Invalid CSS in ${theme} (${message})`)
7575
}
7676
} catch ({message}) {
77-
report(`Unable to read ${theme} (${message})`)
77+
await report(`Unable to read ${theme} (${message})`)
7878
}
7979
}
8080
}

0 commit comments

Comments
 (0)