Skip to content
Draft
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
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules
lib
es2020
commonjs
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./packages/*/tsconfig.json"
"project": ["./packages/*/tsconfig.json", "./tsconfig.scripts.json"]
},
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc", "deprecation", "import"],
"extends": [
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
run: pnpm run build --ignore @temporalio/core-bridge

- name: Publish to Verdaccio
run: node scripts/publish-to-verdaccio.js --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry
run: pnpm tsx scripts/publish-to-verdaccio.ts --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry

- name: Install Temporal CLI
uses: temporalio/setup-temporal@v0
Expand Down Expand Up @@ -222,8 +222,8 @@ jobs:
# Sample 1: hello-world to local server
- name: Instantiate sample project using verdaccio artifacts - Hello World
run: |
node scripts/init-from-verdaccio.js --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/hello-world --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-hello-world
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world"
pnpm tsx scripts/init-from-verdaccio.ts --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/hello-world --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-hello-world
pnpm tsx scripts/test-example.ts --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world"

# Sample 2: hello-world-mtls to cloud server
- name: Instantiate sample project using verdaccio artifacts - Hello World MTLS
Expand All @@ -233,9 +233,9 @@ jobs:
exit 0
fi

node scripts/create-certs-dir.js ${{ steps.tmp-dir.outputs.dir }}/certs
node scripts/init-from-verdaccio.js --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/hello-world-mtls --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls"
pnpm tsx scripts/create-certs-dir.ts ${{ steps.tmp-dir.outputs.dir }}/certs
pnpm tsx scripts/init-from-verdaccio.ts --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/hello-world-mtls --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls
pnpm tsx scripts/test-example.ts --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls"
env:
# These env vars are used by the hello-world-mtls sample
TEMPORAL_ADDRESS: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}.tmprl.cloud:7233
Expand All @@ -255,8 +255,8 @@ jobs:
# Sample 3: fetch-esm to local server
- name: Instantiate sample project using verdaccio artifacts - Fetch ESM
run: |
node scripts/init-from-verdaccio.js --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/fetch-esm --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm" --script-name workflow-local --expected-output "Hello World And Hello Wonderful Temporal!"
pnpm tsx scripts/init-from-verdaccio.ts --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/fetch-esm --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm
pnpm tsx scripts/test-example.ts --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm" --script-name workflow-local --expected-output "Hello World And Hello Wonderful Temporal!"

# End samples

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
run: pnpm run build --ignore @temporalio/core-bridge

- name: Publish to Verdaccio
run: node scripts/publish-to-verdaccio.js --registry-dir ./tmp/registry
run: pnpm tsx scripts/publish-to-verdaccio.ts --registry-dir ./tmp/registry

- name: Save Verdaccio repo artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:

# Note: here, `npx create` fails on windows if shell is bash.
- name: Instantiate sample project using verdaccio artifacts
run: node scripts/init-from-verdaccio.js --registry-dir ./tmp/registry --sample ${{ matrix.sample }} --target-dir ${{ runner.temp }}/example
run: pnpm tsx scripts/init-from-verdaccio.ts --registry-dir ./tmp/registry --sample ${{ matrix.sample }} --target-dir ${{ runner.temp }}/example

- name: Install Temporal CLI
if: matrix.server == 'cli'
Expand All @@ -269,7 +269,7 @@ jobs:
# We write the certs to disk because it serves the sample. Written into /tmp/temporal-certs
- name: Create certs dir
shell: bash
run: node scripts/create-certs-dir.js "${{ runner.temp }}/certs"
run: pnpm tsx scripts/create-certs-dir.ts "${{ runner.temp }}/certs"
if: matrix.server == 'cloud'
env:
# These env vars are used by the hello-world-mtls sample
Expand All @@ -279,14 +279,14 @@ jobs:
TEMPORAL_CLIENT_KEY: ${{ secrets.TEMPORAL_CLIENT_KEY }}

- name: Test run a workflow (non-cloud)
run: node scripts/test-example.js --work-dir "${{ runner.temp }}/example"
run: pnpm tsx scripts/test-example.ts --work-dir "${{ runner.temp }}/example"
shell: bash
if: matrix.server == 'cli'

