From a982d7fd38f8ae24ba76ff1e81e37fb0d6b2b667 Mon Sep 17 00:00:00 2001 From: Ajitomi Daisuke Date: Fri, 18 Oct 2024 10:39:47 +0900 Subject: [PATCH] Refine deno task sample:node. --- .gitignore | 1 + deno.json | 14 +- npm/package-lock.json | 141 +++++++++--------- npm/package.json | 2 +- packages/chacha20poly1305/deno.json | 1 - packages/chacha20poly1305/dnt.ts | 9 ++ .../samples/node/package.json | 3 + packages/core/dnt.ts | 6 + packages/core/samples/node/package.json | 3 + packages/dhkem-secp256k1/dnt.ts | 9 ++ .../dhkem-secp256k1/samples/node/package.json | 3 + packages/dhkem-x25519/dnt.ts | 9 ++ .../dhkem-x25519/samples/node/package.json | 3 + packages/dhkem-x448/dnt.ts | 6 + packages/dhkem-x448/samples/node/package.json | 3 + packages/hpke-js/dnt.ts | 6 + packages/hpke-js/samples/node/package.json | 3 + packages/hybridkem-x25519-kyber768/dnt.ts | 9 ++ .../samples/node/package.json | 3 + 19 files changed, 153 insertions(+), 81 deletions(-) diff --git a/.gitignore b/.gitignore index b944a1b6f..bb56e3eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -81,6 +81,7 @@ docs/ # npm files generated by dnt npm/packages +npm/samples # Gatsby files .cache/ diff --git a/deno.json b/deno.json index 627b0e426..33201283d 100644 --- a/deno.json +++ b/deno.json @@ -119,13 +119,13 @@ "sample:deno:hybridkem-x25519-kyber768": "cd packages/hybridkem-x25519-kyber768 && deno task sample:deno", "sample:deno:hpke-js": "cd packages/hpke-js && deno task sample:deno", "sample:node": "deno task sample:node:core && deno task sample:node:chacha20poly1305 && deno task sample:node:dhkem-x25519 && deno task sample:node:dhkem-x448 && deno task sample:node:dhkem-secp256k1 && deno task sample:node:hybridkem-x25519-kyber768 && deno task sample:node:hpke-js", - "sample:node:core": "cd packages/core && deno task sample:node", - "sample:node:chacha20poly1305": "cd packages/chacha20poly1305 && deno task sample:node", - "sample:node:dhkem-x25519": "cd packages/dhkem-x25519 && deno task sample:node", - "sample:node:dhkem-x448": "cd packages/dhkem-x448 && deno task sample:node", - "sample:node:dhkem-secp256k1": "cd packages/dhkem-secp256k1 && deno task sample:node", - "sample:node:hybridkem-x25519-kyber768": "cd packages/hybridkem-x25519-kyber768 && deno task sample:node", - "sample:node:hpke-js": "cd packages/hpke-js && deno task sample:node", + "sample:node:core": "cd npm && npm run test -w samples/core", + "sample:node:chacha20poly1305": "cd npm && npm run test -w samples/chacha20poly1305", + "sample:node:dhkem-x25519": "cd npm && npm run test -w samples/dhkem-x25519", + "sample:node:dhkem-x448": "cd npm && npm run test -w samples/dhkem-x448", + "sample:node:dhkem-secp256k1": "cd npm && npm run test -w samples/dhkem-secp256k1", + "sample:node:hybridkem-x25519-kyber768": "cd npm && npm run test -w samples/hybridkem-x25519-kyber768", + "sample:node:hpke-js": "cd npm && npm run test -w samples/hpke-js", "update:cloudflare": "deno task update:cloudflare:core || deno task update:cloudflare:chacha20poly1305 || deno task update:cloudflare:dhkem-x25519 || deno task update:cloudflare:dhkem-x448 || deno task update:cloudflare:dhkem-secp256k1 || deno task update:cloudflare:hybridkem-x25519-kyber768 || deno task update:cloudflare:hpke-js", "update:cloudflare:core": "cd packages/core/test/runtimes/cloudflare && npm audit fix", "update:cloudflare:chacha20poly1305": "cd packages/chacha20poly1305/test/runtimes/cloudflare && npm audit fix", diff --git a/npm/package-lock.json b/npm/package-lock.json index 654f9e4ff..ba287043e 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -14,70 +14,9 @@ "packages/dhkem-secp256k1", "packages/hybridkem-x25519-kyber768", "packages/hpke-js", - "../**/*/samples/node" + "samples/**/*" ] }, - "../packages/chacha20poly1305/samples/node": { - "name": "samples-node-hpke-chacha20poly1305", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/chacha20poly1305": "^1.4.3", - "@hpke/core": "^1.4.3" - } - }, - "../packages/core/samples/node": { - "name": "samples-node-hpke-core", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/core": "^1.5.0" - } - }, - "../packages/dhkem-secp256k1/samples/node": { - "name": "samples-node-hpke-dhkem-secp256k1", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/core": "^1.5.0", - "@hpke/dhkem-secp256k1": "^1.5.0" - } - }, - "../packages/dhkem-x25519/samples/node": { - "name": "samples-node-hpke-dhkem-x25519", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/core": "^1.5.0", - "@hpke/dhkem-x25519": "^1.5.0" - } - }, - "../packages/dhkem-x448/samples/node": { - "name": "samples-node-hpke-dhkem-x448", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/core": "^1.4.3", - "@hpke/dhkem-x448": "^1.4.3" - } - }, - "../packages/hpke-js/samples/node": { - "name": "samples-node-hpke-js", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "hpke-js": "^1.5.0" - } - }, - "../packages/hybridkem-x25519-kyber768/samples/node": { - "name": "samples-node-hpke-hybridkem-x25519-kyber768", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "@hpke/core": "^1.5.0", - "@hpke/hybridkem-x25519-kyber768": "^1.5.0" - } - }, "node_modules/@deno/shim-deno": { "version": "0.18.2", "resolved": "https://registry.npmjs.org/@deno/shim-deno/-/shim-deno-0.18.2.tgz", @@ -189,31 +128,27 @@ "license": "ISC" }, "node_modules/samples-node-hpke-chacha20poly1305": { - "resolved": "../packages/chacha20poly1305/samples/node", + "resolved": "samples/chacha20poly1305", "link": true }, "node_modules/samples-node-hpke-core": { - "resolved": "../packages/core/samples/node", + "resolved": "samples/core", "link": true }, "node_modules/samples-node-hpke-dhkem-secp256k1": { - "resolved": "../packages/dhkem-secp256k1/samples/node", + "resolved": "samples/dhkem-secp256k1", "link": true }, "node_modules/samples-node-hpke-dhkem-x25519": { - "resolved": "../packages/dhkem-x25519/samples/node", + "resolved": "samples/dhkem-x25519", "link": true }, "node_modules/samples-node-hpke-dhkem-x448": { - "resolved": "../packages/dhkem-x448/samples/node", + "resolved": "samples/dhkem-x448", "link": true }, "node_modules/samples-node-hpke-hybridkem-x25519-kyber768": { - "resolved": "../packages/hybridkem-x25519-kyber768/samples/node", - "link": true - }, - "node_modules/samples-node-hpke-js": { - "resolved": "../packages/hpke-js/samples/node", + "resolved": "samples/hybridkem-x25519-kyber768", "link": true }, "node_modules/undici-types": { @@ -381,6 +316,68 @@ "engines": { "node": ">=16.0.0" } + }, + "samples/chacha20poly1305": { + "name": "samples-node-hpke-chacha20poly1305", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/chacha20poly1305": "^1.4.3", + "@hpke/core": "^1.4.3" + } + }, + "samples/core": { + "name": "samples-node-hpke-core", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.5.0" + } + }, + "samples/dhkem-secp256k1": { + "name": "samples-node-hpke-dhkem-secp256k1", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.5.0", + "@hpke/dhkem-secp256k1": "^1.5.0" + } + }, + "samples/dhkem-x25519": { + "name": "samples-node-hpke-dhkem-x25519", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.5.0", + "@hpke/dhkem-x25519": "^1.5.0" + } + }, + "samples/dhkem-x448": { + "name": "samples-node-hpke-dhkem-x448", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.4.3", + "@hpke/dhkem-x448": "^1.4.3" + } + }, + "samples/hpke-js": { + "name": "samples-node-hpke-js", + "version": "1.0.0", + "extraneous": true, + "license": "MIT", + "dependencies": { + "hpke-js": "^1.5.0" + } + }, + "samples/hybridkem-x25519-kyber768": { + "name": "samples-node-hpke-hybridkem-x25519-kyber768", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.5.0", + "@hpke/hybridkem-x25519-kyber768": "^1.5.0" + } } } } diff --git a/npm/package.json b/npm/package.json index 07b214700..9614f68e6 100644 --- a/npm/package.json +++ b/npm/package.json @@ -10,6 +10,6 @@ "packages/dhkem-secp256k1", "packages/hybridkem-x25519-kyber768", "packages/hpke-js", - "../**/*/samples/node" + "samples/**/*" ] } diff --git a/packages/chacha20poly1305/deno.json b/packages/chacha20poly1305/deno.json index 06e1b5d4d..f3a7d4cd8 100644 --- a/packages/chacha20poly1305/deno.json +++ b/packages/chacha20poly1305/deno.json @@ -52,7 +52,6 @@ "cov": "deno coverage ./coverage --lcov --exclude='test'", "dnt": "deno run --import-map=../../npm/import_map.json -A dnt.ts", "sample:deno": "cd samples/deno && deno run main.ts", - "sample:node": "cd samples/node && npm install && node app.js", "minify": "esbuild ../../npm/packages/chacha20poly1305/esm/mod.js --bundle --format=esm --minify" } } diff --git a/packages/chacha20poly1305/dnt.ts b/packages/chacha20poly1305/dnt.ts index 0786fc839..19993fa63 100644 --- a/packages/chacha20poly1305/dnt.ts +++ b/packages/chacha20poly1305/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/chacha20poly1305"); +await emptyDir("../../npm/samples/chacha20poly1305"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -70,3 +71,11 @@ Deno.copyFileSync( "README.md", "../../npm/packages/chacha20poly1305/README.md", ); +Deno.copyFileSync( + "samples/node/app.js", + "../../npm/samples/chacha20poly1305/app.js", +); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/chacha20poly1305/package.json", +); diff --git a/packages/chacha20poly1305/samples/node/package.json b/packages/chacha20poly1305/samples/node/package.json index bb67eec3c..33155e9f6 100644 --- a/packages/chacha20poly1305/samples/node/package.json +++ b/packages/chacha20poly1305/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/chacha20poly1305": "^1.4.3", "@hpke/core": "^1.4.3" diff --git a/packages/core/dnt.ts b/packages/core/dnt.ts index 0084fc0c0..f8a0a9d15 100644 --- a/packages/core/dnt.ts +++ b/packages/core/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/core"); +await emptyDir("../../npm/samples/core"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -65,3 +66,8 @@ await build({ // post build steps Deno.copyFileSync("LICENSE", "../../npm/packages/core/LICENSE"); Deno.copyFileSync("README.md", "../../npm/packages/core/README.md"); +Deno.copyFileSync("samples/node/app.js", "../../npm/samples/core/app.js"); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/core/package.json", +); diff --git a/packages/core/samples/node/package.json b/packages/core/samples/node/package.json index 1b2a9327a..b6fda576d 100644 --- a/packages/core/samples/node/package.json +++ b/packages/core/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/core": "^1.5.0" } diff --git a/packages/dhkem-secp256k1/dnt.ts b/packages/dhkem-secp256k1/dnt.ts index 835726b12..5bea42d09 100644 --- a/packages/dhkem-secp256k1/dnt.ts +++ b/packages/dhkem-secp256k1/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/dhkem-secp256k1"); +await emptyDir("../../npm/samples/dhkem-secp256k1"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -70,3 +71,11 @@ Deno.copyFileSync( "README.md", "../../npm/packages/dhkem-secp256k1/README.md", ); +Deno.copyFileSync( + "samples/node/app.js", + "../../npm/samples/dhkem-secp256k1/app.js", +); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/dhkem-secp256k1/package.json", +); diff --git a/packages/dhkem-secp256k1/samples/node/package.json b/packages/dhkem-secp256k1/samples/node/package.json index 64a90c20c..727b60abc 100644 --- a/packages/dhkem-secp256k1/samples/node/package.json +++ b/packages/dhkem-secp256k1/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/core": "^1.5.0", "@hpke/dhkem-secp256k1": "^1.5.0" diff --git a/packages/dhkem-x25519/dnt.ts b/packages/dhkem-x25519/dnt.ts index 0387992f8..5d267aeee 100644 --- a/packages/dhkem-x25519/dnt.ts +++ b/packages/dhkem-x25519/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "jsr:@deno/dnt"; await emptyDir("../../npm/packages/dhkem-x25519"); +await emptyDir("../../npm/samples/dhkem-x25519"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -67,3 +68,11 @@ await build({ // post build steps Deno.copyFileSync("LICENSE", "../../npm/packages/dhkem-x25519/LICENSE"); Deno.copyFileSync("README.md", "../../npm/packages/dhkem-x25519/README.md"); +Deno.copyFileSync( + "samples/node/app.js", + "../../npm/samples/dhkem-x25519/app.js", +); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/dhkem-x25519/package.json", +); diff --git a/packages/dhkem-x25519/samples/node/package.json b/packages/dhkem-x25519/samples/node/package.json index 3a1b0fc04..dfd24a351 100644 --- a/packages/dhkem-x25519/samples/node/package.json +++ b/packages/dhkem-x25519/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/core": "^1.5.0", "@hpke/dhkem-x25519": "^1.5.0" diff --git a/packages/dhkem-x448/dnt.ts b/packages/dhkem-x448/dnt.ts index 6c50351d1..991bb716c 100644 --- a/packages/dhkem-x448/dnt.ts +++ b/packages/dhkem-x448/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/dhkem-x448"); +await emptyDir("../../npm/samples/dhkem-x448"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -67,3 +68,8 @@ await build({ // post build steps Deno.copyFileSync("LICENSE", "../../npm/packages/dhkem-x448/LICENSE"); Deno.copyFileSync("README.md", "../../npm/packages/dhkem-x448/README.md"); +Deno.copyFileSync("samples/node/app.js", "../../npm/samples/dhkem-x448/app.js"); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/dhkem-x448/package.json", +); diff --git a/packages/dhkem-x448/samples/node/package.json b/packages/dhkem-x448/samples/node/package.json index b191a53ba..1e0cb6942 100644 --- a/packages/dhkem-x448/samples/node/package.json +++ b/packages/dhkem-x448/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/core": "^1.4.3", "@hpke/dhkem-x448": "^1.4.3" diff --git a/packages/hpke-js/dnt.ts b/packages/hpke-js/dnt.ts index 5981654b1..8a9a654d9 100644 --- a/packages/hpke-js/dnt.ts +++ b/packages/hpke-js/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/hpke-js"); +await emptyDir("../../npm/samples/hpke-js"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -71,3 +72,8 @@ await build({ // post build steps Deno.copyFileSync("LICENSE", "../../npm/packages/hpke-js/LICENSE"); Deno.copyFileSync("README.md", "../../npm/packages/hpke-js/README.md"); +Deno.copyFileSync("samples/node/app.js", "../../npm/samples/hpke-js/app.js"); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/hpke-js/package.json", +); diff --git a/packages/hpke-js/samples/node/package.json b/packages/hpke-js/samples/node/package.json index 8e1214e7d..0ec3a3190 100644 --- a/packages/hpke-js/samples/node/package.json +++ b/packages/hpke-js/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "hpke-js": "^1.5.0" } diff --git a/packages/hybridkem-x25519-kyber768/dnt.ts b/packages/hybridkem-x25519-kyber768/dnt.ts index 4a12caebc..f828c6ec3 100644 --- a/packages/hybridkem-x25519-kyber768/dnt.ts +++ b/packages/hybridkem-x25519-kyber768/dnt.ts @@ -1,6 +1,7 @@ import { build, emptyDir } from "@deno/dnt"; await emptyDir("../../npm/packages/hybridkem-x25519-kyber768"); +await emptyDir("../../npm/samples/hybridkem-x25519-kyber768"); await emptyDir("test/runtimes/browsers/node_modules"); await emptyDir("test/runtimes/bun/node_modules"); await emptyDir("test/runtimes/cloudflare/node_modules"); @@ -73,3 +74,11 @@ Deno.copyFileSync( "README.md", "../../npm/packages/hybridkem-x25519-kyber768/README.md", ); +Deno.copyFileSync( + "samples/node/app.js", + "../../npm/samples/hybridkem-x25519-kyber768/app.js", +); +Deno.copyFileSync( + "samples/node/package.json", + "../../npm/samples/hybridkem-x25519-kyber768/package.json", +); diff --git a/packages/hybridkem-x25519-kyber768/samples/node/package.json b/packages/hybridkem-x25519-kyber768/samples/node/package.json index 500faaa01..c8db15fe1 100644 --- a/packages/hybridkem-x25519-kyber768/samples/node/package.json +++ b/packages/hybridkem-x25519-kyber768/samples/node/package.json @@ -6,6 +6,9 @@ "main": "app.js", "author": "Ajitomi Daisuke (https://github.com/dajiaji)", "license": "MIT", + "scripts": { + "test": "node app.js" + }, "dependencies": { "@hpke/core": "^1.5.0", "@hpke/hybridkem-x25519-kyber768": "^1.5.0"