Skip to content

Commit 3f79100

Browse files
chore: Convert all scripts to TypeScript (#1842)
Co-authored-by: Chris Olszewski <[email protected]>
1 parent d5cf0a8 commit 3f79100

33 files changed

+543
-322
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
node_modules
22
lib
3-
es2020
4-
commonjs

.eslintrc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"root": true,
33
"parser": "@typescript-eslint/parser",
44
"parserOptions": {
5-
"project": "./packages/*/tsconfig.json"
5+
"project": ["./packages/*/tsconfig.json"]
66
},
77
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc", "deprecation", "import"],
88
"extends": [
@@ -12,7 +12,13 @@
1212
"prettier"
1313
],
1414
"rules": {
15-
"eqeqeq": ["error", "always", { "null": "ignore" }],
15+
"eqeqeq": [
16+
"error",
17+
"always",
18+
{
19+
"null": "ignore"
20+
}
21+
],
1622
"no-duplicate-imports": "error",
1723
"object-shorthand": ["error", "always"],
1824
"deprecation/deprecation": "warn",
@@ -27,7 +33,12 @@
2733
"varsIgnorePattern": "^_"
2834
}
2935
],
30-
"import/no-unresolved": ["error", { "ignore": ["^__temporal_"] }],
36+
"import/no-unresolved": [
37+
"error",
38+
{
39+
"ignore": ["^__temporal_"]
40+
}
41+
],
3142
// TypeScript compilation already ensures that named imports exist in the referenced module
3243
"import/named": "off",
3344
"import/default": "error",

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ jobs:
181181
run: pnpm run build --ignore @temporalio/core-bridge
182182

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

186186
- name: Install Temporal CLI
187187
uses: temporalio/setup-temporal@v0
@@ -222,8 +222,8 @@ jobs:
222222
# Sample 1: hello-world to local server
223223
- name: Instantiate sample project using verdaccio artifacts - Hello World
224224
run: |
225-
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
226-
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world"
225+
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
226+
pnpm tsx scripts/test-example.ts --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world"
227227
228228
# Sample 2: hello-world-mtls to cloud server
229229
- name: Instantiate sample project using verdaccio artifacts - Hello World MTLS
@@ -233,9 +233,9 @@ jobs:
233233
exit 0
234234
fi
235235
236-
node scripts/create-certs-dir.js ${{ steps.tmp-dir.outputs.dir }}/certs
237-
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
238-
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls"
236+
pnpm tsx scripts/create-certs-dir.ts ${{ steps.tmp-dir.outputs.dir }}/certs
237+
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
238+
pnpm tsx scripts/test-example.ts --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-hello-world-mtls"
239239
env:
240240
# These env vars are used by the hello-world-mtls sample
241241
TEMPORAL_ADDRESS: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}.tmprl.cloud:7233
@@ -255,8 +255,8 @@ jobs:
255255
# Sample 3: fetch-esm to local server
256256
- name: Instantiate sample project using verdaccio artifacts - Fetch ESM
257257
run: |
258-
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
259-
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!"
258+
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
259+
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!"
260260
261261
# End samples
262262

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ jobs:
181181
run: pnpm run build --ignore @temporalio/core-bridge
182182

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

186186
- name: Save Verdaccio repo artifact
187187
uses: actions/upload-artifact@v4
@@ -250,7 +250,7 @@ jobs:
250250

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

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

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

286286
- name: Test run a workflow (cloud)
287287
if: matrix.server == 'cloud'
288288
# The required environment variables must be present for releases (this must be run from the official repo)
289-
run: node scripts/test-example.js --work-dir "${{ runner.temp }}/example"
289+
run: pnpm tsx scripts/test-example.ts --work-dir "${{ runner.temp }}/example"
290290
shell: bash
291291
env:
292292
# These env vars are used by the hello-world-mtls sample

.prettierignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ packages/core-bridge/target
44
packages/core-bridge/bridge-macros/target
55
sdk-core
66
lib
7-
es2020
8-
commonjs
97
.docusaurus
108
packages/*/CHANGELOG.md
119
packages/docs/docs/api

CONTRIBUTING.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,10 @@ If building fails, resetting your environment may help:
9393
pnpm dlx lerna clean -y && pnpm install --frozen-lockfile
9494
```
9595

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

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

104101
## Development
105102

@@ -135,14 +132,17 @@ To replicate the `test-npm-init` CI test locally, you can start with the below s
135132
> If you've run `npx @temporalio/create` before, you may need to delete the version of the package that's stored in `~/.npm/_npx/`.
136133
137134
```
138-
rm -rf /tmp/registry
139135
pnpm install --frozen-lockfile
140136
pnpm run rebuild
141-
node scripts/publish-to-verdaccio.js --registry-dir /tmp/registry
142-
node scripts/init-from-verdaccio.js --registry-dir /tmp/registry --sample hello-world
143-
cd /tmp/registry/example
144-
npm run build
145-
node ~/path-to/sdk-typescript/scripts/test-example.js --work-dir /tmp/registry/example
137+
138+
TMP_DIR=$( mktemp -d )
139+
140+
pnpm tsx scripts/publish-to-verdaccio.ts --registry-dir "$TMP_DIR"
141+
pnpm tsx scripts/init-from-verdaccio.ts --registry-dir "$TMP_DIR" --sample hello-world
142+
143+
cd "$TMP_DIR/example"
144+
pnpm run build
145+
pnpm tsx scripts/test-example.ts --work-dir "$TMP_DIR/example"
146146
```
147147

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

196196
## Publishing
197197

198-
First, follow the instructions in [docs/building.md](docs/building.md).
198+
First, download the latest native artifacts from GitHub Actions.
199+
200+
Then run the following commands:
199201

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

251253
git checkout -B fix-deps
252-
node scripts/prepublish.mjs
254+
pnpm tsx scripts/prepublish.ts
253255
git commit -am 'Fix dependencies'
254256
pnpm exec lerna publish from-package # add `--dist-tag next` for pre-release versions
255257
git checkout -

docs/building.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

etc/mac-cargo-config.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
"rebuild": "pnpm run clean && pnpm run build",
2525
"build": "lerna run --stream build",
2626
"build.watch": "pnpm run build:protos && tsc --build --watch packages/*/tsconfig.json",
27-
"build:protos": "node ./packages/proto/scripts/compile-proto.js",
27+
"build:protos": "tsx ./packages/proto/scripts/compile-proto.ts",
2828
"test": "lerna run --stream test",
2929
"test.watch": "lerna run --stream test.watch",
3030
"ci-stress": "node ./packages/test/lib/load/run-all-stress-ci-scenarios.js",
3131
"ci-nightly": "node ./packages/test/lib/load/run-all-nightly-scenarios.js",
32-
"wait-namespace": "node ./scripts/wait-on-temporal.mjs",
3332
"lint": "eslint packages/*/src --ext .ts --no-error-on-unmatched-pattern --fix && prettier --write . && lerna run --no-bail --stream lint",
3433
"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",
3534
"lint.prune": "ts-prune --error -p tsconfig.prune.json --ignore \"used in module\" --skip \".d.ts\"",
3635
"format": "prettier --write . && lerna run --no-bail --stream format",
37-
"clean": "node ./scripts/clean.mjs",
36+
"clean": "tsx ./scripts/clean.ts",
3837
"docs": "cd packages/docs && pnpm run maybe-install-deps-and-build-docs",
3938
"ava": "pnpm -C packages/test exec ava"
4039
},
@@ -81,6 +80,7 @@
8180
"lerna": "^8.2.4",
8281
"prettier": "^3.1.1",
8382
"ts-prune": "^0.10.3",
83+
"tsx": "^4.20.6",
8484
"typescript": "^5.6.3",
8585
"verdaccio": "^6.2.2"
8686
},

packages/core-bridge/common.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const targets: string[];
2+
3+
export class PrebuildError extends Error {}
4+
5+
export function getPrebuiltTargetName(): string;
6+
7+
export function getPrebuiltPath(): string;

0 commit comments

Comments
 (0)