Skip to content

Commit acda2fe

Browse files
committed
Switch npm packaging to deno pack
1 parent 57a7979 commit acda2fe

9 files changed

Lines changed: 103 additions & 208 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: deno lint
3939

4040
- name: Type Check
41-
run: deno check scripts/*.ts *.ts src/*.ts
41+
run: deno task check
4242

4343
deno:
4444
runs-on: ubuntu-24.04
@@ -87,8 +87,7 @@ jobs:
8787
run: deno task build ${{ needs.lint.outputs.version }}
8888

8989
- name: Show NPM Package
90-
working-directory: npm
91-
run: cat package.json
90+
run: tar -xOf npm/fetchclient.tgz package/package.json
9291

9392
- name: Setup Node.js environment
9493
uses: actions/setup-node@v6
@@ -99,8 +98,7 @@ jobs:
9998

10099
- name: Publish Release Package
101100
if: startsWith(github.ref, 'refs/tags/v')
102-
working-directory: npm
103-
run: npm publish --provenance --access public
101+
run: npm publish npm/fetchclient.tgz --provenance --access public
104102

105103
- name: Setup GitHub CI Node.js environment
106104
if: github.event_name != 'pull_request'
@@ -112,7 +110,6 @@ jobs:
112110

113111
- name: Push GitHub CI Packages
114112
if: github.event_name != 'pull_request'
115-
working-directory: npm
116-
run: npm publish --tag ${{ startsWith(github.ref, 'refs/tags/v') && 'latest' || 'next' }} --access public
113+
run: npm publish npm/fetchclient.tgz --tag ${{ startsWith(github.ref, 'refs/tags/v') && 'latest' || 'next' }} --access public
117114
env:
118115
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ concrete, and specific to FetchClient.
2323
`src/RateLimitMiddleware.ts`, `src/LinkHeader.ts`, `src/ObjectEvent.ts`,
2424
`src/Counter.ts`
2525
- Tests: `src/*test.ts`
26-
- Build tooling: `scripts/build.ts`, tasks in `deno.json`
26+
- Build tooling: `scripts/build.ts` wraps `deno pack`, tasks in `deno.json`
2727

2828
## 3) How it works (architecture)
2929

@@ -54,8 +54,8 @@ concrete, and specific to FetchClient.
5454
- Run tests (net allowed): `deno task test`
5555
- Type check: `deno task check`
5656
- Lint/format: `deno task lint`, `deno task format-check`
57-
- Build npm package: `deno task build` (dnt emits to `npm/` CJS + `.d.ts`;
58-
copies `license` and `readme.md`)
57+
- Build npm package: `deno task build` (wraps `deno pack` and emits
58+
`npm/fetchclient.tgz`)
5959

6060
## 5) Common tasks (examples)
6161

deno.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"test": "deno test --allow-net"
1515
},
1616
"imports": {
17-
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
1817
"@std/assert": "jsr:@std/assert@^1.0.17",
1918
"@std/path": "jsr:@std/path@^1.1.4",
2019
"zod": "npm:zod@^4.3.6"

deno.lock

Lines changed: 0 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/guide/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
- Run tests: `deno test --allow-net`
66
- Lint: `deno lint`
77
- Format: `deno fmt`
8-
- Type check: `deno check scripts/*.ts *.ts src/*.ts`
9-
- Build npm package: `deno run -A scripts/build.ts`
8+
- Type check: `deno task check`
9+
- Build npm package: `deno task build`
1010

1111
## Docs
1212

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ handling.
2929
npm install @foundatiofx/fetchclient
3030
```
3131

32+
FetchClient is ESM-only and targets modern browsers, Deno, and current Node.js
33+
versions.
34+
3235
## Quick Example
3336

3437
FetchClient works two ways - pick whichever style you prefer:

scripts/build.ts

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,22 @@
1-
import { build, emptyDir } from "@deno/dnt";
1+
const version = Deno.args[0] ?? "0.0.0";
2+
const outputPath = "npm/fetchclient.tgz";
23

3-
await emptyDir("./npm");
4+
await Deno.mkdir("npm", { recursive: true });
45

5-
await build({
6-
entryPoints: [
7-
"./mod.ts",
8-
{
9-
name: "./mocks",
10-
path: "./src/mocks/mod.ts",
11-
},
6+
const command = new Deno.Command(Deno.execPath(), {
7+
args: [
8+
"pack",
9+
"--allow-dirty",
10+
"--set-version",
11+
version,
12+
"--output",
13+
outputPath,
1214
],
13-
outDir: "./npm",
14-
filterDiagnostic(diagnostic) {
15-
// Ignore diagnostics from docs folder
16-
if (diagnostic.file?.fileName.includes("/docs/")) {
17-
return false;
18-
}
19-
return true;
20-
},
21-
shims: {
22-
deno: true,
23-
},
24-
25-
declaration: "separate",
26-
scriptModule: "cjs",
27-
typeCheck: false,
28-
test: true,
29-
rootTestDir: "./src",
30-
testPattern: "**/*.test.ts",
31-
32-
importMap: "deno.json",
33-
34-
package: {
35-
name: "@foundatiofx/fetchclient",
36-
version: Deno.args[0],
37-
repository: {
38-
type: "git",
39-
url: "git+https://github.com/FoundatioFx/FetchClient.git",
40-
},
41-
homepage: "https://github.com/FoundatioFx/FetchClient#readme",
42-
bugs: {
43-
url: "https://github.com/FoundatioFx/FetchClient/issues",
44-
},
45-
license: "Apache-2.0",
46-
description:
47-
"A typed JSON fetch client with middleware support for Deno, Node and the browser.",
48-
author: {
49-
name: "Eric J. Smith",
50-
email: "eric@exceptionless.com",
51-
url: "https://exceptionless.com",
52-
},
53-
keywords: [
54-
"Fetch",
55-
"Middleware",
56-
"ProblemDetails",
57-
"Problem",
58-
],
59-
},
60-
61-
compilerOptions: {
62-
target: "ES2022",
63-
lib: ["ES2022", "WebWorker"],
64-
},
65-
66-
async postBuild() {
67-
await Deno.copyFile("license", "npm/license");
68-
await Deno.copyFile("readme.md", "npm/readme.md");
69-
},
15+
stdout: "inherit",
16+
stderr: "inherit",
7017
});
18+
19+
const status = await command.spawn().status;
20+
if (!status.success) {
21+
Deno.exit(status.code);
22+
}

src/mocks/MockHistory.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)