Skip to content

Commit

Permalink
fix: lock file maintenance (#129)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: node.js >= 18
  • Loading branch information
renovate[bot] authored Feb 13, 2024
1 parent ea1fb7f commit a0ad536
Show file tree
Hide file tree
Showing 12 changed files with 6,115 additions and 8,164 deletions.
1 change: 0 additions & 1 deletion .baserc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@dword-design/node",
"supportedNodeVersions": [14, 16],
"seeAlso": [
{ "repository": "nuxt-mail", "description": "Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails." },
{ "repository": "nuxt-route-meta", "description": "Adds Nuxt page data to route meta at build time." },
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-16",
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-20",
"updateContentCommand": "yarn --frozen-lockfile"
}
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.head.ref || '' }}
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions"
- run: yarn --frozen-lockfile
Expand All @@ -38,11 +38,11 @@ jobs:
needs: cancel-existing
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn --frozen-lockfile
Expand All @@ -54,20 +54,20 @@ jobs:
with:
name: Image Snapshot Diffs
path: "**/__image_snapshots__/__diff_output__"
- if: matrix.os == 'ubuntu-latest' && matrix.node == 16
- if: matrix.os == 'ubuntu-latest' && matrix.node == 20
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
strategy:
matrix:
include:
- node: 14
- node: 18
os: ubuntu-latest
- node: 16
- node: 20
os: ubuntu-latest
- node: 16
- node: 20
os: macos-latest
- node: 16
- node: 20
os: windows-latest
name: build
on:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deprecated-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
lfs: true
- continue-on-error: true
Expand All @@ -20,7 +20,7 @@ jobs:
update_existing: true
- if: ${{ !steps.check-deprecated-js-deps.outputs.deprecated &&
steps.create-deprecation-issue.outputs.number }}
uses: peter-evans/close-issue@v2
uses: peter-evans/close-issue@v3
with:
comment: Auto-closing the issue
issue-number: ${{ steps.create-deprecation-issue.outputs.number }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: micnncim/action-label-syncer@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: jaid/[email protected]
with:
approve: false
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN sudo apt-get install git-lfs
RUN git lfs install

# https://www.gitpod.io/docs/languages/javascript
RUN bash -c 'VERSION="16" && source $HOME/.nvm/nvm.sh && nvm install $VERSION && nvm use $VERSION && nvm alias default $VERSION'
RUN bash -c 'VERSION="20" && source $HOME/.nvm/nvm.sh && nvm install $VERSION && nvm use $VERSION && nvm alias default $VERSION'

RUN echo "\nexport PATH=$(yarn global bin):\$PATH" >> /home/gitpod/.bashrc

Expand Down
2 changes: 2 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ vscode:
- https://sebastianlandwehr.com/vscode-extensions/karlito40.fix-irregular-whitespace-0.1.1.vsix
- https://sebastianlandwehr.com/vscode-extensions/adrianwilczynski.toggle-hidden-1.0.2.vsix
- [email protected]
- Tobermory.es6-string-html
- zjcompt.es6-string-javascript
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,27 @@
"test": "base test"
},
"dependencies": {
"@nuxt/kit": "^3.10.1",
"modernizr": "^3.11.3",
"nuxt-push-plugins": "^2.0.0"
"nuxt-push-plugins": "^2.1.34"
},
"devDependencies": {
"@dword-design/base": "^9.2.0",
"@dword-design/functions": "^4.0.0",
"@dword-design/puppeteer": "^6.0.0",
"fs-extra": "^10.0.0",
"nuxt": "^2.14.0",
"with-local-tmp-dir": "^4.0.0"
"@dword-design/base": "^11.0.4",
"@dword-design/functions": "^5.0.27",
"@dword-design/puppeteer": "^7.0.0",
"@dword-design/tester": "^2.0.19",
"@dword-design/tester-plugin-puppeteer": "^3.0.0",
"@dword-design/tester-plugin-tmp-dir": "^2.1.26",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"nuxt": "^3.10.1",
"nuxt-dev-ready": "^3.0.0",
"ora": "^8.0.1",
"output-files": "^2.0.32",
"tree-kill-promise": "^3.0.14"
},
"engines": {
"node": ">=14"
"node": ">=18"
},
"publishConfig": {
"access": "public"
Expand Down
35 changes: 26 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import { addPluginTemplate, isNuxt3 as isNuxt3Try } from '@nuxt/kit'
import modernizr from 'modernizr'
import { createRequire } from 'module'
import nuxtPushPlugins from 'nuxt-push-plugins'
import P from 'path'

const _require = createRequire(import.meta.url)
const resolver = createRequire(import.meta.url)

export default async function (moduleOptions) {
const options = { ...this.options.modernizr, ...moduleOptions }
export default async function (moduleOptions, nuxt) {
let isNuxt3 = true
try {
isNuxt3 = isNuxt3Try()
} catch {
isNuxt3 = false
}
nuxt = nuxt || this

const options = { ...nuxt.options.modernizr, ...moduleOptions }

const code = await new Promise(resolve => modernizr.build(options, resolve))
nuxtPushPlugins(this, {
fileName: P.join('nuxt-modernizr', 'plugin.js'),
mode: 'client',
options: code,
src: _require.resolve('./plugin.js.template'),
})
if (isNuxt3) {
addPluginTemplate({
filename: P.join('nuxt-modernizr', 'plugin.js'),
getContents: () => `export default defineNuxtPlugin(() => { ${code} })`,
mode: 'client',
})
} else {
nuxtPushPlugins(nuxt, {
fileName: P.join('nuxt-modernizr', 'plugin.js'),
mode: 'client',
options: code,
src: resolver.resolve('./plugin.js.template'),
})
}
}
159 changes: 100 additions & 59 deletions src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,106 @@
import { endent, mapValues, noop } from '@dword-design/functions'
import puppeteer from '@dword-design/puppeteer'
import { outputFile } from 'fs-extra'
import { Builder, Nuxt } from 'nuxt'
import withLocalTmpDir from 'with-local-tmp-dir'
import { endent } from '@dword-design/functions'
import tester from '@dword-design/tester'
import testerPluginPuppeteer from '@dword-design/tester-plugin-puppeteer'
import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir'
import { execaCommand } from 'execa'
import fs from 'fs-extra'
import nuxtDevReady from 'nuxt-dev-ready'
import ora from 'ora'
import outputFiles from 'output-files'
import P from 'path'
import kill from 'tree-kill-promise'

import self from './index.js'

let browser
let page

const runTest = config => () => {
config = { test: noop, ...config }

return withLocalTmpDir(async () => {
await outputFile('pages/index.vue', config.page)

const nuxt = new Nuxt({
dev: false,
modules: [
[
self,
{
'feature-detects': ['css/rgba'],
options: ['setClasses'],
},
],
],
})
await new Builder(nuxt).build()
await nuxt.listen()
try {
await page.goto('http://localhost:3000')
await config.test()
} finally {
await nuxt.close()
}
})
}
export default tester(
{
async nuxt2() {
await outputFiles({
'nuxt.config.js': endent`
export default {
modules: [
[
'~/../src/index.js',
{
'feature-detects': ['css/rgba'],
options: ['setClasses'],
},
],
],
}
`,
'pages/index.vue': endent`
<template>
<div />
</template>
`,
})
await fs.remove('node_modules')
await fs.symlink(
P.join('..', 'node_modules', '.cache', 'nuxt2', 'node_modules'),
'node_modules',
)

export default {
after: () => browser.close(),
before: async () => {
browser = await puppeteer.launch()
page = await browser.newPage()
},
...({
valid: {
page: endent`
<script>
export default {
render() {
return <div />
const nuxt = execaCommand('node_modules/.bin/nuxt dev')
try {
await nuxtDevReady()
await this.page.goto('http://localhost:3000')
await this.page.waitForSelector('html.rgba')
expect(
await this.page.evaluate(() => window.Modernizr.rgba),
).toBeTruthy()
} finally {
await kill(nuxt.pid)
}
},
async valid() {
await outputFiles({
'nuxt.config.js': endent`
export default {
modules: [
[
'../src/index.js',
{
'feature-detects': ['css/rgba'],
options: ['setClasses'],
},
],
],
}
}
</script>
`,
'pages/index.vue': endent`
<template>
<div />
</template>
`,
})

`,
test: async () => {
await page.waitForSelector('html.rgba')
expect(await page.evaluate(() => window.Modernizr.rgba)).toBeTruthy()
const nuxt = execaCommand('nuxt dev')
try {
await nuxtDevReady()
await this.page.goto('http://localhost:3000')
await this.page.waitForSelector('html.rgba')
expect(
await this.page.evaluate(() => window.Modernizr.rgba),
).toBeTruthy()
} finally {
await kill(nuxt.pid)
}
},
},
[
testerPluginTmpDir(),
testerPluginPuppeteer(),
{
before: async () => {
const spinner = ora('Installing Nuxt 2').start()
await fs.outputFile(
P.join('node_modules', '.cache', 'nuxt2', 'package.json'),
JSON.stringify({}),
)
await execaCommand('yarn add nuxt@^2 @nuxt/content@^1', {
cwd: P.join('node_modules', '.cache', 'nuxt2'),
})
spinner.stop()
},
},
} |> mapValues(runTest)),
}
],
)
Loading

0 comments on commit a0ad536

Please sign in to comment.