Skip to content

Commit

Permalink
chore(types): build types script
Browse files Browse the repository at this point in the history
Adds a script that moves the declaration files we have in `./types` to `./dist` relative to the files they intend to type.

This is the first step, we still need to change what we declare in `package.json`, add the script to the CI pipeline if we're happy with it and figure out how to type `next-auth/jwt`.
  • Loading branch information
ubbe-xyz committed Apr 9, 2021
1 parent 6f9f42a commit e4035b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions config/build-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require("fs")
const path = require("path")

const BUILD_TARGETS = [
"index.d.ts",
"client.d.ts",
"adapters.d.ts",
"providers.d.ts",
"jwt.d.ts",
"_next.d.ts",
"_utils.d.ts",
]

BUILD_TARGETS.forEach((target) => {
fs.copyFile(
path.resolve("types", target),
path.join(process.cwd(), target),
(err) => {
if (err) throw err
console.log(`[build-types] copying "${target}" to root folder`)
}
)
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"author": "Iain Collins <me@iaincollins.com>",
"main": "index.js",
"scripts": {
"build": "npm run build:js && npm run build:css",
"build": "npm run build:js && npm run build:css && npm run build:types",
"build:js": "babel --config-file ./config/babel.config.json src --out-dir dist",
"build:css": "postcss --config config/postcss.config.js src/**/*.css --base src --dir dist && node config/wrap-css.js",
"build:types": "node ./config/build-types.js",
"dev": "next | npm run watch:css",
"watch": "npm run watch:js | npm run watch:css",
"watch:js": "babel --config-file ./config/babel.config.json --watch src --out-dir dist",
Expand Down

0 comments on commit e4035b2

Please sign in to comment.