Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite core to TypeScript #2552

Merged
merged 65 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8c915d1
chore(deps): upgrade TS packages
balazsorban44 Aug 17, 2021
094f870
build(ts): use tsc to compile
balazsorban44 Aug 17, 2021
d9af235
refactor(ts): move some files to TS
balazsorban44 Aug 17, 2021
fcfa07a
chore: implement SkyPack check suggestions
balazsorban44 Aug 17, 2021
8bc510d
chore(ci): temprarily disable tests
balazsorban44 Aug 17, 2021
201613e
chore: add PR comment action
balazsorban44 Aug 17, 2021
2e2e3ae
chore: add determine version github action
balazsorban44 Aug 18, 2021
d9e4981
chore: prefix with env.
balazsorban44 Aug 18, 2021
c278039
chore: add runs to action
balazsorban44 Aug 18, 2021
e303f17
chore: change runs.using to node12
balazsorban44 Aug 18, 2021
97bfc48
chore: fix typo
balazsorban44 Aug 18, 2021
6d31d34
chore: install @actions/core as dev dependency
balazsorban44 Aug 18, 2021
e592d0f
chore: move env var, remove old script
balazsorban44 Aug 18, 2021
2533862
chore: change version comment message
balazsorban44 Aug 18, 2021
b0e35f4
refactor(ts): convert server/index.js to TS
balazsorban44 Aug 18, 2021
489071d
chore: fix `types` path
balazsorban44 Aug 18, 2021
4ef041c
chore: fix paths
balazsorban44 Aug 18, 2021
d142f54
refactor(ts): convert `next-auth/react`
balazsorban44 Aug 18, 2021
c11fbc4
refactor(ts): convert `next-auth/jwt` to TS
balazsorban44 Aug 18, 2021
fb28cce
chore: fix import
balazsorban44 Aug 18, 2021
ad59f51
refactor: move `types` into `src`
balazsorban44 Aug 18, 2021
416b377
refactor(ts): fix types imports
balazsorban44 Aug 18, 2021
e3969be
chore: add cleanup script
balazsorban44 Aug 18, 2021
abae4bb
chore: exclude all `tests` folder from compilation
balazsorban44 Aug 18, 2021
7560f3b
refactor: rename types/index.d.ts to types/index.ts
balazsorban44 Aug 18, 2021
6956ed2
refactor(ts): move `next-auth/jwt`
balazsorban44 Aug 18, 2021
493fc45
refactor(ts): move `next-auth/providers`
balazsorban44 Aug 18, 2021
c821b84
chore(ts): fix `next-auth` types
balazsorban44 Aug 18, 2021
7ee12f3
refactor(ts): change internal import paths
balazsorban44 Aug 18, 2021
0fd7018
test(ts): remove type tests
balazsorban44 Aug 24, 2021
5fc1dab
chore: remove test:types script
balazsorban44 Aug 24, 2021
4025519
refactor(ts): move more code to TypeScript
balazsorban44 Aug 24, 2021
0274bb2
refactor: fix some imports
balazsorban44 Aug 24, 2021
fc85e39
refactor(ts): move error module into server
balazsorban44 Aug 24, 2021
aef779d
fix(ts): add type to .js providers
balazsorban44 Aug 24, 2021
c22316d
chore: rename adapters.ts to adapters.d.ts
balazsorban44 Aug 24, 2021
53cdaff
fix: update exports field
balazsorban44 Aug 24, 2021
c8aeae2
chore: add files that should end up on npm
balazsorban44 Aug 24, 2021
367eb91
chore: add stricter lib checking
balazsorban44 Aug 24, 2021
14b6d22
refactor(ts): remove unnecessary files, fix imports
balazsorban44 Aug 24, 2021
b0c9c6c
chore: autocomplete env variables
balazsorban44 Aug 24, 2021
8c84def
fix: add css folder to npm files
balazsorban44 Aug 24, 2021
fbd2d36
fix: fix CSS import/generation
balazsorban44 Aug 24, 2021
9fdf617
feat: log provider when authorization url error happens
balazsorban44 Aug 24, 2021
c313316
Merge branch 'next' into feat/typescript
balazsorban44 Aug 24, 2021
4ad7ec5
refactor(ts): turn pages into .tsx
balazsorban44 Aug 24, 2021
66048eb
chore: compile differently for client/server
balazsorban44 Aug 24, 2021
2a0f282
refactor(ts): move server file to TS
balazsorban44 Aug 24, 2021
7e1635c
chore: add back node target
balazsorban44 Aug 24, 2021
4388600
chore: add back comment removal
balazsorban44 Aug 24, 2021
3d16a66
chore: re-enable tests
balazsorban44 Aug 25, 2021
530cf63
chore: ignore test files when building
balazsorban44 Aug 25, 2021
c8deeb5
chore(ts): refactor files to TS
balazsorban44 Aug 25, 2021
2d86731
chore(ts): fix imports
balazsorban44 Aug 25, 2021
ddf5ae2
chore(ts): more ts
balazsorban44 Aug 25, 2021
ec41d96
fix(ts): correctly type _NEXTAUTH_DEBUG env var
balazsorban44 Aug 25, 2021
23aeeba
chore: don't generate internals module iwth babel
balazsorban44 Aug 25, 2021
7248a6b
Merge branch 'next'
balazsorban44 Aug 27, 2021
ffa512e
fix(ts): better `clientId`, `clientSecret` constraints
balazsorban44 Aug 27, 2021
011843d
refactor(ts): move facebook provider to TS
balazsorban44 Aug 27, 2021
1b5b5f8
refactor(ts): apply suggested changes
balazsorban44 Aug 28, 2021
10badfd
chore(ts): strip internal types from compilation
balazsorban44 Aug 28, 2021
d203b0a
refactor(ts): move server types to server folder
balazsorban44 Aug 29, 2021
1f95be1
refactor(ts): rename internals to types
balazsorban44 Aug 29, 2021
76ab39f
Merge branch 'next'
balazsorban44 Aug 29, 2021
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
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Build
run: npm run build
- name: Run tests
run: npm test -- --coverage --verbose && npm run test:types
run: npm test -- --coverage --verbose
- name: Coverage
uses: codecov/codecov-action@v1
with:
Expand Down Expand Up @@ -66,11 +66,21 @@ jobs:
node-version: 16
- name: Dependencies
uses: bahmutov/npm-install@v1
- name: Determine version
uses: ./config/version-pr
id: determine-version
env:
PR_NUMBER: ${{ github.event.number }}
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm run version:pr
npm publish --access public --tag experimental
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Comment version on PR
uses: NejcZdovc/comment-pr@v1
with:
message: "🎉 Experimental release [published on npm](https://www.npmjs.com/package/next-auth/v/${{ env.VERSION }})!\n\n```sh\nnpm i next-auth@${{ env.VERSION }}\n```\n```sh\nyarn add next-auth@${{ env.VERSION }}\n```"
env:
VERSION: ${{ steps.determine-version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 6 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,16 @@ node_modules
# Generated files
.docusaurus
.cache-loader
/internals
/providers
/types/providers/*
!types/providers/index.d.ts
!types/providers/email.d.ts
!types/providers/credentials.d.ts
!types/providers/oauth.d.ts
/client
/css
/lib
/server
/jwt
/react
/adapters.d.ts
/adapters.js
/client.d.ts
/client.js
/index.d.ts
/index.js
/jwt.d.ts
/jwt.js
/errors.js
/errors.d.ts
/react.js
/react.d.ts

# Development app
app/next-auth
Expand Down
68 changes: 47 additions & 21 deletions config/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,54 @@
// https://nextjs.org/docs/getting-started#system-requirements
// https://nextjs.org/docs/basic-features/supported-browsers-features

module.exports = {
presets: [["@babel/preset-env", { targets: { node: "12" } }]],
plugins: [
"@babel/plugin-proposal-optional-catch-binding",
"@babel/plugin-transform-runtime",
],
comments: false,
overrides: [
{
test: ["../src/client/**"],
module.exports = (api) => {
const isTest = api.env("test")
if (isTest) {
return {
presets: [
["@babel/preset-env", { targets: { ie: "11" } }],
"@babel/preset-env",
["@babel/preset-react", { runtime: "automatic" }],
["@babel/preset-typescript", { isTSX: true, allExtensions: true }],
],
},
{
test: ["../src/server/pages/**"],
presets: ["preact"],
},
{
test: ["../src/**/*.test.js"],
presets: [["@babel/preset-react", { runtime: "automatic" }]],
},
],
}
}
return {
presets: [
["@babel/preset-env", { targets: { node: 12 } }],
"@babel/preset-typescript",
],
plugins: [
"@babel/plugin-proposal-optional-catch-binding",
"@babel/plugin-transform-runtime",
],
ignore: [
"../src/**/__tests__/**",
"../src/adapters.ts",
"../src/lib/types.ts",
],
comments: false,
overrides: [
{
test: ["../src/react/index.tsx"],
presets: [
["@babel/preset-env", { targets: { ie: 11 } }],
["@babel/preset-react", { runtime: "automatic" }],
],
},
{
test: ["../src/server/pages/*.tsx"],
presets: ["preact"],
plugins: [
[
"jsx-pragmatic",
{
module: "preact",
export: "h",
import: "h",
},
],
],
},
],
}
}
108 changes: 0 additions & 108 deletions config/build.js

