@shopify/scripts-toolchain-as

Shopify's AssemblyScript toolchain to build, verify and bootstrap scripts

Usage no npm install needed!

<script type="module">
  import shopifyScriptsToolchainAs from 'https://cdn.skypack.dev/@shopify/scripts-toolchain-as';
</script>

README

Shopify Scripts AssemblyScript Toolchain

Build status

About this repo | How to use this repo | Contribute to this repo

About this repo

Introduction: CLI to build and bootstrap script projects.

Current status Ongoing
Owner @Shopify/scripts
Help #scripts on Slack

How to use this repo

Requirements

  • npm
  • All commands should be used inside a script project generated with Shopify's App CLI

Installation

npm install -g @shopify/scripts-toolchain-as

Available commands

  • shopify-scripts-toolchain-as bootstrap Helper to bootstrap script projects from Shopify's extension points
  • shopify-scripts-toolchain-as codegen Helper to code generate MessagePack serializers for EP types in extension points.
  • shopify-scripts-toolchain-as build Wrapper around the AssemblyScript compiler. It used to build script projects ensuring compatibility with Shopify's runtime platform.

Usage

Bootstrap
shopify-scripts-toolchain-as bootstrap --from <extension-point-name> --dest <destination dir>
  • from the source extension point from where the script project should be bootstrapped
  • dest the destination location where the bootstrapped script project is going to be placed
Codegen
shopify-scripts-toolchain-as codegen \
  --interface-definition=EP/interface.ts \
  -- --lib=./node_modules --optimize --use Date=
Build
shopify-scripts-toolchain-as build \
  --src ./myscript.ts \
  --binary ./myscript.wasm \
  --metadata ./metadata.json
  • src the name and location of the script's entrypoint
  • binary the name and the location to place the generated WebAssembly binary
  • metadata the name and location to place the generated script's metadata

Since this tool is a wrapper around the AssemblyScript's compiler, additional commands can be passed down to the AssemblyScript compiler CLI

npx shopify-scripts-toolchain-as build \
  --src=sample/script.ts \
  --binary=sample/build.wasm \
  --metadata ./metadata.json \
  -- --lib=node_modules --lib=sample --validate --optimize

Contribute to this repo

Setup

  • Clone the repository
  • Install dependencies via npm install

Running tests

  • Run npm test

Making changes

  • Open a PR
  • Request a review from someone from the Scripts team (@Shopify/scripts, @Shopify/scripts-experience)
  • Once your PR is reviewed and approved, merge it

Deploying / releasing a new version

  • Once your PR is merged, update the version of the package.json and package-lock.json. You can do this manually, by running npm version <version> or by running yarn version. In this repo we try to follow semantic versioning as much as possible, be mindful when releasing a new version.
  • Go to shipit and deploy your change. Please note that shipit only deploys changes that define a new version.