Skip to content

Commit

Permalink
fix: lock file maintenance (#170)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: require node.js >= 18
  • Loading branch information
renovate[bot] authored Feb 12, 2024
1 parent 9380e40 commit ea8bc78
Show file tree
Hide file tree
Showing 9 changed files with 4,389 additions and 4,315 deletions.
3 changes: 1 addition & 2 deletions .baserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
{ "repository": "nuxt-mermaid-string", "description": "Embed a Mermaid diagram in a Nuxt.js app by providing its diagram string." },
{ "repository": "nuxt-content-git", "description": "Additional module for @nuxt/content that replaces or adds createdAt and updatedAt dates based on the git history." },
{ "repository": "nuxt-babel-runtime", "description": "Nuxt CLI that supports babel. Inspired by @nuxt/typescript-runtime." }
],
"supportedNodeVersions": [16, 18]
]
}
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ 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: 20
- run: git config --global user.email "actions@github.com"
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 @@ -61,10 +61,10 @@ jobs:
strategy:
matrix:
include:
- node: 16
os: ubuntu-latest
- node: 18
os: ubuntu-latest
- node: 20
os: ubuntu-latest
- node: 20
os: macos-latest
- node: 20
Expand Down
2 changes: 1 addition & 1 deletion .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 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/action-sync-node-meta@v2.0.0
with:
approve: false
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@
"dependencies": {
"@babel/core": "^7.11.1",
"@babel/traverse": "^7.13.13",
"@dword-design/functions": "^5.0.22",
"@vue/compiler-sfc": "^3.3.4",
"ast-to-literal": "^0.0.5",
"deepmerge": "^4.3.1",
"depcheck-package-name": "^3.0.1",
"fs-extra": "^11.1.0",
"lodash-es": "^4.17.21",
"ts-ast-to-literal": "^3.0.10"
},
"devDependencies": {
"@babel/plugin-proposal-pipeline-operator": "^7.22.5",
"@dword-design/base": "^10.1.2",
"@dword-design/functions": "^5.0.22",
"@dword-design/base": "^11.0.2",
"@dword-design/tester": "^2.0.19",
"@dword-design/tester-plugin-tmp-dir": "^2.1.26",
"depcheck-package-name": "^3.0.1",
"execa": "^7.1.1",
"execa": "^8.0.1",
"expect": "^29.5.0",
"nuxt": "^3.6.1",
"nuxt-babel-runtime": "^4.0.0",
"nuxt-babel-runtime": "^5.0.0",
"output-files": "^2.0.0",
"typescript": "^5.1.6"
"typescript": "^5.3.3"
},
"peerDependencies": {
"optionalDependencies": {
"typescript": "*"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"publishConfig": {
"access": "public"
Expand Down
49 changes: 27 additions & 22 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,43 @@ import parseBabel from './parse-babel.js'
import parseTypescript from './parse-typescript.js'

export default (options, nuxt) => {
const extractMeta = filename => {
const extractMeta = async filename => {
const fileContent = fs.readFileSync(filename, 'utf8')

const Component =
P.extname(filename) === '.vue'
? parseVue(fileContent)
: { descriptor: { script: { content: fileContent, lang: 'js' } } }

const data = ['script', 'scriptSetup']
.filter(name => Component.descriptor[name])
.map(name =>
(Component.descriptor[name].lang === 'ts'
? parseTypescript
: parseBabel)(Component.descriptor[name], {
filename,
nuxt,
}),
)
const data = await Promise.all(
['script', 'scriptSetup']
.filter(name => Component.descriptor[name])
.map(async name =>
(
await (Component.descriptor[name].lang === 'ts'
? parseTypescript
: parseBabel)
)(Component.descriptor[name], {
filename,
nuxt,
}),
),
)

return deepmerge.all(data)
}

const parseRoutes = routes => {
for (const route of routes) {
route.meta = {
...route.meta,
...extractMeta(route.file),
}
if (route.children.length > 0) {
parseRoutes(route.children)
}
}
}
const parseRoutes = routes =>
Promise.all(
routes.map(async route => {
route.meta = {
...route.meta,
...(await extractMeta(route.file)),
}
if (route.children.length > 0) {
await parseRoutes(route.children)
}
}),
)
nuxt.hook('pages:extend', parseRoutes)
}
11 changes: 8 additions & 3 deletions src/parse-typescript.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { property } from '@dword-design/functions'
import deepmerge from 'deepmerge'
import packageName from 'depcheck-package-name'
import { keys, omit } from 'lodash-es'
import tsAstToLiteral from 'ts-ast-to-literal'
import ts from 'typescript'

import predefinedProperties from './predefined-properties.js'

export default script => {
export default async script => {
const ts = import('typescript') |> await |> property('default')

const tsAstToLiteral =
import(packageName`ts-ast-to-literal`) |> await |> property('default')

const rootNode = ts.createSourceFile(
'x.ts',
script.content,
Expand Down
Loading

0 comments on commit ea8bc78

Please sign in to comment.