This file was deleted.

1 change: 1 addition & 0 deletions config/jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import "regenerator-runtime/runtime"
import "@testing-library/jest-dom"
import "whatwg-fetch"
5 changes: 4 additions & 1 deletion config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
transform: {
"\\.js$": ["babel-jest", { configFile: "./config/babel.config.js" }],
"\\.(js|jsx|ts|tsx)$": [
"babel-jest",
{ configFile: "./config/babel.config.js" },
],
},
rootDir: "../src",
setupFilesAfterEnv: ["../config/jest-setup.js"],
Expand Down
8 changes: 8 additions & 0 deletions config/version-pr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "Determine version"
description: "Determines npm package version based on PR number and commit SHA"
outputs:
version:
description: "npm package version"
runs:
using: "node12"
main: "index.js"
9 changes: 5 additions & 4 deletions config/version-pr.js → config/version-pr/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require("fs-extra")
const path = require("path")
const core = require("@actions/core")

try {
const packageJSONPath = path.join(process.cwd(), "package.json")
Expand All @@ -8,10 +9,10 @@ try {
const sha8 = process.env.GITHUB_SHA.substr(0, 8)
const prNumber = process.env.PR_NUMBER

packageJSON.version = `0.0.0-pr.${prNumber}.${sha8}`

const packageVersion = `0.0.0-pr.${prNumber}.${sha8}`
packageJSON.version = packageVersion
core.setOutput("version", packageVersion)
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON))
} catch (error) {
console.error("Could not set PR version", error)
process.exit(1)
core.setFailed(error.message)
}
13 changes: 6 additions & 7 deletions config/wrap-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
// To work around this issue, this script is a manual step that wraps CSS in a
// JavaScript file that has the compiled CSS embedded in it, and exports only
// a function that returns the CSS as a string.
const fs = require('fs')
const path = require('path')
const fs = require("fs")
const path = require("path")

const pathToCssJs = path.join(__dirname, '../dist/css/index.js')
const pathToCss = path.join(__dirname, '../dist/css/index.css')

const css = fs.readFileSync(pathToCss, 'utf8')
const pathToCss = path.join(__dirname, "../css/index.css")
const css = fs.readFileSync(pathToCss, "utf8")
const cssWithEscapedQuotes = css.replace(/"/gm, '\\"')
const js = `module.exports = function() { return "${cssWithEscapedQuotes}" }`

const js = `module.exports = function() { return "${cssWithEscapedQuotes}" }`
const pathToCssJs = path.join(__dirname, "../css/index.js")
fs.writeFileSync(pathToCssJs, js)
Loading