Skip to content

Commit

Permalink
feat: initial migration to nuxt 3 (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jun 26, 2022
1 parent d85bb69 commit 0935f41
Show file tree
Hide file tree
Showing 99 changed files with 10,689 additions and 23,530 deletions.
16 changes: 0 additions & 16 deletions .babelrc

This file was deleted.

4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ module.exports = {
},
},
],
rules: {},
rules: {
'vue/require-default-prop': 'off',
},
}
11 changes: 5 additions & 6 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v2
id: cache
- run: corepack enable
- uses: actions/setup-node@v3
with:
path: "node_modules"
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
node-version: "16"
cache: "pnpm"

- name: Install dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Update blogs on dev.to
run: node scripts/publish.mjs
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/cache@v2
id: cache
- run: corepack enable
- uses: actions/setup-node@v3
with:
path: "node_modules"
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
node-version: "16"
cache: "pnpm"

- name: Install dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Lint project
run: yarn lint
run: pnpm lint

- name: Unit tests
run: yarn test
run: pnpm test
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typings/

# nuxt.js build output
.nuxt
.output

# Nuxt generate
dist
Expand All @@ -90,12 +91,3 @@ sw.*
*.swp

.vercel

# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
pnpm exec commitlint --edit $1
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
pnpm exec lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
4 changes: 4 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.output
.nuxt
dist
363 changes: 0 additions & 363 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarnrc.yml

This file was deleted.

2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ ] legacy app plugin in nuxt
- [ ] useHead issue on index page
8 changes: 0 additions & 8 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion api/build.mjs → api/_build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

const metadata = {}

iterateOnDirectory('../src/content/articles', (path, contents) => {
iterateOnDirectory('../src/content/blog', (path, contents) => {
const slug = getMatchOrReturn(path, /\/[^/]*$/, 0).slice(1, -3)
const { data } = grayMatter(contents)
const date = new Date(data.date)
Expand Down
File renamed without changes.
4 changes: 1 addition & 3 deletions api/file.ts → api/_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const promiseWriteFile = promisify(writeFile)

export async function writeTempFile(fileName: string, html: string) {
const hashedFileName =
createHash('md5')
.update(fileName)
.digest('hex') + '.html'
createHash('md5').update(fileName).digest('hex') + '.html'

const filePath = join(tmpdir(), hashedFileName)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/template.ts → api/_template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParsedReqs } from './parser'
import { ParsedReqs } from './_parser'

function getCss() {
return `
Expand Down
14 changes: 7 additions & 7 deletions api/card.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { IncomingMessage, ServerResponse } from 'http'
import { parseReqs, ParsedReqs } from './parser'
import { getHtml } from './template'
import { writeTempFile } from './file'
import { getScreenshot } from './chromium'
import { parseReqs, ParsedReqs } from './_parser'
import { getHtml } from './_template'
import { writeTempFile } from './_file'
import { getScreenshot } from './_chromium'

const isDev = process.env.NOW_REGION === 'dev1'

export default async function handler(
req: IncomingMessage,
res: ServerResponse,
res: ServerResponse
) {
try {
let parsedReqs: ParsedReqs
Expand All @@ -17,7 +17,7 @@ export default async function handler(
} catch (e) {
res.setHeader(
'Cache-Control',
'public,immutable,no-transform,s-max-age=21600,max-age=21600',
'public,immutable,no-transform,s-max-age=21600,max-age=21600'
)
res.statusCode = 404
return res.end()
Expand All @@ -39,7 +39,7 @@ export default async function handler(
res.setHeader('Content-Type', 'image/jpeg')
res.setHeader(
'Cache-Control',
'public,immutable,no-transform,s-max-age=21600,max-age=21600',
'public,immutable,no-transform,s-max-age=21600,max-age=21600'
)
res.end(file)
} else {
Expand Down
1 change: 0 additions & 1 deletion api/metadata.json

This file was deleted.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"now-build": "node build.mjs"
"now-build": "node _build.mjs"
},
"dependencies": {
"chrome-aws-lambda": "10.1.0",
Expand Down
17 changes: 13 additions & 4 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
"compilerOptions": {
"resolveJsonModule": true,
"baseUrl": ".",
"lib": ["esnext", "dom"],
"types": ["node"]
"lib": [
"esnext",
"dom"
],
"types": [
"node"
]
},
"include": ["api/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"api/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading

1 comment on commit 0935f41

@vercel
Copy link

@vercel vercel bot commented on 0935f41 Jun 26, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.