Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base: refine utils for dnt. #481

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions packages/chacha20poly1305/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/chacha20poly1305");
await emptyDir("../../npm/samples/chacha20poly1305");
await emptyDir("../../npm/test/chacha20poly1305/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("chacha20poly1305");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/chacha20poly1305",
Expand Down Expand Up @@ -69,20 +62,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/chacha20poly1305",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/chacha20poly1305/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/chacha20poly1305/LICENSE");
Deno.copyFileSync(
"README.md",
"../../npm/packages/chacha20poly1305/README.md",
);
afterBuild("chacha20poly1305");
30 changes: 5 additions & 25 deletions packages/core/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/core");
await emptyDir("../../npm/samples/core");
await emptyDir("../../npm/test/core/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("core");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/core",
Expand Down Expand Up @@ -67,17 +60,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/core",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/core/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/core/LICENSE");
Deno.copyFileSync("README.md", "../../npm/packages/core/README.md");
afterBuild("core");
33 changes: 5 additions & 28 deletions packages/dhkem-secp256k1/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-secp256k1");
await emptyDir("../../npm/samples/dhkem-secp256k1");
await emptyDir("../../npm/test/dhkem-secp256k1/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("dhkem-secp256k1");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/dhkem-secp256k1",
Expand Down Expand Up @@ -69,20 +62,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/dhkem-secp256k1",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/dhkem-secp256k1/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/dhkem-secp256k1/LICENSE");
Deno.copyFileSync(
"README.md",
"../../npm/packages/dhkem-secp256k1/README.md",
);
afterBuild("dhkem-secp256k1");
30 changes: 5 additions & 25 deletions packages/dhkem-x25519/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "jsr:@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-x25519");
await emptyDir("../../npm/samples/dhkem-x25519");
await emptyDir("../../npm/test/dhkem-x25519/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("dhkem-x25519");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/dhkem-x25519",
Expand Down Expand Up @@ -69,17 +62,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/dhkem-x25519",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/dhkem-x25519/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/dhkem-x25519/LICENSE");
Deno.copyFileSync("README.md", "../../npm/packages/dhkem-x25519/README.md");
afterBuild("dhkem-x25519");
30 changes: 5 additions & 25 deletions packages/dhkem-x448/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/dhkem-x448");
await emptyDir("../../npm/samples/dhkem-x448");
await emptyDir("../../npm/test/dhkem-x448/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("dhkem-x448");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/dhkem-x448",
Expand Down Expand Up @@ -69,17 +62,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/dhkem-x448",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/dhkem-x448/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/dhkem-x448/LICENSE");
Deno.copyFileSync("README.md", "../../npm/packages/dhkem-x448/README.md");
afterBuild("dhkem-x448");
30 changes: 5 additions & 25 deletions packages/hpke-js/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hpke-js");
await emptyDir("../../npm/samples/hpke-js");
await emptyDir("../../npm/test/hpke-js/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("hpke-js");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/hpke-js",
Expand Down Expand Up @@ -73,17 +66,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/hpke-js",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/hpke-js/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/hpke-js/LICENSE");
Deno.copyFileSync("README.md", "../../npm/packages/hpke-js/README.md");
afterBuild("hpke-js");
36 changes: 5 additions & 31 deletions packages/hybridkem-x-wing/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hybridkem-x-wing");
await emptyDir("../../npm/samples/hybridkem-x-wing");
await emptyDir("../../npm/test/hybridkem-x-wing/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("hybridkem-x-wing");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/hybridkem-x-wing",
Expand Down Expand Up @@ -70,23 +63,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/hybridkem-x-wing",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/hybridkem-x-wing/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync(
"LICENSE",
"../../npm/packages/hybridkem-x-wing/LICENSE",
);
Deno.copyFileSync(
"README.md",
"../../npm/packages/hybridkem-x-wing/README.md",
);
afterBuild("hybridkem-x-wing");
36 changes: 5 additions & 31 deletions packages/hybridkem-x25519-kyber768/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/hybridkem-x25519-kyber768");
await emptyDir("../../npm/samples/hybridkem-x25519-kyber768");
await emptyDir("../../npm/test/hybridkem-x25519-kyber768/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("hybridkem-x25519-kyber768");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/hybridkem-x25519-kyber768",
Expand Down Expand Up @@ -69,23 +62,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/hybridkem-x25519-kyber768",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/hybridkem-x25519-kyber768/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync(
"LICENSE",
"../../npm/packages/hybridkem-x25519-kyber768/LICENSE",
);
Deno.copyFileSync(
"README.md",
"../../npm/packages/hybridkem-x25519-kyber768/README.md",
);
afterBuild("hybridkem-x25519-kyber768");
30 changes: 5 additions & 25 deletions packages/ml-kem/dnt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { build, emptyDir } from "@deno/dnt";
import { copySync } from "@std/fs";
import { removeNodeModules } from "../../utils/misc.ts";

// clean up dist
await emptyDir("../../npm/packages/ml-kem");
await emptyDir("../../npm/samples/ml-kem");
await emptyDir("../../npm/test/ml-kem/runtimes/cloudflare");

// clean up node_modules
await removeNodeModules();
import { build } from "@deno/dnt";
import { afterBuild, beforeBuild } from "../../utils/dntCommon.ts";

const denoPkg = JSON.parse(await Deno.readTextFile("./deno.json"));

await beforeBuild("ml-kem");

await build({
entryPoints: ["./mod.ts"],
outDir: "../../npm/packages/ml-kem",
Expand Down Expand Up @@ -68,17 +61,4 @@ await build({
},
});

copySync(
"samples/node",
"../../npm/samples/ml-kem",
{ overwrite: true },
);
copySync(
"test/runtimes/cloudflare",
"../../npm/test/ml-kem/runtimes/cloudflare",
{ overwrite: true },
);

// post build steps
Deno.copyFileSync("LICENSE", "../../npm/packages/ml-kem/LICENSE");
Deno.copyFileSync("README.md", "../../npm/packages/ml-kem/README.md");
afterBuild("ml-kem");
Loading
Loading