Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
Closed
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
1 change: 0 additions & 1 deletion packages/actor-core-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"ink-gradient": "^3.0.0",
"ink-link": "^4.1.0",
"ink-spinner": "^5.0.0",
"joycon": "^3.1.1",
"micromatch": "^4.0.8",
"pkg-types": "^2.0.0",
"react": "^18.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/actor-core-cli/src/commands/deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const deploy = new Command()
.addArgument(
new Argument("<platform>", "The platform to deploy to").choices(["rivet"]),
)
.addArgument(new Argument("<path>", "Location of the app.ts file"))
.addOption(new Option("-r, --root [path]", "Location of the project").default("./"))
.addOption(new Option("-p, --path [path]", "Location of the app.ts file"))
.addOption(new Option("--skip-manager", "Skip deploying ActorCore manager"))
Expand All @@ -33,9 +34,8 @@ export const deploy = new Command()
"afterAll",
"\nMissing your favorite platform?\nLet us know! https://github.com/rivet-gg/actor-core/issues/new",
)
.action(async (platform, opts: {
.action(async (platform, appPath: string, opts: {
root: string;
path?: string;
port?: string;
skipManager: boolean,
env?: string,
Expand All @@ -54,7 +54,7 @@ export const deploy = new Command()
const { config, cli } = yield* ctx.task(
"Prepare",
async function* (ctx) {
const config = yield* validateConfigTask(ctx, cwd, opts.path);
const config = yield* validateConfigTask(ctx, cwd, appPath);

const cli = yield* ctx.task(
"Locale rivet-cli",
Expand Down
9 changes: 4 additions & 5 deletions packages/actor-core-cli/src/commands/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { spawn } from "node:child_process";
export const dev = new Command()
.name("dev")
.description("Run locally your ActorCore project.")
.addArgument(new Argument("<path>", "Location of the app.ts file"))
.addOption(
new Option("-r, --root [path]", "Location of the project").default("./"),
)
.addOption(new Option("-p, --path [path]", "Location of the app.ts file"))
.addOption(
new Option("--port [port]", "Specify which platform to use").default(
"6420",
Expand All @@ -29,9 +29,8 @@ export const dev = new Command()
.option("--no-open", "Do not open the browser with ActorCore Studio")
.action(action);

export async function action(opts: {
export async function action(appPath: string, opts: {
root: string;
path?: string;
port?: string;
open: boolean;
}) {
Expand Down Expand Up @@ -61,7 +60,7 @@ export async function action(opts: {
"server-entry.js",
),
],
{ env: { ...process.env, PORT: opts.port, PATH: opts.path }, cwd },
{ env: { ...process.env, PORT: opts.port, APP_PATH: appPath }, cwd },
);
}

Expand All @@ -82,7 +81,7 @@ export async function action(opts: {
});

while (true) {
yield* validateConfigTask(ctx, cwd, opts.path);
yield* validateConfigTask(ctx, cwd, appPath);
server = createServer();
createLock();

Expand Down
2 changes: 1 addition & 1 deletion packages/actor-core-cli/src/server-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { validateConfig } from "./utils/config";
import { serve } from "@actor-core/nodejs";

async function run() {
const config = await validateConfig(process.cwd(), process.env.PATH);
const config = await validateConfig(process.cwd(), process.env.APP_PATH!);
config.app.config.inspector = {
enabled: true,
};
Expand Down
40 changes: 7 additions & 33 deletions packages/actor-core-cli/src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from "node:fs";
import path from "node:path";
import { bundleRequire } from "bundle-require";
import JoyCon from "joycon";
import z from "zod";
import type { ActorCoreApp } from "actor-core";

Expand All @@ -12,55 +10,31 @@ const ActorCoreConfig = z.object({
});

export async function loadConfig(
cwd: string,
appPath?: string,
_cwd: string,
appPath: string,
): Promise<{ path: string; data: z.infer<typeof ActorCoreConfig> } | null> {
const configJoycon = new JoyCon();

// Attempt to auto-resolve app path
let resolvedAppPath: string;
if (appPath) {
resolvedAppPath = appPath;
} else {
// Auto-resolve app path
const resolved = await configJoycon.resolve({
files: [
"src/app.ts",
"src/app.tsx",
"src/app.mts",
"src/app.js",
"src/app.cjs",
"src/app.mjs",
],
cwd,
stopDir: path.parse(cwd).root,
});
if (!resolved) return null;
resolvedAppPath = resolved;
}

try {
const config = await bundleRequire({
filepath: resolvedAppPath,
filepath: appPath,
});
return {
path: resolvedAppPath,
path: appPath,
data: config.mod.default || config.mod,
};
} catch (error) {
throw { isBundleError: true, path: resolvedAppPath, details: error };
throw { isBundleError: true, path: appPath, details: error };
}
}

export async function requireConfig(cwd: string, appPath?: string) {
export async function requireConfig(cwd: string, appPath: string) {
const config = await loadConfig(cwd, appPath);
if (!config || !config.data) {
throw { isNotFoundError: true, cwd, appPath };
}
return config;
}

export async function validateConfig(cwd: string, appPath?: string) {
export async function validateConfig(cwd: string, appPath: string) {
const config = await requireConfig(cwd, appPath);
return await ActorCoreConfig.parseAsync({
...config.data,
Expand Down
2 changes: 1 addition & 1 deletion packages/actor-core-cli/src/workflows/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Context } from "../workflow";
export function validateConfigTask(
ctx: Context,
cwd: string,
appPath?: string,
appPath: string,
) {
return ctx.task("Build project", async () => {
try {
Expand Down
Loading