diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e06294..4ab5d2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,12 @@ jobs: - name: run tests generating coverage run: deno task test:coverage + + - name: run tests no check + run: deno task test:no-check + + - name: test build for Node.js + run: deno task build - name: generate lcov run: deno task coverage > cov.lcov diff --git a/.gitignore b/.gitignore index 4be7d74..9fcd62e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ !.vscode .tool-versions +oak.bundle.js cov.lcov cov/ +npm/ \ No newline at end of file diff --git a/_build_npm.ts b/_build_npm.ts new file mode 100755 index 0000000..0d9a535 --- /dev/null +++ b/_build_npm.ts @@ -0,0 +1,63 @@ +#!/usr/bin/env -S deno run --allow-read --allow-write --allow-net --allow-env --allow-run +// Copyright 2018-2024 the oak authors. All rights reserved. MIT license. + +/** + * This is the build script for building the oak framework into a Node.js + * compatible npm package. + * + * @module + */ + +import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts"; +import { copy } from "https://deno.land/std@0.218.2/fs/copy.ts"; + +async function start() { + await emptyDir("./npm"); + await copy("fixtures", "npm/esm/fixtures", { overwrite: true }); + await copy("fixtures", "npm/script/fixtures", { overwrite: true }); + + await build({ + entryPoints: ["./mod.ts"], + outDir: "./npm", + shims: { + blob: true, + crypto: true, + deno: true, + undici: true, + }, + test: true, + typeCheck: false, + compilerOptions: { + importHelpers: true, + target: "ES2022", + lib: ["ESNext", "DOM", "DOM.Iterable"], + }, + package: { + name: "@oakserver/oak", + version: Deno.args[0], + description: "A middleware framework for handling HTTP requests", + license: "MIT", + engines: { + node: ">=16.5.0 <22", + }, + repository: { + type: "git", + url: "git+https://github.com/oakserver/oak.git", + }, + bugs: { + url: "https://github.com/oakserver/oak/issues", + }, + dependencies: { + "tslib": "~2.6.2", + }, + devDependencies: { + "@types/node": "^20", + }, + }, + }); + + await Deno.copyFile("LICENSE", "npm/LICENSE"); + await Deno.copyFile("README.md", "npm/README.md"); +} + +start(); diff --git a/deno.json b/deno.json index 2b2a929..ef8e393 100644 --- a/deno.json +++ b/deno.json @@ -17,9 +17,11 @@ "./testing": "./testing.ts" }, "tasks": { + "build": "deno run --allow-read --allow-write --allow-net --allow-env --allow-run _build_npm.ts", "coverage": "deno coverage --lcov ./cov", "example": "deno run --allow-net examples/echoServer.ts", "test": "deno test --allow-read --allow-write --allow-net --parallel --ignore=npm", + "test:no-check": "deno test --allow-read --allow-write --allow-net --no-check --parallel --ignore=npm,http_server_native_unstable_test.ts", "test:coverage": "deno test --coverage=./cov --allow-read --allow-write --allow-net --cert ./examples/tls/RootCA.crt --parallel --ignore=npm" }, "fmt": {