diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 2f3cd19d3b..d8f6d6aa1a 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -75,14 +75,12 @@ jobs: run: | cat > Dockerfile << 'EOF' FROM --platform=${BUILDPLATFORM} alpine as builder - ADD restate-cli-aarch64-unknown-linux-musl.tar.xz /restate-arm64 - ADD restate-cli-x86_64-unknown-linux-musl.tar.xz /restate-amd64 - # keep output image small by removing the server binary - RUN rm /restate-*/restate-server + ADD restate-cli-aarch64-unknown-linux-musl.tar.xz /restate-cli-arm64 + ADD restate-cli-x86_64-unknown-linux-musl.tar.xz /restate-cli-amd64 FROM alpine ARG TARGETARCH - COPY --from=builder /restate-${TARGETARCH} / + COPY --from=builder /restate-cli-${TARGETARCH} / ENTRYPOINT [ "/restate" ] EOF diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index c56dbeabea..0b170c0a41 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -21,6 +21,7 @@ jobs: matrix: app_name: - restate-cli + - restatectl - restate-server build: - target: aarch64-apple-darwin @@ -96,6 +97,7 @@ jobs: matrix: app_name: - restate-cli + - restatectl - restate-server steps: - name: Checkout diff --git a/npm/restate-server/src/index.ts b/npm/restate-server/src/index.ts index c79581fd5d..957cf5c7f2 100644 --- a/npm/restate-server/src/index.ts +++ b/npm/restate-server/src/index.ts @@ -1,17 +1,31 @@ #!/usr/bin/env node +/* + * Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH. + * All rights reserved. + * + * Use of this software is governed by the Business Source License + * included in the LICENSE file. + * + * As of the Change Date specified in that file, in accordance with + * the Business Source License, use of this software will be governed + * by the Apache License, Version 2.0. + */ + import { spawnSync } from "child_process"; -import os from 'node:os'; +import os from "node:os"; function getExePath() { const arch = os.arch(); const op = os.platform(); try { - return require.resolve(`@restatedev/restate-server-${op}-${arch}/bin/restate-server`); + return require.resolve( + `@restatedev/restate-server-${op}-${arch}/bin/restate-server`, + ); } catch (e) { throw new Error( - `Couldn't find application binary inside node_modules for ${op}-${arch}` + `Couldn't find application binary inside node_modules for ${op}-${arch}`, ); } } diff --git a/npm/restate/src/index.ts b/npm/restate/src/index.ts index 6d451f1b62..eabe11a811 100644 --- a/npm/restate/src/index.ts +++ b/npm/restate/src/index.ts @@ -1,3 +1,5 @@ +#!/usr/bin/env node + /* * Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH. * All rights reserved. @@ -10,10 +12,8 @@ * by the Apache License, Version 2.0. */ -#!/usr/bin/env node - import { spawnSync } from "child_process"; -import os from 'node:os'; +import os from "node:os"; function getExePath() { const arch = os.arch(); @@ -23,7 +23,7 @@ function getExePath() { return require.resolve(`@restatedev/restate-${op}-${arch}/bin/restate`); } catch (e) { throw new Error( - `Couldn't find application binary inside node_modules for ${op}-${arch}` + `Couldn't find application binary inside node_modules for ${op}-${arch}`, ); } } diff --git a/npm/restatectl/package.json b/npm/restatectl/package.json new file mode 100644 index 0000000000..f84b10978b --- /dev/null +++ b/npm/restatectl/package.json @@ -0,0 +1,37 @@ +{ + "name": "@restatedev/restatectl", + "description": "Restate administration tools", + "version": "0.5.1", + "bin": "lib/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/restatedev/restate.git" + }, + "publishConfig": { + "@restatedev:registry": "https://registry.npmjs.org" + }, + "author": "Restate Developers", + "license": "BSL", + "email": "code@restate.dev", + "homepage": "https://github.com/restatedev/restate#readme", + "scripts": { + "typecheck": "tsc --noEmit", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "build": "tsc", + "dev": "npm run build && node lib/index.js" + }, + "devDependencies": { + "@types/node": "^18.11.18", + "@typescript-eslint/eslint-plugin": "^5.48.0", + "@typescript-eslint/parser": "^5.48.0", + "eslint": "^8.31.0", + "typescript": "^4.9.4" + }, + "optionalDependencies": { + "@restatedev/restatectl-linux-x64": "0.5.1", + "@restatedev/restatectl-linux-arm64": "0.5.1", + "@restatedev/restatectl-darwin-x64": "0.5.1", + "@restatedev/restatectl-darwin-arm64": "0.5.1" + } +} diff --git a/npm/restatectl/src/index.ts b/npm/restatectl/src/index.ts new file mode 100644 index 0000000000..ffb94cf889 --- /dev/null +++ b/npm/restatectl/src/index.ts @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +/* + * Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH. + * All rights reserved. + * + * Use of this software is governed by the Business Source License + * included in the LICENSE file. + * + * As of the Change Date specified in that file, in accordance with + * the Business Source License, use of this software will be governed + * by the Apache License, Version 2.0. + */ + +import { spawnSync } from "child_process"; +import os from "node:os"; + +function getExePath() { + const arch = os.arch(); + const op = os.platform(); + + try { + return require.resolve( + `@restatedev/restatectl-${op}-${arch}/bin/restatectl`, + ); + } catch (e) { + throw new Error( + `Couldn't find application binary inside node_modules for ${op}-${arch}`, + ); + } +} + +function run() { + const args = process.argv.slice(2); + const processResult = spawnSync(getExePath(), args, { stdio: "inherit" }); + process.exit(processResult.status ?? 0); +} + +run(); diff --git a/npm/restatectl/tsconfig.json b/npm/restatectl/tsconfig.json new file mode 100644 index 0000000000..5ed5d484c0 --- /dev/null +++ b/npm/restatectl/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "esModuleInterop": true, + "baseUrl": "./", + "outDir": "lib", + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/tools/restatectl/Cargo.toml b/tools/restatectl/Cargo.toml index 705928e511..a007104b6a 100644 --- a/tools/restatectl/Cargo.toml +++ b/tools/restatectl/Cargo.toml @@ -2,11 +2,18 @@ name = "restatectl" version.workspace = true authors.workspace = true +description = "Restate administration tools" edition.workspace = true rust-version.workspace = true license.workspace = true +repository.workspace = true +homepage.workspace = true publish = false +[package.metadata.dist] +dist = true +formula = "restatectl" + [features] default = ["replicated-loglet", "memory-loglet", "no-trace-logging"] replicated-loglet = [