Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Open
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
6 changes: 3 additions & 3 deletions .baserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@dword-design/node",
"supportedNodeVersions": [14, 16],
"windows": false
}
"supportedNodeVersions": [16, 18],
"nodeVersion": 18
}
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-18",
"updateContentCommand": "yarn --frozen-lockfile"
}
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
github.event.pull_request.head.ref || '' }}
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions"
- run: yarn --frozen-lockfile
Expand Down Expand Up @@ -54,19 +54,21 @@ 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 == 18
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
strategy:
matrix:
include:
- node: 14
os: ubuntu-latest
- node: 16
os: ubuntu-latest
- node: 16
- node: 18
os: ubuntu-latest
- node: 18
os: macos-latest
- node: 18
os: windows-latest
name: build
on:
pull_request: {}
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="18" && 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
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@
"@nuxt/kit": "^3.0.0"
},
"devDependencies": {
"@dword-design/base": "^9.1.10",
"@dword-design/base": "^10.0.1",
"@dword-design/puppeteer": "^5.0.0",
"@dword-design/tester": "^2.0.11",
"@dword-design/tester-plugin-nuxt-config": "^1.1.11",
"@dword-design/tester-plugin-puppeteer": "^2.1.21"
"@dword-design/tester-plugin-puppeteer": "^2.1.21",
"@dword-design/tester-plugin-tmp-dir": "^2.1.26",
"execa": "^7.1.1",
"fs-extra": "^11.1.1",
"nuxt": "^3.5.0",
"nuxt-dev-ready": "^2.0.1",
"ora": "^6.3.1",
"output-files": "^2.0.28",
"tree-kill-promise": "^3.0.14"
},
"engines": {
"node": ">=14"
"node": ">=16"
},
"publishConfig": {
"access": "public"
Expand Down
123 changes: 85 additions & 38 deletions src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,108 @@
import { endent } from '@dword-design/functions'
import tester from '@dword-design/tester'
import testerPluginNuxtConfig from '@dword-design/tester-plugin-nuxt-config'
import testerPluginPuppeteer from '@dword-design/tester-plugin-puppeteer'
import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir'
import { execa, 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'

export default tester(
{
nuxt3: {
config: {
modules: ['./modules/foo', './modules/bar'],
},
files: {
async nuxt2() {
await outputFiles({
modules: {
bar: {
1: {
'index.js': endent`
import self from '../../../src'
import { createRequire } from 'module'

import self from '../../../src/index.js'

const _require = createRequire(import.meta.url)

export default function () {
self(this, require.resolve('./plugin'))
self(this, _require.resolve('./plugin'))
}

`,
'plugin.js':
"export default (context, inject) => inject('bar', context.$foo)",
},
foo: {
2: {
'index.js': endent`
import self from '../../../src'
import { createRequire } from 'module'

import self from '../../../src/index.js'

const _require = createRequire(import.meta.url)

export default function () {
self(this, require.resolve('./plugin'))
self(this, _require.resolve('./plugin'))
}

`,
'plugin.js':
"export default (context, inject) => inject('foo', 'bar')",
},
},
'nuxt.config.js': endent`
export default {
modules: ['~/modules/1', '~/modules/2'],
}
`,
'pages/index.vue': endent`
<template>
<div :class="$bar" />
</template>

`,
},
nuxtVersion: 3,
async test() {
})
await fs.symlink(
P.join('..', 'node_modules', '.cache', 'nuxt2', 'node_modules'),
'node_modules',
)

const nuxt = execa(P.join('node_modules', '.bin', 'nuxt'), ['dev'])
try {
await nuxtDevReady()
await this.page.goto('http://localhost:3000')
await this.page.waitForSelector('.bar')
},
} finally {
await kill(nuxt.pid)
}
},
works: {
config: {
modules: ['~/modules/foo', '~/modules/bar'],
},
files: {
async works() {
await outputFiles({
modules: {
bar: {
1: {
'index.js': endent`
import self from '../../../src'
import { createResolver } from '@nuxt/kit'

import self from '../../../src/index.js'

const resolver = createResolver(import.meta.url)

export default function () {
self(this, require.resolve('./plugin'))
self(this, resolver.resolve('./plugin.js'))
}

`,
'plugin.js':
"export default (context, inject) => inject('bar', context.$foo)",
"export default (context, inject) => inject('foo', 'bar')",
},
foo: {
2: {
'index.js': endent`
import self from '../../../src'
import { createResolver } from '@nuxt/kit'

import self from '../../../src/index.js'

const resolver = createResolver(import.meta.url)

export default function () {
self(this, require.resolve('./plugin'))
self(this, resolver.resolve('./plugin'))
}

`,
'plugin.js':
"export default (context, inject) => inject('foo', 'bar')",
"export default (context, inject) => inject('bar', context.$foo)",
},
},
'pages/index.vue': endent`
Expand All @@ -86,12 +111,34 @@ export default tester(
</template>

`,
},
async test() {
})

const nuxt = execaCommand('nuxt dev')
try {
await nuxtDevReady()
await this.page.goto('http://localhost:3000')
await this.page.waitForSelector('.bar')
},
} finally {
await kill(nuxt.pid)
}
},
},
[testerPluginPuppeteer(), testerPluginNuxtConfig()],
[
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', {
cwd: P.join('node_modules', '.cache', 'nuxt2'),
stderr: 'inherit',
})
spinner.stop()
},
},
],
)
Loading