From c2c8d7164835184607d12c683e01aecb463b39a2 Mon Sep 17 00:00:00 2001 From: karthik2804 Date: Tue, 9 Jul 2024 17:18:21 +0200 Subject: [PATCH] configure knitwit Signed-off-by: karthik2804 update componentizeJS Signed-off-by: karthik2804 --- bin/j2w.mjs | 2 +- bin/wit/spin.wit | 1 - package-lock.json | 142 +++++++++++++++++++------ package.json | 15 ++- templates/http-ts/content/knitwit.json | 9 ++ templates/http-ts/content/package.json | 10 +- 6 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 templates/http-ts/content/knitwit.json diff --git a/bin/j2w.mjs b/bin/j2w.mjs index 47285e07..fedbddd6 100755 --- a/bin/j2w.mjs +++ b/bin/j2w.mjs @@ -30,7 +30,6 @@ const args = yargs(hideBin(process.argv)) .option('trigger-type', { alias: '-n', describe: "Spin trigger to target", - choices: validSpinWorlds, demandOption: true }) .argv; @@ -50,6 +49,7 @@ const { component } = await componentize(source, { witPath: resolve(args.witPath), worldName: args.triggerType, disableFeatures: [], + enableFeatures: ["http"], }); await writeFile(args.output, component); diff --git a/bin/wit/spin.wit b/bin/wit/spin.wit index 1e901776..38431356 100644 --- a/bin/wit/spin.wit +++ b/bin/wit/spin.wit @@ -2,7 +2,6 @@ package fermyon:spin@2.0.0; world spin-imports { import wasi:http/outgoing-handler@0.2.0; - include wasi:cli/imports@0.2.0; import llm; import redis; import postgres; diff --git a/package-lock.json b/package-lock.json index 197d8527..e818b227 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,9 +7,11 @@ "": { "name": "@fermyon/spin-sdk", "version": "2.0.0-alpha.2", + "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@bytecodealliance/componentize-js": "https://github.com/fermyon/ComponentizeJS#use_fetch_event", + "@bytecodealliance/componentize-js": "^0.10.1", + "@fermyon/knitwit": "https://github.com/fermyon/knitwit", "itty-router": "^3.0.12", "yargs": "^17.7.2" }, @@ -22,26 +24,27 @@ } }, "node_modules/@bytecodealliance/componentize-js": { - "version": "0.8.3", - "resolved": "git+ssh://git@github.com/fermyon/ComponentizeJS.git#c3107d1240ca0e1b5b7d3bdad95f0168a1a808ef", + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.10.1.tgz", + "integrity": "sha512-gbCFn2h/dx9ovCU+xPsveTjyWIcWw645LH9aIaC0qqGYhkfeYJTYBbMxTUQx4sLDyx1UnHMMMCDFOv8LPuFZzQ==", "workspaces": [ "." ], "dependencies": { - "@bytecodealliance/jco": "1.1.1", + "@bytecodealliance/jco": "1.3.0", "@bytecodealliance/wizer": "^3.0.1", - "es-module-lexer": "^1.4.1" + "es-module-lexer": "^1.5.4" } }, "node_modules/@bytecodealliance/jco": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.1.1.tgz", - "integrity": "sha512-s8Zz6GFPlo2g+dsGp1OMIWXSZnM4FyIloxNAc4grF5TZwFoD00Gj8b0xvpmFSeZj36X/bJPa7x3za3j7Cfeetw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@bytecodealliance/jco/-/jco-1.3.0.tgz", + "integrity": "sha512-Iowdj+Z2axUWuy0tUjWgxt50MO3WtfAswI5oQjAfBsAnTY/0w/0+STNRay9QMyi3dWZbUOS4SaA9/P2HonLXeg==", "workspaces": [ "packages/preview2-shim" ], "dependencies": { - "@bytecodealliance/preview2-shim": "^0.16.1", + "@bytecodealliance/preview2-shim": "^0.16.3", "binaryen": "^116.0.0", "chalk-template": "^1", "commander": "^12", @@ -54,9 +57,9 @@ } }, "node_modules/@bytecodealliance/preview2-shim": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/@bytecodealliance/preview2-shim/-/preview2-shim-0.16.2.tgz", - "integrity": "sha512-36MwesmbLSf3Y5/OHcS85iBaF0N92CQ4gpjtDVKSbrjxmrBKCWlWVfoQ03F/cqDg8k5K7pzVaVBH0XBIbTCfTQ==" + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@bytecodealliance/preview2-shim/-/preview2-shim-0.16.4.tgz", + "integrity": "sha512-G6IB1YQjy6csGe6OEAlBYHqtsakZu5ilh59w08h1IR6IEoZG3O1dmCRdy/zcBgvyk/ORXyhiBMKFCzOCACw01g==" }, "node_modules/@bytecodealliance/wizer": { "version": "3.0.1", @@ -167,6 +170,19 @@ "wizer-win32-x64": "wizer" } }, + "node_modules/@fermyon/knitwit": { + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/fermyon/knitwit.git#09a7d30e63ebbe333ec4b682b253ecda5a792768", + "dependencies": { + "@bytecodealliance/preview2-shim": "^0.16.4", + "proper-lockfile": "^4.1.2", + "yup": "^1.4.0" + }, + "bin": { + "knitwit": "bin/knitwit.mjs", + "knitwit-postinstall": "bin/knitwit-postinstall.js" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -206,9 +222,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.25", @@ -220,9 +236,9 @@ } }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "bin": { "acorn": "bin/acorn" }, @@ -399,9 +415,9 @@ "integrity": "sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==" }, "node_modules/es-module-lexer": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", - "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==" + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", + "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==" }, "node_modules/escalade": { "version": "3.1.2", @@ -430,6 +446,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -550,9 +571,9 @@ } }, "node_modules/prettier": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.1.tgz", - "integrity": "sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -564,6 +585,21 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/proper-lockfile": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", + "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", + "dependencies": { + "graceful-fs": "^4.2.4", + "retry": "^0.12.0", + "signal-exit": "^3.0.2" + } + }, + "node_modules/property-expr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.6.tgz", + "integrity": "sha512-SVtmxhRE/CGkn3eZY1T6pC8Nln6Fr/lu1mKSgRud0eC73whjGfoAogbn78LkD8aFL0zz3bAFerKSnOl7NlErBA==" + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -587,6 +623,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "engines": { + "node": ">= 4" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -621,9 +665,9 @@ } }, "node_modules/string-width": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.1.0.tgz", - "integrity": "sha512-SEIJCWiX7Kg4c129n48aDRwLbFb2LJmXXFrWBG4NGaRtMQ3myKPKbwrD1BKqQn74oCoNMBVrfDEr5M9YxCsrkw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", @@ -651,9 +695,9 @@ } }, "node_modules/terser": { - "version": "5.31.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.1.tgz", - "integrity": "sha512-37upzU1+viGvuFtBo9NPufCb9dwM0+l9hMxYyWfBA+fbwrPqNJAhbZ6W47bBFnZHKHTUBnMvi87434qq+qnxOg==", + "version": "5.31.3", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.3.tgz", + "integrity": "sha512-pAfYn3NIZLyZpa83ZKigvj6Rn9c/vd5KfYGX7cN1mnzqgDcxWvrU5ZtAfIKhEXz9nRecw4z3LXkjaq96/qZqAA==", "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", @@ -672,10 +716,31 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, + "node_modules/tiny-case": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-case/-/tiny-case-1.0.3.tgz", + "integrity": "sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==" + }, + "node_modules/toposort": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz", + "integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==" + }, + "node_modules/type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -807,6 +872,17 @@ "engines": { "node": ">=8" } + }, + "node_modules/yup": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/yup/-/yup-1.4.0.tgz", + "integrity": "sha512-wPbgkJRCqIf+OHyiTBQoJiP5PFuAXaWiJK6AmYkzQAh5/c2K9hzSApBZG5wV9KoKSePF7sAxmNSvh/13YHkFDg==", + "dependencies": { + "property-expr": "^2.0.5", + "tiny-case": "^1.0.3", + "toposort": "^2.0.2", + "type-fest": "^2.19.0" + } } } } diff --git a/package.json b/package.json index 071f790f..8535104b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "test": "echo \"Error: no test specified\" && exit 1", "fmt": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\"", "fmt-check": "prettier --check \"src/**/*.{ts,tsx,js,jsx}\"", - "build": "tsc && cp -r src/types ./lib/" + "build": "tsc && cp -r src/types ./lib/", + "postinstall": "knitwit-postinstall" }, "sideEffects": false, "author": "", @@ -21,8 +22,16 @@ "typescript": "^5.4.3" }, "dependencies": { - "@bytecodealliance/componentize-js": "https://github.com/fermyon/ComponentizeJS#use_fetch_event", + "@bytecodealliance/componentize-js": "^0.10.1", "itty-router": "^3.0.12", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "@fermyon/knitwit": "https://github.com/fermyon/knitwit" + }, + "config": { + "wit": "test", + "knitwit": { + "witPath": "../../bin/wit", + "world": "spin-imports" + } } } \ No newline at end of file diff --git a/templates/http-ts/content/knitwit.json b/templates/http-ts/content/knitwit.json new file mode 100644 index 00000000..a9375762 --- /dev/null +++ b/templates/http-ts/content/knitwit.json @@ -0,0 +1,9 @@ +{ + "version": 1, + "project": { + "worlds": [ + "spin-http" + ] + }, + "packages": {} +} \ No newline at end of file diff --git a/templates/http-ts/content/package.json b/templates/http-ts/content/package.json index 3bb49f16..a6a37c01 100644 --- a/templates/http-ts/content/package.json +++ b/templates/http-ts/content/package.json @@ -4,8 +4,9 @@ "description": "{{project-description}}", "main": "index.js", "scripts": { - "build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -n spin-http -o target/{{project-name | kebab_case}}.wasm", - "test": "echo \"Error: no test specified\" && exit 1" + "build": "npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/{{project-name | kebab_case}}.wasm", + "test": "echo \"Error: no test specified\" && exit 1", + "postinstall": "knitwit" }, "keywords": [], "author": "", @@ -15,9 +16,10 @@ "ts-loader": "^9.4.1", "typescript": "^4.8.4", "webpack": "^5.74.0", - "webpack-cli": "^4.10.0" + "webpack-cli": "^4.10.0", + "@fermyon/knitwit": "https://github.com/fermyon/knitwit" }, "dependencies": { "@fermyon/spin-sdk": "^2.0.0-alpha.2" } -} +} \ No newline at end of file