Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
# Genrated code from cargo-component
component-model/examples/tutorial/*/src/bindings.rs linguist-generated

# Generated code from JS tutorial
component-model/examples/tutorial/jco/package-lock.json linguist-generated

Cargo-component.lock linguist-language=toml

55 changes: 55 additions & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: javascript

on:
merge_group:
push:
branches:
- main

pull_request:
branches:
- main

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 18.x
- 20.x
- latest
projects:
- folder: component-model/examples/tutorial/jco
script-target: all
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm install
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: node-modules-${{ matrix.node-version }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('${{ matrix.projects.folder }}/package-lock.json') }}
path: |
${{ matrix.projects.folder }}

- name: Install NodeJS dependencies
working-directory: ${{ matrix.projects.folder }}
run: |
npm install

- name: Run NodeJS script target
working-directory: ${{ matrix.projects.folder }}
run: |
npm run ${{ matrix.projects.script-target }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# Build artifacts from examples
**/jco/bindings
**/examples/**/*.wasm
/component-model/examples/tutorial/jco/node_modules/
125 changes: 56 additions & 69 deletions component-model/examples/tutorial/calculator/src/bindings.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
2 changes: 1 addition & 1 deletion component-model/examples/tutorial/jco/cli-calc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// See the README for details on *generation* of the required import
import { calculate } from "./bindings/composed.js";
import { calculate } from "./bindings/calculator.composed.js";

console.log("Answer (to life) = " + calculate.evalExpression("add", 21, 21));
Loading