From 38896f24a9ff56cd220c440caf4d61de8fcd2211 Mon Sep 17 00:00:00 2001 From: Ryan Fox-Tyler <60440289+ryanfoxtyler@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:15:29 -0500 Subject: [PATCH 01/11] chore: init trunk --- .github/ISSUE_TEMPLATE/bug_report.md | 20 +- .github/ISSUE_TEMPLATE/feature_request.md | 21 +- .github/actionlint.yml | 6 + .github/pull_request_template.md | 18 +- .github/workflows/ci-cli-lint.yml | 7 +- .github/workflows/ci-go-lint.yml | 8 +- .github/workflows/ci-go-test.yml | 10 +- .github/workflows/ci-release-info-build.yaml | 7 +- .github/workflows/ci-release-info-lint.yaml | 7 +- .github/workflows/ci-sdk-as-build.yml | 4 +- .github/workflows/ci-sdk-as-lint.yml | 4 +- .github/workflows/ci-sdk-go-build.yml | 8 +- .github/workflows/codeql.yml | 11 +- .github/workflows/release-cli.yaml | 40 +- .github/workflows/release-info.yaml | 6 +- .github/workflows/release-runtime.yaml | 2 +- .github/workflows/release-schema.yaml | 4 +- .github/workflows/release-sdk-as.yaml | 9 +- .github/workflows/release-sdk-go.yaml | 4 +- .markdownlint.json | 5 - .trunk/.gitignore | 9 + .trunk/configs/.hadolint.yaml | 4 + .trunk/configs/.markdownlint.json | 8 + .trunk/configs/.prettierrc | 6 + .trunk/configs/.shellcheckrc | 7 + .trunk/configs/.yamllint.yaml | 7 + cspell.json => .trunk/configs/cspell.json | 0 .trunk/trunk.yaml | 44 ++ .vscode/extensions.json | 4 +- .vscode/settings.json | 15 +- CHANGELOG.md | 386 ++++++++++++------ CODE_OF_CONDUCT.md | 135 +++--- CONTRIBUTING.md | 44 +- README.md | 88 ++-- SECURITY.md | 7 +- cli/install.sh | 386 +++++++++--------- lib/README.md | 10 +- runtime/.goreleaser.yaml | 8 +- runtime/README.md | 4 +- runtime/explorer/content/ModusIcon.tsx | 18 +- runtime/explorer/content/index.html | 2 +- runtime/explorer/content/main.tsx | 54 ++- runtime/explorer/content/postcss.config.js | 2 +- runtime/explorer/content/tailwind.config.js | 2 +- runtime/explorer/content/vite.config.ts | 8 +- .../graphql/schemagen/schemagen_go_test.go | 2 +- .../testdata/assembly/arraybuffers.ts | 26 +- .../testdata/assembly/arrays.ts | 89 ++-- .../testdata/assembly/classes.ts | 156 +++---- .../assemblyscript/testdata/assembly/dates.ts | 20 +- .../assemblyscript/testdata/assembly/env.ts | 10 +- .../testdata/assembly/hostfns.ts | 18 +- .../assemblyscript/testdata/assembly/index.ts | 20 +- .../assemblyscript/testdata/assembly/maps.ts | 189 ++++----- .../testdata/assembly/primitives.ts | 104 ++--- .../testdata/assembly/strings.ts | 22 +- .../testdata/assembly/typedarrays.ts | 184 ++++----- runtime/languages/golang/testdata/README.md | 4 +- runtime/languages/golang/testdata/build.sh | 10 +- sdk/README.md | 8 +- sdk/assemblyscript/CHANGELOG.md | 139 +++++-- sdk/assemblyscript/README.md | 57 +-- sdk/assemblyscript/scripts/install-all.sh | 10 +- sdk/assemblyscript/scripts/prepare-release.sh | 42 +- sdk/assemblyscript/scripts/upgrade-deps.sh | 12 +- sdk/go/examples/anthropic-functions/build.sh | 10 +- sdk/go/examples/auth/build.sh | 10 +- sdk/go/examples/classification/build.sh | 10 +- sdk/go/examples/collections/build.sh | 10 +- sdk/go/examples/dgraph/build.sh | 10 +- sdk/go/examples/embedding/build.sh | 10 +- sdk/go/examples/graphql/build.sh | 10 +- sdk/go/examples/http/build.sh | 10 +- sdk/go/examples/neo4j/build.sh | 10 +- sdk/go/examples/postgresql/build.sh | 10 +- sdk/go/examples/simple/build.sh | 10 +- sdk/go/examples/textgeneration/build.sh | 10 +- sdk/go/examples/time/build.sh | 10 +- sdk/go/examples/vectors/build.sh | 10 +- sdk/go/scripts/prepare-release.sh | 22 +- sdk/go/scripts/tidy-all.sh | 12 +- 81 files changed, 1527 insertions(+), 1228 deletions(-) create mode 100644 .github/actionlint.yml delete mode 100644 .markdownlint.json create mode 100644 .trunk/.gitignore create mode 100644 .trunk/configs/.hadolint.yaml create mode 100644 .trunk/configs/.markdownlint.json create mode 100644 .trunk/configs/.prettierrc create mode 100644 .trunk/configs/.shellcheckrc create mode 100644 .trunk/configs/.yamllint.yaml rename cspell.json => .trunk/configs/cspell.json (100%) create mode 100644 .trunk/trunk.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5598bb691..1f676e3ba 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,28 +1,23 @@ --- name: Bug report about: Create a report to help us improve -title: '' +title: "" labels: bug -assignees: '' - +assignees: "" --- -**Describe the bug** -A clear and concise description of what the bug is. +**Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: +**To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error -**Expected behavior** -A clear and concise description of what you expected to happen. +**Expected behavior** A clear and concise description of what you expected to happen. -**Screenshots** -If applicable, add screenshots to help explain your problem. +**Screenshots** If applicable, add screenshots to help explain your problem. **Environment** @@ -30,5 +25,4 @@ If applicable, add screenshots to help explain your problem. - Language [e.g. AssemblyScript, Go] - Version [e.g. v0.xx] -**Additional context** -Add any other context about the problem here. +**Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d6..3a3c1418e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,20 +1,17 @@ --- name: Feature request about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] +**Is your feature request related to a problem? Please describe.** A clear and concise description +of what the problem is. Ex. I'm always frustrated when [...] -**Describe the solution you'd like** -A clear and concise description of what you want to happen. +**Describe the solution you'd like** A clear and concise description of what you want to happen. -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. +**Describe alternatives you've considered** A clear and concise description of any alternative +solutions or features you've considered. -**Additional context** -Add any other context or screenshots about the feature request here. +**Additional context** Add any other context or screenshots about the feature request here. diff --git a/.github/actionlint.yml b/.github/actionlint.yml new file mode 100644 index 000000000..dd2f86bfb --- /dev/null +++ b/.github/actionlint.yml @@ -0,0 +1,6 @@ +self-hosted-runner: + # Labels of self-hosted runner in array of string + labels: + - warp-ubuntu-latest-x64-2x + - warp-ubuntu-latest-x64-4x + - warp-ubuntu-latest-x64-8x diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 67da69e11..6256c56dd 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -5,16 +5,22 @@ Please explain the changes you made here. **Checklist** - [ ] Code compiles correctly and linting passes locally -- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to this PR +- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to + this PR - [ ] Tests added for new functionality, or regression tests for bug fixes added as applicable -- [ ] For public APIs, new features, etc., PR on [docs repo](https://github.com/hypermodeinc/docs) staged and linked here +- [ ] For public APIs, new features, etc., PR on [docs repo](https://github.com/hypermodeinc/docs) + staged and linked here **Instructions** -- The PR title should follow the [Conventional Commits](https://www.conventionalcommits.org/) syntax, leading with `fix:`, `feat:`, `chore:`, `ci:`, etc. -- The description should briefly explain what the PR is about. In the case of a bugfix, describe or link to the bug. +- The PR title should follow the [Conventional Commits](https://www.conventionalcommits.org/) + syntax, leading with `fix:`, `feat:`, `chore:`, `ci:`, etc. +- The description should briefly explain what the PR is about. In the case of a bugfix, describe or + link to the bug. - In the checklist section, check the boxes in that are applicable, using `[x]` syntax. - - If not applicable, remove the entire line. Only leave the box unchecked if you intend to come back and check the box later. -- Delete the `Instructions` line and everything below it, to indicate you have read and are following these instructions. πŸ™‚ + - If not applicable, remove the entire line. Only leave the box unchecked if you intend to come + back and check the box later. +- Delete the `Instructions` line and everything below it, to indicate you have read and are + following these instructions. πŸ™‚ Thank you for your contribution to the Modus project! diff --git a/.github/workflows/ci-cli-lint.yml b/.github/workflows/ci-cli-lint.yml index 263b04b56..65ee4bce7 100644 --- a/.github/workflows/ci-cli-lint.yml +++ b/.github/workflows/ci-cli-lint.yml @@ -1,4 +1,5 @@ name: ci-cli-lint + on: pull_request: types: @@ -7,7 +8,11 @@ on: - reopened - ready_for_review paths: - - "cli/**" + - cli/** + +permissions: + contents: read + jobs: lint: runs-on: ubuntu-latest diff --git a/.github/workflows/ci-go-lint.yml b/.github/workflows/ci-go-lint.yml index 4661bae90..068cb9358 100644 --- a/.github/workflows/ci-go-lint.yml +++ b/.github/workflows/ci-go-lint.yml @@ -9,8 +9,8 @@ on: - reopened - ready_for_review paths: - - '**/*.go' - - '**/go.mod' + - "**/*.go" + - "**/go.mod" permissions: contents: read @@ -27,7 +27,9 @@ jobs: uses: actions/checkout@v4 - name: Search for go.mod files id: get-dirs - run: echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc + 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} go-lint: needs: get-dirs diff --git a/.github/workflows/ci-go-test.yml b/.github/workflows/ci-go-test.yml index 720159918..b61ea06a9 100644 --- a/.github/workflows/ci-go-test.yml +++ b/.github/workflows/ci-go-test.yml @@ -9,9 +9,9 @@ on: - reopened - ready_for_review paths: - - '**/*.go' - - '**/go.mod' - - '**/testdata/**' + - "**/*.go" + - "**/go.mod" + - "**/testdata/**" permissions: contents: read @@ -29,7 +29,9 @@ jobs: uses: actions/checkout@v4 - name: Search for go.mod files id: get-dirs - run: echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc + 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} go-test: needs: get-dirs diff --git a/.github/workflows/ci-release-info-build.yaml b/.github/workflows/ci-release-info-build.yaml index 64a7b3e86..a4ea5928c 100644 --- a/.github/workflows/ci-release-info-build.yaml +++ b/.github/workflows/ci-release-info-build.yaml @@ -1,4 +1,5 @@ name: ci-release-info-build + on: pull_request: types: @@ -7,7 +8,11 @@ on: - reopened - ready_for_review paths: - - 'tools/release-info/**' + - tools/release-info/** + +permissions: + contents: read + jobs: build: if: github.event_name == 'pull_request' diff --git a/.github/workflows/ci-release-info-lint.yaml b/.github/workflows/ci-release-info-lint.yaml index 61e225253..dea4d3fbf 100644 --- a/.github/workflows/ci-release-info-lint.yaml +++ b/.github/workflows/ci-release-info-lint.yaml @@ -1,4 +1,5 @@ name: ci-release-info-lint + on: pull_request: types: @@ -7,7 +8,11 @@ on: - reopened - ready_for_review paths: - - 'tools/release-info/**' + - tools/release-info/** + +permissions: + contents: read + jobs: lint: if: github.event_name == 'pull_request' diff --git a/.github/workflows/ci-sdk-as-build.yml b/.github/workflows/ci-sdk-as-build.yml index 84698dfda..5f3f8bdec 100644 --- a/.github/workflows/ci-sdk-as-build.yml +++ b/.github/workflows/ci-sdk-as-build.yml @@ -25,7 +25,9 @@ jobs: uses: actions/checkout@v4 - name: Find Examples id: get-dirs - run: echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> + ${GITHUB_OUTPUT} sdk-as-build-examples: needs: get-dirs diff --git a/.github/workflows/ci-sdk-as-lint.yml b/.github/workflows/ci-sdk-as-lint.yml index 360b69e4b..103c08444 100644 --- a/.github/workflows/ci-sdk-as-lint.yml +++ b/.github/workflows/ci-sdk-as-lint.yml @@ -25,7 +25,9 @@ jobs: uses: actions/checkout@v4 - name: Find Examples id: get-dirs - run: echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> + ${GITHUB_OUTPUT} sdk-as-lint-src: if: github.event_name == 'pull_request' diff --git a/.github/workflows/ci-sdk-go-build.yml b/.github/workflows/ci-sdk-go-build.yml index e03c24a89..6976e2bde 100644 --- a/.github/workflows/ci-sdk-go-build.yml +++ b/.github/workflows/ci-sdk-go-build.yml @@ -26,10 +26,14 @@ jobs: uses: actions/checkout@v4 - name: Find tools id: get-tools-dirs - run: echo "dirs=$(find ./sdk/go/tools -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(find ./sdk/go/tools -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq + -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} - name: Find examples id: get-examples-dirs - run: echo "dirs=$(find ./sdk/go/examples -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: + echo "dirs=$(find ./sdk/go/examples -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq + -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} sdk-go-build-tools: needs: get-dirs diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cffa154a0..4768adcc8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,15 +9,18 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL Advanced" +name: CodeQL Advanced on: push: - branches: ["main"] + branches: [main] pull_request: - branches: ["main"] + branches: [main] schedule: - - cron: "41 3 * * 3" + - cron: 41 3 * * 3 + +permissions: + contents: read jobs: analyze: diff --git a/.github/workflows/release-cli.yaml b/.github/workflows/release-cli.yaml index 566852dcf..d0c257b6e 100644 --- a/.github/workflows/release-cli.yaml +++ b/.github/workflows/release-cli.yaml @@ -1,4 +1,4 @@ -name: "Release CLI" +name: Release CLI on: push: @@ -15,9 +15,9 @@ jobs: # note: must use GitHub-hosted runner for publishing to NPM with --provenance flag runs-on: ubuntu-latest steps: - - name: "Validate version" + - name: Validate version if: ${{ !startsWith(github.ref_name, 'cli/v') }} - run: 'echo "Modus CLI version must start with `cli/v` && exit 1' + run: echo "Modus CLI version must start with `cli/v` && exit 1 - uses: actions/checkout@v4 with: ref: "${{ github.ref_name }}" @@ -30,7 +30,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ">=22" - registry-url: "https://registry.npmjs.org" + registry-url: https://registry.npmjs.org - name: Prepare Release working-directory: cli run: npm version ${{ steps.parse_cli_version.outputs.cli_version }} --no-git-tag-version @@ -42,7 +42,9 @@ jobs: run: npm run build - name: Publish NPM Package working-directory: cli - run: npm publish --provenance --access public --tag ${{ steps.parse_cli_version.outputs.npm_tag }} + run: + npm publish --provenance --access public --tag ${{ steps.parse_cli_version.outputs.npm_tag + }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Release @@ -60,17 +62,17 @@ jobs: name: Release Install Script runs-on: warp-ubuntu-latest-x64-2x steps: - - uses: actions/checkout@v4 - with: - ref: "${{ github.ref_name }}" - - name: Push to R2 Bucket - uses: cloudflare/wrangler-action@v3 - with: - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - apiToken: ${{ secrets.CLOUDFLARE_TOKEN }} - wranglerVersion: "3.83.0" - workingDirectory: cli - preCommands: | - cat install.sh - command: | - r2 object put install/modus.sh -f install.sh --content-type text/x-sh + - uses: actions/checkout@v4 + with: + ref: "${{ github.ref_name }}" + - name: Push to R2 Bucket + uses: cloudflare/wrangler-action@v3 + with: + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + apiToken: ${{ secrets.CLOUDFLARE_TOKEN }} + wranglerVersion: 3.83.0 + workingDirectory: cli + preCommands: | + cat install.sh + command: | + r2 object put install/modus.sh -f install.sh --content-type text/x-sh diff --git a/.github/workflows/release-info.yaml b/.github/workflows/release-info.yaml index 9d878719a..edc86ea71 100644 --- a/.github/workflows/release-info.yaml +++ b/.github/workflows/release-info.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ">=22" - registry-url: "https://registry.npmjs.org" + registry-url: https://registry.npmjs.org - name: Install Dependencies working-directory: tools/release-info run: npm ci @@ -30,8 +30,8 @@ jobs: with: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} apiToken: ${{ secrets.CLOUDFLARE_TOKEN }} - wranglerVersion: "3.83.0" - workingDirectory: "tools/release-info" + wranglerVersion: 3.83.0 + workingDirectory: tools/release-info preCommands: | cat modus-latest.json cat modus-preview.json diff --git a/.github/workflows/release-runtime.yaml b/.github/workflows/release-runtime.yaml index 2a6d7d9a2..40579f714 100644 --- a/.github/workflows/release-runtime.yaml +++ b/.github/workflows/release-runtime.yaml @@ -38,7 +38,7 @@ jobs: - uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser-pro - version: "~> v2" + version: ~> v2 args: release --clean -f ./runtime/.goreleaser.yaml env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release-schema.yaml b/.github/workflows/release-schema.yaml index f860472ea..9861b4dce 100644 --- a/.github/workflows/release-schema.yaml +++ b/.github/workflows/release-schema.yaml @@ -19,8 +19,8 @@ jobs: with: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} apiToken: ${{ secrets.CLOUDFLARE_TOKEN }} - wranglerVersion: "3.83.0" - workingDirectory: "lib/manifest" + wranglerVersion: 3.83.0 + workingDirectory: lib/manifest preCommands: | cat modus_schema.json command: | diff --git a/.github/workflows/release-sdk-as.yaml b/.github/workflows/release-sdk-as.yaml index 4e942241a..32b384dae 100644 --- a/.github/workflows/release-sdk-as.yaml +++ b/.github/workflows/release-sdk-as.yaml @@ -17,7 +17,8 @@ jobs: steps: - name: Validate version if: ${{ !startsWith(github.ref_name, 'sdk/assemblyscript/v') }} - run: echo "Modus AssemblyScript SDK version must start with `sdk/assemblyscript/v`" && exit 1 + run: + echo "Modus AssemblyScript SDK version must start with `sdk/assemblyscript/v`" && exit 1 - uses: actions/checkout@v4 with: ref: "${{ github.ref_name }}" @@ -30,7 +31,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ">=22" - registry-url: "https://registry.npmjs.org" + registry-url: https://registry.npmjs.org - name: Prepare Release working-directory: sdk/assemblyscript run: ./scripts/prepare-release.sh ${{ steps.parse_sdk_version.outputs.sdk_version }} @@ -39,7 +40,9 @@ jobs: run: npm ci - name: Publish NPM Package working-directory: sdk/assemblyscript/src - run: npm publish --provenance --access public --tag ${{ steps.parse_sdk_version.outputs.npm_tag }} + run: + npm publish --provenance --access public --tag ${{ steps.parse_sdk_version.outputs.npm_tag + }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Release diff --git a/.github/workflows/release-sdk-go.yaml b/.github/workflows/release-sdk-go.yaml index c04170f7f..091fd7c30 100644 --- a/.github/workflows/release-sdk-go.yaml +++ b/.github/workflows/release-sdk-go.yaml @@ -26,8 +26,8 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - cache-dependency-path: "./sdk/go/go.sum" - go-version-file: "./sdk/go/go.mod" + cache-dependency-path: ./sdk/go/go.sum + go-version-file: ./sdk/go/go.mod - name: Prepare Release working-directory: sdk/go run: ./scripts/prepare-release.sh ${{ steps.parse_sdk_version.outputs.sdk_version }} diff --git a/.markdownlint.json b/.markdownlint.json deleted file mode 100644 index f2d969fe0..000000000 --- a/.markdownlint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "default": true, - "MD013": false, - "MD034": false -} diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 000000000..15966d087 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,9 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml +tmp diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml new file mode 100644 index 000000000..98bf0cd2e --- /dev/null +++ b/.trunk/configs/.hadolint.yaml @@ -0,0 +1,4 @@ +# Following source doesn't work in most setups +ignored: + - SC1090 + - SC1091 diff --git a/.trunk/configs/.markdownlint.json b/.trunk/configs/.markdownlint.json new file mode 100644 index 000000000..449148d13 --- /dev/null +++ b/.trunk/configs/.markdownlint.json @@ -0,0 +1,8 @@ +{ + "line-length": { "line_length": 150, "tables": false }, + "no-inline-html": false, + "no-bare-urls": false, + "no-space-in-emphasis": false, + "no-emphasis-as-heading": false, + "first-line-heading": false +} diff --git a/.trunk/configs/.prettierrc b/.trunk/configs/.prettierrc new file mode 100644 index 000000000..7497b18d2 --- /dev/null +++ b/.trunk/configs/.prettierrc @@ -0,0 +1,6 @@ +{ + "plugins": ["assemblyscript-prettier"], + "semi": false, + "proseWrap": "always", + "printWidth": 100 +} diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 000000000..8c7b1ada8 --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 000000000..184e251f8 --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,7 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/cspell.json b/.trunk/configs/cspell.json similarity index 100% rename from cspell.json rename to .trunk/configs/cspell.json diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 000000000..8bd179c03 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,44 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml +version: 0.1 +cli: + version: 1.22.8 + +# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) +plugins: + sources: + - id: trunk + ref: v1.6.6 + uri: https://github.com/trunk-io/plugins + +# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) +runtimes: + enabled: + - go@1.23.4 + - node@18.20.5 + - python@3.10.8 + +# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) +lint: + enabled: + - actionlint@1.7.5 + - checkov@3.2.346 + - git-diff-check + - gofmt@1.20.4 + - golangci-lint@1.62.2 + - hadolint@2.12.1-beta + - markdownlint@0.43.0 + - osv-scanner@1.9.2 + - prettier@3.4.2: + packages: + - assemblyscript-prettier@3.0.1 + - shellcheck@0.10.0 + - shfmt@3.6.0 + - trufflehog@3.88.0 + - yamllint@1.35.1 +actions: + enabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + - trunk-upgrade-available diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 99c20c6bb..8327e8bd7 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,6 @@ { "recommendations": [ - "dbaeumer.vscode-eslint", - "DavidAnson.vscode-markdownlint", - "esbenp.prettier-vscode", + "trunk.io", "golang.go", "GraphQL.vscode-graphql", "ms-vscode.makefile-tools", diff --git a/.vscode/settings.json b/.vscode/settings.json index 27b021ddc..1daa81da5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,8 @@ { "cSpell.flagWords": ["teh", "hte"], "editor.formatOnSave": true, + "editor.defaultFormatter": "trunk.io", + "trunk.autoInit": false, "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "files.associations": { @@ -9,20 +11,7 @@ "*hypermode.json": "jsonc", "*modus.json": "jsonc" }, - "go.lintTool": "golangci-lint", "go.testEnvVars": { "MODUS_DEBUG": "true" - }, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[jsonc]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" } } diff --git a/CHANGELOG.md b/CHANGELOG.md index f722418af..0de2ca7be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,24 +6,30 @@ ## 2024-12-23 - Runtime 0.16.0 -- fix: unused imports should not be included in metadata [#657](https://github.com/hypermodeinc/modus/pull/657) +- fix: unused imports should not be included in metadata + [#657](https://github.com/hypermodeinc/modus/pull/657) - fix: update runtime wasm tests [#661](https://github.com/hypermodeinc/modus/pull/661) - fix: support TinyGo 0.35.0 [#662](https://github.com/hypermodeinc/modus/pull/662) -- feat: add APIs for local time and time zones [#663](https://github.com/hypermodeinc/modus/pull/663) +- feat: add APIs for local time and time zones + [#663](https://github.com/hypermodeinc/modus/pull/663) ## 2024-12-23 - Go SDK 0.16.0 - chore: lint example test [#656](https://github.com/hypermodeinc/modus/pull/656) -- fix: unused imports should not be included in metadata [#657](https://github.com/hypermodeinc/modus/pull/657) +- fix: unused imports should not be included in metadata + [#657](https://github.com/hypermodeinc/modus/pull/657) - fix: improve Go version handling [#660](https://github.com/hypermodeinc/modus/pull/660) - fix: update runtime wasm tests [#661](https://github.com/hypermodeinc/modus/pull/661) - fix: support TinyGo 0.35.0 [#662](https://github.com/hypermodeinc/modus/pull/662) -- feat: add APIs for local time and time zones [#663](https://github.com/hypermodeinc/modus/pull/663) +- feat: add APIs for local time and time zones + [#663](https://github.com/hypermodeinc/modus/pull/663) ## 2024-12-23 - AssemblyScript SDK 0.16.0 -- test: add tests for AssemblyScript SDK Transform [#659](https://github.com/hypermodeinc/modus/pull/659) -- feat: add APIs for local time and time zones [#663](https://github.com/hypermodeinc/modus/pull/663) +- test: add tests for AssemblyScript SDK Transform + [#659](https://github.com/hypermodeinc/modus/pull/659) +- feat: add APIs for local time and time zones + [#663](https://github.com/hypermodeinc/modus/pull/663) ## 2024-12-23 - CLI 0.16.0 @@ -31,48 +37,60 @@ ## 2024-12-13 - Runtime 0.15.0 -- fix: doc comments from object fields should be present in generated GraphQL schema [#630](https://github.com/hypermodeinc/modus/pull/630) +- fix: doc comments from object fields should be present in generated GraphQL schema + [#630](https://github.com/hypermodeinc/modus/pull/630) - feat: add neo4j support in modus [#636](https://github.com/hypermodeinc/modus/pull/636) - perf: improve locking code [#637](https://github.com/hypermodeinc/modus/pull/637) -- fix: make jwk conversion warn to remove sentry overflow [#641](https://github.com/hypermodeinc/modus/pull/641) +- fix: make jwk conversion warn to remove sentry overflow + [#641](https://github.com/hypermodeinc/modus/pull/641) - chore: update dockerfile [#642](https://github.com/hypermodeinc/modus/pull/642) ## 2024-12-13 - Go SDK 0.15.0 -- fix: vector package should return generic type in computations [#628](https://github.com/hypermodeinc/modus/pull/628) +- fix: vector package should return generic type in computations + [#628](https://github.com/hypermodeinc/modus/pull/628) - chore: Remove unused go package reference [#632](https://github.com/hypermodeinc/modus/pull/632) - feat: add neo4j support in modus [#636](https://github.com/hypermodeinc/modus/pull/636) - fix: support point types [#650](https://github.com/hypermodeinc/modus/pull/650) ## 2024-12-13 - AssemblyScript SDK 0.15.0 -- fix: vector package should return generic type in computations [#628](https://github.com/hypermodeinc/modus/pull/628) -- chore: Delete extraneous copy of Anthropic model interface [#631](https://github.com/hypermodeinc/modus/pull/631) +- fix: vector package should return generic type in computations + [#628](https://github.com/hypermodeinc/modus/pull/628) +- chore: Delete extraneous copy of Anthropic model interface + [#631](https://github.com/hypermodeinc/modus/pull/631) - feat: add neo4j support in modus [#636](https://github.com/hypermodeinc/modus/pull/636) - feat: Add `DynamicMap` type [#638](https://github.com/hypermodeinc/modus/pull/638) -- fix: Dgraph AssemblyScript example query issues [#643](https://github.com/hypermodeinc/modus/pull/643) -- fix: neo4j as type unmarshalling & support point types [#650](https://github.com/hypermodeinc/modus/pull/650) +- fix: Dgraph AssemblyScript example query issues + [#643](https://github.com/hypermodeinc/modus/pull/643) +- fix: neo4j as type unmarshalling & support point types + [#650](https://github.com/hypermodeinc/modus/pull/650) ## 2024-12-11 - CLI 0.15.0 -- feat: Support `MODUS_HOME` environment variable [#639](https://github.com/hypermodeinc/modus/pull/639) +- feat: Support `MODUS_HOME` environment variable + [#639](https://github.com/hypermodeinc/modus/pull/639) ## 2024-11-27 - CLI 0.14.0 -- fix: Lookup of 'latest' SDK when no Modus SDK is referenced [#625](https://github.com/hypermodeinc/modus/pull/625) +- fix: Lookup of 'latest' SDK when no Modus SDK is referenced + [#625](https://github.com/hypermodeinc/modus/pull/625) ## 2024-11-27 - Runtime 0.14.1 -- feat: updates to API explorer [#617](https://github.com/hypermodeinc/modus/pull/617) [#626](https://github.com/hypermodeinc/modus/pull/626) +- feat: updates to API explorer [#617](https://github.com/hypermodeinc/modus/pull/617) + [#626](https://github.com/hypermodeinc/modus/pull/626) - various dependency updates ## 2024-11-27 - AssemblyScript SDK 0.14.2 -- chore: Export base Message class in OpenAI chat SDK [#616](https://github.com/hypermodeinc/modus/pull/616) +- chore: Export base Message class in OpenAI chat SDK + [#616](https://github.com/hypermodeinc/modus/pull/616) ## 2024-11-27 - Go SDK 0.14.3 -- chore: Export base Message class in OpenAI chat SDK [#616](https://github.com/hypermodeinc/modus/pull/616) +- chore: Export base Message class in OpenAI chat SDK + [#616](https://github.com/hypermodeinc/modus/pull/616) - fix: Filter imports to modus host functions [#623](https://github.com/hypermodeinc/modus/pull/623) ## 2024-11-25 - Go SDK 0.14.2 @@ -82,16 +100,21 @@ ## 2024-11-25 - CLI 0.13.10 - fix: modus new rename branch to main if not [#613](https://github.com/hypermodeinc/modus/pull/613) -- fix: use git commit with double quotes for Windows [#612](https://github.com/hypermodeinc/modus/pull/612) +- fix: use git commit with double quotes for Windows + [#612](https://github.com/hypermodeinc/modus/pull/612) ## 2024-11-23 - Runtime 0.14.0 -- feat: Apply in-code documentation to generated GraphQL [#519](https://github.com/hypermodeinc/modus/pull/519) -- feat: Reduce logger output during development [#576](https://github.com/hypermodeinc/modus/pull/576) -- chore: Trigger internal release pipeline at the end of the release-runtime workflow [#577](https://github.com/hypermodeinc/modus/pull/577) +- feat: Apply in-code documentation to generated GraphQL + [#519](https://github.com/hypermodeinc/modus/pull/519) +- feat: Reduce logger output during development + [#576](https://github.com/hypermodeinc/modus/pull/576) +- chore: Trigger internal release pipeline at the end of the release-runtime workflow + [#577](https://github.com/hypermodeinc/modus/pull/577) - feat: Add API explorer to runtime [#578](https://github.com/hypermodeinc/modus/pull/578) - feat: Add API explorer component to runtime [#584](https://github.com/hypermodeinc/modus/pull/584) -- fix: logic for jwks endpoint unmarshalling was incorrect [#594](https://github.com/hypermodeinc/modus/pull/594) +- fix: logic for jwks endpoint unmarshalling was incorrect + [#594](https://github.com/hypermodeinc/modus/pull/594) - chore: Refactoring schema generation [#605](https://github.com/hypermodeinc/modus/pull/605) ## 2024-11-23 - AssemblyScript SDK 0.14.1 @@ -112,52 +135,72 @@ ## 2024-11-20 - CLI 0.13.9 -- feat: use user provided name for package.json and go.mod [#595](https://github.com/hypermodeinc/modus/pull/595) -- feat: Add scarf to track installs and modus new [#596](https://github.com/hypermodeinc/modus/pull/596) +- feat: use user provided name for package.json and go.mod + [#595](https://github.com/hypermodeinc/modus/pull/595) +- feat: Add scarf to track installs and modus new + [#596](https://github.com/hypermodeinc/modus/pull/596) ## 2024-11-18 - AssemblyScript SDK 0.13.5 -- Update json-as to `0.9.26` to fix stack overflow error [#586](https://github.com/hypermodeinc/modus/pull/586) +- Update json-as to `0.9.26` to fix stack overflow error + [#586](https://github.com/hypermodeinc/modus/pull/586) - Updated various other dependencies ## 2024-11-08 - CLI 0.13.8 -- fix: Make `modus --version` just print modus CLI's version [#563](https://github.com/hypermodeinc/modus/pull/563) -- fix: implement retry and caching for CLI downloads [#571](https://github.com/hypermodeinc/modus/pull/571) [#574](https://github.com/hypermodeinc/modus/pull/574) +- fix: Make `modus --version` just print modus CLI's version + [#563](https://github.com/hypermodeinc/modus/pull/563) +- fix: implement retry and caching for CLI downloads + [#571](https://github.com/hypermodeinc/modus/pull/571) + [#574](https://github.com/hypermodeinc/modus/pull/574) ## 2024-11-08 - Runtime 0.13.2 -- fix: Introspection query should succeed when only mutations exist [#558](https://github.com/hypermodeinc/modus/pull/558) -- ci: Add `secrets: inherit` when calling release-info workflow [#555](https://github.com/hypermodeinc/modus/pull/555) +- fix: Introspection query should succeed when only mutations exist + [#558](https://github.com/hypermodeinc/modus/pull/558) +- ci: Add `secrets: inherit` when calling release-info workflow + [#555](https://github.com/hypermodeinc/modus/pull/555) - chore: Refactor metadata dependencies [#564](https://github.com/hypermodeinc/modus/pull/564) -- chore: Use Go workspace to simplify project dependencies [#565](https://github.com/hypermodeinc/modus/pull/565) -- fix: "WASM Host not found in context" error on shutdown [#566](https://github.com/hypermodeinc/modus/pull/566) -- fix: `__typename` should succeed on root fields [#573](https://github.com/hypermodeinc/modus/pull/573) +- chore: Use Go workspace to simplify project dependencies + [#565](https://github.com/hypermodeinc/modus/pull/565) +- fix: "WASM Host not found in context" error on shutdown + [#566](https://github.com/hypermodeinc/modus/pull/566) +- fix: `__typename` should succeed on root fields + [#573](https://github.com/hypermodeinc/modus/pull/573) ## 2024-11-06 - AssemblyScript SDK 0.13.4 -- fix: Don't empty previous contents of build dir [#568](https://github.com/hypermodeinc/modus/pull/568) +- fix: Don't empty previous contents of build dir + [#568](https://github.com/hypermodeinc/modus/pull/568) ## 2024-11-04 - CLI 0.13.7 -- Automatically generate and push releases info to R2 bucket on every release [#526](https://github.com/hypermodeinc/modus/pull/526) -- Consistent help + print enum options + validate SDK prereq [#542](https://github.com/hypermodeinc/modus/pull/542) +- Automatically generate and push releases info to R2 bucket on every release + [#526](https://github.com/hypermodeinc/modus/pull/526) +- Consistent help + print enum options + validate SDK prereq + [#542](https://github.com/hypermodeinc/modus/pull/542) - Consistent padding in the help section - `modus new`: Enum options need to print possible options - Validate SDK prereq immediately after choosing SDK - `modus sdk remove`: Use select prompt to allow selection -- For CLI to track non-prereleases, pull from releases json to remove rate limiting issues from github releases [#543](https://github.com/hypermodeinc/modus/pull/543) -- Modify isOnline in CLI to query releases.json [#544](https://github.com/hypermodeinc/modus/pull/544) -- remove all github api call references, add prerelease support to CLI [#545](https://github.com/hypermodeinc/modus/pull/545) +- For CLI to track non-prereleases, pull from releases json to remove rate limiting issues from + github releases [#543](https://github.com/hypermodeinc/modus/pull/543) +- Modify isOnline in CLI to query releases.json + [#544](https://github.com/hypermodeinc/modus/pull/544) +- remove all github api call references, add prerelease support to CLI + [#545](https://github.com/hypermodeinc/modus/pull/545) - Add CLI build CI [#547](https://github.com/hypermodeinc/modus/pull/547) - Add CLI Lint CI [#550](https://github.com/hypermodeinc/modus/pull/550) - Update installer script [#551](https://github.com/hypermodeinc/modus/pull/551) ## 2024-10-30 - CLI 0.13.6 -- `modus new`: Initialize git repo on interactive flow [#538](https://github.com/hypermodeinc/modus/pull/538) -- `modus new`: Skip confirmation if all required params are provided [#539](https://github.com/hypermodeinc/modus/pull/539) -- `modus new`: Fix issues with Go/TinyGo version detection [#540](https://github.com/hypermodeinc/modus/pull/540) +- `modus new`: Initialize git repo on interactive flow + [#538](https://github.com/hypermodeinc/modus/pull/538) +- `modus new`: Skip confirmation if all required params are provided + [#539](https://github.com/hypermodeinc/modus/pull/539) +- `modus new`: Fix issues with Go/TinyGo version detection + [#540](https://github.com/hypermodeinc/modus/pull/540) ## 2024-10-30 - AssemblyScript SDK 0.13.3 @@ -169,7 +212,8 @@ ## 2024-10-30 - Runtime 0.13.1 -- Add env file callback support for auth key reloading [#520](https://github.com/hypermodeinc/modus/pull/520) +- Add env file callback support for auth key reloading + [#520](https://github.com/hypermodeinc/modus/pull/520) - Fix timestamp parsing bug [#527](https://github.com/hypermodeinc/modus/pull/527) ## 2024-10-30 - Go/AS SDKs 0.13.1 @@ -182,7 +226,8 @@ ## 2024-10-29 - CLI 0.13.4 -- `modus build` should install SDK if not already installed [#524](https://github.com/hypermodeinc/modus/pull/524) +- `modus build` should install SDK if not already installed + [#524](https://github.com/hypermodeinc/modus/pull/524) ## 2024-10-29 - CLI 0.13.3 @@ -202,66 +247,90 @@ _NOTE: This is the first fully open-source release, using the name "Modus" for t "Hypermode" still refers to the company and the commercial hosting platform - but not the framework. In previous releases, the name "Hypermode" was used for all three._ -- Add Modus CLI [#389](https://github.com/hypermodeinc/modus/pull/389) [#483](https://github.com/hypermodeinc/modus/pull/483) [#484](https://github.com/hypermodeinc/modus/pull/484) [#485](https://github.com/hypermodeinc/modus/pull/485) -- Support user defined jwt auth and sdk functions [#405](https://github.com/hypermodeinc/modus/pull/405) +- Add Modus CLI [#389](https://github.com/hypermodeinc/modus/pull/389) + [#483](https://github.com/hypermodeinc/modus/pull/483) + [#484](https://github.com/hypermodeinc/modus/pull/484) + [#485](https://github.com/hypermodeinc/modus/pull/485) +- Support user defined jwt auth and sdk functions + [#405](https://github.com/hypermodeinc/modus/pull/405) - Migrate from Hypermode to Modus [#412](https://github.com/hypermodeinc/modus/pull/412) - Import WasmExtractor code [#415](https://github.com/hypermodeinc/modus/pull/415) - Import Manifest code [#416](https://github.com/hypermodeinc/modus/pull/416) - Update the runtime's manifest usage [#417](https://github.com/hypermodeinc/modus/pull/417) - Add Modus Go SDK [#418](https://github.com/hypermodeinc/modus/pull/418) - Add Local Model Invocation Support [#421](https://github.com/hypermodeinc/modus/pull/421) -- Remove HTTP Timeout, Add Context Timeout on Collections [#422](https://github.com/hypermodeinc/modus/pull/422) +- Remove HTTP Timeout, Add Context Timeout on Collections + [#422](https://github.com/hypermodeinc/modus/pull/422) - Add Modus AssemblyScript SDK [#423](https://github.com/hypermodeinc/modus/pull/423) - Add models to Modus AssemblyScript SDK [#428](https://github.com/hypermodeinc/modus/pull/428) - Add Vectors SDK support [#431](https://github.com/hypermodeinc/modus/pull/431) - Update Readme files [#432](https://github.com/hypermodeinc/modus/pull/432) -- Fix vulnerability in AssemblyScript SDK install script [#435](https://github.com/hypermodeinc/modus/pull/435) -- Fix potential array out of bounds in the runtime [#437](https://github.com/hypermodeinc/modus/pull/437) +- Fix vulnerability in AssemblyScript SDK install script + [#435](https://github.com/hypermodeinc/modus/pull/435) +- Fix potential array out of bounds in the runtime + [#437](https://github.com/hypermodeinc/modus/pull/437) - Set minimum Go version to 1.23.0 [#438](https://github.com/hypermodeinc/modus/pull/438) - Change default for environment setting [#439](https://github.com/hypermodeinc/modus/pull/439) -- Remove compatibility code for previous versions [#441](https://github.com/hypermodeinc/modus/pull/441) +- Remove compatibility code for previous versions + [#441](https://github.com/hypermodeinc/modus/pull/441) - Target Node 22 [#446](https://github.com/hypermodeinc/modus/pull/446) - Fix object/map field stitching [#447](https://github.com/hypermodeinc/modus/pull/447) -- Use cli component instead of direct node execution modus-sdk-as [#448](https://github.com/hypermodeinc/modus/pull/448) +- Use cli component instead of direct node execution modus-sdk-as + [#448](https://github.com/hypermodeinc/modus/pull/448) - Cleanup Go Modules [#450](https://github.com/hypermodeinc/modus/pull/450) - Modularize / Rename host functions [#452](https://github.com/hypermodeinc/modus/pull/452) -- Add release pipeline for the runtime [#453](https://github.com/hypermodeinc/modus/pull/453) [#454](https://github.com/hypermodeinc/modus/pull/454) +- Add release pipeline for the runtime [#453](https://github.com/hypermodeinc/modus/pull/453) + [#454](https://github.com/hypermodeinc/modus/pull/454) - Remove `go generate` and fix docker build [#455](https://github.com/hypermodeinc/modus/pull/455) - Remove AWS Secrets Manager client [#456](https://github.com/hypermodeinc/modus/pull/456) - Make app path required [#457](https://github.com/hypermodeinc/modus/pull/457) - Improve `.env` file handling [#458](https://github.com/hypermodeinc/modus/pull/458) - Update command-line args and env variables [#459](https://github.com/hypermodeinc/modus/pull/459) - Update Sentry telemetry collection rules [#460](https://github.com/hypermodeinc/modus/pull/460) -- Fix entry alignment issue with AssemblyScript maps [#461](https://github.com/hypermodeinc/modus/pull/461) +- Fix entry alignment issue with AssemblyScript maps + [#461](https://github.com/hypermodeinc/modus/pull/461) - Update to use new Modus manifest [#462](https://github.com/hypermodeinc/modus/pull/462) -- Enable GraphQL endpoints to be defined in the manifest [#464](https://github.com/hypermodeinc/modus/pull/464) -- Publish SDKs and templates via release workflows [#465](https://github.com/hypermodeinc/modus/pull/465) -- Fix AssemblyScript build failure when no Git repo is present [#475](https://github.com/hypermodeinc/modus/pull/475) +- Enable GraphQL endpoints to be defined in the manifest + [#464](https://github.com/hypermodeinc/modus/pull/464) +- Publish SDKs and templates via release workflows + [#465](https://github.com/hypermodeinc/modus/pull/465) +- Fix AssemblyScript build failure when no Git repo is present + [#475](https://github.com/hypermodeinc/modus/pull/475) - Disable AWS Bedrock support temporarily [#479](https://github.com/hypermodeinc/modus/pull/479) - Update SDK releases [#480](https://github.com/hypermodeinc/modus/pull/480) - Add metadata shared library [#482](https://github.com/hypermodeinc/modus/pull/482) - Add `.gitignore` files to default templates [#486](https://github.com/hypermodeinc/modus/pull/486) -- Fix CLI warnings about Go/TinyGo installation [#487](https://github.com/hypermodeinc/modus/pull/487) +- Fix CLI warnings about Go/TinyGo installation + [#487](https://github.com/hypermodeinc/modus/pull/487) - Remove deprecated model fields [#488](https://github.com/hypermodeinc/modus/pull/488) - Improve dev first use log messages [#489](https://github.com/hypermodeinc/modus/pull/489) - Highlight endpoints when running in dev [#490](https://github.com/hypermodeinc/modus/pull/490) - Fix data race in logging adapter [#491](https://github.com/hypermodeinc/modus/pull/491) - Add Anthropic model interface to the Go SDK [#493](https://github.com/hypermodeinc/modus/pull/493) - Simplify and polish `modus new` experience [#494](https://github.com/hypermodeinc/modus/pull/494) -- Move hyp settings for local model invocation to env variables [#495](https://github.com/hypermodeinc/modus/pull/495) [#504](https://github.com/hypermodeinc/modus/pull/504) -- Change GraphQL SDK examples to use a generic public GraphQL API [#501](https://github.com/hypermodeinc/modus/pull/501) -- Improve file watching and fix Windows issues [#505](https://github.com/hypermodeinc/modus/pull/505) -- Improve help messages, add `modus info` and show SDK version in `modus new` [#506](https://github.com/hypermodeinc/modus/pull/506) -- Fix runtime shutdown issues with `modus dev` [#508](https://github.com/hypermodeinc/modus/pull/508) -- Monitored manifest and env files for changes [#509](https://github.com/hypermodeinc/modus/pull/509) +- Move hyp settings for local model invocation to env variables + [#495](https://github.com/hypermodeinc/modus/pull/495) + [#504](https://github.com/hypermodeinc/modus/pull/504) +- Change GraphQL SDK examples to use a generic public GraphQL API + [#501](https://github.com/hypermodeinc/modus/pull/501) +- Improve file watching and fix Windows issues + [#505](https://github.com/hypermodeinc/modus/pull/505) +- Improve help messages, add `modus info` and show SDK version in `modus new` + [#506](https://github.com/hypermodeinc/modus/pull/506) +- Fix runtime shutdown issues with `modus dev` + [#508](https://github.com/hypermodeinc/modus/pull/508) +- Monitored manifest and env files for changes + [#509](https://github.com/hypermodeinc/modus/pull/509) - Log bad GraphQL requests in dev [#510](https://github.com/hypermodeinc/modus/pull/510) - Add JWKS endpoint key support to auth [#511](https://github.com/hypermodeinc/modus/pull/511) -- Use conventions to support GraphQL mutations and adjust query names [#513](https://github.com/hypermodeinc/modus/pull/513) +- Use conventions to support GraphQL mutations and adjust query names + [#513](https://github.com/hypermodeinc/modus/pull/513) ## 2024-10-02 - Version 0.12.7 - Use reader-writer lock on AWS secrets cache [#400](https://github.com/hypermodeinc/modus/pull/400) -- Improve bucket layout for FunctionExecutionDurationMilliseconds metric and add function_name label [#401](https://github.com/hypermodeinc/modus/pull/401) +- Improve bucket layout for FunctionExecutionDurationMilliseconds metric and add function_name label + [#401](https://github.com/hypermodeinc/modus/pull/401) - Improve JSON performance [#402](https://github.com/hypermodeinc/modus/pull/402) - Misc performance improvements [#403](https://github.com/hypermodeinc/modus/pull/403) - Fix error on void response [#404](https://github.com/hypermodeinc/modus/pull/404) @@ -269,11 +338,13 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-09-26 - Version 0.12.6 -- Revert #393 and #396, then apply correct fix for field alignment issue [#397](https://github.com/hypermodeinc/modus/pull/397) +- Revert #393 and #396, then apply correct fix for field alignment issue + [#397](https://github.com/hypermodeinc/modus/pull/397) ## 2024-09-26 - Version 0.12.5 -- Fix AssemblyScript error unpinning objects from memory [#396](https://github.com/hypermodeinc/modus/pull/396) +- Fix AssemblyScript error unpinning objects from memory + [#396](https://github.com/hypermodeinc/modus/pull/396) ## 2024-09-26 - Version 0.12.4 @@ -282,17 +353,21 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-09-26 - Version 0.12.3 -- Arrays in collections host functions should be non-nil [#384](https://github.com/hypermodeinc/modus/pull/384) +- Arrays in collections host functions should be non-nil + [#384](https://github.com/hypermodeinc/modus/pull/384) - Update error handling for function calls [#385](https://github.com/hypermodeinc/modus/pull/385) -- Fix array-like types passed via interface wrappers [#386](https://github.com/hypermodeinc/modus/pull/386) -- Cast slice values to handle json.Number and others [#387](https://github.com/hypermodeinc/modus/pull/387) +- Fix array-like types passed via interface wrappers + [#386](https://github.com/hypermodeinc/modus/pull/386) +- Cast slice values to handle json.Number and others + [#387](https://github.com/hypermodeinc/modus/pull/387) - Trap JSON unsupported value errors [#388](https://github.com/hypermodeinc/modus/pull/388) - Adjust Sentry transactions [#390](https://github.com/hypermodeinc/modus/pull/390) ## 2024-09-24 - Version 0.12.2 - Fix missing GraphQL type schema [#376](https://github.com/hypermodeinc/modus/pull/376) -- Add FunctionExecutionDurationMillisecondsSummary metric [#377](https://github.com/hypermodeinc/modus/pull/377) +- Add FunctionExecutionDurationMillisecondsSummary metric + [#377](https://github.com/hypermodeinc/modus/pull/377) - Fix field alignment issue [#378](https://github.com/hypermodeinc/modus/pull/378) - Improve execution plan creation [#379](https://github.com/hypermodeinc/modus/pull/379) - Fix plan creation / registration bug [#380](https://github.com/hypermodeinc/modus/pull/380) @@ -300,17 +375,23 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-09-18 - Version 0.12.1 - Fix panic from Go maps with primitive types [#370](https://github.com/hypermodeinc/modus/pull/370) -- Fix error when using a map as an input parameter [#373](https://github.com/hypermodeinc/modus/pull/373) +- Fix error when using a map as an input parameter + [#373](https://github.com/hypermodeinc/modus/pull/373) - Fix errors related to nil slices [#374](https://github.com/hypermodeinc/modus/pull/374) ## 2024-09-16 - Version 0.12.0 -- Add language support for Hypermode Go SDK [#317](https://github.com/hypermodeinc/modus/pull/317) [#351](https://github.com/hypermodeinc/modus/pull/351) [#352](https://github.com/hypermodeinc/modus/pull/352) -- Major refactoring to support multiple guest languages [#347](https://github.com/hypermodeinc/modus/pull/347) +- Add language support for Hypermode Go SDK [#317](https://github.com/hypermodeinc/modus/pull/317) + [#351](https://github.com/hypermodeinc/modus/pull/351) + [#352](https://github.com/hypermodeinc/modus/pull/352) +- Major refactoring to support multiple guest languages + [#347](https://github.com/hypermodeinc/modus/pull/347) - Rename `hmruntime` to `hypruntime` [#348](https://github.com/hypermodeinc/modus/pull/348) - Make empty dgraph responses nil [#355](https://github.com/hypermodeinc/modus/pull/355) -- Support objects as parameters to functions via GraphQL input types [#359](https://github.com/hypermodeinc/modus/pull/359) -- Fix GraphQL schema generation for Go functions [#360](https://github.com/hypermodeinc/modus/pull/360) +- Support objects as parameters to functions via GraphQL input types + [#359](https://github.com/hypermodeinc/modus/pull/359) +- Fix GraphQL schema generation for Go functions + [#360](https://github.com/hypermodeinc/modus/pull/360) - Add getLabel to collection host functions [#361](https://github.com/hypermodeinc/modus/pull/361) - Fix import registration issue [#364](https://github.com/hypermodeinc/modus/pull/364) - Fix conversion of empty arrays and slices [#365](https://github.com/hypermodeinc/modus/pull/365) @@ -318,8 +399,10 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-08-27 - Version 0.11.2 -- Refactor dgraph host functions to use single execute host function [#342](https://github.com/hypermodeinc/modus/pull/342) -- Add vector retrieval and search by vector to collections [#343](https://github.com/hypermodeinc/modus/pull/343) +- Refactor dgraph host functions to use single execute host function + [#342](https://github.com/hypermodeinc/modus/pull/342) +- Add vector retrieval and search by vector to collections + [#343](https://github.com/hypermodeinc/modus/pull/343) ## 2024-08-16 - Version 0.11.1 @@ -328,75 +411,105 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-08-12 - Version 0.11.0 -- Perf improvements to internal storage of hnsw data in Collections [#299](https://github.com/hypermodeinc/modus/pull/299) -- Fix type resolution issues [#304](https://github.com/hypermodeinc/modus/pull/304) [#306](https://github.com/hypermodeinc/modus/pull/306) -- Implement nearest neighbor classification in Collections [#305](https://github.com/hypermodeinc/modus/pull/305) +- Perf improvements to internal storage of hnsw data in Collections + [#299](https://github.com/hypermodeinc/modus/pull/299) +- Fix type resolution issues [#304](https://github.com/hypermodeinc/modus/pull/304) + [#306](https://github.com/hypermodeinc/modus/pull/306) +- Implement nearest neighbor classification in Collections + [#305](https://github.com/hypermodeinc/modus/pull/305) - Fix certain errors reporting incorrectly [#307](https://github.com/hypermodeinc/modus/pull/307) -- Improve encoding and decoding of arrays and maps [#308](https://github.com/hypermodeinc/modus/pull/308) +- Improve encoding and decoding of arrays and maps + [#308](https://github.com/hypermodeinc/modus/pull/308) - Listen on both IPv4 and IPv6 for localhost [#309](https://github.com/hypermodeinc/modus/pull/309) -- Warn instead of error on some db connection failures [#310](https://github.com/hypermodeinc/modus/pull/310) -- Modularize language-specific features [#314](https://github.com/hypermodeinc/modus/pull/314) [#325](https://github.com/hypermodeinc/modus/pull/325) +- Warn instead of error on some db connection failures + [#310](https://github.com/hypermodeinc/modus/pull/310) +- Modularize language-specific features [#314](https://github.com/hypermodeinc/modus/pull/314) + [#325](https://github.com/hypermodeinc/modus/pull/325) - Fix error reporting with host functions [#318](https://github.com/hypermodeinc/modus/pull/318) -- Log cancellations and host function activity [#320](https://github.com/hypermodeinc/modus/pull/320) -- Add namespaces to collections to isolate storage [#321](https://github.com/hypermodeinc/modus/pull/321) -- Use more direct approach for registering host functions [#322](https://github.com/hypermodeinc/modus/pull/322) [#326](https://github.com/hypermodeinc/modus/pull/326) [#327](https://github.com/hypermodeinc/modus/pull/327) -- Add getNamespaces host function for collections [#324](https://github.com/hypermodeinc/modus/pull/324) +- Log cancellations and host function activity + [#320](https://github.com/hypermodeinc/modus/pull/320) +- Add namespaces to collections to isolate storage + [#321](https://github.com/hypermodeinc/modus/pull/321) +- Use more direct approach for registering host functions + [#322](https://github.com/hypermodeinc/modus/pull/322) + [#326](https://github.com/hypermodeinc/modus/pull/326) + [#327](https://github.com/hypermodeinc/modus/pull/327) +- Add getNamespaces host function for collections + [#324](https://github.com/hypermodeinc/modus/pull/324) - Add cross namespace search to collections [#330](https://github.com/hypermodeinc/modus/pull/330) ## 2024-07-23 - Version 0.10.1 - Add HNSW indexing for collection [#285](https://github.com/hypermodeinc/modus/pull/285) -- Use default parameter value in metadata if it exists [#286](https://github.com/hypermodeinc/modus/pull/286) -- Fix memory corruption issue with multiple input parameters [#288](https://github.com/hypermodeinc/modus/pull/288) +- Use default parameter value in metadata if it exists + [#286](https://github.com/hypermodeinc/modus/pull/286) +- Fix memory corruption issue with multiple input parameters + [#288](https://github.com/hypermodeinc/modus/pull/288) ## 2024-07-15 - Version 0.10.0 - Update manifest library and usage [#275](https://github.com/hypermodeinc/modus/pull/275) - Support pointers when marshalling objects [#277](https://github.com/hypermodeinc/modus/pull/277) - Add support for PostgreSQL host functions [#278](https://github.com/hypermodeinc/modus/pull/278) -- Fix dbpool reading after failed initialization [#281](https://github.com/hypermodeinc/modus/pull/281) +- Fix dbpool reading after failed initialization + [#281](https://github.com/hypermodeinc/modus/pull/281) - Update for metadata changes [#282](https://github.com/hypermodeinc/modus/pull/282) - Store function info with inference history [#283](https://github.com/hypermodeinc/modus/pull/283) -- Fix issues with GraphQL block quotes [wundergraph/graphql-go-tools/843](https://github.com/wundergraph/graphql-go-tools/pull/843) +- Fix issues with GraphQL block quotes + [wundergraph/graphql-go-tools/843](https://github.com/wundergraph/graphql-go-tools/pull/843) ## 2024-07-09 - Version 0.9.5 -- Use anonymous wasm modules for better performance [#264](https://github.com/hypermodeinc/modus/pull/264) -- Assume normalized vectors when calculating cosine similarity [#265](https://github.com/hypermodeinc/modus/pull/265) +- Use anonymous wasm modules for better performance + [#264](https://github.com/hypermodeinc/modus/pull/264) +- Assume normalized vectors when calculating cosine similarity + [#265](https://github.com/hypermodeinc/modus/pull/265) - Support optional parameters [#269](https://github.com/hypermodeinc/modus/pull/269) - Handle null parameters [#270](https://github.com/hypermodeinc/modus/pull/2270) ## 2024-06-26 - Version 0.9.4 -- Increase batch size for auto-embedding collection texts [#259](https://github.com/hypermodeinc/modus/pull/259) -- Fix error with multiline input in GraphQL query [#260](https://github.com/hypermodeinc/modus/pull/260) +- Increase batch size for auto-embedding collection texts + [#259](https://github.com/hypermodeinc/modus/pull/259) +- Fix error with multiline input in GraphQL query + [#260](https://github.com/hypermodeinc/modus/pull/260) ## 2024-06-25 - Version 0.9.3 -- Don't panic when the metadata DB is not configured [#256](https://github.com/hypermodeinc/modus/pull/256) -- Don't panic when collections are renamed or deleted [#257](https://github.com/hypermodeinc/modus/pull/257) +- Don't panic when the metadata DB is not configured + [#256](https://github.com/hypermodeinc/modus/pull/256) +- Don't panic when collections are renamed or deleted + [#257](https://github.com/hypermodeinc/modus/pull/257) ## 2024-06-24 - Version 0.9.2 -- Add auto-embedding for collection based on text checkpoint [#250](https://github.com/hypermodeinc/modus/pull/250) +- Add auto-embedding for collection based on text checkpoint + [#250](https://github.com/hypermodeinc/modus/pull/250) - Remove extraneous types in graphql schemas [#251](https://github.com/hypermodeinc/modus/pull/251) - Allow arrays as inputs to host functions [#252](https://github.com/hypermodeinc/modus/pull/252) -- Add batch upsert & batch recompute for collection & on auto-embedding [#253](https://github.com/hypermodeinc/modus/pull/253) +- Add batch upsert & batch recompute for collection & on auto-embedding + [#253](https://github.com/hypermodeinc/modus/pull/253) ## 2024-06-22 - Version 0.9.1 -- Filter collection embedding functions from GraphQL schema [#245](https://github.com/hypermodeinc/modus/pull/245) -- Remove collection index from memory when manifest changes [#246](https://github.com/hypermodeinc/modus/pull/246) -- Fix missing execution id and plugin from logs from previous functions version [#247](https://github.com/hypermodeinc/modus/pull/247) -- Fix content type header when calling Hypermode-hosted models [#248](https://github.com/hypermodeinc/modus/pull/248) +- Filter collection embedding functions from GraphQL schema + [#245](https://github.com/hypermodeinc/modus/pull/245) +- Remove collection index from memory when manifest changes + [#246](https://github.com/hypermodeinc/modus/pull/246) +- Fix missing execution id and plugin from logs from previous functions version + [#247](https://github.com/hypermodeinc/modus/pull/247) +- Fix content type header when calling Hypermode-hosted models + [#248](https://github.com/hypermodeinc/modus/pull/248) ## 2024-06-21 - Version 0.9.0 - Add nullable check in ReadString [#228](https://github.com/hypermodeinc/modus/pull/228) -- Lowercase model name before invoking for hypermode hosted models [#221](https://github.com/hypermodeinc/modus/pull/221) +- Lowercase model name before invoking for hypermode hosted models + [#221](https://github.com/hypermodeinc/modus/pull/221) - Improve HTTP error messages [#222](https://github.com/hypermodeinc/modus/pull/222) - Add host function for direct logging [#224](https://github.com/hypermodeinc/modus/pull/224) -- Refactoring, and add helpers for calling functions [#226](https://github.com/hypermodeinc/modus/pull/226) +- Refactoring, and add helpers for calling functions + [#226](https://github.com/hypermodeinc/modus/pull/226) - Add support for new model interface [#229](https://github.com/hypermodeinc/modus/pull/229) - Add sequential vector search [#240](https://github.com/hypermodeinc/modus/pull/240) - Update Hypermode-hosted model endpoint URL [#242](https://github.com/hypermodeinc/modus/pull/242) @@ -404,63 +517,84 @@ In previous releases, the name "Hypermode" was used for all three._ ## 2024-06-03 - Version 0.8.2 -- Send backend ID with Sentry events [#211](https://github.com/hypermodeinc/modus/pull/211) [#213](https://github.com/hypermodeinc/modus/pull/213) +- Send backend ID with Sentry events [#211](https://github.com/hypermodeinc/modus/pull/211) + [#213](https://github.com/hypermodeinc/modus/pull/213) - Add some logging for secrets [#212](https://github.com/hypermodeinc/modus/pull/212) - Update logging to include Runtime version [#215](https://github.com/hypermodeinc/modus/pull/215) ## 2024-05-30 - Version 0.8.1 -- Fix compatibility with v1 `authHeader` secret [#208](https://github.com/hypermodeinc/modus/pull/208) -- Fix double-escaped JSON in OpenAI inference history [#209](https://github.com/hypermodeinc/modus/pull/209) +- Fix compatibility with v1 `authHeader` secret + [#208](https://github.com/hypermodeinc/modus/pull/208) +- Fix double-escaped JSON in OpenAI inference history + [#209](https://github.com/hypermodeinc/modus/pull/209) ## 2024-05-29 - Version 0.8.0 - Add Model Inference History to runtime [#186](https://github.com/hypermodeinc/modus/pull/186) -- Pass auth headers correctly when invoking a GraphQL API [#196](https://github.com/hypermodeinc/modus/pull/196) -- Use shared manifest module to read `hypermode.json` [#199](https://github.com/hypermodeinc/modus/pull/199) -- Pass HTTP auth secrets using v2 manifest format [#203](https://github.com/hypermodeinc/modus/pull/203) [#205](https://github.com/hypermodeinc/modus/pull/205) +- Pass auth headers correctly when invoking a GraphQL API + [#196](https://github.com/hypermodeinc/modus/pull/196) +- Use shared manifest module to read `hypermode.json` + [#199](https://github.com/hypermodeinc/modus/pull/199) +- Pass HTTP auth secrets using v2 manifest format + [#203](https://github.com/hypermodeinc/modus/pull/203) + [#205](https://github.com/hypermodeinc/modus/pull/205) ## 2024-05-13 - Version 0.7.0 -- Sentry is no longer used when `HYPERMODE_DEBUG` is enabled [#187](https://github.com/hypermodeinc/modus/pull/187) -- Only listen on `localhost` when `HYPERMODE_DEBUG` is enabled, to prevent firewall prompt [#188](https://github.com/hypermodeinc/modus/pull/188) -- Improve support for marshaling classes [#189](https://github.com/hypermodeinc/modus/pull/189) [#191](https://github.com/hypermodeinc/modus/pull/191) +- Sentry is no longer used when `HYPERMODE_DEBUG` is enabled + [#187](https://github.com/hypermodeinc/modus/pull/187) +- Only listen on `localhost` when `HYPERMODE_DEBUG` is enabled, to prevent firewall prompt + [#188](https://github.com/hypermodeinc/modus/pull/188) +- Improve support for marshaling classes [#189](https://github.com/hypermodeinc/modus/pull/189) + [#191](https://github.com/hypermodeinc/modus/pull/191) - Add support for binary data fields [#190](https://github.com/hypermodeinc/modus/pull/190) - Add host function for HTTP fetch [#191](https://github.com/hypermodeinc/modus/pull/191) ## 2024-05-08 - Version 0.6.6 -- Remove `Access-Control-Allow-Credentials`. Add `Access-Control-Request-Headers` [#180](https://github.com/hypermodeinc/modus/pull/180) +- Remove `Access-Control-Allow-Credentials`. Add `Access-Control-Request-Headers` + [#180](https://github.com/hypermodeinc/modus/pull/180) - Restrict incoming http requests methods [#182](https://github.com/hypermodeinc/modus/pull/182) ## 2024-05-07 - Version 0.6.5 -- Add `Access-Control-Allow-Credentials` in CORS preflight [#177](https://github.com/hypermodeinc/modus/pull/177) +- Add `Access-Control-Allow-Credentials` in CORS preflight + [#177](https://github.com/hypermodeinc/modus/pull/177) ## 2024-05-03 - Version 0.6.4 - Add CORS support to all endpoints [#171](https://github.com/hypermodeinc/modus/pull/171) -- Replace hyphens with underscores in environment variables [#172](https://github.com/hypermodeinc/modus/pull/172) -- Allow comments and trailing commas in `hypermode.json` [#173](https://github.com/hypermodeinc/modus/pull/173) +- Replace hyphens with underscores in environment variables + [#172](https://github.com/hypermodeinc/modus/pull/172) +- Allow comments and trailing commas in `hypermode.json` + [#173](https://github.com/hypermodeinc/modus/pull/173) ## 2024-05-02 - Version 0.6.3 - Update metrics collection to remove labels [#163](https://github.com/hypermodeinc/modus/pull/163) -- Add environment and version to health endpoint [#164](https://github.com/hypermodeinc/modus/pull/164) -- Capture function execution duration in metrics [#165](https://github.com/hypermodeinc/modus/pull/165) +- Add environment and version to health endpoint + [#164](https://github.com/hypermodeinc/modus/pull/164) +- Capture function execution duration in metrics + [#165](https://github.com/hypermodeinc/modus/pull/165) ## 2024-04-29 - Version 0.6.2 -- Traces and non-user errors are now sent to Sentry [#158](https://github.com/hypermodeinc/modus/issues/158) +- Traces and non-user errors are now sent to Sentry + [#158](https://github.com/hypermodeinc/modus/issues/158) - Fix OpenAI text generation [#161](https://github.com/hypermodeinc/modus/issues/161) ## 2024-04-26 - Version 0.6.1 -- Fix GraphQL error when resulting data contains a nested null field [#150](https://github.com/hypermodeinc/modus/issues/150) -- Fix GraphQL error when resolving `__typename` fields; also add `HYPERMODE_TRACE` debugging flag [#151](https://github.com/hypermodeinc/modus/issues/151) -- Collect metrics and expose metrics and health endpoints [#152](https://github.com/hypermodeinc/modus/issues/152) +- Fix GraphQL error when resulting data contains a nested null field + [#150](https://github.com/hypermodeinc/modus/issues/150) +- Fix GraphQL error when resolving `__typename` fields; also add `HYPERMODE_TRACE` debugging flag + [#151](https://github.com/hypermodeinc/modus/issues/151) +- Collect metrics and expose metrics and health endpoints + [#152](https://github.com/hypermodeinc/modus/issues/152) - Add graceful shutdown for HTTP server [#153](https://github.com/hypermodeinc/modus/issues/153) - - Note: It works correctly for system-generated and user-generated (`ctrl-C`) terminations, but [not when debugging in VS Code](https://github.com/golang/vscode-go/issues/120). + - Note: It works correctly for system-generated and user-generated (`ctrl-C`) terminations, but + [not when debugging in VS Code](https://github.com/golang/vscode-go/issues/120). - Add version awareness [#155](https://github.com/hypermodeinc/modus/issues/155) ## 2024-04-25 - Version 0.6.0 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 1f59696b4..614af544e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,124 +2,109 @@ ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. +We as members, contributors, and leaders pledge to make participation in our community a +harassment-free experience for everyone, regardless of age, body size, visible or invisible +disability, ethnicity, sex characteristics, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, religion, or sexual +identity and orientation. -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and +healthy community. ## Our Standards -Examples of behavior that contributes to a positive environment for our -community include: +Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the + experience +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery, and sexual attention or advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their + explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior +and will take appropriate and fair corrective action in response to any behavior that they deem +inappropriate, threatening, offensive, or harmful. -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, +code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and +will communicate reasons for moderation decisions when appropriate. ## Scope -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. +This Code of Conduct applies within all community spaces, and also applies when an individual is +officially representing the community in public spaces. Examples of representing our community +include using an official e-mail address, posting via an official social media account, or acting as +an appointed representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -hello@hypermode.com. -All complaints will be reviewed and investigated promptly and fairly. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community +leaders responsible for enforcement at hello@hypermode.com. All complaints will be reviewed and +investigated promptly and fairly. -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. +All community leaders are obligated to respect the privacy and security of the reporter of any +incident. ## Enforcement Guidelines -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: +Community leaders will follow these Community Impact Guidelines in determining the consequences for +any action they deem in violation of this Code of Conduct: ### 1. Correction -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or +unwelcome in the community. -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. +**Consequence**: A private, written warning from community leaders, providing clarity around the +nature of the violation and an explanation of why the behavior was inappropriate. A public apology +may be requested. ### 2. Warning -**Community Impact**: A violation through a single incident or series -of actions. +**Community Impact**: A violation through a single incident or series of actions. -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. +**Consequence**: A warning with consequences for continued behavior. No interaction with the people +involved, including unsolicited interaction with those enforcing the Code of Conduct, for a +specified period of time. This includes avoiding interactions in community spaces as well as +external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. +**Community Impact**: A serious violation of community standards, including sustained inappropriate +behavior. -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. +**Consequence**: A temporary ban from any sort of interaction or public communication with the +community for a specified period of time. No public or private interaction with the people involved, +including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this +period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. +**Community Impact**: Demonstrating a pattern of violation of community standards, including +sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement +of classes of individuals. -**Consequence**: A permanent ban from any sort of public interaction within -the community. +**Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca8428534..f3a3cb858 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,32 +1,46 @@ # Contributing to Modus -We're really glad you're here and would love for you to contribute to Modus! There are a variety of ways to make Modus better, including bug fixes, features, docs, and blog posts (among others). Every bit helps πŸ™ +We're really glad you're here and would love for you to contribute to Modus! There are a variety of +ways to make Modus better, including bug fixes, features, docs, and blog posts (among others). Every +bit helps πŸ™ -Please help us keep the community safe while working on the project by upholding our [Code of Conduct](/CODE_OF_CONDUCT.md) at all times. +Please help us keep the community safe while working on the project by upholding our +[Code of Conduct](/CODE_OF_CONDUCT.md) at all times. -Before jumping to a pull request, ensure you've looked at [PRs](https://github.com/hypermodeinc/modus/pulls) and [issues](https://github.com/hypermodeinc/modus/issues) (open and closed) for existing work related to your idea. +Before jumping to a pull request, ensure you've looked at +[PRs](https://github.com/hypermodeinc/modus/pulls) and +[issues](https://github.com/hypermodeinc/modus/issues) (open and closed) for existing work related +to your idea. -If in doubt or contemplating a larger change, join the [Hypermode Discord](https://discord.hypermode.com) and start a discussion in the [#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel. +If in doubt or contemplating a larger change, join the +[Hypermode Discord](https://discord.hypermode.com) and start a discussion in the +[#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel. ## Codebase -The primary development language of Modus is Go. The **runtime** and supporting packages are all written in Go. +The primary development language of Modus is Go. The **runtime** and supporting packages are all +written in Go. -**Modus SDKs** enable users to build apps in multiple languages, currently including Go and AssemblyScript. +**Modus SDKs** enable users to build apps in multiple languages, currently including Go and +AssemblyScript. The **Modus CLI** drives the local development experience and is written in TypeScript. ### Development environment -The fastest path to setting up a development environment for Modus is through VS Code. The repo includes a set of configs to set VS Code up automatically. +The fastest path to setting up a development environment for Modus is through VS Code. The repo +includes a set of configs to set VS Code up automatically. ### Clone the Modus repository -To contribute code, start by forking the Modus repository. In the top-right of the [repo](https://github.com/hypermodeinc/modus), click **Fork**. Follow the instructions to create a fork of the repo in your GitHub workspace. +To contribute code, start by forking the Modus repository. In the top-right of the +[repo](https://github.com/hypermodeinc/modus), click **Fork**. Follow the instructions to create a +fork of the repo in your GitHub workspace. ### Building and running tests -Wherever possible, we use the built-in capabilities of each language. For example, unit tests for Go components can be run with: +Wherever possible, we use the built-in capabilities of each language. For example, unit tests for Go +components can be run with: ```bash go test ./... @@ -34,9 +48,11 @@ go test ./... ### Opening a pull request -When you're ready, open a pull request against the `main` branch in the Modus repo. Include a clear, detailed description of the changes you've made. Be sure to add and update tests and docs as needed. +When you're ready, open a pull request against the `main` branch in the Modus repo. Include a clear, +detailed description of the changes you've made. Be sure to add and update tests and docs as needed. -We do our best to respond to PRs within a few days. If you've not heard back, feel free to ping on Discord. +We do our best to respond to PRs within a few days. If you've not heard back, feel free to ping on +Discord. ## Other ways to help @@ -44,11 +60,13 @@ Pull requests are awesome, but there are many ways to help. ### Documentation improvements -Modus docs are maintained in a [separate repository](https://github.com/hypermodeinc/docs). Relevant updates and issues should be opened in that repo. +Modus docs are maintained in a [separate repository](https://github.com/hypermodeinc/docs). Relevant +updates and issues should be opened in that repo. ### Blogging and presenting your work -Share what you're building with Modus in your preferred medium. We'd love to help amplify your work and/or provide feedback, so get in touch if you'd like some help! +Share what you're building with Modus in your preferred medium. We'd love to help amplify your work +and/or provide feedback, so get in touch if you'd like some help! ### Join the community diff --git a/README.md b/README.md index 0d947006f..4f1be572d 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,26 @@
- [![modus](https://github.com/user-attachments/assets/1a6020bd-d041-4dd0-b4a9-ce01dc015b65)](https://github.com/hypermodeinc/modus) +[![modus](https://github.com/user-attachments/assets/1a6020bd-d041-4dd0-b4a9-ce01dc015b65)](https://github.com/hypermodeinc/modus) - [![GitHub License](https://img.shields.io/github/license/hypermodeinc/modus)](https://github.com/hypermodeinc/modus?tab=Apache-2.0-1-ov-file#readme) - [![chat](https://img.shields.io/discord/1267579648657850441)](https://discord.gg/NJQ4bJpffF) - [![GitHub Repo stars](https://img.shields.io/github/stars/hypermodeinc/modus)](https://github.com/hypermodeinc/modus/stargazers) - [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/hypermodeinc/modus)](https://github.com/hypermodeinc/modus/commits/main/) +[![GitHub License](https://img.shields.io/github/license/hypermodeinc/modus)](https://github.com/hypermodeinc/modus?tab=Apache-2.0-1-ov-file#readme) +[![chat](https://img.shields.io/discord/1267579648657850441)](https://discord.gg/NJQ4bJpffF) +[![GitHub Repo stars](https://img.shields.io/github/stars/hypermodeinc/modus)](https://github.com/hypermodeinc/modus/stargazers) +[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/hypermodeinc/modus)](https://github.com/hypermodeinc/modus/commits/main/)

- Get Started Β· - Docs Β· + Get Started + Β· + Docs + Β· Discord

-**Modus is an open-source, serverless framework for building APIs powered by WebAssembly.** It simplifies integrating AI models, data, and business logic with sandboxed execution. And, it's really fast. +**Modus is an open-source, serverless framework for building APIs powered by WebAssembly.** It +simplifies integrating AI models, data, and business logic with sandboxed execution. And, it's +really fast. We built Modus to put code back at the heart of development. @@ -24,7 +28,7 @@ You write a function. ```ts export function sayHello(name: string): string { - return `Hello, ${name}!`; + return `Hello, ${name}!` } ``` @@ -52,7 +56,8 @@ In a few milliseconds, Modus: - securely queries data and AI models as needed, without exposing credentials to your code - responds via the API result and releases the execution environment -**Now you have a production ready scalable endpoint for your AI-enabled app. AI-ready when you’re ready. Launch and iterate.** +**Now you have a production ready scalable endpoint for your AI-enabled app. AI-ready when you’re +ready. Launch and iterate.** ## Quickstart @@ -84,19 +89,24 @@ modus dev ## What's it good for? -We designed Modus primarily as a general-purpose framework, it just happens to treat models as a first-class component. With Modus you can use models, as appropriate, without additional complexity. +We designed Modus primarily as a general-purpose framework, it just happens to treat models as a +first-class component. With Modus you can use models, as appropriate, without additional complexity. -Modus is optimized for applications that require sub-second response times. We’ve made trade-offs to prioritize speed and simplicity. +Modus is optimized for applications that require sub-second response times. We’ve made trade-offs to +prioritize speed and simplicity. ## Programming Languages -Since Modus is based on WebAssembly, you can write Modus apps in various programming languages. -Each language offers the full capabilities of the Modus framework. +Since Modus is based on WebAssembly, you can write Modus apps in various programming languages. Each +language offers the full capabilities of the Modus framework. Currently, the supported languages you may choose from are: -- [AssemblyScript](https://www.assemblyscript.org/) - A TypeScript-like language designed for WebAssembly. - - If you are primarily used to writing front-end web apps, you'll feel at home with AssemblyScript. +- [AssemblyScript](https://www.assemblyscript.org/) - A TypeScript-like language designed for + WebAssembly. + + - If you are primarily used to writing front-end web apps, you'll feel at home with + AssemblyScript. - [Go](https://go.dev/) - A general-purpose programming language originally designed by Google. - If you are primarily used to writing back-end apps, you'll likely prefer to use Go. @@ -105,31 +115,45 @@ Additional programming languages may be supported in the future. ## Hosting -We have designed Hypermode to be the best place to run your Modus app. -Hypermode hosting plans include features you might expect, such as support, telemetry, and high availability. -They also include specialty features such as model hosting that are purposefully designed to work in tandem with Modus apps. +We have designed Hypermode to be the best place to run your Modus app. Hypermode hosting plans +include features you might expect, such as support, telemetry, and high availability. They also +include specialty features such as model hosting that are purposefully designed to work in tandem +with Modus apps. -As Modus is a free, open-source framework, you’re welcome to run your Modus apps on your own hardware or on any -hosting platform that meets your needs. +As Modus is a free, open-source framework, you’re welcome to run your Modus apps on your own +hardware or on any hosting platform that meets your needs. ## Open Source -Modus is developed by [Hypermode](https://hypermode.com/) as an open-source project, integral but independent from Hypermode. +Modus is developed by [Hypermode](https://hypermode.com/) as an open-source project, integral but +independent from Hypermode. -We welcome external contributions. See the [CONTRIBUTING.md](./CONTRIBUTING.md) file if you would like to get involved. +We welcome external contributions. See the [CONTRIBUTING.md](./CONTRIBUTING.md) file if you would +like to get involved. ## Acknowledgements -It's taken a lot of hard work to bring Modus to life, but we couldn't have done it alone. Modus is built upon _many_ open source components and projects. We'd especially like to express our gratitude to the authors and teams of our core dependencies: - -- Takeshi Yoneda, author of [Wazero](https://wazero.io/), and other contributors to the Wazero project - and to [Tetrate](https://tetrate.io/) for continuing its support of Wazero. Modus uses Wazero to execute WebAssembly modules. -- Jens Neuse, Stefan Avram, and the rest of the team at [Wundergraph](https://wundergraph.com/). Modus uses Wundergraph's [GraphQL Go Tools](https://github.com/wundergraph/graphql-go-tools) library to process incoming GraphQL API requests. -- Max Graey, Daniel Wirtz, and other contributors to the [AssemblyScript](https://www.assemblyscript.org/) project. Modus chose AssemblyScript as one of its core languages because it is ideal for web developers getting started with Web Assembly. -- The [Go language](https://go.dev/) team, and also the maintainers of [TinyGo](https://tinygo.org/). The Modus Runtime is written in Go, and the Modus Go SDK uses TinyGo. +It's taken a lot of hard work to bring Modus to life, but we couldn't have done it alone. Modus is +built upon _many_ open source components and projects. We'd especially like to express our gratitude +to the authors and teams of our core dependencies: + +- Takeshi Yoneda, author of [Wazero](https://wazero.io/), and other contributors to the Wazero + project - and to [Tetrate](https://tetrate.io/) for continuing its support of Wazero. Modus uses + Wazero to execute WebAssembly modules. +- Jens Neuse, Stefan Avram, and the rest of the team at [Wundergraph](https://wundergraph.com/). + Modus uses Wundergraph's [GraphQL Go Tools](https://github.com/wundergraph/graphql-go-tools) + library to process incoming GraphQL API requests. +- Max Graey, Daniel Wirtz, and other contributors to the + [AssemblyScript](https://www.assemblyscript.org/) project. Modus chose AssemblyScript as one of + its core languages because it is ideal for web developers getting started with Web Assembly. +- The [Go language](https://go.dev/) team, and also the maintainers of + [TinyGo](https://tinygo.org/). The Modus Runtime is written in Go, and the Modus Go SDK uses + TinyGo. ## License -Modus and its components are Copyright 2024 Hypermode Inc., and licensed under the terms of the Apache License, Version 2.0. -See the [LICENSE](./LICENSE) file for a complete copy of the license. +Modus and its components are Copyright 2024 Hypermode Inc., and licensed under the terms of the +Apache License, Version 2.0. See the [LICENSE](./LICENSE) file for a complete copy of the license. -If you have any questions about Modus licensing, or need an alternate license or other arrangement, please contact us at hello@hypermode.com. +If you have any questions about Modus licensing, or need an alternate license or other arrangement, +please contact us at hello@hypermode.com. diff --git a/SECURITY.md b/SECURITY.md index e698ff6db..65d28b643 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,7 +1,10 @@ # Reporting Security Concerns -We take the security of Modus very seriously. If you believe you have found a security vulnerability in Modus, we encourage you to let us know right away. +We take the security of Modus very seriously. If you believe you have found a security vulnerability +in Modus, we encourage you to let us know right away. -We will investigate all legitimate reports and do our best to quickly fix the problem. Please report any issues or vulnerabilities via Github Security Advisories instead of posting a public issue in GitHub. You can also send security communications to security@hypermode.com. +We will investigate all legitimate reports and do our best to quickly fix the problem. Please report +any issues or vulnerabilities via Github Security Advisories instead of posting a public issue in +GitHub. You can also send security communications to security@hypermode.com. Please include the version identifier and details on how the vulnerability can be exploited. diff --git a/cli/install.sh b/cli/install.sh index 73674489a..3d3edb990 100755 --- a/cli/install.sh +++ b/cli/install.sh @@ -12,7 +12,7 @@ # Config PACKAGE_ORG="@hypermode" PACKAGE_NAME="modus-cli" -INSTALL_DIR="${MODUS_CLI:-"${MODUS_HOME:-"$HOME/.modus"}/cli"}" +INSTALL_DIR="${MODUS_CLI:-"${MODUS_HOME:-"${HOME}/.modus"}/cli"}" VERSION="latest" INSTALLER_VERSION="0.1.2" @@ -26,247 +26,247 @@ OS="$(uname -s)" # ANSI escape codes if [[ -t 1 ]]; then - CLEAR_LINE="\e[1A\e[2K\e[2K" - BOLD="\e[1m" - BLUE="\e[34;1m" - YELLOW="\e[33m" - RED="\e[31m" - DIM="\e[2m" - RESET="\e[0m" + CLEAR_LINE="\e[1A\e[2K\e[2K" + BOLD="\e[1m" + BLUE="\e[34;1m" + YELLOW="\e[33m" + RED="\e[31m" + DIM="\e[2m" + RESET="\e[0m" else - CLEAR_LINE="" - BOLD="" - BLUE="" - YELLOW="" - RED="" - DIM="" - RESET="" + CLEAR_LINE="" + BOLD="" + BLUE="" + YELLOW="" + RED="" + DIM="" + RESET="" fi get_latest_version() { - local url="https://releases.hypermode.com/modus-latest.json" - curl -sL "$url" | grep '"cli"' | sed -E 's/.*"cli": "v([^"]+)".*/\1/' + local url="https://releases.hypermode.com/modus-latest.json" + curl -sL "${url}" | grep '"cli"' | sed -E 's/.*"cli": "v([^"]+)".*/\1/' } ARCHIVE_URL="" download_from_npm() { - local tmpdir="$1" - local url="$2" - local filename="${PACKAGE_NAME}-${VERSION}.tgz" - local download_file="$tmpdir/$filename" + local tmpdir="$1" + local url="$2" + local filename="${PACKAGE_NAME}-${VERSION}.tgz" + local download_file="${tmpdir}/${filename}" - mkdir -p "$tmpdir" + mkdir -p "${tmpdir}" - curl --progress-bar --show-error --location --fail "$url" --output "$download_file" - if [ "$?" != 0 ]; then - return 1 - fi + curl --progress-bar --show-error --location --fail "${url}" --output "${download_file}" + if [[ $? != 0 ]]; then + return 1 + fi - printf "$CLEAR_LINE" >&2 - echo "$download_file" + printf "${CLEAR_LINE}" >&2 + echo "${download_file}" } echo_fexists() { - [ -f "$1" ] && echo "$1" + [[ -f $1 ]] && echo "$1" } detect_profile() { - local shellname="$1" - local uname="$2" - - if [ -f "$PROFILE" ]; then - echo "$PROFILE" - return - fi - - case "$shellname" in - bash) - case $uname in - Darwin) - echo_fexists "$HOME/.bash_profile" || echo_fexists "$HOME/.bashrc" - ;; - *) - echo_fexists "$HOME/.bashrc" || echo_fexists "$HOME/.bash_profile" - ;; - esac - ;; - zsh) - echo "$HOME/.zshrc" - ;; - fish) - echo "$HOME/.config/fish/config.fish" - ;; - *) - local profiles - case $uname in - Darwin) - profiles=(.profile .bash_profile .bashrc .zshrc .config/fish/config.fish) - ;; - *) - profiles=(.profile .bashrc .bash_profile .zshrc .config/fish/config.fish) - ;; - esac - - for profile in "${profiles[@]}"; do - echo_fexists "$HOME/$profile" && break - done - ;; - esac + local shellname="$1" + local uname="$2" + + if [[ -f ${PROFILE} ]]; then + echo "${PROFILE}" + return + fi + + case "${shellname}" in + bash) + case ${uname} in + Darwin) + echo_fexists "${HOME}/.bash_profile" || echo_fexists "${HOME}/.bashrc" + ;; + *) + echo_fexists "${HOME}/.bashrc" || echo_fexists "${HOME}/.bash_profile" + ;; + esac + ;; + zsh) + echo "${HOME}/.zshrc" + ;; + fish) + echo "${HOME}/.config/fish/config.fish" + ;; + *) + local profiles + case ${uname} in + Darwin) + profiles=(.profile .bash_profile .bashrc .zshrc .config/fish/config.fish) + ;; + *) + profiles=(.profile .bashrc .bash_profile .zshrc .config/fish/config.fish) + ;; + esac + + for profile in "${profiles[@]}"; do + echo_fexists "${HOME}/${profile}" && break + done + ;; + esac } build_path_str() { - local profile="$1" install_dir="$2" - if [[ $profile == *.fish ]]; then - echo -e "set -gx MODUS_CLI \"$install_dir\"\nstring match -r \".modus\" \"\$PATH\" > /dev/null; or set -gx PATH \"\$MODUS_CLI/bin\" \$PATH" - else - install_dir="${install_dir/#$HOME/\$HOME}" - echo -e "\n# Modus CLI\nexport MODUS_CLI=\"$install_dir\"\nexport PATH=\"\$MODUS_CLI/bin:\$PATH\"" - fi + local profile="$1" install_dir="$2" + if [[ ${profile} == *.fish ]]; then + echo -e "set -gx MODUS_CLI \"${install_dir}\"\nstring match -r \".modus\" \"\$PATH\" > /dev/null; or set -gx PATH \"\$MODUS_CLI/bin\" \$PATH" + else + install_dir="${install_dir/#${HOME}/\$HOME}" + echo -e "\n# Modus CLI\nexport MODUS_CLI=\"${install_dir}\"\nexport PATH=\"\$MODUS_CLI/bin:\$PATH\"" + fi } cli_dir_valid() { - if [ -n "${MODUS_CLI-}" ] && [ -e "$MODUS_CLI" ] && ! [ -d "$MODUS_CLI" ]; then - printf "\$MODUS_CLI is set but is not a directory ($MODUS_CLI).\n" >&2 - printf "Please check your profile scripts and environment.\n" >&2 - exit 1 - fi - return 0 + if [[ -n ${MODUS_CLI-} ]] && [[ -e ${MODUS_CLI} ]] && ! [[ -d ${MODUS_CLI} ]]; then + printf "\$MODUS_CLI is set but is not a directory (${MODUS_CLI}).\n" >&2 + printf "Please check your profile scripts and environment.\n" >&2 + exit 1 + fi + return 0 } update_profile() { - local install_dir="$1" - if [[ ":$PATH:" == *":$install_dir:"* ]]; then - printf "[3/4] ${DIM}The Modus CLI is already in \$PATH${RESET}\n" >&2 - return 0 - fi - - local profile="$(detect_profile $(basename "$SHELL") $(uname -s))" - if [ -z "$profile" ]; then - printf "No user shell profile found.\n" >&2 - return 1 - fi - - export SHOW_RESET_PROFILE=1 - export PROFILE="~/$(basename "$profile")" - - if grep -q 'MODUS_CLI' "$profile"; then - printf "[3/4] ${DIM}The Modus CLI has already been configured in ${PROFILE}${RESET}\n" >&2 - return 0 - fi - - local path_str="$(build_path_str "$profile" "$install_dir")" - echo "$path_str" >>"$profile" - - printf "[3/4] ${DIM}Added the Modus CLI to the PATH in ${PROFILE}${RESET}\n" >&2 + local install_dir="$1" + if [[ ":${PATH}:" == *":${install_dir}:"* ]]; then + printf "[3/4] ${DIM}The Modus CLI is already in \$PATH${RESET}\n" >&2 + return 0 + fi + + local profile="$(detect_profile $(basename "${SHELL}") $(uname -s))" + if [[ -z ${profile} ]]; then + printf "No user shell profile found.\n" >&2 + return 1 + fi + + export SHOW_RESET_PROFILE=1 + export PROFILE="~/$(basename "${profile}")" + + if grep -q 'MODUS_CLI' "${profile}"; then + printf "[3/4] ${DIM}The Modus CLI has already been configured in ${PROFILE}${RESET}\n" >&2 + return 0 + fi + + local path_str="$(build_path_str "${profile}" "${install_dir}")" + echo "${path_str}" >>"${profile}" + + printf "[3/4] ${DIM}Added the Modus CLI to the PATH in ${PROFILE}${RESET}\n" >&2 } install_version() { - if ! cli_dir_valid; then - exit 1 - fi - - case "$VERSION" in - latest) - VERSION="$(get_latest_version)" - ;; - *) ;; - esac - - install_release - if [ "$?" == 0 ]; then - update_profile "$INSTALL_DIR" && printf "[4/4] ${DIM}Installed Modus CLI${RESET}\n" >&2 - fi + if ! cli_dir_valid; then + exit 1 + fi + + case "${VERSION}" in + latest) + VERSION="$(get_latest_version)" + ;; + *) ;; + esac + + install_release + if [[ $? == 0 ]]; then + update_profile "${INSTALL_DIR}" && printf "[4/4] ${DIM}Installed Modus CLI${RESET}\n" >&2 + fi } install_release() { - printf "[1/4] ${DIM}Downloading Modus CLI from NPM${RESET}\n" + printf "[1/4] ${DIM}Downloading Modus CLI from NPM${RESET}\n" - local url="https://registry.npmjs.org/${PACKAGE_ORG:+$PACKAGE_ORG/}${PACKAGE_NAME}/-/${PACKAGE_NAME}-${VERSION}.tgz" + local url="https://registry.npmjs.org/${PACKAGE_ORG:+${PACKAGE_ORG}/}${PACKAGE_NAME}/-/${PACKAGE_NAME}-${VERSION}.tgz" - download_archive="$( - download_release "$url" - exit "$?" - )" - exit_status="$?" - if [ "$exit_status" != 0 ]; then - printf "Could not download Modus version '$VERSION' from\n$url\n" >&2 - exit 1 - fi + download_archive="$( + download_release "${url}" + exit "$?" + )" + exit_status="$?" + if [[ ${exit_status} != 0 ]]; then + printf "Could not download Modus version '${VERSION}' from\n${url}\n" >&2 + exit 1 + fi - printf "$CLEAR_LINE" >&2 - printf "[1/4] ${DIM}Downloaded latest Modus CLI v${VERSION}${RESET}\n" >&2 + printf "${CLEAR_LINE}" >&2 + printf "[1/4] ${DIM}Downloaded latest Modus CLI v${VERSION}${RESET}\n" >&2 - install_from_file "$download_archive" + install_from_file "${download_archive}" } download_release() { - local url="$1" - local download_dir="$(mktemp -d)" - download_from_npm "$download_dir" "$url" + local url="$1" + local download_dir="$(mktemp -d)" + download_from_npm "${download_dir}" "${url}" } install_from_file() { - local archive="$1" - local extract_to="$(dirname "$archive")" + local archive="$1" + local extract_to="$(dirname "${archive}")" - printf "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2 + printf "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2 - tar -xf "$archive" -C "$extract_to" + tar -xf "${archive}" -C "${extract_to}" - rm -rf "$INSTALL_DIR" - mkdir -p "$INSTALL_DIR" - rm -f "$archive" - mv "$extract_to/package/"* "$INSTALL_DIR" - rm -rf "$extract_to" + rm -rf "${INSTALL_DIR}" + mkdir -p "${INSTALL_DIR}" + rm -f "${archive}" + mv "${extract_to}/package/"* "${INSTALL_DIR}" + rm -rf "${extract_to}" - ln -s "$INSTALL_DIR/bin/modus.js" "$INSTALL_DIR/bin/modus" + ln -s "${INSTALL_DIR}/bin/modus.js" "${INSTALL_DIR}/bin/modus" - printf "$CLEAR_LINE" >&2 - printf "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2 - (cd "$INSTALL_DIR" && "$NPM_PATH" install --omit=dev --silent && find . -type d -empty -delete) + printf "${CLEAR_LINE}" >&2 + printf "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2 + (cd "${INSTALL_DIR}" && "${NPM_PATH}" install --omit=dev --silent && find . -type d -empty -delete) - printf "$CLEAR_LINE" >&2 - printf "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2 + printf "${CLEAR_LINE}" >&2 + printf "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2 } check_platform() { - case $ARCH in - arm64) ARCH="arm64" ;; - x86_64) ARCH="x64" ;; - *) ;; - esac - - case "$ARCH/$OS" in - x64/Linux | arm64/Linux | x64/Darwin | arm64/Darwin) return 0 ;; - *) - printf "Unsupported os $OS $ARCH\n" >&2 - exit 1 - ;; - esac + case ${ARCH} in + arm64) ARCH="arm64" ;; + x86_64) ARCH="x64" ;; + *) ;; + esac + + case "${ARCH}/${OS}" in + x64/Linux | arm64/Linux | x64/Darwin | arm64/Darwin) return 0 ;; + *) + printf "Unsupported os ${OS} ${ARCH}\n" >&2 + exit 1 + ;; + esac } check_node() { - if [ -z "$NODE_PATH" ]; then - printf "${RED}Node.js is not installed.${RESET}\n" >&2 - printf "${RED}Please install Node.js $NODE_WANTED or later and try again.${RESET}\n" >&2 - exit 1 - fi - - # check node version - local node_version="$("$NODE_PATH" --version)" - local node_major="${node_version%%.*}" - node_major="${node_major#v}" - if [ "$node_major" -lt "$NODE_MIN" ]; then - printf "${RED}Node.js $NODE_MIN or later is required. You have $node_version.${RESET}\n" >&2 - printf "${RED}Please update and try again${RESET}\n" >&2 - exit 1 - fi - - # make sure npm can be found too - if [ -z "$NPM_PATH" ]; then - printf "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2 - exit 1 - fi + if [[ -z ${NODE_PATH} ]]; then + printf "${RED}Node.js is not installed.${RESET}\n" >&2 + printf "${RED}Please install Node.js ${NODE_WANTED} or later and try again.${RESET}\n" >&2 + exit 1 + fi + + # check node version + local node_version="$("${NODE_PATH}" --version)" + local node_major="${node_version%%.*}" + node_major="${node_major#v}" + if [[ ${node_major} -lt ${NODE_MIN} ]]; then + printf "${RED}Node.js ${NODE_MIN} or later is required. You have ${node_version}.${RESET}\n" >&2 + printf "${RED}Please update and try again${RESET}\n" >&2 + exit 1 + fi + + # make sure npm can be found too + if [[ -z ${NPM_PATH} ]]; then + printf "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2 + exit 1 + fi } # This is the entry point @@ -278,12 +278,12 @@ install_version printf "\nThe Modus CLI has been installed! πŸŽ‰\n" >&2 -if [ -n "${SHOW_RESET_PROFILE-}" ]; then - printf "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2 - printf " ${DIM}source ${PROFILE}${RESET}\n" >&2 - printf "\nThen, run ${DIM}modus${RESET} to get started${RESET}\n" >&2 +if [[ -n ${SHOW_RESET_PROFILE-} ]]; then + printf "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2 + printf " ${DIM}source ${PROFILE}${RESET}\n" >&2 + printf "\nThen, run ${DIM}modus${RESET} to get started${RESET}\n" >&2 else - printf "\nRun ${DIM}modus${RESET} to get started${RESET}\n" >&2 + printf "\nRun ${DIM}modus${RESET} to get started${RESET}\n" >&2 fi printf "\n" >&2 diff --git a/lib/README.md b/lib/README.md index 11688b898..e2df2fbbe 100644 --- a/lib/README.md +++ b/lib/README.md @@ -2,10 +2,11 @@ This directory contains shared libraries that are used by various Modus components, or externally. -Each subdirectory contains a separate Go module that is versioned independently from the rest of the repository, -using a module path and tag scheme that matches the folder path. +Each subdirectory contains a separate Go module that is versioned independently from the rest of the +repository, using a module path and tag scheme that matches the folder path. -For example, updates to the `manifest` subdirectory are tagged as `lib/manifest/vX.Y.Z`, and are installed with +For example, updates to the `manifest` subdirectory are tagged as `lib/manifest/vX.Y.Z`, and are +installed with ```sh go get -u github.com/hypermodeinc/modus/lib/manifest @@ -14,4 +15,5 @@ go get -u github.com/hypermodeinc/modus/lib/manifest ## Usage outside Modus The shared libraries can be used for any purpose, subject to the Modus [LICENSE](../LICENSE). -Primarily they are used by the Modus runtime, and hosting infrastructure such as [Hypermode](https://hypermode.com). +Primarily they are used by the Modus runtime, and hosting infrastructure such as +[Hypermode](https://hypermode.com). diff --git a/runtime/.goreleaser.yaml b/runtime/.goreleaser.yaml index 66306b129..4bf6f7ea8 100644 --- a/runtime/.goreleaser.yaml +++ b/runtime/.goreleaser.yaml @@ -5,7 +5,7 @@ monorepo: tag_prefix: runtime/ dir: runtime git: - tag_sort: "-version:creatordate" + tag_sort: -version:creatordate prerelease_suffix: "-" before: hooks: @@ -46,8 +46,8 @@ builds: archives: - files: - - "../README.md" - - "../LICENSE" + - ../README.md + - ../LICENSE name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" format: tar.gz # use zip for windows archives @@ -55,7 +55,7 @@ archives: - goos: windows format: zip checksum: - name_template: "checksums.txt" + name_template: checksums.txt release: prerelease: auto changelog: diff --git a/runtime/README.md b/runtime/README.md index 34abacc06..8119dfa12 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -1,7 +1,7 @@ # Modus Runtime -This directory contains the source code for the Modus runtime, -which is responsible for loading and executing your Modus app. +This directory contains the source code for the Modus runtime, which is responsible for loading and +executing your Modus app. Unless you are contributing to the Modus project, you will not need to download this code directly. Instead, a compiled platform-specific binary of the Modus runtime will be downloaded and installed diff --git a/runtime/explorer/content/ModusIcon.tsx b/runtime/explorer/content/ModusIcon.tsx index edce09181..5e2326494 100644 --- a/runtime/explorer/content/ModusIcon.tsx +++ b/runtime/explorer/content/ModusIcon.tsx @@ -1,12 +1,7 @@ -import React from "react"; +import React from "react" const ModusLogo = ({ className }: { className?: string }) => ( - + -); +) -export default ModusLogo; +export default ModusLogo diff --git a/runtime/explorer/content/index.html b/runtime/explorer/content/index.html index 965b83892..084259ef3 100644 --- a/runtime/explorer/content/index.html +++ b/runtime/explorer/content/index.html @@ -1,4 +1,4 @@ - + diff --git a/runtime/explorer/content/main.tsx b/runtime/explorer/content/main.tsx index 111b75245..1c51e4d1c 100644 --- a/runtime/explorer/content/main.tsx +++ b/runtime/explorer/content/main.tsx @@ -1,15 +1,15 @@ -import React, { useEffect, useState } from "react"; -import { createRoot } from "react-dom/client"; -import { ApiExplorer } from "@hypermode/react-api-explorer"; -import ModusIcon from "./ModusIcon"; -import "@hypermode/react-api-explorer/styles.css"; -import "./index.css"; +import React, { useEffect, useState } from "react" +import { createRoot } from "react-dom/client" +import { ApiExplorer } from "@hypermode/react-api-explorer" +import ModusIcon from "./ModusIcon" +import "@hypermode/react-api-explorer/styles.css" +import "./index.css" -const rootElement = document.getElementById("root"); +const rootElement = document.getElementById("root") if (!rootElement) { - throw new Error("Root element not found"); + throw new Error("Root element not found") } -const root = createRoot(rootElement); +const root = createRoot(rootElement) function App() { const modusTheme = { @@ -32,33 +32,29 @@ function App() { border: "150 35% 17%", input: "150 35% 17%", ring: "150 60% 39%", - }; - const [endpoints, setEndpoints] = useState([ - "http://localhost:8686/graphql", - ]); + } + const [endpoints, setEndpoints] = useState(["http://localhost:8686/graphql"]) useEffect(() => { // Fetch endpoints when component mounts const fetchEndpoints = async () => { try { - const response = await fetch("/explorer/api/endpoints"); - const data = await response.json(); + const response = await fetch("/explorer/api/endpoints") + const data = await response.json() - const origin = window.location.origin; + const origin = window.location.origin const ep = data.map((endpoint: { path: string }) => { - return endpoint.path.startsWith("/") - ? `${origin}${endpoint.path}` - : endpoint.path; - }); + return endpoint.path.startsWith("/") ? `${origin}${endpoint.path}` : endpoint.path + }) - setEndpoints(ep); + setEndpoints(ep) } catch (error) { - console.error("Failed to fetch endpoints:", error); + console.error("Failed to fetch endpoints:", error) } - }; + } - fetchEndpoints(); - }, []); + fetchEndpoints() + }, []) return (

@@ -67,15 +63,13 @@ function App() { theme={modusTheme} title={
-

- Modus API Explorer -

+

Modus API Explorer

} />
- ); + ) } -root.render(); +root.render() diff --git a/runtime/explorer/content/postcss.config.js b/runtime/explorer/content/postcss.config.js index 2aa7205d4..2e7af2b7f 100644 --- a/runtime/explorer/content/postcss.config.js +++ b/runtime/explorer/content/postcss.config.js @@ -3,4 +3,4 @@ export default { tailwindcss: {}, autoprefixer: {}, }, -}; +} diff --git a/runtime/explorer/content/tailwind.config.js b/runtime/explorer/content/tailwind.config.js index b4a0081b3..c6b6326c7 100644 --- a/runtime/explorer/content/tailwind.config.js +++ b/runtime/explorer/content/tailwind.config.js @@ -5,4 +5,4 @@ export default { extend: {}, }, plugins: [], -}; +} diff --git a/runtime/explorer/content/vite.config.ts b/runtime/explorer/content/vite.config.ts index 1a9c3d542..ef9a83524 100644 --- a/runtime/explorer/content/vite.config.ts +++ b/runtime/explorer/content/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from "vite"; -import react from "@vitejs/plugin-react"; -import { resolve } from "path"; +import { defineConfig } from "vite" +import react from "@vitejs/plugin-react" +import { resolve } from "path" export default defineConfig({ plugins: [react()], @@ -26,4 +26,4 @@ export default defineConfig({ chunkSizeWarningLimit: 1000, }, base: "/explorer/", -}); +}) diff --git a/runtime/graphql/schemagen/schemagen_go_test.go b/runtime/graphql/schemagen/schemagen_go_test.go index 835c47f97..25e8d2958 100644 --- a/runtime/graphql/schemagen/schemagen_go_test.go +++ b/runtime/graphql/schemagen/schemagen_go_test.go @@ -125,7 +125,7 @@ func Test_GetGraphQLSchema_Go(t *testing.T) { md.FnExports.AddFunction("testObj1"). WithParameter("obj", "testdata.Obj1"). WithResult("testdata.Obj1") - + md.Types.AddType("testdata.Obj1"). WithField("id", "int32"). WithField("name", "string") diff --git a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts index 846e6b79e..85f8e9a67 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts @@ -8,20 +8,20 @@ */ export function testArrayBufferInput(buffer: ArrayBuffer): void { - const view = Uint8Array.wrap(buffer); - assert(view.length == 4); - assert(view[0] == 1); - assert(view[1] == 2); - assert(view[2] == 3); - assert(view[3] == 4); + const view = Uint8Array.wrap(buffer) + assert(view.length == 4) + assert(view[0] == 1) + assert(view[1] == 2) + assert(view[2] == 3) + assert(view[3] == 4) } export function testArrayBufferOutput(): ArrayBuffer { - const buffer = new ArrayBuffer(4); - const view = Uint8Array.wrap(buffer); - view[0] = 1; - view[1] = 2; - view[2] = 3; - view[3] = 4; - return buffer; + const buffer = new ArrayBuffer(4) + const view = Uint8Array.wrap(buffer) + view[0] = 1 + view[1] = 2 + view[2] = 3 + view[3] = 4 + return buffer } diff --git a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts index d8a16e64c..f0bc8d85e 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts @@ -8,79 +8,79 @@ */ export function testArrayOutput_i8(): i8[] { - return [1, 2, 3]; + return [1, 2, 3] } export function testArrayInput_i8(arr: i8[]): void { - assert(arr.length == 3); - assert(arr[0] == 1); - assert(arr[1] == 2); - assert(arr[2] == 3); + assert(arr.length == 3) + assert(arr[0] == 1) + assert(arr[1] == 2) + assert(arr[2] == 3) } export function testArrayOutput_i8_empty(): i8[] { - return []; + return [] } export function testArrayInput_i8_empty(arr: i8[]): void { - assert(arr.length == 0); + assert(arr.length == 0) } export function testArrayOutput_i8_null(): i8[] | null { - return null; + return null } export function testArrayInput_i8_null(arr: i8[] | null): void { - assert(arr == null); + assert(arr == null) } export function testArrayInput_i32(arr: i32[]): void { - assert(arr.length == 3); - assert(arr[0] == 1); - assert(arr[1] == 2); - assert(arr[2] == 3); + assert(arr.length == 3) + assert(arr[0] == 1) + assert(arr[1] == 2) + assert(arr[2] == 3) } export function testArrayOutput_i32(): i32[] { - return [1, 2, 3]; + return [1, 2, 3] } export function testArrayInput_f32(arr: f32[]): void { - assert(arr.length == 3); - assert(arr[0] == 1); - assert(arr[1] == 2); - assert(arr[2] == 3); + assert(arr.length == 3) + assert(arr[0] == 1) + assert(arr[1] == 2) + assert(arr[2] == 3) } export function testArrayOutput_f32(): f32[] { - return [1, 2, 3]; + return [1, 2, 3] } export function testArrayInput_string(arr: string[]): void { - assert(arr.length == 3); - assert(arr[0] == "abc"); - assert(arr[1] == "def"); - assert(arr[2] == "ghi"); + assert(arr.length == 3) + assert(arr[0] == "abc") + assert(arr[1] == "def") + assert(arr[2] == "ghi") } export function testArrayOutput_string(): string[] { - return ["abc", "def", "ghi"]; + return ["abc", "def", "ghi"] } export function testArrayInput_string_2d(arr: string[][]): void { - assert(arr.length == 3); - assert(arr[0].length == 3); - assert(arr[0][0] == "abc"); - assert(arr[0][1] == "def"); - assert(arr[0][2] == "ghi"); - assert(arr[1].length == 3); - assert(arr[1][0] == "jkl"); - assert(arr[1][1] == "mno"); - assert(arr[1][2] == "pqr"); - assert(arr[2].length == 3); - assert(arr[2][0] == "stu"); - assert(arr[2][1] == "vwx"); - assert(arr[2][2] == "yz"); + assert(arr.length == 3) + assert(arr[0].length == 3) + assert(arr[0][0] == "abc") + assert(arr[0][1] == "def") + assert(arr[0][2] == "ghi") + assert(arr[1].length == 3) + assert(arr[1][0] == "jkl") + assert(arr[1][1] == "mno") + assert(arr[1][2] == "pqr") + assert(arr[2].length == 3) + assert(arr[2][0] == "stu") + assert(arr[2][1] == "vwx") + assert(arr[2][2] == "yz") } export function testArrayOutput_string_2d(): string[][] { @@ -88,24 +88,27 @@ export function testArrayOutput_string_2d(): string[][] { ["abc", "def", "ghi"], ["jkl", "mno", "pqr"], ["stu", "vwx", "yz"], - ]; + ] } export function testArrayInput_string_2d_empty(arr: string[][]): void { - assert(arr.length == 0); + assert(arr.length == 0) } export function testArrayOutput_string_2d_empty(): string[][] { - return []; + return [] } class TestObject1 { - constructor(public a: i32, public b: i32) {} + constructor( + public a: i32, + public b: i32, + ) {} } export function testArrayIteration(arr: TestObject1[]): void { for (let i = 0; i < arr.length; i++) { - let obj = arr[i]; - console.log(`[${i}]: a=${obj.a}, b=${obj.b}`); + let obj = arr[i] + console.log(`[${i}]: a=${obj.a}, b=${obj.b}`) } } diff --git a/runtime/languages/assemblyscript/testdata/assembly/classes.ts b/runtime/languages/assemblyscript/testdata/assembly/classes.ts index 4125e4d69..1b452b721 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/classes.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/classes.ts @@ -8,191 +8,191 @@ */ class TestClass1 { - a!: bool; + a!: bool } class TestClass1_map { - a!: bool; + a!: bool } class TestClass2 { - a!: bool; - b!: isize; + a!: bool + b!: isize } class TestClass2_map { - a!: bool; - b!: isize; + a!: bool + b!: isize } class TestClass3 { - a!: bool; - b!: isize; - c!: string; + a!: bool + b!: isize + c!: string } class TestClass3_map { - a!: bool; - b!: isize; - c!: string; + a!: bool + b!: isize + c!: string } class TestClass4 { - a!: bool; - b!: isize; - c!: string | null; + a!: bool + b!: isize + c!: string | null } class TestClass4_map { - a!: bool; - b!: isize; - c!: string | null; + a!: bool + b!: isize + c!: string | null } class TestClass5 { - a!: bool; - b!: TestClass3; + a!: bool + b!: TestClass3 } class TestClass5_map { - a!: bool; - b!: TestClass3_map; + a!: bool + b!: TestClass3_map } class TestRecursiveClass { - a!: bool; - b!: TestRecursiveClass | null; + a!: bool + b!: TestRecursiveClass | null } class TestRecursiveClass_map { - a!: bool; - b!: TestRecursiveClass_map | null; + a!: bool + b!: TestRecursiveClass_map | null } -const testClass1 = { a: true }; -const testClass2 = { a: true, b: 123 }; -const testClass3 = { a: true, b: 123, c: "abc" }; -const testClass4 = { a: true, b: 123, c: "abc" }; -const testClass4_withNull = { a: true, b: 123, c: null }; -const testClass5 = { a: true, b: testClass3 }; +const testClass1 = { a: true } +const testClass2 = { a: true, b: 123 } +const testClass3 = { a: true, b: 123, c: "abc" } +const testClass4 = { a: true, b: 123, c: "abc" } +const testClass4_withNull = { a: true, b: 123, c: null } +const testClass5 = { a: true, b: testClass3 } -const testRecursiveClass = { a: true }; -testRecursiveClass.b = testRecursiveClass; +const testRecursiveClass = { a: true } +testRecursiveClass.b = testRecursiveClass -const testClass1_map = { a: true }; -const testClass2_map = { a: true, b: 123 }; -const testClass3_map = { a: true, b: 123, c: "abc" }; -const testClass4_map = { a: true, b: 123, c: "abc" }; -const testClass4_map_withNull = { a: true, b: 123, c: null }; -const testClass5_map = { a: true, b: testClass3_map }; +const testClass1_map = { a: true } +const testClass2_map = { a: true, b: 123 } +const testClass3_map = { a: true, b: 123, c: "abc" } +const testClass4_map = { a: true, b: 123, c: "abc" } +const testClass4_map_withNull = { a: true, b: 123, c: null } +const testClass5_map = { a: true, b: testClass3_map } -const testRecursiveClass_map = { a: true }; -testRecursiveClass_map.b = testRecursiveClass_map; +const testRecursiveClass_map = { a: true } +testRecursiveClass_map.b = testRecursiveClass_map export function testClassInput1(o: TestClass1): void { - assert(o.a == testClass1.a); + assert(o.a == testClass1.a) } export function testClassOutput1(): TestClass1 { - return testClass1; + return testClass1 } export function testClassOutput1_map(): TestClass1_map { - return testClass1_map; + return testClass1_map } export function testClassInput2(o: TestClass2): void { - assert(o.a == testClass2.a); - assert(o.b == testClass2.b); + assert(o.a == testClass2.a) + assert(o.b == testClass2.b) } export function testClassOutput2(): TestClass2 { - return testClass2; + return testClass2 } export function testClassOutput2_map(): TestClass2_map { - return testClass2_map; + return testClass2_map } export function testClassInput3(o: TestClass3): void { - assert(o.a == testClass3.a); - assert(o.b == testClass3.b); - assert(o.c == testClass3.c); + assert(o.a == testClass3.a) + assert(o.b == testClass3.b) + assert(o.c == testClass3.c) } export function testClassOutput3(): TestClass3 { - return testClass3; + return testClass3 } export function testClassOutput3_map(): TestClass3_map { - return testClass3_map; + return testClass3_map } export function testClassInput4_withNull(o: TestClass4): void { - assert(o.a == testClass4_withNull.a); - assert(o.b == testClass4_withNull.b); - assert(o.c == testClass4_withNull.c); + assert(o.a == testClass4_withNull.a) + assert(o.b == testClass4_withNull.b) + assert(o.c == testClass4_withNull.c) } export function testClassOutput4(): TestClass4 { - return testClass4; + return testClass4 } export function testClassOutput4_map(): TestClass4_map { - return testClass4_map; + return testClass4_map } export function testClassInput4(o: TestClass4): void { - assert(o.a == testClass4.a); - assert(o.b == testClass4.b); - assert(o.c == testClass4.c); + assert(o.a == testClass4.a) + assert(o.b == testClass4.b) + assert(o.c == testClass4.c) } export function testClassOutput4_withNull(): TestClass4 { - return testClass4_withNull; + return testClass4_withNull } export function testClassOutput4_map_withNull(): TestClass4_map { - return testClass4_map_withNull; + return testClass4_map_withNull } export function testClassInput5(o: TestClass5): void { - assert(o.a == testClass5.a); - assert(o.b.a == testClass5.b.a); - assert(o.b.b == testClass5.b.b); - assert(o.b.c == testClass5.b.c); + assert(o.a == testClass5.a) + assert(o.b.a == testClass5.b.a) + assert(o.b.b == testClass5.b.b) + assert(o.b.c == testClass5.b.c) } export function testClassOutput5(): TestClass5 { - return testClass5; + return testClass5 } export function testClassOutput5_map(): TestClass5_map { - return testClass5_map; + return testClass5_map } export function testRecursiveClassInput(o: TestRecursiveClass): void { - assert(o.a == testRecursiveClass.a); - assert(o.b == testRecursiveClass.b); + assert(o.a == testRecursiveClass.a) + assert(o.b == testRecursiveClass.b) } export function testRecursiveClassOutput(): TestRecursiveClass { - return testRecursiveClass; + return testRecursiveClass } export function testNullableClassInput1(o: TestClass1 | null): void { - assert(o != null); - assert(o!.a == testClass1.a); + assert(o != null) + assert(o!.a == testClass1.a) } export function testNullableClassOutput1(): TestClass1 | null { - return testClass1; + return testClass1 } export function testNullableClassInput1_null(o: TestClass1 | null): void { - assert(o == null); + assert(o == null) } export function testNullableClassOutput1_null(): TestClass1 | null { - return null; + return null } diff --git a/runtime/languages/assemblyscript/testdata/assembly/dates.ts b/runtime/languages/assemblyscript/testdata/assembly/dates.ts index 5e199f1b6..86bbcca5f 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/dates.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/dates.ts @@ -7,32 +7,32 @@ * SPDX-License-Identifier: Apache-2.0 */ -const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime(); +const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime() export function testDateInput(d: Date): void { - const ts = d.getTime(); - assert(ts == testTime, `Expected ${testTime}, got ${ts}`); + const ts = d.getTime() + assert(ts == testTime, `Expected ${testTime}, got ${ts}`) } export function testDateOutput(): Date { - return new Date(testTime); + return new Date(testTime) } export function testNullDateInput(d: Date | null): void { - assert(d != null, `Expected non-null, got null`); + assert(d != null, `Expected non-null, got null`) - const ts = d!.getTime(); - assert(ts == testTime, `Expected ${testTime}, got ${ts}`); + const ts = d!.getTime() + assert(ts == testTime, `Expected ${testTime}, got ${ts}`) } export function testNullDateOutput(): Date | null { - return new Date(testTime); + return new Date(testTime) } export function testNullDateInput_null(d: Date | null): void { - assert(d == null, `Expected null, got ${d!.getTime()}`); + assert(d == null, `Expected null, got ${d!.getTime()}`) } export function testNullDateOutput_null(): Date | null { - return null; + return null } diff --git a/runtime/languages/assemblyscript/testdata/assembly/env.ts b/runtime/languages/assemblyscript/testdata/assembly/env.ts index 9b96fef4f..1242b44f7 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/env.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/env.ts @@ -8,18 +8,18 @@ */ export function now(): i64 { - return Date.now(); + return Date.now() } export function spin(duration: i64): i64 { - const start = performance.now(); + const start = performance.now() - let d = Date.now(); + let d = Date.now() while (Date.now() - d <= duration) { // do nothing } - const end = performance.now(); + const end = performance.now() - return i64(end - start); + return i64(end - start) } diff --git a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts index 5247646fa..4936eefe4 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts @@ -9,30 +9,30 @@ // @ts-expect-error: decorator @external("modus_test", "add") -declare function hostAdd(a: i32, b: i32): i32; +declare function hostAdd(a: i32, b: i32): i32 // @ts-expect-error: decorator @external("modus_test", "echo") -declare function hostEcho(message: string): string; +declare function hostEcho(message: string): string // @ts-expect-error: decorator @external("modus_test", "echoObject") -declare function hostEchoObject(obj: TestHostObject): TestHostObject; +declare function hostEchoObject(obj: TestHostObject): TestHostObject class TestHostObject { - a!: i32; - b!: bool; - c!: string; + a!: i32 + b!: bool + c!: string } export function add(a: i32, b: i32): i32 { - return hostAdd(a, b); + return hostAdd(a, b) } export function echo(message: string): string { - return hostEcho(message); + return hostEcho(message) } export function echoObject(obj: TestHostObject): TestHostObject { - return hostEchoObject(obj); + return hostEchoObject(obj) } diff --git a/runtime/languages/assemblyscript/testdata/assembly/index.ts b/runtime/languages/assemblyscript/testdata/assembly/index.ts index f22035389..552217bf6 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/index.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/index.ts @@ -7,13 +7,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -export * from "./arrays"; -export * from "./arraybuffers"; -export * from "./classes"; -export * from "./dates"; -export * from "./env"; -export * from "./hostfns"; -export * from "./maps"; -export * from "./primitives"; -export * from "./strings"; -export * from "./typedarrays"; +export * from "./arrays" +export * from "./arraybuffers" +export * from "./classes" +export * from "./dates" +export * from "./env" +export * from "./hostfns" +export * from "./maps" +export * from "./primitives" +export * from "./strings" +export * from "./typedarrays" diff --git a/runtime/languages/assemblyscript/testdata/assembly/maps.ts b/runtime/languages/assemblyscript/testdata/assembly/maps.ts index f2256c8cc..a1995d708 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/maps.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/maps.ts @@ -8,162 +8,147 @@ */ export function testMapInput_u8_string(m: Map): void { - assert(m.size == 3, "expected size 3"); + assert(m.size == 3, "expected size 3") - assert(m.has(1), "expected key 1 to be present"); - assert(m.get(1) == "a", "expected value for key 1 to be 'a'"); + assert(m.has(1), "expected key 1 to be present") + assert(m.get(1) == "a", "expected value for key 1 to be 'a'") - assert(m.has(2), "expected key 2 to be present"); - assert(m.get(2) == "b", "expected value for key 2 to be 'b'"); + assert(m.has(2), "expected key 2 to be present") + assert(m.get(2) == "b", "expected value for key 2 to be 'b'") - assert(m.has(3), "expected key 3 to be present"); - assert(m.get(3) == "c", "expected value for key 3 to be 'c'"); + assert(m.has(3), "expected key 3 to be present") + assert(m.get(3) == "c", "expected value for key 3 to be 'c'") } export function testMapOutput_u8_string(): Map { - const m = new Map(); - m.set(1, "a"); - m.set(2, "b"); - m.set(3, "c"); - return m; + const m = new Map() + m.set(1, "a") + m.set(2, "b") + m.set(3, "c") + return m } export function testMapInput_string_string(m: Map): void { - assert(m.size == 3, "expected size 3"); + assert(m.size == 3, "expected size 3") - assert(m.has("a"), "expected key 'a' to be present"); - assert(m.get("a") == "1", "expected value for key 'a' to be '1'"); + assert(m.has("a"), "expected key 'a' to be present") + assert(m.get("a") == "1", "expected value for key 'a' to be '1'") - assert(m.has("b"), "expected key 'b' to be present"); - assert(m.get("b") == "2", "expected value for key 'b' to be '2'"); + assert(m.has("b"), "expected key 'b' to be present") + assert(m.get("b") == "2", "expected value for key 'b' to be '2'") - assert(m.has("c"), "expected key 'c' to be present"); - assert(m.get("c") == "3", "expected value for key 'c' to be '3'"); + assert(m.has("c"), "expected key 'c' to be present") + assert(m.get("c") == "3", "expected value for key 'c' to be '3'") } export function testMapOutput_string_string(): Map { - const m = new Map(); - m.set("a", "1"); - m.set("b", "2"); - m.set("c", "3"); - return m; + const m = new Map() + m.set("a", "1") + m.set("b", "2") + m.set("c", "3") + return m } -export function testNullableMapInput_string_string( - m: Map | null -): void { - assert(m != null, "expected non-null map"); - assert(m!.size == 3, "expected size 3"); +export function testNullableMapInput_string_string(m: Map | null): void { + assert(m != null, "expected non-null map") + assert(m!.size == 3, "expected size 3") - assert(m!.has("a"), "expected key 'a' to be present"); - assert(m!.get("a") == "1", "expected value for key 'a' to be '1'"); + assert(m!.has("a"), "expected key 'a' to be present") + assert(m!.get("a") == "1", "expected value for key 'a' to be '1'") - assert(m!.has("b"), "expected key 'b' to be present"); - assert(m!.get("b") == "2", "expected value for key 'b' to be '2'"); + assert(m!.has("b"), "expected key 'b' to be present") + assert(m!.get("b") == "2", "expected value for key 'b' to be '2'") - assert(m!.has("c"), "expected key 'c' to be present"); - assert(m!.get("c") == "3", "expected value for key 'c' to be '3'"); + assert(m!.has("c"), "expected key 'c' to be present") + assert(m!.get("c") == "3", "expected value for key 'c' to be '3'") } -export function testNullableMapInput_string_string_null( - m: Map | null -): void { - assert(m == null, "expected null map"); +export function testNullableMapInput_string_string_null(m: Map | null): void { + assert(m == null, "expected null map") } -export function testNullableMapOutput_string_string(): Map< - string, - string -> | null { - const m = new Map(); - m.set("a", "1"); - m.set("b", "2"); - m.set("c", "3"); - return m; +export function testNullableMapOutput_string_string(): Map | null { + const m = new Map() + m.set("a", "1") + m.set("b", "2") + m.set("c", "3") + return m } -export function testNullableMapOutput_string_string_null(): Map< - string, - string -> | null { - return null; +export function testNullableMapOutput_string_string_null(): Map | null { + return null } export function testIterateMap_string_string(m: Map): void { - const keys = m.keys(); - const values = m.values(); + const keys = m.keys() + const values = m.values() for (let i = 0; i < m.size; i++) { - const key = keys[i]; - const value = values[i]; - console.log(key + " => " + value); + const key = keys[i] + const value = values[i] + console.log(key + " => " + value) } } -export function testMapLookup_string_string( - m: Map, - key: string -): string | null { +export function testMapLookup_string_string(m: Map, key: string): string | null { if (m.has(key)) { - return m.get(key); + return m.get(key) } - return null; + return null } class TestClassWithMap { - m!: Map; + m!: Map } -export function testClassContainingMapInput_string_string( - c: TestClassWithMap -): void { - assert(c != null, "expected non-null class"); - assert(c.m != null, "expected non-null map"); - assert(c.m.size == 3, "expected size 3"); +export function testClassContainingMapInput_string_string(c: TestClassWithMap): void { + assert(c != null, "expected non-null class") + assert(c.m != null, "expected non-null map") + assert(c.m.size == 3, "expected size 3") - assert(c.m.has("a"), "expected key 'a' to be present"); - assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'"); + assert(c.m.has("a"), "expected key 'a' to be present") + assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'") - assert(c.m.has("b"), "expected key 'b' to be present"); - assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'"); + assert(c.m.has("b"), "expected key 'b' to be present") + assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'") - assert(c.m.has("c"), "expected key 'c' to be present"); - assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'"); + assert(c.m.has("c"), "expected key 'c' to be present") + assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'") } export function testClassContainingMapOutput_string_string(): TestClassWithMap { - const c = new TestClassWithMap(); - c.m = new Map(); - c.m.set("a", "1"); - c.m.set("b", "2"); - c.m.set("c", "3"); - return c; + const c = new TestClassWithMap() + c.m = new Map() + c.m.set("a", "1") + c.m.set("b", "2") + c.m.set("c", "3") + return c } export function testMapInput_string_f64(m: Map): void { - assert(m.size == 4, "expected size 4"); + assert(m.size == 4, "expected size 4") - let n: f64 = 0.5; - assert(m.has("a"), "expected key 'a' to be present"); - assert(m.get("a") == n, `expected value for key 'a' to be ${n}`); + let n: f64 = 0.5 + assert(m.has("a"), "expected key 'a' to be present") + assert(m.get("a") == n, `expected value for key 'a' to be ${n}`) - n = f64.EPSILON; - assert(m.has("b"), "expected key 'b' to be present"); - assert(m.get("b") == n, `expected value for key 'b' to be ${n}`); + n = f64.EPSILON + assert(m.has("b"), "expected key 'b' to be present") + assert(m.get("b") == n, `expected value for key 'b' to be ${n}`) - n = f64.MIN_VALUE; - assert(m.has("c"), "expected key 'c' to be present"); - assert(m.get("c") == n, `expected value for key 'c' to be ${n}`); + n = f64.MIN_VALUE + assert(m.has("c"), "expected key 'c' to be present") + assert(m.get("c") == n, `expected value for key 'c' to be ${n}`) - n = f64.MAX_VALUE; - assert(m.has("d"), "expected key 'd' to be present"); - assert(m.get("d") == n, `expected value for key 'd' to be ${n}`); + n = f64.MAX_VALUE + assert(m.has("d"), "expected key 'd' to be present") + assert(m.get("d") == n, `expected value for key 'd' to be ${n}`) } export function testMapOutput_string_f64(): Map { - const m = new Map(); - m.set("a", 0.5); - m.set("b", f64.EPSILON); - m.set("c", f64.MIN_VALUE); - m.set("d", f64.MAX_VALUE); - return m; + const m = new Map() + m.set("a", 0.5) + m.set("b", f64.EPSILON) + m.set("c", f64.MIN_VALUE) + m.set("d", f64.MAX_VALUE) + return m } diff --git a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts index ecb317be6..264166388 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts @@ -8,209 +8,209 @@ */ export function testBoolInput_false(b: bool): void { - assert(b == false); + assert(b == false) } export function testBoolInput_true(b: bool): void { - assert(b == true); + assert(b == true) } export function testBoolOutput_false(): bool { - return false; + return false } export function testBoolOutput_true(): bool { - return true; + return true } export function testI8Input_min(n: i8): void { - assert(n == i8.MIN_VALUE); + assert(n == i8.MIN_VALUE) } export function testI8Input_max(n: i8): void { - assert(n == i8.MAX_VALUE); + assert(n == i8.MAX_VALUE) } export function testI8Output_min(): i8 { - return i8.MIN_VALUE; + return i8.MIN_VALUE } export function testI8Output_max(): i8 { - return i8.MAX_VALUE; + return i8.MAX_VALUE } export function testI16Input_min(n: i16): void { - assert(n == i16.MIN_VALUE); + assert(n == i16.MIN_VALUE) } export function testI16Input_max(n: i16): void { - assert(n == i16.MAX_VALUE); + assert(n == i16.MAX_VALUE) } export function testI16Output_min(): i16 { - return i16.MIN_VALUE; + return i16.MIN_VALUE } export function testI16Output_max(): i16 { - return i16.MAX_VALUE; + return i16.MAX_VALUE } export function testI32Input_min(n: i32): void { - assert(n == i32.MIN_VALUE); + assert(n == i32.MIN_VALUE) } export function testI32Input_max(n: i32): void { - assert(n == i32.MAX_VALUE); + assert(n == i32.MAX_VALUE) } export function testI32Output_min(): i32 { - return i32.MIN_VALUE; + return i32.MIN_VALUE } export function testI32Output_max(): i32 { - return i32.MAX_VALUE; + return i32.MAX_VALUE } export function testI64Input_min(n: i64): void { - assert(n == i64.MIN_VALUE); + assert(n == i64.MIN_VALUE) } export function testI64Input_max(n: i64): void { - assert(n == i64.MAX_VALUE); + assert(n == i64.MAX_VALUE) } export function testI64Output_min(): i64 { - return i64.MIN_VALUE; + return i64.MIN_VALUE } export function testI64Output_max(): i64 { - return i64.MAX_VALUE; + return i64.MAX_VALUE } export function testISizeInput_min(n: isize): void { - assert(n == isize.MIN_VALUE); + assert(n == isize.MIN_VALUE) } export function testISizeInput_max(n: isize): void { - assert(n == isize.MAX_VALUE); + assert(n == isize.MAX_VALUE) } export function testISizeOutput_min(): isize { - return isize.MIN_VALUE; + return isize.MIN_VALUE } export function testISizeOutput_max(): isize { - return isize.MAX_VALUE; + return isize.MAX_VALUE } export function testU8Input_min(n: u8): void { - assert(n == u8.MIN_VALUE); + assert(n == u8.MIN_VALUE) } export function testU8Input_max(n: u8): void { - assert(n == u8.MAX_VALUE); + assert(n == u8.MAX_VALUE) } export function testU8Output_min(): u8 { - return u8.MIN_VALUE; + return u8.MIN_VALUE } export function testU8Output_max(): u8 { - return u8.MAX_VALUE; + return u8.MAX_VALUE } export function testU16Input_min(n: u16): void { - assert(n == u16.MIN_VALUE); + assert(n == u16.MIN_VALUE) } export function testU16Input_max(n: u16): void { - assert(n == u16.MAX_VALUE); + assert(n == u16.MAX_VALUE) } export function testU16Output_min(): u16 { - return u16.MIN_VALUE; + return u16.MIN_VALUE } export function testU16Output_max(): u16 { - return u16.MAX_VALUE; + return u16.MAX_VALUE } export function testU32Input_min(n: u32): void { - assert(n == u32.MIN_VALUE); + assert(n == u32.MIN_VALUE) } export function testU32Input_max(n: u32): void { - assert(n == u32.MAX_VALUE); + assert(n == u32.MAX_VALUE) } export function testU32Output_min(): u32 { - return u32.MIN_VALUE; + return u32.MIN_VALUE } export function testU32Output_max(): u32 { - return u32.MAX_VALUE; + return u32.MAX_VALUE } export function testU64Input_min(n: u64): void { - assert(n == u64.MIN_VALUE); + assert(n == u64.MIN_VALUE) } export function testU64Input_max(n: u64): void { - assert(n == u64.MAX_VALUE); + assert(n == u64.MAX_VALUE) } export function testU64Output_min(): u64 { - return u64.MIN_VALUE; + return u64.MIN_VALUE } export function testU64Output_max(): u64 { - return u64.MAX_VALUE; + return u64.MAX_VALUE } export function testUSizeInput_min(n: usize): void { - assert(n == usize.MIN_VALUE); + assert(n == usize.MIN_VALUE) } export function testUSizeInput_max(n: usize): void { - assert(n == usize.MAX_VALUE); + assert(n == usize.MAX_VALUE) } export function testUSizeOutput_min(): usize { - return usize.MIN_VALUE; + return usize.MIN_VALUE } export function testUSizeOutput_max(): usize { - return usize.MAX_VALUE; + return usize.MAX_VALUE } export function testF32Input_min(n: f32): void { - assert(n == f32.MIN_VALUE); + assert(n == f32.MIN_VALUE) } export function testF32Input_max(n: f32): void { - assert(n == f32.MAX_VALUE); + assert(n == f32.MAX_VALUE) } export function testF32Output_min(): f32 { - return f32.MIN_VALUE; + return f32.MIN_VALUE } export function testF32Output_max(): f32 { - return f32.MAX_VALUE; + return f32.MAX_VALUE } export function testF64Input_min(n: f64): void { - assert(n == f64.MIN_VALUE); + assert(n == f64.MIN_VALUE) } export function testF64Input_max(n: f64): void { - assert(n == f64.MAX_VALUE); + assert(n == f64.MAX_VALUE) } export function testF64Output_min(): f64 { - return f64.MIN_VALUE; + return f64.MIN_VALUE } export function testF64Output_max(): f64 { - return f64.MAX_VALUE; + return f64.MAX_VALUE } diff --git a/runtime/languages/assemblyscript/testdata/assembly/strings.ts b/runtime/languages/assemblyscript/testdata/assembly/strings.ts index 7de9085e0..ca77b3986 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/strings.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/strings.ts @@ -8,44 +8,44 @@ */ // "Hello World" in Japanese -const testString = "γ“γ‚“γ«γ‘γ―γ€δΈ–η•Œ"; +const testString = "γ“γ‚“γ«γ‘γ―γ€δΈ–η•Œ" export function testStringInput(s: string): void { - assert(s == testString); + assert(s == testString) } export function testStringOutput(): string { - return testString; + return testString } export function testStringInput_empty(s: string): void { - assert(s == ""); + assert(s == "") } export function testStringOutput_empty(): string { - return ""; + return "" } export function testNullStringInput(s: string | null): void { - assert(s == testString); + assert(s == testString) } export function testNullStringOutput(): string | null { - return testString; + return testString } export function testNullStringInput_empty(s: string | null): void { - assert(s == ""); + assert(s == "") } export function testNullStringOutput_empty(): string | null { - return ""; + return "" } export function testNullStringInput_null(s: string | null): void { - assert(s == null); + assert(s == null) } export function testNullStringOutput_null(): string | null { - return null; + return null } diff --git a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts index 895966fc1..96d4ccf00 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts @@ -8,171 +8,171 @@ */ export function testInt8ArrayInput(view: Int8Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testInt8ArrayOutput(): Int8Array { - const view = new Int8Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Int8Array(4) + view.set([0, 1, 2, 3]) + return view } export function testInt16ArrayInput(view: Int16Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testInt16ArrayOutput(): Int16Array { - const view = new Int16Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Int16Array(4) + view.set([0, 1, 2, 3]) + return view } export function testInt32ArrayInput(view: Int32Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testInt32ArrayOutput(): Int32Array { - const view = new Int32Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Int32Array(4) + view.set([0, 1, 2, 3]) + return view } export function testInt64ArrayInput(view: Int64Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testInt64ArrayOutput(): Int64Array { - const view = new Int64Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Int64Array(4) + view.set([0, 1, 2, 3]) + return view } export function testUint8ArrayInput(view: Uint8Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testUint8ArrayInput_empty(view: Uint8Array): void { - assert(view.length == 0); + assert(view.length == 0) } export function testUint8ArrayInput_null(view: Uint8Array | null): void { - assert(view == null); + assert(view == null) } export function testUint8ArrayOutput(): Uint8Array { - const view = new Uint8Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Uint8Array(4) + view.set([0, 1, 2, 3]) + return view } export function testUint8ArrayOutput_empty(): Uint8Array { - return new Uint8Array(0); + return new Uint8Array(0) } export function testUint8ArrayOutput_null(): Uint8Array | null { - return null; + return null } export function testUint8ClampedArrayInput(view: Uint8ClampedArray): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testUint8ClampedArrayOutput(): Uint8ClampedArray { - const view = new Uint8ClampedArray(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Uint8ClampedArray(4) + view.set([0, 1, 2, 3]) + return view } export function testUint16ArrayInput(view: Uint16Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testUint16ArrayOutput(): Uint16Array { - const view = new Uint16Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Uint16Array(4) + view.set([0, 1, 2, 3]) + return view } export function testUint32ArrayInput(view: Uint32Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testUint32ArrayOutput(): Uint32Array { - const view = new Uint32Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Uint32Array(4) + view.set([0, 1, 2, 3]) + return view } export function testUint64ArrayInput(view: Uint64Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testUint64ArrayOutput(): Uint64Array { - const view = new Uint64Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Uint64Array(4) + view.set([0, 1, 2, 3]) + return view } export function testFloat32ArrayInput(view: Float32Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testFloat32ArrayOutput(): Float32Array { - const view = new Float32Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Float32Array(4) + view.set([0, 1, 2, 3]) + return view } export function testFloat64ArrayInput(view: Float64Array): void { - assert(view.length == 4); - assert(view[0] == 0); - assert(view[1] == 1); - assert(view[2] == 2); - assert(view[3] == 3); + assert(view.length == 4) + assert(view[0] == 0) + assert(view[1] == 1) + assert(view[2] == 2) + assert(view[3] == 3) } export function testFloat64ArrayOutput(): Float64Array { - const view = new Float64Array(4); - view.set([0, 1, 2, 3]); - return view; + const view = new Float64Array(4) + view.set([0, 1, 2, 3]) + return view } diff --git a/runtime/languages/golang/testdata/README.md b/runtime/languages/golang/testdata/README.md index 8f6fd4d33..42ae1fb6d 100644 --- a/runtime/languages/golang/testdata/README.md +++ b/runtime/languages/golang/testdata/README.md @@ -2,5 +2,5 @@ This is a Modus project that is used for testing the runtime's Go language features. -If you make changes, please build using `make build-testdata-golang` from the runtime root, -and commit the resulting `testdata.wasm` file. +If you make changes, please build using `make build-testdata-golang` from the runtime root, and +commit the resulting `testdata.wasm` file. diff --git a/runtime/languages/golang/testdata/build.sh b/runtime/languages/golang/testdata/build.sh index 7cdc6f5ce..21b98bceb 100755 --- a/runtime/languages/golang/testdata/build.sh +++ b/runtime/languages/golang/testdata/build.sh @@ -1,7 +1,7 @@ #!/bin/bash -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../../../sdk/go/tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../../../sdk/go/tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/README.md b/sdk/README.md index 05d5851fe..1c4803aad 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -1,6 +1,8 @@ # Modus SDKs -This directory contains the source code for the SDKs of each language that you can write Modus apps in. +This directory contains the source code for the SDKs of each language that you can write Modus apps +in. -Typically, you will not need to download this code directly, as the SDK will automatically be installed when -you create a new Modus project. However, you may wish to explore the example projects in each SDK. +Typically, you will not need to download this code directly, as the SDK will automatically be +installed when you create a new Modus project. However, you may wish to explore the example projects +in each SDK. diff --git a/sdk/assemblyscript/CHANGELOG.md b/sdk/assemblyscript/CHANGELOG.md index 9d80ea863..f0f0912f6 100644 --- a/sdk/assemblyscript/CHANGELOG.md +++ b/sdk/assemblyscript/CHANGELOG.md @@ -1,46 +1,61 @@ # Change Log -## *NOTICE* +## _NOTICE_ -This change log is retained for historical reference only, and is no longer updated. -See the [root-level change log](../../CHANGELOG.md) for current versions. +This change log is retained for historical reference only, and is no longer updated. See the +[root-level change log](../../CHANGELOG.md) for current versions. ## 2024-09-16 - Version 0.12.0 -- Update to v2 Hypermode metadata format [#176](https://github.com/hypermodeinc/functions-as/pull/176) -- Fix display output of certain types during build [#180](https://github.com/hypermodeinc/functions-as/pull/180) -- Make json in dgraph response not nullable [#181](https://github.com/hypermodeinc/functions-as/pull/181) +- Update to v2 Hypermode metadata format + [#176](https://github.com/hypermodeinc/functions-as/pull/176) +- Fix display output of certain types during build + [#180](https://github.com/hypermodeinc/functions-as/pull/180) +- Make json in dgraph response not nullable + [#181](https://github.com/hypermodeinc/functions-as/pull/181) - Add getLabel collection sdk function [#183](https://github.com/hypermodeinc/functions-as/pull/183) ## 2024-08-27 - Version 0.11.2 -- Redo Dgraph host functions implementation [#171](https://github.com/hypermodeinc/functions-as/pull/171) -- Add get vector and search by vector functions to collections [#172](https://github.com/hypermodeinc/functions-as/pull/172) +- Redo Dgraph host functions implementation + [#171](https://github.com/hypermodeinc/functions-as/pull/171) +- Add get vector and search by vector functions to collections + [#172](https://github.com/hypermodeinc/functions-as/pull/172) ## 2024-08-13 - Version 0.11.1 -- Add Dgraph support with host functions [#165](https://github.com/hypermodeinc/functions-as/pull/165) +- Add Dgraph support with host functions + [#165](https://github.com/hypermodeinc/functions-as/pull/165) ## 2024-08-12 - Version 0.11.0 -- Add nearest neighbor classification support for collections [#156](https://github.com/hypermodeinc/functions-as/pull/156) -- Add namespace support for collections [#158](https://github.com/hypermodeinc/functions-as/pull/158) -- Add getNamespaces host function to collections [#160](https://github.com/hypermodeinc/functions-as/pull/160) -- Add cross namespace search support to collections [#161](https://github.com/hypermodeinc/functions-as/pull/161) +- Add nearest neighbor classification support for collections + [#156](https://github.com/hypermodeinc/functions-as/pull/156) +- Add namespace support for collections + [#158](https://github.com/hypermodeinc/functions-as/pull/158) +- Add getNamespaces host function to collections + [#160](https://github.com/hypermodeinc/functions-as/pull/160) +- Add cross namespace search support to collections + [#161](https://github.com/hypermodeinc/functions-as/pull/161) - Update collections example [#162](https://github.com/hypermodeinc/functions-as/pull/162) ## 2024-08-01 - Version 0.10.5 -- Upgrade linters and include config in npm package [#152](https://github.com/hypermodeinc/functions-as/pull/152) +- Upgrade linters and include config in npm package + [#152](https://github.com/hypermodeinc/functions-as/pull/152) ## 2024-07-23 - Version 0.10.4 -- Result object scoring name changed to distance [#143](https://github.com/hypermodeinc/functions-as/pull/143) -- Collect default values for optional parameters instead of rewriting with supplied_params [#144](https://github.com/hypermodeinc/functions-as/pull/144) [#146](https://github.com/hypermodeinc/functions-as/pull/146) +- Result object scoring name changed to distance + [#143](https://github.com/hypermodeinc/functions-as/pull/143) +- Collect default values for optional parameters instead of rewriting with supplied_params + [#144](https://github.com/hypermodeinc/functions-as/pull/144) + [#146](https://github.com/hypermodeinc/functions-as/pull/146) ## 2024-07-16 - Version 0.10.3 -- Actual fix of compatibility with older QueryVariables API [#140](https://github.com/hypermodeinc/functions-as/pull/140) +- Actual fix of compatibility with older QueryVariables API + [#140](https://github.com/hypermodeinc/functions-as/pull/140) ## 2024-07-15 - Version 0.10.2 @@ -48,18 +63,23 @@ See the [root-level change log](../../CHANGELOG.md) for current versions. ## 2024-07-15 - Version 0.10.1 -- Attempted fix compatibility with older QueryVariables API [#137](https://github.com/hypermodeinc/functions-as/pull/137) +- Attempted fix compatibility with older QueryVariables API + [#137](https://github.com/hypermodeinc/functions-as/pull/137) ## 2024-07-15 - Version 0.10.0 -- Add functions and example for accessing PostgreSQL [#119](https://github.com/hypermodeinc/functions-as/pull/119) +- Add functions and example for accessing PostgreSQL + [#119](https://github.com/hypermodeinc/functions-as/pull/119) - Make plugin version optional [#133](https://github.com/hypermodeinc/functions-as/pull/133) -- Fix transform display of optional string literal [#134](https://github.com/hypermodeinc/functions-as/pull/134) -- Fix exporting imported functions or exporting as an alias does not work [#135](https://github.com/hypermodeinc/functions-as/pull/135) +- Fix transform display of optional string literal + [#134](https://github.com/hypermodeinc/functions-as/pull/134) +- Fix exporting imported functions or exporting as an alias does not work + [#135](https://github.com/hypermodeinc/functions-as/pull/135) ## 2024-07-10 - Version 0.9.4 -- Fix transform error when reexporting function from another file [#129](https://github.com/hypermodeinc/functions-as/pull/129) +- Fix transform error when reexporting function from another file + [#129](https://github.com/hypermodeinc/functions-as/pull/129) ## 2024-07-09 - Version 0.9.3 @@ -68,12 +88,14 @@ See the [root-level change log](../../CHANGELOG.md) for current versions. ## 2024-06-26 - Version 0.9.2 -- Move/rename GraphQL types to `graphql` namespace [#118](https://github.com/hypermodeinc/functions-as/pull/118) +- Move/rename GraphQL types to `graphql` namespace + [#118](https://github.com/hypermodeinc/functions-as/pull/118) ## 2024-06-24 - Version 0.9.1 - Remove `@embedder` decorator [#112](https://github.com/hypermodeinc/functions-as/pull/112) -- Update examples [#113](https://github.com/hypermodeinc/functions-as/pull/113) [#115](https://github.com/hypermodeinc/functions-as/pull/115) +- Update examples [#113](https://github.com/hypermodeinc/functions-as/pull/113) + [#115](https://github.com/hypermodeinc/functions-as/pull/115) - Misc updates [#114](https://github.com/hypermodeinc/functions-as/pull/114) - `connection.invokeGraphqlApi` is now `graphql.execute` - `connection` and `inference` classes are now marked deprecated @@ -86,11 +108,16 @@ _Note: Requires Hypermode Runtime v0.9.0 or newer_ - Add collections host functions [#96](https://github.com/hypermodeinc/functions-as/pull/96) - Fixed bug in plugin build script [#87](https://github.com/gohypermode/functions-as/pull/87) -- Updated all examples to use new manifest format [#94](https://github.com/gohypermode/functions-as/pull/94) -- Support query variables of any serializable type [#99](https://github.com/gohypermode/functions-as/pull/99) -- Route `console.log` through Runtime host function [#102](https://github.com/gohypermode/functions-as/pull/102) -- Support `@embedder` decorator to denote embedded function [#104](https://github.com/hypermodeinc/functions-as/pull/104) -- Implement new models interface and rework examples [#106](https://github.com/hypermodeinc/functions-as/pull/106) +- Updated all examples to use new manifest format + [#94](https://github.com/gohypermode/functions-as/pull/94) +- Support query variables of any serializable type + [#99](https://github.com/gohypermode/functions-as/pull/99) +- Route `console.log` through Runtime host function + [#102](https://github.com/gohypermode/functions-as/pull/102) +- Support `@embedder` decorator to denote embedded function + [#104](https://github.com/hypermodeinc/functions-as/pull/104) +- Implement new models interface and rework examples + [#106](https://github.com/hypermodeinc/functions-as/pull/106) ## Version 0.8.0 @@ -100,22 +127,31 @@ _skipped to align with runtime version_ _Note: Requires Hypermode Runtime v0.7.0 or newer_ -- Fixed threshold logic bug in `inference.classifyText` [#76](https://github.com/hypermodeinc/functions-as/pull/76) -- Align `hypermode.json` examples to changes in manifest schema [#79](https://github.com/hypermodeinc/functions-as/pull/79) [#80](https://github.com/hypermodeinc/functions-as/pull/80) [#81](https://github.com/hypermodeinc/functions-as/pull/81) +- Fixed threshold logic bug in `inference.classifyText` + [#76](https://github.com/hypermodeinc/functions-as/pull/76) +- Align `hypermode.json` examples to changes in manifest schema + [#79](https://github.com/hypermodeinc/functions-as/pull/79) + [#80](https://github.com/hypermodeinc/functions-as/pull/80) + [#81](https://github.com/hypermodeinc/functions-as/pull/81) - Add `http.fetch` API [#84](https://github.com/hypermodeinc/functions-as/pull/84) ## 2024-04-25 - Version 0.6.1 -- Fixed compilation transform error when there are no host functions used. [#69](https://github.com/hypermodeinc/functions-as/pull/69) +- Fixed compilation transform error when there are no host functions used. + [#69](https://github.com/hypermodeinc/functions-as/pull/69) ## 2024-04-25 - Version 0.6.0 _Note: Requires Hypermode Runtime v0.6.0 or newer_ -- **(BREAKING)** Most APIs for host functions have been renamed. [#44](https://github.com/hypermodeinc/functions-as/pull/44) -- Types used by host functions are captured in the metadata. [#65](https://github.com/hypermodeinc/functions-as/pull/65) -- **(BREAKING)** DQL-based host functions and examples have been removed. [#66](https://github.com/hypermodeinc/functions-as/pull/66) -- **(BREAKING)** Update host functions, and improve error handling. [#67](https://github.com/hypermodeinc/functions-as/pull/67) +- **(BREAKING)** Most APIs for host functions have been renamed. + [#44](https://github.com/hypermodeinc/functions-as/pull/44) +- Types used by host functions are captured in the metadata. + [#65](https://github.com/hypermodeinc/functions-as/pull/65) +- **(BREAKING)** DQL-based host functions and examples have been removed. + [#66](https://github.com/hypermodeinc/functions-as/pull/66) +- **(BREAKING)** Update host functions, and improve error handling. + [#67](https://github.com/hypermodeinc/functions-as/pull/67) ## 2024-04-18 - Version 0.5.0 @@ -124,23 +160,35 @@ _Note: Requires Hypermode Runtime v0.5.0_ - Internal metadata format has changed. [#39](https://github.com/hypermodeinc/functions-as/pull/39) - Metadata includes function signatures for improved Runtime support. - Compiling a project now outputs the metadata. -- **(BREAKING)** Support query parameters of different types. [#40](https://github.com/hypermodeinc/functions-as/pull/40) -- Further improvements to compiler output. [#41](https://github.com/hypermodeinc/functions-as/pull/41) -- Example project now uses a local path to the source library. [#42](https://github.com/hypermodeinc/functions-as/pull/42) -- Capture custom data type definitions in the metadata. [#44](https://github.com/hypermodeinc/functions-as/pull/44) [#52](https://github.com/hypermodeinc/functions-as/pull/52) [#53](https://github.com/hypermodeinc/functions-as/pull/53) [#55](https://github.com/hypermodeinc/functions-as/pull/55) [#56](https://github.com/hypermodeinc/functions-as/pull/56) -- Improve build scripts [#46](https://github.com/hypermodeinc/functions-as/pull/46) [#51](https://github.com/hypermodeinc/functions-as/pull/51) -- Add environment variable to debug metadata [#54](https://github.com/hypermodeinc/functions-as/pull/54) +- **(BREAKING)** Support query parameters of different types. + [#40](https://github.com/hypermodeinc/functions-as/pull/40) +- Further improvements to compiler output. + [#41](https://github.com/hypermodeinc/functions-as/pull/41) +- Example project now uses a local path to the source library. + [#42](https://github.com/hypermodeinc/functions-as/pull/42) +- Capture custom data type definitions in the metadata. + [#44](https://github.com/hypermodeinc/functions-as/pull/44) + [#52](https://github.com/hypermodeinc/functions-as/pull/52) + [#53](https://github.com/hypermodeinc/functions-as/pull/53) + [#55](https://github.com/hypermodeinc/functions-as/pull/55) + [#56](https://github.com/hypermodeinc/functions-as/pull/56) +- Improve build scripts [#46](https://github.com/hypermodeinc/functions-as/pull/46) + [#51](https://github.com/hypermodeinc/functions-as/pull/51) +- Add environment variable to debug metadata + [#54](https://github.com/hypermodeinc/functions-as/pull/54) ## 2024-03-22 - Version 0.4.0 -- Adds `model.generate` and `model.generateList` [#30](https://github.com/hypermodeinc/functions-as/pull/30) +- Adds `model.generate` and `model.generateList` + [#30](https://github.com/hypermodeinc/functions-as/pull/30) - **(BREAKING)** `model.invokeTextGenerator` has been renamed to `model.generateText` ## 2024-03-14 - Version 0.3.0 - Metadata is now included during build. [#27](https://github.com/hypermodeinc/functions-as/pull/27) - - You must also add `@hypermode/functions-as/transform` to the transforms in the `asconfig.json` file. For example: + - You must also add `@hypermode/functions-as/transform` to the transforms in the `asconfig.json` + file. For example: ```json "options": { @@ -154,7 +202,8 @@ _Note: Requires Hypermode Runtime v0.5.0_ ## 2024-03-13 - Version 0.2.2 -- **(BREAKING)** Host functions that previously returned vector embeddings as strings now return `f64[]` instead. [#25](https://github.com/hypermodeinc/functions-as/pull/25) +- **(BREAKING)** Host functions that previously returned vector embeddings as strings now return + `f64[]` instead. [#25](https://github.com/hypermodeinc/functions-as/pull/25) _note: 0.2.1 was published prematurely and has been unpublished. Use 0.2.2._ diff --git a/sdk/assemblyscript/README.md b/sdk/assemblyscript/README.md index de2ec538e..8c8b5aa7f 100644 --- a/sdk/assemblyscript/README.md +++ b/sdk/assemblyscript/README.md @@ -7,16 +7,16 @@ ![NPM Version](https://img.shields.io/npm/v/%40hypermode%2Ffunctions-as) ![NPM Downloads](https://img.shields.io/npm/dw/%40hypermode%2Ffunctions-as) -This repository contains the SDK used by [Hypermode](https://hypermode.com) -Functions written in [AssemblyScript](https://www.assemblyscript.org/). +This repository contains the SDK used by [Hypermode](https://hypermode.com) Functions written in +[AssemblyScript](https://www.assemblyscript.org/). -The SDK provides a library to access the Hypermode platform, and helper classes -and functions for use with Hypermode Functions, and examples to demonstrate usage. +The SDK provides a library to access the Hypermode platform, and helper classes and functions for +use with Hypermode Functions, and examples to demonstrate usage. ## Documentation -Please visit [docs.hypermode.com](https://docs.hypermode.com/) for detailed docs -covering the Hypermode platform, including this SDK. +Please visit [docs.hypermode.com](https://docs.hypermode.com/) for detailed docs covering the +Hypermode platform, including this SDK. ## Getting Started @@ -31,8 +31,8 @@ You can install Node.js with any supported method, including: ### Trying out the examples -The [`examples`](./examples/) folder contains example projects that demonstrate the -features of the Hypermode platform. +The [`examples`](./examples/) folder contains example projects that demonstrate the features of the +Hypermode platform. #### Initial setup @@ -82,8 +82,8 @@ Now that we've set up the prerequisites, we can compile an example project with On a successful build, you'll find the output in the example's `build` folder. -> _NOTE:_ For convenience, the examples have their `package.json` configured -> with a local path to the source project, as follows: +> _NOTE:_ For convenience, the examples have their `package.json` configured with a local path to +> the source project, as follows: > > ```json > "dependencies": { @@ -92,32 +92,35 @@ On a successful build, you'll find the output in the example's `build` folder. > ``` > > In your own project, you should instead reference a version number of -> [the published package](https://www.npmjs.com/package/@hypermode/functions-as), -> as you would with any other project dependency. +> [the published package](https://www.npmjs.com/package/@hypermode/functions-as), as you would with +> any other project dependency. ### Creating your own Hypermode plugin -When you are ready to start writing your own Hypermode plugin, we recommend starting -from the [Hypermode Base Template](https://github.com/hypermodeinc/base-template). +When you are ready to start writing your own Hypermode plugin, we recommend starting from the +[Hypermode Base Template](https://github.com/hypermodeinc/base-template). -It is pre-configured to use the latest version of this library, and has all of the -necessary configuration, scripts, and workflows needed to develop your Hypermode functions. +It is pre-configured to use the latest version of this library, and has all of the necessary +configuration, scripts, and workflows needed to develop your Hypermode functions. -1. Navigate to the [Hypermode Base Template](https://github.com/hypermodeinc/base-template) repository. +1. Navigate to the [Hypermode Base Template](https://github.com/hypermodeinc/base-template) + repository. 2. Click the "Use this template" button in the upper-right corner to create your own repository. -3. In the `functions` folder, edit the `package.json` file to update the `name`, `version`, `description`, - `author`, and `license` properties as needed for your purposes. -4. In the `functions/assembly` folder, begin writing your Hypermode functions in `index.ts`. - You can replace the starter function with your own code. You can also add more files to the `assembly` - folder and use `import` and `export` statements to connect them (as seen in the `simple` example). - _Note that only the final function exports from `index.ts` will be registered as Hypermode Functions._ +3. In the `functions` folder, edit the `package.json` file to update the `name`, `version`, + `description`, `author`, and `license` properties as needed for your purposes. +4. In the `functions/assembly` folder, begin writing your Hypermode functions in `index.ts`. You can + replace the starter function with your own code. You can also add more files to the `assembly` + folder and use `import` and `export` statements to connect them (as seen in the `simple` + example). _Note that only the final function exports from `index.ts` will be registered as + Hypermode Functions._ 5. In the root folder of your project, edit the `modus.json` manifest file as needed to connect the models and hosts used by your functions. ### Publishing to Hypermode -Currently, your project must be created from the template project in order to publish it to Hypermode. +Currently, your project must be created from the template project in order to publish it to +Hypermode. -The Hypermode GitHub application will need to be added to your repository, and Hypermode backend will -need to be set up. During this early phase, Hypermode staff will coordinate with you to perform these -steps manually. Please contact your Hypermode representative for further details. +The Hypermode GitHub application will need to be added to your repository, and Hypermode backend +will need to be set up. During this early phase, Hypermode staff will coordinate with you to perform +these steps manually. Please contact your Hypermode representative for further details. diff --git a/sdk/assemblyscript/scripts/install-all.sh b/sdk/assemblyscript/scripts/install-all.sh index 3b482143f..89d43b95a 100755 --- a/sdk/assemblyscript/scripts/install-all.sh +++ b/sdk/assemblyscript/scripts/install-all.sh @@ -11,9 +11,9 @@ npm install cd ../examples for example in *; do - if [ -d "${example}" ]; then - cd "${example}" - npm install - cd .. - fi + if [[ -d ${example} ]]; then + cd "${example}" + npm install + cd .. + fi done diff --git a/sdk/assemblyscript/scripts/prepare-release.sh b/sdk/assemblyscript/scripts/prepare-release.sh index 38603db67..6fb502888 100755 --- a/sdk/assemblyscript/scripts/prepare-release.sh +++ b/sdk/assemblyscript/scripts/prepare-release.sh @@ -6,9 +6,9 @@ trap "cd \"${PWD}\"" EXIT cd "$(dirname "$0")" # get the version number from the command line argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " + exit 1 fi version=$1 @@ -17,37 +17,37 @@ echo "Preparing release for version ${version}" cd .. # Update the version in the sdk.json file -jq --arg ver "${version}" '.sdk.version = $ver' sdk.json > tmp.json && mv tmp.json sdk.json +jq --arg ver "${version}" '.sdk.version = $ver' sdk.json >tmp.json && mv tmp.json sdk.json # Update the version of the sdk used in the templates cd templates for template in *; do - if [ -d "${template}" ]; then - cd "${template}" + if [[ -d ${template} ]]; then + cd "${template}" - # Remove any output files - rm -rf node_modules - rm -rf build + # Remove any output files + rm -rf node_modules + rm -rf build - # Remove the lockfile - it will be regenerated by npm install when the template is used. - rm -f package-lock.json + # Remove the lockfile - it will be regenerated by npm install when the template is used. + rm -f package-lock.json - # Update the version of the modus-sdk-as dependency to match the release version. - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json - else - sed -i 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json - fi + # Update the version of the modus-sdk-as dependency to match the release version. + if [[ ${OSTYPE} == "darwin"* ]]; then + sed -i '' 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json + else + sed -i 's/"@hypermode\/modus-sdk-as": "..\/..\/src"/"@hypermode\/modus-sdk-as": "^'"${version}"'"/' package.json + fi - cd .. - fi + cd .. + fi done cd .. # Create a tarball of the templates -tar -czvf templates_assemblyscript_v${version}.tar.gz templates +tar -czvf templates_assemblyscript_v"${version}".tar.gz templates # set the version in the package.json file cd src -npm version ${version} --no-git-tag-version +npm version "${version}" --no-git-tag-version cd .. diff --git a/sdk/assemblyscript/scripts/upgrade-deps.sh b/sdk/assemblyscript/scripts/upgrade-deps.sh index 89fb4679c..072cf5511 100755 --- a/sdk/assemblyscript/scripts/upgrade-deps.sh +++ b/sdk/assemblyscript/scripts/upgrade-deps.sh @@ -13,10 +13,10 @@ npm install cd ../examples for example in *; do - if [ -d "${example}" ]; then - cd "${example}" - ncu -u -t minor - npm install - cd .. - fi + if [[ -d ${example} ]]; then + cd "${example}" + ncu -u -t minor + npm install + cd .. + fi done diff --git a/sdk/go/examples/anthropic-functions/build.sh b/sdk/go/examples/anthropic-functions/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/anthropic-functions/build.sh +++ b/sdk/go/examples/anthropic-functions/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/auth/build.sh b/sdk/go/examples/auth/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/auth/build.sh +++ b/sdk/go/examples/auth/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/classification/build.sh b/sdk/go/examples/classification/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/classification/build.sh +++ b/sdk/go/examples/classification/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/collections/build.sh b/sdk/go/examples/collections/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/collections/build.sh +++ b/sdk/go/examples/collections/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/dgraph/build.sh b/sdk/go/examples/dgraph/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/dgraph/build.sh +++ b/sdk/go/examples/dgraph/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/embedding/build.sh b/sdk/go/examples/embedding/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/embedding/build.sh +++ b/sdk/go/examples/embedding/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/graphql/build.sh b/sdk/go/examples/graphql/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/graphql/build.sh +++ b/sdk/go/examples/graphql/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/http/build.sh b/sdk/go/examples/http/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/http/build.sh +++ b/sdk/go/examples/http/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/neo4j/build.sh b/sdk/go/examples/neo4j/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/neo4j/build.sh +++ b/sdk/go/examples/neo4j/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/postgresql/build.sh b/sdk/go/examples/postgresql/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/postgresql/build.sh +++ b/sdk/go/examples/postgresql/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/simple/build.sh b/sdk/go/examples/simple/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/simple/build.sh +++ b/sdk/go/examples/simple/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/textgeneration/build.sh b/sdk/go/examples/textgeneration/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/textgeneration/build.sh +++ b/sdk/go/examples/textgeneration/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/time/build.sh b/sdk/go/examples/time/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/time/build.sh +++ b/sdk/go/examples/time/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/examples/vectors/build.sh b/sdk/go/examples/vectors/build.sh index 02743fecf..93bc3e15b 100755 --- a/sdk/go/examples/vectors/build.sh +++ b/sdk/go/examples/vectors/build.sh @@ -4,9 +4,9 @@ # If you are using this as a template for your own project, you may need to modify this script, # to invoke the modus-go-build tool with the correct path to your project. -PROJECTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -pushd ../../tools/modus-go-build > /dev/null -go run . "$PROJECTDIR" +PROJECTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +pushd ../../tools/modus-go-build >/dev/null || exit +go run . "${PROJECTDIR}" exit_code=$? -popd > /dev/null -exit $exit_code +popd >/dev/null || exit +exit "${exit_code}" diff --git a/sdk/go/scripts/prepare-release.sh b/sdk/go/scripts/prepare-release.sh index ce1346073..3f6755b69 100755 --- a/sdk/go/scripts/prepare-release.sh +++ b/sdk/go/scripts/prepare-release.sh @@ -6,9 +6,9 @@ trap "cd \"${PWD}\"" EXIT cd "$(dirname "$0")" # get the version number from the command line argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " + exit 1 fi version=$1 @@ -17,21 +17,21 @@ echo "Preparing release for version ${version}" cd .. # Update the version in the sdk.json file -jq --arg ver "${version}" '.sdk.version = $ver' sdk.json > tmp.json && mv tmp.json sdk.json +jq --arg ver "${version}" '.sdk.version = $ver' sdk.json >tmp.json && mv tmp.json sdk.json # Update the version of the sdk used in the templates cd templates for template in *; do - if [ -d "${template}" ]; then - cd "${template}" + if [[ -d ${template} ]]; then + cd "${template}" - # update the go.mod file to use the new version - go get -u github.com/hypermodeinc/modus/sdk/go@v${version} + # update the go.mod file to use the new version + go get -u github.com/hypermodeinc/modus/sdk/go@v"${version}" - cd .. - fi + cd .. + fi done cd .. # Create a tarball of the templates -tar -czvf templates_go_v${version}.tar.gz templates +tar -czvf templates_go_v"${version}".tar.gz templates diff --git a/sdk/go/scripts/tidy-all.sh b/sdk/go/scripts/tidy-all.sh index 7515879a9..df93a0491 100755 --- a/sdk/go/scripts/tidy-all.sh +++ b/sdk/go/scripts/tidy-all.sh @@ -11,10 +11,10 @@ go mod tidy cd examples for example in *; do - if [ -d "${example}" ]; then - cd "${example}" - echo "Tidying examples/${example}" - go mod tidy - cd .. - fi + if [[ -d ${example} ]]; then + cd "${example}" + echo "Tidying examples/${example}" + go mod tidy + cd .. + fi done From 68886cf0207239d9d94b0675dbee6296c758fe0a Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 16:08:43 -0800 Subject: [PATCH 02/11] Fix markdown headings . --- .github/ISSUE_TEMPLATE/bug_report.md | 22 ++++++++++++++++------ .github/ISSUE_TEMPLATE/feature_request.md | 18 ++++++++++++------ .github/pull_request_template.md | 8 +++++--- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1f676e3ba..5f95c2849 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -6,23 +6,33 @@ labels: bug assignees: "" --- -**Describe the bug** A clear and concise description of what the bug is. +## Describe the bug -**To Reproduce** Steps to reproduce the behavior: +A clear and concise description of what the bug is. + +## To Reproduce + +Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error -**Expected behavior** A clear and concise description of what you expected to happen. +## Expected behavior + +A clear and concise description of what you expected to happen. -**Screenshots** If applicable, add screenshots to help explain your problem. +## Screenshots -**Environment** +If applicable, add screenshots to help explain your problem. + +## Environment - OS: [e.g. macOS, Windows, Ubuntu] - Language [e.g. AssemblyScript, Go] - Version [e.g. v0.xx] -**Additional context** Add any other context about the problem here. +## Additional context + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 3a3c1418e..9a4aae5a1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -6,12 +6,18 @@ labels: "" assignees: "" --- -**Is your feature request related to a problem? Please describe.** A clear and concise description -of what the problem is. Ex. I'm always frustrated when [...] +## Is your feature request related to a problem? Please describe -**Describe the solution you'd like** A clear and concise description of what you want to happen. +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -**Describe alternatives you've considered** A clear and concise description of any alternative -solutions or features you've considered. +## Describe the solution you'd like -**Additional context** Add any other context or screenshots about the feature request here. +A clear and concise description of what you want to happen. + +## Describe alternatives you've considered + +A clear and concise description of any alternative solutions or features you've considered. + +## Additional context + +Add any other context or screenshots about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6256c56dd..aecd7180f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,8 +1,10 @@ -**Description** + + +## Description Please explain the changes you made here. -**Checklist** +## Checklist - [ ] Code compiles correctly and linting passes locally - [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to @@ -11,7 +13,7 @@ Please explain the changes you made here. - [ ] For public APIs, new features, etc., PR on [docs repo](https://github.com/hypermodeinc/docs) staged and linked here -**Instructions** +## Instructions - The PR title should follow the [Conventional Commits](https://www.conventionalcommits.org/) syntax, leading with `fix:`, `feat:`, `chore:`, `ci:`, etc. From 3c24e8cca5eb0ff8684d4213b2d3820f3dfd7464 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 16:15:00 -0800 Subject: [PATCH 03/11] Fix run split lines --- .github/workflows/ci-go-lint.yml | 9 ++++++--- .github/workflows/ci-go-test.yml | 9 ++++++--- .github/workflows/ci-sdk-as-build.yml | 8 +++++--- .github/workflows/ci-sdk-as-lint.yml | 8 +++++--- .github/workflows/ci-sdk-go-build.yml | 18 ++++++++++++------ .github/workflows/release-cli.yaml | 8 +++++--- .github/workflows/release-sdk-as.yaml | 8 +++++--- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci-go-lint.yml b/.github/workflows/ci-go-lint.yml index 068cb9358..d638d568a 100644 --- a/.github/workflows/ci-go-lint.yml +++ b/.github/workflows/ci-go-lint.yml @@ -27,9 +27,12 @@ jobs: uses: actions/checkout@v4 - name: Search for go.mod files id: get-dirs - run: - echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc - 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + find . -name 'go.mod' -exec dirname {} \; | + sed 's|^\./||' | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} go-lint: needs: get-dirs diff --git a/.github/workflows/ci-go-test.yml b/.github/workflows/ci-go-test.yml index b61ea06a9..bc58eb4ea 100644 --- a/.github/workflows/ci-go-test.yml +++ b/.github/workflows/ci-go-test.yml @@ -29,9 +29,12 @@ jobs: uses: actions/checkout@v4 - name: Search for go.mod files id: get-dirs - run: - echo "dirs=$(find . -name 'go.mod' -exec dirname {} \; | sed 's|^\./||' | jq -Rsc - 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + find . -name 'go.mod' -exec dirname {} \; | + sed 's|^\./||' | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} go-test: needs: get-dirs diff --git a/.github/workflows/ci-sdk-as-build.yml b/.github/workflows/ci-sdk-as-build.yml index 5f3f8bdec..5c42bee28 100644 --- a/.github/workflows/ci-sdk-as-build.yml +++ b/.github/workflows/ci-sdk-as-build.yml @@ -25,9 +25,11 @@ jobs: uses: actions/checkout@v4 - name: Find Examples id: get-dirs - run: - echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> - ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + ls -d sdk/assemblyscript/examples/* | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} sdk-as-build-examples: needs: get-dirs diff --git a/.github/workflows/ci-sdk-as-lint.yml b/.github/workflows/ci-sdk-as-lint.yml index 103c08444..5c76f7158 100644 --- a/.github/workflows/ci-sdk-as-lint.yml +++ b/.github/workflows/ci-sdk-as-lint.yml @@ -25,9 +25,11 @@ jobs: uses: actions/checkout@v4 - name: Find Examples id: get-dirs - run: - echo "dirs=$(ls -d sdk/assemblyscript/examples/* | jq -Rsc 'split("\n")[:-1]' )" >> - ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + ls -d sdk/assemblyscript/examples/* | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} sdk-as-lint-src: if: github.event_name == 'pull_request' diff --git a/.github/workflows/ci-sdk-go-build.yml b/.github/workflows/ci-sdk-go-build.yml index 6976e2bde..653f98d44 100644 --- a/.github/workflows/ci-sdk-go-build.yml +++ b/.github/workflows/ci-sdk-go-build.yml @@ -26,14 +26,20 @@ jobs: uses: actions/checkout@v4 - name: Find tools id: get-tools-dirs - run: - echo "dirs=$(find ./sdk/go/tools -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq - -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + find ./sdk/go/tools -mindepth 1 -maxdepth 1 -type d | + sed 's|^\./||' | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} - name: Find examples id: get-examples-dirs - run: - echo "dirs=$(find ./sdk/go/examples -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | jq - -Rsc 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: > + echo "dirs=$( + find ./sdk/go/examples -mindepth 1 -maxdepth 1 -type d | + sed 's|^\./||' | + jq -Rsc 'split("\n")[:-1]' + )" >> ${GITHUB_OUTPUT} sdk-go-build-tools: needs: get-dirs diff --git a/.github/workflows/release-cli.yaml b/.github/workflows/release-cli.yaml index d0c257b6e..e5b352ee2 100644 --- a/.github/workflows/release-cli.yaml +++ b/.github/workflows/release-cli.yaml @@ -42,9 +42,11 @@ jobs: run: npm run build - name: Publish NPM Package working-directory: cli - run: - npm publish --provenance --access public --tag ${{ steps.parse_cli_version.outputs.npm_tag - }} + run: > + npm publish + --provenance + --access public + --tag ${{ steps.parse_cli_version.outputs.npm_tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Release diff --git a/.github/workflows/release-sdk-as.yaml b/.github/workflows/release-sdk-as.yaml index 32b384dae..064b6e244 100644 --- a/.github/workflows/release-sdk-as.yaml +++ b/.github/workflows/release-sdk-as.yaml @@ -40,9 +40,11 @@ jobs: run: npm ci - name: Publish NPM Package working-directory: sdk/assemblyscript/src - run: - npm publish --provenance --access public --tag ${{ steps.parse_sdk_version.outputs.npm_tag - }} + run: > + npm publish + --provenance + --access public + --tag ${{ steps.parse_sdk_version.outputs.npm_tag }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Create Release From da85c5aae2564c7d986f3614550b03e5e4c43f3e Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 17:23:45 -0800 Subject: [PATCH 04/11] Fix VSCode settings --- .vscode/extensions.json | 4 ++-- .vscode/launch.json | 6 +++--- .vscode/settings.json | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8327e8bd7..caf660a8b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,9 +1,9 @@ { "recommendations": [ - "trunk.io", "golang.go", "GraphQL.vscode-graphql", "ms-vscode.makefile-tools", - "streetsidesoftware.code-spell-checker" + "streetsidesoftware.code-spell-checker", + "trunk.io" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 3e35788b3..2e9f0b265 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "FORCE_COLOR": "1", "MODUS_ENV": "dev", "MODUS_DEBUG": "true", - "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" + "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" // checkov:skip=CKV_SECRET_4 }, "args": [ "--refresh=1s", @@ -29,7 +29,7 @@ "FORCE_COLOR": "1", "MODUS_ENV": "dev", "MODUS_DEBUG": "true", - "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" + "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" // checkov:skip=CKV_SECRET_4 }, "args": ["--refresh=1s", "--appPath", "${input:appPath}"] }, @@ -47,7 +47,7 @@ "AWS_REGION": "${input:awsRegion}", "AWS_PROFILE": "${input:awsProfile}", "AWS_SDK_LOAD_CONFIG": "true", - "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" + "MODUS_DB": "postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable" // checkov:skip=CKV_SECRET_4 }, "args": [ "--useAwsStorage", diff --git a/.vscode/settings.json b/.vscode/settings.json index 1daa81da5..f4d02a181 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.flagWords": ["teh", "hte"], + "cSpell.import": ["${workspaceRoot}/.trunk/configs/cspell.json"], "editor.formatOnSave": true, "editor.defaultFormatter": "trunk.io", "trunk.autoInit": false, @@ -11,7 +12,20 @@ "*hypermode.json": "jsonc", "*modus.json": "jsonc" }, + "go.lintTool": "golangci-lint", "go.testEnvVars": { "MODUS_DEBUG": "true" + }, + "[javascript]": { + "editor.defaultFormatter": "trunk.io" + }, + "[json]": { + "editor.defaultFormatter": "trunk.io" + }, + "[jsonc]": { + "editor.defaultFormatter": "trunk.io" + }, + "[typescript]": { + "editor.defaultFormatter": "trunk.io" } } From 7a26690968994fb50b443e8e65788660d67dbe3d Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 17:38:27 -0800 Subject: [PATCH 05/11] Remove old SDK readme files --- sdk/assemblyscript/README.md | 126 ----------------------------------- sdk/go/README.md | 3 - 2 files changed, 129 deletions(-) delete mode 100644 sdk/assemblyscript/README.md delete mode 100644 sdk/go/README.md diff --git a/sdk/assemblyscript/README.md b/sdk/assemblyscript/README.md deleted file mode 100644 index 8c8b5aa7f..000000000 --- a/sdk/assemblyscript/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# Modus SDK for AssemblyScript - -## TODO: Rewrite this file in the context of Modus - -![NPM Version](https://img.shields.io/npm/v/%40hypermode%2Ffunctions-as) -![NPM Downloads](https://img.shields.io/npm/dw/%40hypermode%2Ffunctions-as) - -This repository contains the SDK used by [Hypermode](https://hypermode.com) Functions written in -[AssemblyScript](https://www.assemblyscript.org/). - -The SDK provides a library to access the Hypermode platform, and helper classes and functions for -use with Hypermode Functions, and examples to demonstrate usage. - -## Documentation - -Please visit [docs.hypermode.com](https://docs.hypermode.com/) for detailed docs covering the -Hypermode platform, including this SDK. - -## Getting Started - -### Prerequisites - -Ensure you have [Node.js](https://nodejs.org/) 22 or higher installed and activated. - -You can install Node.js with any supported method, including: - -- Downloading the official [prebuilt installer](https://nodejs.org/en/download) -- Using a [package manager](https://nodejs.org/en/download/package-manager) - -### Trying out the examples - -The [`examples`](./examples/) folder contains example projects that demonstrate the features of the -Hypermode platform. - -#### Initial setup - -Before compiling any example, you must first do the following: - -1. Clone this repository locally: - - ```sh - git clone https://github.com/hypermodeinc/functions-as - ``` - -2. From the repository root, navigate to the `src` folder: - - ```sh - cd ./src/ - ``` - -3. Install dependencies with NPM: - - ```sh - npm install - ``` - -The above steps only needs to be performed one time. - -#### Compiling an example - -Now that we've set up the prerequisites, we can compile an example project with the following steps: - -1. From the repository root, navigate to the example's folder: - - ```sh - cd ./examples// - ``` - -2. Install dependencies with NPM: - - ```sh - npm install - ``` - -3. Build the project with NPM: - - ```sh - npm run build - ``` - -On a successful build, you'll find the output in the example's `build` folder. - -> _NOTE:_ For convenience, the examples have their `package.json` configured with a local path to -> the source project, as follows: -> -> ```json -> "dependencies": { -> "@hypermode/functions-as": "../../src", -> }, -> ``` -> -> In your own project, you should instead reference a version number of -> [the published package](https://www.npmjs.com/package/@hypermode/functions-as), as you would with -> any other project dependency. - -### Creating your own Hypermode plugin - -When you are ready to start writing your own Hypermode plugin, we recommend starting from the -[Hypermode Base Template](https://github.com/hypermodeinc/base-template). - -It is pre-configured to use the latest version of this library, and has all of the necessary -configuration, scripts, and workflows needed to develop your Hypermode functions. - -1. Navigate to the [Hypermode Base Template](https://github.com/hypermodeinc/base-template) - repository. -2. Click the "Use this template" button in the upper-right corner to create your own repository. -3. In the `functions` folder, edit the `package.json` file to update the `name`, `version`, - `description`, `author`, and `license` properties as needed for your purposes. -4. In the `functions/assembly` folder, begin writing your Hypermode functions in `index.ts`. You can - replace the starter function with your own code. You can also add more files to the `assembly` - folder and use `import` and `export` statements to connect them (as seen in the `simple` - example). _Note that only the final function exports from `index.ts` will be registered as - Hypermode Functions._ -5. In the root folder of your project, edit the `modus.json` manifest file as needed to connect the - models and hosts used by your functions. - -### Publishing to Hypermode - -Currently, your project must be created from the template project in order to publish it to -Hypermode. - -The Hypermode GitHub application will need to be added to your repository, and Hypermode backend -will need to be set up. During this early phase, Hypermode staff will coordinate with you to perform -these steps manually. Please contact your Hypermode representative for further details. diff --git a/sdk/go/README.md b/sdk/go/README.md deleted file mode 100644 index e3bc4362b..000000000 --- a/sdk/go/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Modus GO SDK - -TODO: finish this readme From d008d232ff559a5867e9b0fc596a4be7e1485a54 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 17:42:43 -0800 Subject: [PATCH 06/11] Share markdownlint config --- .github/pull_request_template.md | 2 -- .vscode/settings.json | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index aecd7180f..e03822d59 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,3 @@ - - ## Description Please explain the changes you made here. diff --git a/.vscode/settings.json b/.vscode/settings.json index f4d02a181..8e854d779 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,9 @@ "go.testEnvVars": { "MODUS_DEBUG": "true" }, + "markdownlint.config": { + "extends": ".trunk/configs/.markdownlint.json" + }, "[javascript]": { "editor.defaultFormatter": "trunk.io" }, From 9bc3db3820c1b1d55a981852c8d8930b8909d5f1 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 17:49:11 -0800 Subject: [PATCH 07/11] Update trunk.yaml --- .trunk/trunk.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 8bd179c03..31952fc58 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -21,8 +21,8 @@ runtimes: # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) lint: enabled: - - actionlint@1.7.5 - - checkov@3.2.346 + - actionlint@1.7.6 + - checkov@3.2.347 - git-diff-check - gofmt@1.20.4 - golangci-lint@1.62.2 From b7f37b436c3b90d4f43d39ce0e1b4e1e81df1bbd Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 17:53:05 -0800 Subject: [PATCH 08/11] restore semicolons --- .trunk/configs/.prettierrc | 2 +- README.md | 2 +- runtime/explorer/content/ModusIcon.tsx | 6 +- runtime/explorer/content/main.tsx | 46 ++--- runtime/explorer/content/postcss.config.js | 2 +- runtime/explorer/content/tailwind.config.js | 2 +- runtime/explorer/content/vite.config.ts | 8 +- .../testdata/assembly/arraybuffers.ts | 26 +-- .../testdata/assembly/arrays.ts | 84 ++++---- .../testdata/assembly/classes.ts | 156 +++++++-------- .../assemblyscript/testdata/assembly/dates.ts | 20 +- .../assemblyscript/testdata/assembly/env.ts | 10 +- .../testdata/assembly/hostfns.ts | 18 +- .../assemblyscript/testdata/assembly/index.ts | 20 +- .../assemblyscript/testdata/assembly/maps.ts | 162 +++++++-------- .../testdata/assembly/primitives.ts | 104 +++++----- .../testdata/assembly/strings.ts | 22 +-- .../testdata/assembly/typedarrays.ts | 184 +++++++++--------- 18 files changed, 437 insertions(+), 437 deletions(-) diff --git a/.trunk/configs/.prettierrc b/.trunk/configs/.prettierrc index 7497b18d2..fadc34a94 100644 --- a/.trunk/configs/.prettierrc +++ b/.trunk/configs/.prettierrc @@ -1,6 +1,6 @@ { "plugins": ["assemblyscript-prettier"], - "semi": false, + "semi": true, "proseWrap": "always", "printWidth": 100 } diff --git a/README.md b/README.md index 4f1be572d..acf7084de 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ You write a function. ```ts export function sayHello(name: string): string { - return `Hello, ${name}!` + return `Hello, ${name}!`; } ``` diff --git a/runtime/explorer/content/ModusIcon.tsx b/runtime/explorer/content/ModusIcon.tsx index 5e2326494..119704a8f 100644 --- a/runtime/explorer/content/ModusIcon.tsx +++ b/runtime/explorer/content/ModusIcon.tsx @@ -1,4 +1,4 @@ -import React from "react" +import React from "react"; const ModusLogo = ({ className }: { className?: string }) => ( @@ -29,6 +29,6 @@ const ModusLogo = ({ className }: { className?: string }) => ( /> -) +); -export default ModusLogo +export default ModusLogo; diff --git a/runtime/explorer/content/main.tsx b/runtime/explorer/content/main.tsx index 1c51e4d1c..559193510 100644 --- a/runtime/explorer/content/main.tsx +++ b/runtime/explorer/content/main.tsx @@ -1,15 +1,15 @@ -import React, { useEffect, useState } from "react" -import { createRoot } from "react-dom/client" -import { ApiExplorer } from "@hypermode/react-api-explorer" -import ModusIcon from "./ModusIcon" -import "@hypermode/react-api-explorer/styles.css" -import "./index.css" +import React, { useEffect, useState } from "react"; +import { createRoot } from "react-dom/client"; +import { ApiExplorer } from "@hypermode/react-api-explorer"; +import ModusIcon from "./ModusIcon"; +import "@hypermode/react-api-explorer/styles.css"; +import "./index.css"; -const rootElement = document.getElementById("root") +const rootElement = document.getElementById("root"); if (!rootElement) { - throw new Error("Root element not found") + throw new Error("Root element not found"); } -const root = createRoot(rootElement) +const root = createRoot(rootElement); function App() { const modusTheme = { @@ -32,29 +32,29 @@ function App() { border: "150 35% 17%", input: "150 35% 17%", ring: "150 60% 39%", - } - const [endpoints, setEndpoints] = useState(["http://localhost:8686/graphql"]) + }; + const [endpoints, setEndpoints] = useState(["http://localhost:8686/graphql"]); useEffect(() => { // Fetch endpoints when component mounts const fetchEndpoints = async () => { try { - const response = await fetch("/explorer/api/endpoints") - const data = await response.json() + const response = await fetch("/explorer/api/endpoints"); + const data = await response.json(); - const origin = window.location.origin + const origin = window.location.origin; const ep = data.map((endpoint: { path: string }) => { - return endpoint.path.startsWith("/") ? `${origin}${endpoint.path}` : endpoint.path - }) + return endpoint.path.startsWith("/") ? `${origin}${endpoint.path}` : endpoint.path; + }); - setEndpoints(ep) + setEndpoints(ep); } catch (error) { - console.error("Failed to fetch endpoints:", error) + console.error("Failed to fetch endpoints:", error); } - } + }; - fetchEndpoints() - }, []) + fetchEndpoints(); + }, []); return (
@@ -69,7 +69,7 @@ function App() { } />
- ) + ); } -root.render() +root.render(); diff --git a/runtime/explorer/content/postcss.config.js b/runtime/explorer/content/postcss.config.js index 2e7af2b7f..2aa7205d4 100644 --- a/runtime/explorer/content/postcss.config.js +++ b/runtime/explorer/content/postcss.config.js @@ -3,4 +3,4 @@ export default { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/runtime/explorer/content/tailwind.config.js b/runtime/explorer/content/tailwind.config.js index c6b6326c7..b4a0081b3 100644 --- a/runtime/explorer/content/tailwind.config.js +++ b/runtime/explorer/content/tailwind.config.js @@ -5,4 +5,4 @@ export default { extend: {}, }, plugins: [], -} +}; diff --git a/runtime/explorer/content/vite.config.ts b/runtime/explorer/content/vite.config.ts index ef9a83524..1a9c3d542 100644 --- a/runtime/explorer/content/vite.config.ts +++ b/runtime/explorer/content/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" -import { resolve } from "path" +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { resolve } from "path"; export default defineConfig({ plugins: [react()], @@ -26,4 +26,4 @@ export default defineConfig({ chunkSizeWarningLimit: 1000, }, base: "/explorer/", -}) +}); diff --git a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts index 85f8e9a67..846e6b79e 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts @@ -8,20 +8,20 @@ */ export function testArrayBufferInput(buffer: ArrayBuffer): void { - const view = Uint8Array.wrap(buffer) - assert(view.length == 4) - assert(view[0] == 1) - assert(view[1] == 2) - assert(view[2] == 3) - assert(view[3] == 4) + const view = Uint8Array.wrap(buffer); + assert(view.length == 4); + assert(view[0] == 1); + assert(view[1] == 2); + assert(view[2] == 3); + assert(view[3] == 4); } export function testArrayBufferOutput(): ArrayBuffer { - const buffer = new ArrayBuffer(4) - const view = Uint8Array.wrap(buffer) - view[0] = 1 - view[1] = 2 - view[2] = 3 - view[3] = 4 - return buffer + const buffer = new ArrayBuffer(4); + const view = Uint8Array.wrap(buffer); + view[0] = 1; + view[1] = 2; + view[2] = 3; + view[3] = 4; + return buffer; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts index f0bc8d85e..9254bd61c 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts @@ -8,79 +8,79 @@ */ export function testArrayOutput_i8(): i8[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_i8(arr: i8[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_i8_empty(): i8[] { - return [] + return []; } export function testArrayInput_i8_empty(arr: i8[]): void { - assert(arr.length == 0) + assert(arr.length == 0); } export function testArrayOutput_i8_null(): i8[] | null { - return null + return null; } export function testArrayInput_i8_null(arr: i8[] | null): void { - assert(arr == null) + assert(arr == null); } export function testArrayInput_i32(arr: i32[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_i32(): i32[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_f32(arr: f32[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_f32(): f32[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_string(arr: string[]): void { - assert(arr.length == 3) - assert(arr[0] == "abc") - assert(arr[1] == "def") - assert(arr[2] == "ghi") + assert(arr.length == 3); + assert(arr[0] == "abc"); + assert(arr[1] == "def"); + assert(arr[2] == "ghi"); } export function testArrayOutput_string(): string[] { - return ["abc", "def", "ghi"] + return ["abc", "def", "ghi"]; } export function testArrayInput_string_2d(arr: string[][]): void { - assert(arr.length == 3) - assert(arr[0].length == 3) - assert(arr[0][0] == "abc") - assert(arr[0][1] == "def") - assert(arr[0][2] == "ghi") - assert(arr[1].length == 3) - assert(arr[1][0] == "jkl") - assert(arr[1][1] == "mno") - assert(arr[1][2] == "pqr") - assert(arr[2].length == 3) - assert(arr[2][0] == "stu") - assert(arr[2][1] == "vwx") - assert(arr[2][2] == "yz") + assert(arr.length == 3); + assert(arr[0].length == 3); + assert(arr[0][0] == "abc"); + assert(arr[0][1] == "def"); + assert(arr[0][2] == "ghi"); + assert(arr[1].length == 3); + assert(arr[1][0] == "jkl"); + assert(arr[1][1] == "mno"); + assert(arr[1][2] == "pqr"); + assert(arr[2].length == 3); + assert(arr[2][0] == "stu"); + assert(arr[2][1] == "vwx"); + assert(arr[2][2] == "yz"); } export function testArrayOutput_string_2d(): string[][] { @@ -88,15 +88,15 @@ export function testArrayOutput_string_2d(): string[][] { ["abc", "def", "ghi"], ["jkl", "mno", "pqr"], ["stu", "vwx", "yz"], - ] + ]; } export function testArrayInput_string_2d_empty(arr: string[][]): void { - assert(arr.length == 0) + assert(arr.length == 0); } export function testArrayOutput_string_2d_empty(): string[][] { - return [] + return []; } class TestObject1 { @@ -108,7 +108,7 @@ class TestObject1 { export function testArrayIteration(arr: TestObject1[]): void { for (let i = 0; i < arr.length; i++) { - let obj = arr[i] - console.log(`[${i}]: a=${obj.a}, b=${obj.b}`) + let obj = arr[i]; + console.log(`[${i}]: a=${obj.a}, b=${obj.b}`); } } diff --git a/runtime/languages/assemblyscript/testdata/assembly/classes.ts b/runtime/languages/assemblyscript/testdata/assembly/classes.ts index 1b452b721..4125e4d69 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/classes.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/classes.ts @@ -8,191 +8,191 @@ */ class TestClass1 { - a!: bool + a!: bool; } class TestClass1_map { - a!: bool + a!: bool; } class TestClass2 { - a!: bool - b!: isize + a!: bool; + b!: isize; } class TestClass2_map { - a!: bool - b!: isize + a!: bool; + b!: isize; } class TestClass3 { - a!: bool - b!: isize - c!: string + a!: bool; + b!: isize; + c!: string; } class TestClass3_map { - a!: bool - b!: isize - c!: string + a!: bool; + b!: isize; + c!: string; } class TestClass4 { - a!: bool - b!: isize - c!: string | null + a!: bool; + b!: isize; + c!: string | null; } class TestClass4_map { - a!: bool - b!: isize - c!: string | null + a!: bool; + b!: isize; + c!: string | null; } class TestClass5 { - a!: bool - b!: TestClass3 + a!: bool; + b!: TestClass3; } class TestClass5_map { - a!: bool - b!: TestClass3_map + a!: bool; + b!: TestClass3_map; } class TestRecursiveClass { - a!: bool - b!: TestRecursiveClass | null + a!: bool; + b!: TestRecursiveClass | null; } class TestRecursiveClass_map { - a!: bool - b!: TestRecursiveClass_map | null + a!: bool; + b!: TestRecursiveClass_map | null; } -const testClass1 = { a: true } -const testClass2 = { a: true, b: 123 } -const testClass3 = { a: true, b: 123, c: "abc" } -const testClass4 = { a: true, b: 123, c: "abc" } -const testClass4_withNull = { a: true, b: 123, c: null } -const testClass5 = { a: true, b: testClass3 } +const testClass1 = { a: true }; +const testClass2 = { a: true, b: 123 }; +const testClass3 = { a: true, b: 123, c: "abc" }; +const testClass4 = { a: true, b: 123, c: "abc" }; +const testClass4_withNull = { a: true, b: 123, c: null }; +const testClass5 = { a: true, b: testClass3 }; -const testRecursiveClass = { a: true } -testRecursiveClass.b = testRecursiveClass +const testRecursiveClass = { a: true }; +testRecursiveClass.b = testRecursiveClass; -const testClass1_map = { a: true } -const testClass2_map = { a: true, b: 123 } -const testClass3_map = { a: true, b: 123, c: "abc" } -const testClass4_map = { a: true, b: 123, c: "abc" } -const testClass4_map_withNull = { a: true, b: 123, c: null } -const testClass5_map = { a: true, b: testClass3_map } +const testClass1_map = { a: true }; +const testClass2_map = { a: true, b: 123 }; +const testClass3_map = { a: true, b: 123, c: "abc" }; +const testClass4_map = { a: true, b: 123, c: "abc" }; +const testClass4_map_withNull = { a: true, b: 123, c: null }; +const testClass5_map = { a: true, b: testClass3_map }; -const testRecursiveClass_map = { a: true } -testRecursiveClass_map.b = testRecursiveClass_map +const testRecursiveClass_map = { a: true }; +testRecursiveClass_map.b = testRecursiveClass_map; export function testClassInput1(o: TestClass1): void { - assert(o.a == testClass1.a) + assert(o.a == testClass1.a); } export function testClassOutput1(): TestClass1 { - return testClass1 + return testClass1; } export function testClassOutput1_map(): TestClass1_map { - return testClass1_map + return testClass1_map; } export function testClassInput2(o: TestClass2): void { - assert(o.a == testClass2.a) - assert(o.b == testClass2.b) + assert(o.a == testClass2.a); + assert(o.b == testClass2.b); } export function testClassOutput2(): TestClass2 { - return testClass2 + return testClass2; } export function testClassOutput2_map(): TestClass2_map { - return testClass2_map + return testClass2_map; } export function testClassInput3(o: TestClass3): void { - assert(o.a == testClass3.a) - assert(o.b == testClass3.b) - assert(o.c == testClass3.c) + assert(o.a == testClass3.a); + assert(o.b == testClass3.b); + assert(o.c == testClass3.c); } export function testClassOutput3(): TestClass3 { - return testClass3 + return testClass3; } export function testClassOutput3_map(): TestClass3_map { - return testClass3_map + return testClass3_map; } export function testClassInput4_withNull(o: TestClass4): void { - assert(o.a == testClass4_withNull.a) - assert(o.b == testClass4_withNull.b) - assert(o.c == testClass4_withNull.c) + assert(o.a == testClass4_withNull.a); + assert(o.b == testClass4_withNull.b); + assert(o.c == testClass4_withNull.c); } export function testClassOutput4(): TestClass4 { - return testClass4 + return testClass4; } export function testClassOutput4_map(): TestClass4_map { - return testClass4_map + return testClass4_map; } export function testClassInput4(o: TestClass4): void { - assert(o.a == testClass4.a) - assert(o.b == testClass4.b) - assert(o.c == testClass4.c) + assert(o.a == testClass4.a); + assert(o.b == testClass4.b); + assert(o.c == testClass4.c); } export function testClassOutput4_withNull(): TestClass4 { - return testClass4_withNull + return testClass4_withNull; } export function testClassOutput4_map_withNull(): TestClass4_map { - return testClass4_map_withNull + return testClass4_map_withNull; } export function testClassInput5(o: TestClass5): void { - assert(o.a == testClass5.a) - assert(o.b.a == testClass5.b.a) - assert(o.b.b == testClass5.b.b) - assert(o.b.c == testClass5.b.c) + assert(o.a == testClass5.a); + assert(o.b.a == testClass5.b.a); + assert(o.b.b == testClass5.b.b); + assert(o.b.c == testClass5.b.c); } export function testClassOutput5(): TestClass5 { - return testClass5 + return testClass5; } export function testClassOutput5_map(): TestClass5_map { - return testClass5_map + return testClass5_map; } export function testRecursiveClassInput(o: TestRecursiveClass): void { - assert(o.a == testRecursiveClass.a) - assert(o.b == testRecursiveClass.b) + assert(o.a == testRecursiveClass.a); + assert(o.b == testRecursiveClass.b); } export function testRecursiveClassOutput(): TestRecursiveClass { - return testRecursiveClass + return testRecursiveClass; } export function testNullableClassInput1(o: TestClass1 | null): void { - assert(o != null) - assert(o!.a == testClass1.a) + assert(o != null); + assert(o!.a == testClass1.a); } export function testNullableClassOutput1(): TestClass1 | null { - return testClass1 + return testClass1; } export function testNullableClassInput1_null(o: TestClass1 | null): void { - assert(o == null) + assert(o == null); } export function testNullableClassOutput1_null(): TestClass1 | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/dates.ts b/runtime/languages/assemblyscript/testdata/assembly/dates.ts index 86bbcca5f..5e199f1b6 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/dates.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/dates.ts @@ -7,32 +7,32 @@ * SPDX-License-Identifier: Apache-2.0 */ -const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime() +const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime(); export function testDateInput(d: Date): void { - const ts = d.getTime() - assert(ts == testTime, `Expected ${testTime}, got ${ts}`) + const ts = d.getTime(); + assert(ts == testTime, `Expected ${testTime}, got ${ts}`); } export function testDateOutput(): Date { - return new Date(testTime) + return new Date(testTime); } export function testNullDateInput(d: Date | null): void { - assert(d != null, `Expected non-null, got null`) + assert(d != null, `Expected non-null, got null`); - const ts = d!.getTime() - assert(ts == testTime, `Expected ${testTime}, got ${ts}`) + const ts = d!.getTime(); + assert(ts == testTime, `Expected ${testTime}, got ${ts}`); } export function testNullDateOutput(): Date | null { - return new Date(testTime) + return new Date(testTime); } export function testNullDateInput_null(d: Date | null): void { - assert(d == null, `Expected null, got ${d!.getTime()}`) + assert(d == null, `Expected null, got ${d!.getTime()}`); } export function testNullDateOutput_null(): Date | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/env.ts b/runtime/languages/assemblyscript/testdata/assembly/env.ts index 1242b44f7..9b96fef4f 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/env.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/env.ts @@ -8,18 +8,18 @@ */ export function now(): i64 { - return Date.now() + return Date.now(); } export function spin(duration: i64): i64 { - const start = performance.now() + const start = performance.now(); - let d = Date.now() + let d = Date.now(); while (Date.now() - d <= duration) { // do nothing } - const end = performance.now() + const end = performance.now(); - return i64(end - start) + return i64(end - start); } diff --git a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts index 4936eefe4..fa7eefa6a 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts @@ -9,30 +9,30 @@ // @ts-expect-error: decorator @external("modus_test", "add") -declare function hostAdd(a: i32, b: i32): i32 +declare function hostAdd(a: i32, b: i32): i32; // @ts-expect-error: decorator @external("modus_test", "echo") -declare function hostEcho(message: string): string +declare function hostEcho(message: string): string; // @ts-expect-error: decorator @external("modus_test", "echoObject") -declare function hostEchoObject(obj: TestHostObject): TestHostObject +declare function hostEchoObject(obj: TestHostObject): TestHostObject; class TestHostObject { - a!: i32 - b!: bool - c!: string + a!: i32; + b!: bool; + c!: string; } export function add(a: i32, b: i32): i32 { - return hostAdd(a, b) + return hostAdd(a, b); } export function echo(message: string): string { - return hostEcho(message) + return hostEcho(message); } export function echoObject(obj: TestHostObject): TestHostObject { - return hostEchoObject(obj) + return hostEchoObject(obj); } diff --git a/runtime/languages/assemblyscript/testdata/assembly/index.ts b/runtime/languages/assemblyscript/testdata/assembly/index.ts index 552217bf6..f22035389 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/index.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/index.ts @@ -7,13 +7,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -export * from "./arrays" -export * from "./arraybuffers" -export * from "./classes" -export * from "./dates" -export * from "./env" -export * from "./hostfns" -export * from "./maps" -export * from "./primitives" -export * from "./strings" -export * from "./typedarrays" +export * from "./arrays"; +export * from "./arraybuffers"; +export * from "./classes"; +export * from "./dates"; +export * from "./env"; +export * from "./hostfns"; +export * from "./maps"; +export * from "./primitives"; +export * from "./strings"; +export * from "./typedarrays"; diff --git a/runtime/languages/assemblyscript/testdata/assembly/maps.ts b/runtime/languages/assemblyscript/testdata/assembly/maps.ts index a1995d708..385a0a6bf 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/maps.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/maps.ts @@ -8,147 +8,147 @@ */ export function testMapInput_u8_string(m: Map): void { - assert(m.size == 3, "expected size 3") + assert(m.size == 3, "expected size 3"); - assert(m.has(1), "expected key 1 to be present") - assert(m.get(1) == "a", "expected value for key 1 to be 'a'") + assert(m.has(1), "expected key 1 to be present"); + assert(m.get(1) == "a", "expected value for key 1 to be 'a'"); - assert(m.has(2), "expected key 2 to be present") - assert(m.get(2) == "b", "expected value for key 2 to be 'b'") + assert(m.has(2), "expected key 2 to be present"); + assert(m.get(2) == "b", "expected value for key 2 to be 'b'"); - assert(m.has(3), "expected key 3 to be present") - assert(m.get(3) == "c", "expected value for key 3 to be 'c'") + assert(m.has(3), "expected key 3 to be present"); + assert(m.get(3) == "c", "expected value for key 3 to be 'c'"); } export function testMapOutput_u8_string(): Map { - const m = new Map() - m.set(1, "a") - m.set(2, "b") - m.set(3, "c") - return m + const m = new Map(); + m.set(1, "a"); + m.set(2, "b"); + m.set(3, "c"); + return m; } export function testMapInput_string_string(m: Map): void { - assert(m.size == 3, "expected size 3") + assert(m.size == 3, "expected size 3"); - assert(m.has("a"), "expected key 'a' to be present") - assert(m.get("a") == "1", "expected value for key 'a' to be '1'") + assert(m.has("a"), "expected key 'a' to be present"); + assert(m.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(m.has("b"), "expected key 'b' to be present") - assert(m.get("b") == "2", "expected value for key 'b' to be '2'") + assert(m.has("b"), "expected key 'b' to be present"); + assert(m.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(m.has("c"), "expected key 'c' to be present") - assert(m.get("c") == "3", "expected value for key 'c' to be '3'") + assert(m.has("c"), "expected key 'c' to be present"); + assert(m.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testMapOutput_string_string(): Map { - const m = new Map() - m.set("a", "1") - m.set("b", "2") - m.set("c", "3") - return m + const m = new Map(); + m.set("a", "1"); + m.set("b", "2"); + m.set("c", "3"); + return m; } export function testNullableMapInput_string_string(m: Map | null): void { - assert(m != null, "expected non-null map") - assert(m!.size == 3, "expected size 3") + assert(m != null, "expected non-null map"); + assert(m!.size == 3, "expected size 3"); - assert(m!.has("a"), "expected key 'a' to be present") - assert(m!.get("a") == "1", "expected value for key 'a' to be '1'") + assert(m!.has("a"), "expected key 'a' to be present"); + assert(m!.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(m!.has("b"), "expected key 'b' to be present") - assert(m!.get("b") == "2", "expected value for key 'b' to be '2'") + assert(m!.has("b"), "expected key 'b' to be present"); + assert(m!.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(m!.has("c"), "expected key 'c' to be present") - assert(m!.get("c") == "3", "expected value for key 'c' to be '3'") + assert(m!.has("c"), "expected key 'c' to be present"); + assert(m!.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testNullableMapInput_string_string_null(m: Map | null): void { - assert(m == null, "expected null map") + assert(m == null, "expected null map"); } export function testNullableMapOutput_string_string(): Map | null { - const m = new Map() - m.set("a", "1") - m.set("b", "2") - m.set("c", "3") - return m + const m = new Map(); + m.set("a", "1"); + m.set("b", "2"); + m.set("c", "3"); + return m; } export function testNullableMapOutput_string_string_null(): Map | null { - return null + return null; } export function testIterateMap_string_string(m: Map): void { - const keys = m.keys() - const values = m.values() + const keys = m.keys(); + const values = m.values(); for (let i = 0; i < m.size; i++) { - const key = keys[i] - const value = values[i] - console.log(key + " => " + value) + const key = keys[i]; + const value = values[i]; + console.log(key + " => " + value); } } export function testMapLookup_string_string(m: Map, key: string): string | null { if (m.has(key)) { - return m.get(key) + return m.get(key); } - return null + return null; } class TestClassWithMap { - m!: Map + m!: Map; } export function testClassContainingMapInput_string_string(c: TestClassWithMap): void { - assert(c != null, "expected non-null class") - assert(c.m != null, "expected non-null map") - assert(c.m.size == 3, "expected size 3") + assert(c != null, "expected non-null class"); + assert(c.m != null, "expected non-null map"); + assert(c.m.size == 3, "expected size 3"); - assert(c.m.has("a"), "expected key 'a' to be present") - assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'") + assert(c.m.has("a"), "expected key 'a' to be present"); + assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(c.m.has("b"), "expected key 'b' to be present") - assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'") + assert(c.m.has("b"), "expected key 'b' to be present"); + assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(c.m.has("c"), "expected key 'c' to be present") - assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'") + assert(c.m.has("c"), "expected key 'c' to be present"); + assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testClassContainingMapOutput_string_string(): TestClassWithMap { - const c = new TestClassWithMap() - c.m = new Map() - c.m.set("a", "1") - c.m.set("b", "2") - c.m.set("c", "3") - return c + const c = new TestClassWithMap(); + c.m = new Map(); + c.m.set("a", "1"); + c.m.set("b", "2"); + c.m.set("c", "3"); + return c; } export function testMapInput_string_f64(m: Map): void { - assert(m.size == 4, "expected size 4") + assert(m.size == 4, "expected size 4"); - let n: f64 = 0.5 - assert(m.has("a"), "expected key 'a' to be present") - assert(m.get("a") == n, `expected value for key 'a' to be ${n}`) + let n: f64 = 0.5; + assert(m.has("a"), "expected key 'a' to be present"); + assert(m.get("a") == n, `expected value for key 'a' to be ${n}`); - n = f64.EPSILON - assert(m.has("b"), "expected key 'b' to be present") - assert(m.get("b") == n, `expected value for key 'b' to be ${n}`) + n = f64.EPSILON; + assert(m.has("b"), "expected key 'b' to be present"); + assert(m.get("b") == n, `expected value for key 'b' to be ${n}`); - n = f64.MIN_VALUE - assert(m.has("c"), "expected key 'c' to be present") - assert(m.get("c") == n, `expected value for key 'c' to be ${n}`) + n = f64.MIN_VALUE; + assert(m.has("c"), "expected key 'c' to be present"); + assert(m.get("c") == n, `expected value for key 'c' to be ${n}`); - n = f64.MAX_VALUE - assert(m.has("d"), "expected key 'd' to be present") - assert(m.get("d") == n, `expected value for key 'd' to be ${n}`) + n = f64.MAX_VALUE; + assert(m.has("d"), "expected key 'd' to be present"); + assert(m.get("d") == n, `expected value for key 'd' to be ${n}`); } export function testMapOutput_string_f64(): Map { - const m = new Map() - m.set("a", 0.5) - m.set("b", f64.EPSILON) - m.set("c", f64.MIN_VALUE) - m.set("d", f64.MAX_VALUE) - return m + const m = new Map(); + m.set("a", 0.5); + m.set("b", f64.EPSILON); + m.set("c", f64.MIN_VALUE); + m.set("d", f64.MAX_VALUE); + return m; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts index 264166388..ecb317be6 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts @@ -8,209 +8,209 @@ */ export function testBoolInput_false(b: bool): void { - assert(b == false) + assert(b == false); } export function testBoolInput_true(b: bool): void { - assert(b == true) + assert(b == true); } export function testBoolOutput_false(): bool { - return false + return false; } export function testBoolOutput_true(): bool { - return true + return true; } export function testI8Input_min(n: i8): void { - assert(n == i8.MIN_VALUE) + assert(n == i8.MIN_VALUE); } export function testI8Input_max(n: i8): void { - assert(n == i8.MAX_VALUE) + assert(n == i8.MAX_VALUE); } export function testI8Output_min(): i8 { - return i8.MIN_VALUE + return i8.MIN_VALUE; } export function testI8Output_max(): i8 { - return i8.MAX_VALUE + return i8.MAX_VALUE; } export function testI16Input_min(n: i16): void { - assert(n == i16.MIN_VALUE) + assert(n == i16.MIN_VALUE); } export function testI16Input_max(n: i16): void { - assert(n == i16.MAX_VALUE) + assert(n == i16.MAX_VALUE); } export function testI16Output_min(): i16 { - return i16.MIN_VALUE + return i16.MIN_VALUE; } export function testI16Output_max(): i16 { - return i16.MAX_VALUE + return i16.MAX_VALUE; } export function testI32Input_min(n: i32): void { - assert(n == i32.MIN_VALUE) + assert(n == i32.MIN_VALUE); } export function testI32Input_max(n: i32): void { - assert(n == i32.MAX_VALUE) + assert(n == i32.MAX_VALUE); } export function testI32Output_min(): i32 { - return i32.MIN_VALUE + return i32.MIN_VALUE; } export function testI32Output_max(): i32 { - return i32.MAX_VALUE + return i32.MAX_VALUE; } export function testI64Input_min(n: i64): void { - assert(n == i64.MIN_VALUE) + assert(n == i64.MIN_VALUE); } export function testI64Input_max(n: i64): void { - assert(n == i64.MAX_VALUE) + assert(n == i64.MAX_VALUE); } export function testI64Output_min(): i64 { - return i64.MIN_VALUE + return i64.MIN_VALUE; } export function testI64Output_max(): i64 { - return i64.MAX_VALUE + return i64.MAX_VALUE; } export function testISizeInput_min(n: isize): void { - assert(n == isize.MIN_VALUE) + assert(n == isize.MIN_VALUE); } export function testISizeInput_max(n: isize): void { - assert(n == isize.MAX_VALUE) + assert(n == isize.MAX_VALUE); } export function testISizeOutput_min(): isize { - return isize.MIN_VALUE + return isize.MIN_VALUE; } export function testISizeOutput_max(): isize { - return isize.MAX_VALUE + return isize.MAX_VALUE; } export function testU8Input_min(n: u8): void { - assert(n == u8.MIN_VALUE) + assert(n == u8.MIN_VALUE); } export function testU8Input_max(n: u8): void { - assert(n == u8.MAX_VALUE) + assert(n == u8.MAX_VALUE); } export function testU8Output_min(): u8 { - return u8.MIN_VALUE + return u8.MIN_VALUE; } export function testU8Output_max(): u8 { - return u8.MAX_VALUE + return u8.MAX_VALUE; } export function testU16Input_min(n: u16): void { - assert(n == u16.MIN_VALUE) + assert(n == u16.MIN_VALUE); } export function testU16Input_max(n: u16): void { - assert(n == u16.MAX_VALUE) + assert(n == u16.MAX_VALUE); } export function testU16Output_min(): u16 { - return u16.MIN_VALUE + return u16.MIN_VALUE; } export function testU16Output_max(): u16 { - return u16.MAX_VALUE + return u16.MAX_VALUE; } export function testU32Input_min(n: u32): void { - assert(n == u32.MIN_VALUE) + assert(n == u32.MIN_VALUE); } export function testU32Input_max(n: u32): void { - assert(n == u32.MAX_VALUE) + assert(n == u32.MAX_VALUE); } export function testU32Output_min(): u32 { - return u32.MIN_VALUE + return u32.MIN_VALUE; } export function testU32Output_max(): u32 { - return u32.MAX_VALUE + return u32.MAX_VALUE; } export function testU64Input_min(n: u64): void { - assert(n == u64.MIN_VALUE) + assert(n == u64.MIN_VALUE); } export function testU64Input_max(n: u64): void { - assert(n == u64.MAX_VALUE) + assert(n == u64.MAX_VALUE); } export function testU64Output_min(): u64 { - return u64.MIN_VALUE + return u64.MIN_VALUE; } export function testU64Output_max(): u64 { - return u64.MAX_VALUE + return u64.MAX_VALUE; } export function testUSizeInput_min(n: usize): void { - assert(n == usize.MIN_VALUE) + assert(n == usize.MIN_VALUE); } export function testUSizeInput_max(n: usize): void { - assert(n == usize.MAX_VALUE) + assert(n == usize.MAX_VALUE); } export function testUSizeOutput_min(): usize { - return usize.MIN_VALUE + return usize.MIN_VALUE; } export function testUSizeOutput_max(): usize { - return usize.MAX_VALUE + return usize.MAX_VALUE; } export function testF32Input_min(n: f32): void { - assert(n == f32.MIN_VALUE) + assert(n == f32.MIN_VALUE); } export function testF32Input_max(n: f32): void { - assert(n == f32.MAX_VALUE) + assert(n == f32.MAX_VALUE); } export function testF32Output_min(): f32 { - return f32.MIN_VALUE + return f32.MIN_VALUE; } export function testF32Output_max(): f32 { - return f32.MAX_VALUE + return f32.MAX_VALUE; } export function testF64Input_min(n: f64): void { - assert(n == f64.MIN_VALUE) + assert(n == f64.MIN_VALUE); } export function testF64Input_max(n: f64): void { - assert(n == f64.MAX_VALUE) + assert(n == f64.MAX_VALUE); } export function testF64Output_min(): f64 { - return f64.MIN_VALUE + return f64.MIN_VALUE; } export function testF64Output_max(): f64 { - return f64.MAX_VALUE + return f64.MAX_VALUE; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/strings.ts b/runtime/languages/assemblyscript/testdata/assembly/strings.ts index ca77b3986..7de9085e0 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/strings.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/strings.ts @@ -8,44 +8,44 @@ */ // "Hello World" in Japanese -const testString = "γ“γ‚“γ«γ‘γ―γ€δΈ–η•Œ" +const testString = "γ“γ‚“γ«γ‘γ―γ€δΈ–η•Œ"; export function testStringInput(s: string): void { - assert(s == testString) + assert(s == testString); } export function testStringOutput(): string { - return testString + return testString; } export function testStringInput_empty(s: string): void { - assert(s == "") + assert(s == ""); } export function testStringOutput_empty(): string { - return "" + return ""; } export function testNullStringInput(s: string | null): void { - assert(s == testString) + assert(s == testString); } export function testNullStringOutput(): string | null { - return testString + return testString; } export function testNullStringInput_empty(s: string | null): void { - assert(s == "") + assert(s == ""); } export function testNullStringOutput_empty(): string | null { - return "" + return ""; } export function testNullStringInput_null(s: string | null): void { - assert(s == null) + assert(s == null); } export function testNullStringOutput_null(): string | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts index 96d4ccf00..895966fc1 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts @@ -8,171 +8,171 @@ */ export function testInt8ArrayInput(view: Int8Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt8ArrayOutput(): Int8Array { - const view = new Int8Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int8Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt16ArrayInput(view: Int16Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt16ArrayOutput(): Int16Array { - const view = new Int16Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int16Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt32ArrayInput(view: Int32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt32ArrayOutput(): Int32Array { - const view = new Int32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt64ArrayInput(view: Int64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt64ArrayOutput(): Int64Array { - const view = new Int64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int64Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint8ArrayInput(view: Uint8Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint8ArrayInput_empty(view: Uint8Array): void { - assert(view.length == 0) + assert(view.length == 0); } export function testUint8ArrayInput_null(view: Uint8Array | null): void { - assert(view == null) + assert(view == null); } export function testUint8ArrayOutput(): Uint8Array { - const view = new Uint8Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint8Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint8ArrayOutput_empty(): Uint8Array { - return new Uint8Array(0) + return new Uint8Array(0); } export function testUint8ArrayOutput_null(): Uint8Array | null { - return null + return null; } export function testUint8ClampedArrayInput(view: Uint8ClampedArray): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint8ClampedArrayOutput(): Uint8ClampedArray { - const view = new Uint8ClampedArray(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint8ClampedArray(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint16ArrayInput(view: Uint16Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint16ArrayOutput(): Uint16Array { - const view = new Uint16Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint16Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint32ArrayInput(view: Uint32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint32ArrayOutput(): Uint32Array { - const view = new Uint32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint64ArrayInput(view: Uint64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint64ArrayOutput(): Uint64Array { - const view = new Uint64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint64Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testFloat32ArrayInput(view: Float32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testFloat32ArrayOutput(): Float32Array { - const view = new Float32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Float32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testFloat64ArrayInput(view: Float64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testFloat64ArrayOutput(): Float64Array { - const view = new Float64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Float64Array(4); + view.set([0, 1, 2, 3]); + return view; } From 19e1dfdf4ffb93a61f79672aac84a4f383844702 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 18:09:35 -0800 Subject: [PATCH 09/11] Fix shell scripts --- cli/install.sh | 92 ++++++++++--------- sdk/assemblyscript/scripts/install-all.sh | 2 +- sdk/assemblyscript/scripts/prepare-release.sh | 2 +- sdk/assemblyscript/scripts/upgrade-deps.sh | 2 +- sdk/go/scripts/prepare-release.sh | 2 +- sdk/go/scripts/tidy-all.sh | 2 +- 6 files changed, 54 insertions(+), 48 deletions(-) diff --git a/cli/install.sh b/cli/install.sh index 3d3edb990..82b2d71b4 100755 --- a/cli/install.sh +++ b/cli/install.sh @@ -17,8 +17,8 @@ VERSION="latest" INSTALLER_VERSION="0.1.2" NODE_MIN=22 -NODE_PATH="$(which node)" -NPM_PATH="$(which npm)" +NODE_PATH="$(command -v node)" +NPM_PATH="$(command -v npm)" # Properties ARCH="$(uname -m)" @@ -45,10 +45,9 @@ fi get_latest_version() { local url="https://releases.hypermode.com/modus-latest.json" - curl -sL "${url}" | grep '"cli"' | sed -E 's/.*"cli": "v([^"]+)".*/\1/' + (curl -sL "${url}" || true) | (grep '"cli"' || true) | sed -E 's/.*"cli": "v([^"]+)".*/\1/' } -ARCHIVE_URL="" download_from_npm() { local tmpdir="$1" local url="$2" @@ -57,12 +56,11 @@ download_from_npm() { mkdir -p "${tmpdir}" - curl --progress-bar --show-error --location --fail "${url}" --output "${download_file}" - if [[ $? != 0 ]]; then + if ! curl --progress-bar --show-error --location --fail "${url}" --output "${download_file}"; then return 1 fi - printf "${CLEAR_LINE}" >&2 + printf %b "${CLEAR_LINE}" >&2 echo "${download_file}" } @@ -126,7 +124,7 @@ build_path_str() { cli_dir_valid() { if [[ -n ${MODUS_CLI-} ]] && [[ -e ${MODUS_CLI} ]] && ! [[ -d ${MODUS_CLI} ]]; then - printf "\$MODUS_CLI is set but is not a directory (${MODUS_CLI}).\n" >&2 + printf "\$MODUS_CLI is set but is not a directory (%s).\n" "${MODUS_CLI}" >&2 printf "Please check your profile scripts and environment.\n" >&2 exit 1 fi @@ -136,28 +134,34 @@ cli_dir_valid() { update_profile() { local install_dir="$1" if [[ ":${PATH}:" == *":${install_dir}:"* ]]; then - printf "[3/4] ${DIM}The Modus CLI is already in \$PATH${RESET}\n" >&2 + printf %b "[3/4] ${DIM}The Modus CLI is already in \$PATH${RESET}\n" >&2 return 0 fi - local profile="$(detect_profile $(basename "${SHELL}") $(uname -s))" + local shell os profile + shell="$(basename "${SHELL}")" + os="$(uname -s)" + profile="$(detect_profile "${shell}" "${os}")" if [[ -z ${profile} ]]; then printf "No user shell profile found.\n" >&2 return 1 fi export SHOW_RESET_PROFILE=1 - export PROFILE="~/$(basename "${profile}")" + + PROFILE="${HOME}/$(basename "${profile}")" + export PROFILE if grep -q 'MODUS_CLI' "${profile}"; then - printf "[3/4] ${DIM}The Modus CLI has already been configured in ${PROFILE}${RESET}\n" >&2 + printf %b "[3/4] ${DIM}The Modus CLI has already been configured in ${PROFILE}${RESET}\n" >&2 return 0 fi - local path_str="$(build_path_str "${profile}" "${install_dir}")" + local path_str + path_str="$(build_path_str "${profile}" "${install_dir}")" echo "${path_str}" >>"${profile}" - printf "[3/4] ${DIM}Added the Modus CLI to the PATH in ${PROFILE}${RESET}\n" >&2 + printf %b "[3/4] ${DIM}Added the Modus CLI to the PATH in ${PROFILE}${RESET}\n" >&2 } install_version() { @@ -172,14 +176,13 @@ install_version() { *) ;; esac - install_release - if [[ $? == 0 ]]; then - update_profile "${INSTALL_DIR}" && printf "[4/4] ${DIM}Installed Modus CLI${RESET}\n" >&2 + if ! install_release; then + update_profile "${INSTALL_DIR}" && printf %b "[4/4] ${DIM}Installed Modus CLI${RESET}\n" >&2 fi } install_release() { - printf "[1/4] ${DIM}Downloading Modus CLI from NPM${RESET}\n" + printf %b "[1/4] ${DIM}Downloading Modus CLI from NPM${RESET}\n" local url="https://registry.npmjs.org/${PACKAGE_ORG:+${PACKAGE_ORG}/}${PACKAGE_NAME}/-/${PACKAGE_NAME}-${VERSION}.tgz" @@ -189,27 +192,29 @@ install_release() { )" exit_status="$?" if [[ ${exit_status} != 0 ]]; then - printf "Could not download Modus version '${VERSION}' from\n${url}\n" >&2 + printf "Could not download Modus version '%s' from\n%s\n" "${VERSION}" "${url}" >&2 exit 1 fi - printf "${CLEAR_LINE}" >&2 - printf "[1/4] ${DIM}Downloaded latest Modus CLI v${VERSION}${RESET}\n" >&2 + printf %b "${CLEAR_LINE}" >&2 + printf %b "[1/4] ${DIM}Downloaded latest Modus CLI v${VERSION}${RESET}\n" >&2 install_from_file "${download_archive}" } download_release() { - local url="$1" - local download_dir="$(mktemp -d)" + local url download_dir + url="$1" + download_dir="$(mktemp -d)" download_from_npm "${download_dir}" "${url}" } install_from_file() { - local archive="$1" - local extract_to="$(dirname "${archive}")" + local archive extract_to + archive="$1" + extract_to="$(dirname "${archive}")" - printf "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2 + printf %b "[2/4] ${DIM}Unpacking archive${RESET}\n" >&2 tar -xf "${archive}" -C "${extract_to}" @@ -221,12 +226,12 @@ install_from_file() { ln -s "${INSTALL_DIR}/bin/modus.js" "${INSTALL_DIR}/bin/modus" - printf "${CLEAR_LINE}" >&2 - printf "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2 + printf %b "${CLEAR_LINE}" >&2 + printf %b "[2/4] ${DIM}Installing dependencies${RESET}\n" >&2 (cd "${INSTALL_DIR}" && "${NPM_PATH}" install --omit=dev --silent && find . -type d -empty -delete) - printf "${CLEAR_LINE}" >&2 - printf "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2 + printf %b "${CLEAR_LINE}" >&2 + printf %b "[2/4] ${DIM}Unpacked archive${RESET}\n" >&2 } check_platform() { @@ -239,7 +244,7 @@ check_platform() { case "${ARCH}/${OS}" in x64/Linux | arm64/Linux | x64/Darwin | arm64/Darwin) return 0 ;; *) - printf "Unsupported os ${OS} ${ARCH}\n" >&2 + printf "Unsupported os %s %s\n" "${OS}" "${ARCH}" >&2 exit 1 ;; esac @@ -247,30 +252,31 @@ check_platform() { check_node() { if [[ -z ${NODE_PATH} ]]; then - printf "${RED}Node.js is not installed.${RESET}\n" >&2 - printf "${RED}Please install Node.js ${NODE_WANTED} or later and try again.${RESET}\n" >&2 + printf %b "${RED}Node.js is not installed.${RESET}\n" >&2 + printf %b "${RED}Please install Node.js ${NODE_WANTED} or later and try again.${RESET}\n" >&2 exit 1 fi # check node version - local node_version="$("${NODE_PATH}" --version)" - local node_major="${node_version%%.*}" + local node_version node_major + node_version="$("${NODE_PATH}" --version)" + node_major="${node_version%%.*}" node_major="${node_major#v}" if [[ ${node_major} -lt ${NODE_MIN} ]]; then - printf "${RED}Node.js ${NODE_MIN} or later is required. You have ${node_version}.${RESET}\n" >&2 - printf "${RED}Please update and try again${RESET}\n" >&2 + printf %b "${RED}Node.js ${NODE_MIN} or later is required. You have ${node_version}.${RESET}\n" >&2 + printf %b "${RED}Please update and try again${RESET}\n" >&2 exit 1 fi # make sure npm can be found too if [[ -z ${NPM_PATH} ]]; then - printf "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2 + printf %b "${RED}npm is not installed. Please install npm and try again.${RESET}\n" >&2 exit 1 fi } # This is the entry point -printf "\n${BOLD}${BLUE}Modus${RESET} Installer ${DIM}v${INSTALLER_VERSION}${RESET}\n\n" >&2 +printf %b "\n${BOLD}${BLUE}Modus${RESET} Installer ${DIM}v${INSTALLER_VERSION}${RESET}\n\n" >&2 check_platform check_node @@ -279,11 +285,11 @@ install_version printf "\nThe Modus CLI has been installed! πŸŽ‰\n" >&2 if [[ -n ${SHOW_RESET_PROFILE-} ]]; then - printf "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2 - printf " ${DIM}source ${PROFILE}${RESET}\n" >&2 - printf "\nThen, run ${DIM}modus${RESET} to get started${RESET}\n" >&2 + printf %b "\n${YELLOW}Please restart your terminal or run:${RESET}\n" >&2 + printf %b " ${DIM}source ${PROFILE}${RESET}\n" >&2 + printf %b "\nThen, run ${DIM}modus${RESET} to get started${RESET}\n" >&2 else - printf "\nRun ${DIM}modus${RESET} to get started${RESET}\n" >&2 + printf %b "\nRun ${DIM}modus${RESET} to get started${RESET}\n" >&2 fi printf "\n" >&2 diff --git a/sdk/assemblyscript/scripts/install-all.sh b/sdk/assemblyscript/scripts/install-all.sh index 89d43b95a..b55b2fa57 100755 --- a/sdk/assemblyscript/scripts/install-all.sh +++ b/sdk/assemblyscript/scripts/install-all.sh @@ -2,7 +2,7 @@ # Runs "npm install" on all projects. set -euo pipefail -trap "cd \"${PWD}\"" EXIT +trap 'cd "${PWD}"' EXIT cd "$(dirname "$0")" cd .. diff --git a/sdk/assemblyscript/scripts/prepare-release.sh b/sdk/assemblyscript/scripts/prepare-release.sh index 6fb502888..9033142fd 100755 --- a/sdk/assemblyscript/scripts/prepare-release.sh +++ b/sdk/assemblyscript/scripts/prepare-release.sh @@ -2,7 +2,7 @@ # Prepares templates for release. set -euo pipefail -trap "cd \"${PWD}\"" EXIT +trap 'cd "${PWD}"' EXIT cd "$(dirname "$0")" # get the version number from the command line argument diff --git a/sdk/assemblyscript/scripts/upgrade-deps.sh b/sdk/assemblyscript/scripts/upgrade-deps.sh index 072cf5511..3ce66fe17 100755 --- a/sdk/assemblyscript/scripts/upgrade-deps.sh +++ b/sdk/assemblyscript/scripts/upgrade-deps.sh @@ -3,7 +3,7 @@ # Requires npm-check-updates (https://www.npmjs.com/package/npm-check-updates). set -euo pipefail -trap "cd \"${PWD}\"" EXIT +trap 'cd "${PWD}"' EXIT cd "$(dirname "$0")" cd .. diff --git a/sdk/go/scripts/prepare-release.sh b/sdk/go/scripts/prepare-release.sh index 3f6755b69..46538b502 100755 --- a/sdk/go/scripts/prepare-release.sh +++ b/sdk/go/scripts/prepare-release.sh @@ -2,7 +2,7 @@ # Prepares templates for release. set -euo pipefail -trap "cd \"${PWD}\"" EXIT +trap 'cd "${PWD}"' EXIT cd "$(dirname "$0")" # get the version number from the command line argument diff --git a/sdk/go/scripts/tidy-all.sh b/sdk/go/scripts/tidy-all.sh index df93a0491..89e2ee743 100755 --- a/sdk/go/scripts/tidy-all.sh +++ b/sdk/go/scripts/tidy-all.sh @@ -2,7 +2,7 @@ # Runs "go mod tidy" on all projects. set -euo pipefail -trap "cd \"${PWD}\"" EXIT +trap 'cd "${PWD}"' EXIT cd "$(dirname "$0")" cd .. From 823d002b865a38920713d81b52bba8ce853715a6 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 19:10:49 -0800 Subject: [PATCH 10/11] Misc lintings --- .vscode/settings.json | 1 + lib/manifest/go.mod | 2 +- lib/metadata/go.mod | 2 +- lib/wasmextractor/go.mod | 2 +- runtime/integration_tests/.golangci.yaml | 3 +++ runtime/integration_tests/testdata/modus.json | 2 +- 6 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 runtime/integration_tests/.golangci.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index 8e854d779..54fc6c60b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "*hypermode.json": "jsonc", "*modus.json": "jsonc" }, + "go.buildTags": "integration", "go.lintTool": "golangci-lint", "go.testEnvVars": { "MODUS_DEBUG": "true" diff --git a/lib/manifest/go.mod b/lib/manifest/go.mod index 27258c946..ca697fa2b 100644 --- a/lib/manifest/go.mod +++ b/lib/manifest/go.mod @@ -1,6 +1,6 @@ module github.com/hypermodeinc/modus/lib/manifest -go 1.23.0 +go 1.23 require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 diff --git a/lib/metadata/go.mod b/lib/metadata/go.mod index e04f11feb..756a5938a 100644 --- a/lib/metadata/go.mod +++ b/lib/metadata/go.mod @@ -1,6 +1,6 @@ module github.com/hypermodeinc/modus/lib/metadata -go 1.23.0 +go 1.23 require github.com/hypermodeinc/modus/lib/wasmextractor v0.13.0 diff --git a/lib/wasmextractor/go.mod b/lib/wasmextractor/go.mod index 530623daa..b80af4edd 100644 --- a/lib/wasmextractor/go.mod +++ b/lib/wasmextractor/go.mod @@ -1,3 +1,3 @@ module github.com/hypermodeinc/modus/lib/wasmextractor -go 1.23.0 +go 1.23 diff --git a/runtime/integration_tests/.golangci.yaml b/runtime/integration_tests/.golangci.yaml new file mode 100644 index 000000000..4341bcf98 --- /dev/null +++ b/runtime/integration_tests/.golangci.yaml @@ -0,0 +1,3 @@ +run: + build-tags: + - integration diff --git a/runtime/integration_tests/testdata/modus.json b/runtime/integration_tests/testdata/modus.json index 9a18d01e9..1a46c392c 100644 --- a/runtime/integration_tests/testdata/modus.json +++ b/runtime/integration_tests/testdata/modus.json @@ -10,7 +10,7 @@ "connections": { "my-database": { "type": "postgresql", - "connString": "postgresql://postgres:password@localhost:5499/data?sslmode=disable" + "connString": "postgresql://postgres:password@localhost:5499/data?sslmode=disable" // checkov:skip=CKV_SECRET_4 } } } From c667cc2cd23ed1847a0edd8d7e70148b81b3e388 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Mon, 6 Jan 2025 20:29:10 -0800 Subject: [PATCH 11/11] Fix dockerfile issues --- .trunk/configs/.hadolint.yaml | 4 +--- .trunk/configs/.shellcheckrc | 4 ---- Dockerfile | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml index 98bf0cd2e..8f7e23e45 100644 --- a/.trunk/configs/.hadolint.yaml +++ b/.trunk/configs/.hadolint.yaml @@ -1,4 +1,2 @@ -# Following source doesn't work in most setups ignored: - - SC1090 - - SC1091 + - DL3008 diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc index 8c7b1ada8..ecc904070 100644 --- a/.trunk/configs/.shellcheckrc +++ b/.trunk/configs/.shellcheckrc @@ -1,7 +1,3 @@ enable=all source-path=SCRIPTDIR disable=SC2154 - -# If you're having issues with shellcheck following source, disable the errors via: -# disable=SC1090 -# disable=SC1091 diff --git a/Dockerfile b/Dockerfile index 140707237..840fd17f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,8 @@ COPY ./lib ./lib # Copy and modify go.work file COPY ./go.work ./ -RUN sed -i '/^[[:space:]]*\.\/sdk\//d' ./go.work -RUN sed -i '/^[[:space:]]*\.\/.*\/testdata/d' ./go.work +RUN sed -i '/^[[:space:]]*\.\/sdk\//d' ./go.work && \ + sed -i '/^[[:space:]]*\.\/.*\/testdata/d' ./go.work # switch to the runtime directory WORKDIR /src/runtime @@ -42,12 +42,17 @@ RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o modus_runtime -ldflags "-s -w FROM ubuntu:22.04 LABEL maintainer="Hypermode Inc. " +# Create a custom group and user +RUN groupadd -g 1234 modus && \ + useradd -m -u 1234 -g modus modus + # add common tools RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ iputils-ping \ jq \ - less + less \ + && rm -rf /var/lib/apt/lists/* # copy runtime binary from the build phase COPY --from=builder /src/runtime/modus_runtime /usr/bin/modus_runtime @@ -58,5 +63,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ tzdata \ && rm -rf /var/lib/apt/lists/* +# Switch to the custom user and set the working directory +USER modus +WORKDIR /home/modus + # set the default entrypoint and options ENTRYPOINT ["modus_runtime", "--jsonlogs"] + +# define the health check for the container +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl -f http://localhost:8686/health | jq -e '.status == "ok"' > /dev/null || exit 1