Skip to content

Commit

Permalink
chore(sdks): proper build system
Browse files Browse the repository at this point in the history
  • Loading branch information
jog1t committed Jan 16, 2025
1 parent 22fef37 commit d2f528b
Show file tree
Hide file tree
Showing 21 changed files with 636 additions and 410 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ tests/basic-game/.env

/target
.env*
.yarn/cache
.yarn/cache
.yarn/install-state.gz
34 changes: 5 additions & 29 deletions examples/react/actor/deno.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
{
"nodeModulesDir": "auto",
"imports": {
"@rivet-gg/actor": "../../../sdks/actor/runtime/src/mod.ts",
"@rivet-gg/actor/": "../../../sdks/actor/runtime/src/",
"@rivet-gg/actor/unstable-react": "../../../sdks/actor/runtime/src/unstable-react.ts",
"@rivet-gg/actor-protocol": "../../../sdks/actor/protocol/src/mod.ts",
"@rivet-gg/actor-protocol/": "../../../sdks/actor/protocol/src/",
"@rivet-gg/actor-protocol/ws/to_client": "../../../sdks/actor/protocol/src/ws/to_client.ts",
"@rivet-gg/actor-protocol/ws/to_server": "../../../sdks/actor/protocol/src/ws/to_server.ts",
"@rivet-gg/actor-protocol/ws": "../../../sdks/actor/protocol/src/ws/mod.ts",
"@rivet-gg/actor-protocol/http/inspect": "../../../sdks/actor/protocol/src/http/inspect.ts",
"@rivet-gg/actor-core": "../../../sdks/actor/core/src/mod.ts",
"@rivet-gg/actor-core/": "../../../sdks/actor/core/src/",
"@rivet-gg/actor-client": "../../../sdks/actor/client/src/mod.ts",
"@rivet-gg/actor-common": "../../../sdks/actor/common/src/mod.ts",
"@rivet-gg/actor-common/": "../../../sdks/actor/common/src/",
"@rivet-gg/actor-common/log": "../../../sdks/actor/common/src/log.ts",
"@rivet-gg/actor-common/utils": "../../../sdks/actor/common/src/utils.ts",
"@rivet-gg/actor-common/reflect": "../../../sdks/actor/common/src/reflect.ts",
"@core/asyncutil": "jsr:@core/asyncutil@^1.2.0",
"@std/assert": "jsr:@std/assert@^1.0.8",
"@std/async": "jsr:@std/async@^1.0.9",
"@std/cbor": "jsr:@std/cbor@^0.1.3",
"@std/log": "jsr:@std/log@^0.224.11",
"@types/react": "npm:@types/react@^19",
"hono": "jsr:@hono/hono@^4.6.12",
"on-change": "npm:on-change@^5.0.1",
"zod": "npm:zod@^3.24.1",
"react": "npm:react"
"@rivet-gg/actor": "jsr:@rivet-gg/[email protected]",
"react": "npm:react@^19.0.0",
"react-dom": "npm:react-dom@^19.0.0"
},
"compilerOptions": {
"types": ["react", "react-dom", "@types/react"],
"jsx": "react-jsx",
"jsxImportSource": "react"
"jsxImportSource": "react",
"jsxImportSourceTypes": "npm:@types/react@^19"
}
}
97 changes: 44 additions & 53 deletions examples/react/actor/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/react/actor/server-driven-ui.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Rpc } from "@rivet-gg/actor";
import { RscActor } from "@rivet-gg/actor/unstable-react";
// import { RscActor } from "@rivet-gg/actor/unstable-react";

