mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-13 04:51:00 +08:00
153 lines
4.8 KiB
TOML
153 lines
4.8 KiB
TOML
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# TypeScript SDK tasks (sdk/typescript). Codegen runs `buf generate` (buf and
|
|
# the connect-es plugin come from the package's own devDependencies); buf
|
|
# self-compiles proto/, so no protoc is required.
|
|
|
|
["sdk:ts:install"]
|
|
description = "Install TypeScript SDK dependencies"
|
|
dir = "sdk/typescript"
|
|
run = "npm ci"
|
|
hide = true
|
|
|
|
["sdk:ts:proto"]
|
|
description = "Generate TypeScript protobuf stubs for the SDK"
|
|
depends = ["sdk:ts:install"]
|
|
dir = "sdk/typescript"
|
|
run = "npm run gen"
|
|
|
|
# Lints the repo-level proto module (buf.yaml at the root) against STANDARD.
|
|
# buf ships only in the SDK's devDependencies today, so this depends on the
|
|
# SDK install and runs buf from there; the target is all of proto/, not just
|
|
# the SDK's client-surface subset.
|
|
["proto:lint"]
|
|
description = "Lint proto/ with buf (repo-level buf.yaml)"
|
|
depends = ["sdk:ts:install"]
|
|
run = "./sdk/typescript/node_modules/.bin/buf lint"
|
|
run_windows = "sdk\\typescript\\node_modules\\.bin\\buf.cmd lint"
|
|
|
|
["sdk:ts:typecheck"]
|
|
description = "Type-check the TypeScript SDK"
|
|
depends = ["sdk:ts:proto"]
|
|
dir = "sdk/typescript"
|
|
run = "npm run typecheck"
|
|
|
|
["sdk:ts:lint"]
|
|
description = "Lint + format-check the TypeScript SDK (Biome, read-only)"
|
|
depends = ["sdk:ts:install"]
|
|
dir = "sdk/typescript"
|
|
run = "npm run lint"
|
|
|
|
["sdk:ts:format"]
|
|
description = "Format the TypeScript SDK and apply safe fixes (Biome, writes)"
|
|
depends = ["sdk:ts:install"]
|
|
dir = "sdk/typescript"
|
|
run = "npm run format"
|
|
|
|
["sdk:ts:build"]
|
|
description = "Build the TypeScript SDK (emit dist/)"
|
|
depends = ["sdk:ts:proto"]
|
|
dir = "sdk/typescript"
|
|
run = "npm run build"
|
|
|
|
["sdk:ts:test"]
|
|
description = "Run TypeScript SDK unit tests (Vitest, in-memory transport)"
|
|
depends = ["sdk:ts:proto"]
|
|
dir = "sdk/typescript"
|
|
run = "npm test"
|
|
|
|
["sdk:ts:ci"]
|
|
description = "TypeScript SDK checks (proto lint, Biome lint, codegen, typecheck, test, build)"
|
|
depends = [
|
|
"proto:lint",
|
|
"sdk:ts:lint",
|
|
"sdk:ts:typecheck",
|
|
"sdk:ts:test",
|
|
"sdk:ts:build",
|
|
]
|
|
hide = true
|
|
|
|
["sdk:ts:proto:drift"]
|
|
description = "Check TypeScript SDK proto drift and output a JSON report"
|
|
dir = "sdk/typescript"
|
|
run = """
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# TS SDK generated files (src/gen/) are gitignored, so there's no committed
|
|
# baseline to diff against. Instead, detect drift by regenerating + type
|
|
# checking: if the handwritten SDK code no longer compiles against the current
|
|
# proto definitions, that's drift.
|
|
|
|
if ! command -v jq &>/dev/null; then
|
|
echo '{"sdk":"typescript","synced":false,"error":"jq not found"}'
|
|
exit 1
|
|
fi
|
|
|
|
LOG_FILE=$(mktemp)
|
|
trap 'rm -f "$LOG_FILE"' EXIT
|
|
|
|
if ! mise run sdk:ts:proto > "$LOG_FILE" 2>&1; then
|
|
jq -n -c '{sdk:"typescript", synced:false, files:[], summary:"proto generation failed"}'
|
|
exit 1
|
|
fi
|
|
|
|
if ! mise run sdk:ts:typecheck >> "$LOG_FILE" 2>&1; then
|
|
jq -n -c '{sdk:"typescript", synced:false, files:[], summary:"typecheck failed after proto regeneration"}'
|
|
exit 1
|
|
fi
|
|
|
|
jq -n -c '{sdk:"typescript", synced:true, files:[], summary:"all files synced"}'
|
|
"""
|
|
hide = true
|
|
|
|
["sdk:ts:proto:build-check"]
|
|
description = "Run full TypeScript SDK proto generate, typecheck, and test pipeline"
|
|
dir = "sdk/typescript"
|
|
run = 'bash ../../tasks/scripts/sdk_build_check.sh typescript gen=sdk:ts:proto typecheck=sdk:ts:typecheck test=sdk:ts:test'
|
|
hide = true
|
|
|
|
# Publish to the registry in package.json publishConfig. Set OPENSHELL_NPM_VERSION
|
|
# to stamp the version from the release tag (release.py get-version --npm); the
|
|
# package.json placeholder 0.0.0 is restored afterward, mirroring the Cargo
|
|
# version stamping in tasks/python.toml. Auth is expected via a .npmrc the caller
|
|
# writes (CI) or the user's own npm login.
|
|
#
|
|
# Prerelease versions (e.g. 0.0.37-dev.N.gSHA from an off-tag build) must not
|
|
# claim the `latest` dist-tag, so they publish under `next` instead — npm also
|
|
# refuses a bare `npm publish` for a prerelease. Set OPENSHELL_NPM_PUBLISH_ARGS
|
|
# (e.g. `--dry-run`) to pass extra flags through; CI uses this to validate the
|
|
# publishable artifact on PRs without uploading.
|
|
["sdk:ts:publish"]
|
|
description = "Publish the TypeScript SDK to its configured registry"
|
|
depends = ["sdk:ts:build"]
|
|
dir = "sdk/typescript"
|
|
run = """
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ORIGINAL_PKG=""
|
|
cleanup() {
|
|
if [ -n "$ORIGINAL_PKG" ] && [ -f "$ORIGINAL_PKG" ]; then
|
|
cp "$ORIGINAL_PKG" package.json
|
|
rm -f "$ORIGINAL_PKG"
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
DIST_TAG="latest"
|
|
if [ -n "${OPENSHELL_NPM_VERSION:-}" ]; then
|
|
ORIGINAL_PKG=$(mktemp)
|
|
cp package.json "$ORIGINAL_PKG"
|
|
npm pkg set version="$OPENSHELL_NPM_VERSION"
|
|
# A hyphen means a SemVer prerelease (X.Y.Z-dev.N...) -> publish off `latest`.
|
|
case "$OPENSHELL_NPM_VERSION" in
|
|
*-*) DIST_TAG="next" ;;
|
|
esac
|
|
fi
|
|
|
|
npm publish --tag "$DIST_TAG" ${OPENSHELL_NPM_PUBLISH_ARGS:-}
|
|
"""
|
|
hide = true
|