- name: Test run a workflow (cloud)
if: matrix.server == 'cloud'
# The required environment variables must be present for releases (this must be run from the official repo)
run: node scripts/test-example.js --work-dir "${{ runner.temp }}/example"
run: pnpm tsx scripts/test-example.ts --work-dir "${{ runner.temp }}/example"
shell: bash
env:
# These env vars are used by the hello-world-mtls sample
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ packages/core-bridge/target
packages/core-bridge/bridge-macros/target
sdk-core
lib
es2020
commonjs
.docusaurus
packages/*/CHANGELOG.md
packages/docs/docs/api
Expand Down
28 changes: 15 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ If building fails, resetting your environment may help:
pnpm dlx lerna clean -y && pnpm install --frozen-lockfile
```

If `pnpm install` fails in `@temporalio/core-bridge` on the command `node ./scripts/build.js`, you may
If `pnpm install` fails in `@temporalio/core-bridge` on the command `pnpm tsx ./scripts/build.ts`, you may
need to do `rustup update`.

To update to the latest version of the Core SDK, run `git submodule update` followed by `npm run build` to recompile.

> For cross compilation on MacOS follow [these instructions](https://github.com/temporalio/sdk-typescript/blob/main/docs/building.md)
> (only required for publishing packages).
To update to the latest version of the Core SDK, run `git submodule update` followed by `pnpm run build` to recompile.

## Development

Expand Down Expand Up @@ -135,14 +132,17 @@ To replicate the `test-npm-init` CI test locally, you can start with the below s
> If you've run `npx @temporalio/create` before, you may need to delete the version of the package that's stored in `~/.npm/_npx/`.

```
rm -rf /tmp/registry
pnpm install --frozen-lockfile
pnpm run rebuild
node scripts/publish-to-verdaccio.js --registry-dir /tmp/registry
node scripts/init-from-verdaccio.js --registry-dir /tmp/registry --sample hello-world
cd /tmp/registry/example
npm run build
node ~/path-to/sdk-typescript/scripts/test-example.js --work-dir /tmp/registry/example

TMP_DIR=$( mktemp -d )

pnpm tsx scripts/publish-to-verdaccio.ts --registry-dir "$TMP_DIR"
pnpm tsx scripts/init-from-verdaccio.ts --registry-dir "$TMP_DIR" --sample hello-world

cd "$TMP_DIR/example"
pnpm run build
pnpm tsx scripts/test-example.ts --work-dir "$TMP_DIR/example"
```

### Style Guide
Expand Down Expand Up @@ -195,7 +195,9 @@ To install both tools: `npm i -g npm-check npm-check-updates`.

## Publishing

First, follow the instructions in [docs/building.md](docs/building.md).
First, download the latest native artifacts from GitHub Actions.

Then run the following commands:

```sh
cargo install git-cliff
Expand Down Expand Up @@ -249,7 +251,7 @@ ls packages/core-bridge/releases/
pnpm exec lerna version patch --force-publish='*' # or major|minor|etc, or leave out to be prompted. either way, you get a confirmation dialog.

git checkout -B fix-deps
node scripts/prepublish.mjs
pnpm tsx scripts/prepublish.ts
git commit -am 'Fix dependencies'
pnpm exec lerna publish from-package # add `--dist-tag next` for pre-release versions
git checkout -
Expand Down
32 changes: 0 additions & 32 deletions docs/building.md

This file was deleted.

7 changes: 0 additions & 7 deletions etc/mac-cargo-config.toml

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
"rebuild": "pnpm run clean && pnpm run build",
"build": "lerna run --stream build",
"build.watch": "pnpm run build:protos && tsc --build --watch packages/*/tsconfig.json",
"build:protos": "node ./packages/proto/scripts/compile-proto.js",
"build:protos": "tsx ./packages/proto/scripts/compile-proto.ts",
"test": "lerna run --stream test",
"test.watch": "lerna run --stream test.watch",
"ci-stress": "node ./packages/test/lib/load/run-all-stress-ci-scenarios.js",
"ci-nightly": "node ./packages/test/lib/load/run-all-nightly-scenarios.js",
"wait-namespace": "node ./scripts/wait-on-temporal.mjs",
"lint": "eslint packages/*/src --ext .ts --no-error-on-unmatched-pattern --fix && prettier --write . && lerna run --no-bail --stream lint",
"lint.check": "eslint packages/*/src --ext .ts --no-error-on-unmatched-pattern && prettier --end-of-line auto --check . && lerna run --no-bail --stream lint.check",
"lint.prune": "ts-prune --error -p tsconfig.prune.json --ignore \"used in module\" --skip \".d.ts\"",
"format": "prettier --write . && lerna run --no-bail --stream format",
"clean": "node ./scripts/clean.mjs",
"clean": "tsx ./scripts/clean.ts",
"docs": "cd packages/docs && pnpm run maybe-install-deps-and-build-docs",
"ava": "pnpm -C packages/test exec ava"
},
Expand Down Expand Up @@ -80,6 +79,7 @@
"lerna": "^8.2.4",
"prettier": "^3.1.1",
"ts-prune": "^0.10.3",
"tsx": "^4.20.6",
"typescript": "^5.6.3",
"verdaccio": "^6.2.2"
},
Expand Down
11 changes: 6 additions & 5 deletions packages/core-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"main": "index.js",
"types": "lib/index.d.ts",
"scripts": {
"build-rust": "node ./scripts/build.js --force",
"build-rust": "tsx ./scripts/build.ts --force",
"build": "pnpm run build-rust",
"build-rust-release": "pnpm run build-rust --release",
"install": "node ./scripts/build.js",
"format": "cargo fmt",
"lint": "cargo clippy --fix --allow-staged",
"lint.check": "cargo clippy"
Expand All @@ -23,10 +22,12 @@
"license": "MIT",
"dependencies": {
"@grpc/grpc-js": "^1.12.4",
"@temporalio/common": "workspace:*",
"@temporalio/common": "workspace:*"
},
"devDependencies": {
"arg": "^5.0.2",
"cargo-cp-artifact": "^0.1.8",
"which": "^4.0.0"
"cargo-cp-artifact": "^0.1.9",
"tsx": "^4.20.6"
},
"bugs": {
"url": "https://github.com/temporalio/sdk-typescript/issues"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const path = require('path');
const arg = require('arg');
const fs = require('fs');
const which = require('which');
const { spawnSync } = require('child_process');
const { version } = require('../package.json');
const { targets, getPrebuiltPath, getPrebuiltTargetName, PrebuildError } = require('../common');
import * as path from 'node:path';
import * as fs from 'node:fs';
import arg from 'arg';
import cargoCpArtifact from 'cargo-cp-artifact';
import { version } from '../package.json';
import { targets, getPrebuiltPath, getPrebuiltTargetName, PrebuildError } from '../common';

process.chdir(path.resolve(__dirname, '..'));

Expand Down Expand Up @@ -54,7 +53,7 @@ if (unsupportedTargets.length) {
const forceBuild = args['--force'];
const buildRelease = args['--release'] || process.env.BUILD_CORE_RELEASE !== undefined;

function compile(requestedTarget) {
function compile(requestedTarget?: string) {
if (!fs.existsSync('sdk-core/Cargo.toml')) {
throw new Error('Missing sdk-core/Cargo.toml. Did you forget to run `git submodule update --init --recursive`?');
}
Expand Down Expand Up @@ -83,16 +82,12 @@ function compile(requestedTarget) {
...(buildRelease ? ['--release'] : []),
...(target ? ['--target', target] : []),
];
const cmd = which.sync('cargo-cp-artifact');

console.log('Running', cmd, argv);
const { status, error } = spawnSync(cmd, argv, {
stdio: 'inherit',
shell: process.platform === 'win32',
console.log('Running cargo-cp-artifact', argv);

cargoCpArtifact(argv, {
env: process.env,
});
if (status !== 0 || error) {
throw new Error(`Failed to build${target ? ' for ' + target : ''}: status code ${status}`, error);
}
}

if (requestedTargets.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lib/"
],
"scripts": {
"build": "node ./scripts/compile-proto.js"
"build": "pnpm tsx ./scripts/compile-proto.ts"
},
"keywords": [
"temporal",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const { rm, readFile, writeFile } = require('fs/promises');
const { resolve } = require('path');
const { promisify } = require('util');
const glob = require('glob');
const { statSync, mkdirSync } = require('fs');
const pbjs = require('protobufjs-cli/pbjs');
const pbts = require('protobufjs-cli/pbts');
import { rm, readFile, writeFile } from 'node:fs/promises';
import { statSync, mkdirSync } from 'node:fs';
import { resolve } from 'node:path';
import { promisify } from 'node:util';
import * as glob from 'glob';
import * as pbjs from 'protobufjs-cli/pbjs';
import * as pbts from 'protobufjs-cli/pbts';

const outputDir = resolve(__dirname, '../protos');
const jsOutputFile = resolve(outputDir, 'json-module.js');
const tempFile = resolve(outputDir, 'temp.js');

const protoBaseDir = resolve(__dirname, '../../core-bridge/sdk-core/crates/common/protos');

function mtime(path) {
function mtime(path: string) {
try {
return statSync(path).mtimeMs;
} catch (err) {
Expand All @@ -23,7 +23,7 @@ function mtime(path) {
}
}

async function compileProtos(dtsOutputFile, ...args) {
async function compileProtos(dtsOutputFile: string, ...args: string[]) {
const pbjsArgs = [
...['--wrap', 'commonjs'],
'--force-long',
Expand Down
2 changes: 1 addition & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "pnpm run \"/^build:.*/\"",
"build:ts": "tsc --build",
"build:protos": "node ./scripts/compile-proto.js",
"build:protos": "pnpm tsx ./scripts/compile-proto.ts",
"test": "ava ./lib/test-*.js",
"test.watch": "ava --watch ./lib/test-*.js"
},
Expand Down
Loading