export default class ServerDrivenUi extends RscActor {
messages(_rpc: Rpc<this>, props: Record<string, unknown>) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"@std/path": "jsr:@std/path@^1.0.8",
"@std/toml": "jsr:@std/toml@^1.0.1",
"dedent": "npm:dedent@^1.5.3",
"glob": "npm:glob@^11.0.0"
"glob": "npm:glob@^11.0.0",
"type-fest": "npm:type-fest@^4.32.0"
},
"fmt": {
"useTabs": true
Expand Down
20 changes: 18 additions & 2 deletions scripts/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/release/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assert, assertEquals, assertExists } from "jsr:@std/assert";
import { publishSdk } from "./sdk.ts";
import { updateVersion } from "./update_version.ts";
import { configureReleasePlease } from "./release_please.ts";
import { getCommit, validateGit } from "./git.ts";
import { validateGit } from "./git.ts";
import { parseArgs } from "jsr:@std/cli";
import $ from "dax";
import { tagDocker } from "./docker.ts";
Expand Down
38 changes: 29 additions & 9 deletions scripts/release/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReleaseOpts } from "./main.ts";
import { assertStringIncludes } from "@std/assert";
import $ from "dax";
import { transformPackageJsonToDenoJson } from "../sdk_actor/transform_pkg_to_deno.ts";

async function npmVersionExists(
packageName: string,
Expand Down Expand Up @@ -56,20 +57,29 @@ export async function publishSdk(opts: ReleaseOpts) {
path: `${opts.root}/sdks/actor/runtime`,
name: "@rivet-gg/actor",
jsr: true,
turbo: true,
},
{
path: `${opts.root}/sdks/actor/client`,
name: "@rivet-gg/actor-client",
jsr: true,
npm: true,
turbo: true,
},
{
path: `${opts.root}/sdks/actor/core`,
name: "@rivet-gg/actor-core",
jsr: true,
npm: true,
turbo: true
},
];

for (const pkg of packages) {
if(pkg.turbo) {
await $`yarn build --filter ${pkg.name}`;
}

// Check if version already exists
let versionExists = false;
if (pkg.npm) {
Expand All @@ -85,29 +95,39 @@ export async function publishSdk(opts: ReleaseOpts) {
continue;
}

// Update version in config
const pkgJsonPath = `${pkg.path}/package.json`;
const pkgJsonContent = await Deno.readTextFile(pkgJsonPath);
const pkgJson = JSON.parse(pkgJsonContent);
pkgJson.version = opts.version;
await Deno.writeTextFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));

// Publish
if (pkg.npm) {
$.logStep("Publishing to NPM", `${pkg.name}@${opts.version}`);
await $`yarn install`.cwd(pkg.path);
await $`yarn publish --new-version ${opts.version} --no-git-tag-version`.cwd(pkg.path);
try {
await $`yarn publish --new-version ${opts.version} --no-git-tag-version`.cwd(pkg.path);
} catch {
await $`yarn npm publish --access public`.cwd(pkg.path);
}
}

if (pkg.jsr) {
$.logStep("Publishing to JSR", `${pkg.name}@${opts.version}`);

// TODO(https://github.com/denoland/deno/issues/27428): `--set-version` not working, so we have to manually update `jsr.jsonc`
// Update version in config
const jsrJsonPath = `${pkg.path}/deno.json`;
const jsrJsonContent = await Deno.readTextFile(jsrJsonPath);
const jsrJson = JSON.parse(jsrJsonContent);
jsrJson.version = opts.version;
await Deno.writeTextFile(jsrJsonPath, JSON.stringify(jsrJson, null, 2));

await transformPackageJsonToDenoJson({
cwd: pkg.path,
skipPathInInternalPackages: "src",
internalPackagesLinkPath: "internal",
});

// TODO: Auto-populate token here
// --allow-slow-types = we use zod which doesn't support this
// --allow-dirty = we change the version on the fly
// --set-version = validate the correct version is used
await $`deno publish --allow-slow-types --allow-dirty --set-version ${opts.version}`
await $`DENO_NO_PACKAGE_JSON=1 deno publish --allow-slow-types --allow-dirty`
.cwd(pkg.path);
}
}
Expand Down
Loading

0 comments on commit d2f528b

Please sign in to comment.