From a532445629a5a7956e739d93bc251efe6bad5ab2 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 5 Mar 2024 11:33:40 +1100 Subject: [PATCH] Revert "chore: remove npm build" This reverts commit 42f1af6bd22c1611d6a63ce84f23f0c1211efd1b. --- .github/workflows/ci.yml | 6 ++++ .gitignore | 2 ++ _build_npm.ts | 63 ++++++++++++++++++++++++++++++++++++++++ deno.json | 2 ++ 4 files changed, 73 insertions(+) create mode 100755 _build_npm.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e062942..4ab5d2ff 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 4be7d742..9fcd62e2 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 00000000..0d9a5351 --- /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 2b2a929a..ef8e393f 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": {