Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.

Commit 3641f59

Browse files
committed
wip(npm): adds dnt module to build npm package in parallel to deno module (see also githook)
1 parent 6f31f2f commit 3641f59

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*bak
55
.history
66
.temp/**
7-
.env
7+
.env
8+
npm/

deno.jsonc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"tasks": {
33
"test": "deno test --allow-all",
44
"gen:types": "deno types > deno-runtime-types.ts",
5-
"check": "deno fmt --check && deno lint"
5+
"check": "deno fmt --check && deno lint",
6+
"npm:publish": "deno run -A scripts/build_npm.ts & cd npm & npm publish"
67
}
78
// generate hooks in .git/hooks by running (or specify hookPath)
89
// "deno run -A -r https://deno.land/x/githooks/githooks.ts"
910
// "githooks": {
1011
// "pre-commit": "check"
12+
// "pre-commit": "npm:publish"
1113
// },
1214
}

scripts/build_npm.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
import { build, emptyDir } from "https://deno.land/x/dnt/mod.ts";
22

3-
await emptyDir("./npm");
3+
await emptyDir("./npm"); // NOTE: added npm/ to .gitignore (optional)
44

55
await build({
66
entryPoints: ["./mod.ts"],
77
outDir: "./npm",
8+
typeCheck: true,
9+
test: true,
10+
declaration: true,
11+
// scriptModule: false to allow use of top-level await
12+
// see https://github.com/denoland/dnt/#top-level-await
13+
scriptModule: false,
814
shims: {
915
// see JS docs for overview and more options
1016
deno: true,
1117
},
1218
package: {
1319
// package.json properties
14-
name: "your-package",
15-
version: Deno.args[0],
16-
description: "Your package.",
20+
name: "@netzoio/sdk",
21+
version: Deno.args[0]?.replace(/^v/, ""), // remove leading v
22+
description: "Software development kit (SDK) for Netzo, the open Web platform to unify IoT devices, applications and services.",
1723
license: "MIT",
1824
repository: {
1925
type: "git",
20-
url: "git+https://github.com/username/repo.git",
26+
url: "git+https://github.com/netzoio/sdk.git",
2127
},
2228
bugs: {
23-
url: "https://github.com/username/repo/issues",
29+
url: "https://github.com/netzoio/sdk/issues",
2430
},
2531
},
2632
});
2733

2834
// post build steps
35+
Deno.copyFileSync("CHANGELOG.md", "npm/CHANGELOG.md");
2936
Deno.copyFileSync("LICENSE", "npm/LICENSE");
3037
Deno.copyFileSync("README.md", "npm/README.md");

0 commit comments

Comments
 (0)