From fc01dae8c04b9b3c8dbc5961549614eb0d02d894 Mon Sep 17 00:00:00 2001 From: warman Date: Sun, 4 May 2025 16:24:38 -0400 Subject: [PATCH 1/4] fix: TargetInfo path resoluton --- src/lib/engine.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/engine.ts b/src/lib/engine.ts index 5ccb532..aedf232 100644 --- a/src/lib/engine.ts +++ b/src/lib/engine.ts @@ -165,7 +165,7 @@ export abstract class Engine { const args = ['-Mode=QueryTargets', `-Project=${projectFile}`] await this.ubt(args, { quiet: true }) try { - const targetInfoJson = path.resolve(`${projectPath}\\Intermediate\\TargetInfo.json`) + const targetInfoJson = path.resolve(path.join(projectPath, 'Intermediate', 'TargetInfo.json')) const { Targets } = JSON.parse(Deno.readTextFileSync(targetInfoJson)) const targets = Targets.map((target: TargetInfo) => target.Name) return targets @@ -266,7 +266,7 @@ class WindowsEngine extends Engine { const args = ['-Mode=QueryTargets'] await this.ubt(args, { quiet: true }) try { - const targetInfoJson = path.resolve(`${this.enginePath}\\Engine\\Intermediate\\TargetInfo.json`) + const targetInfoJson = path.resolve(path.join(this.enginePath, 'Engine', 'Intermediate', 'TargetInfo.json')) const { Targets } = JSON.parse(Deno.readTextFileSync(targetInfoJson)) const targets = Targets.map((target: TargetInfo) => target.Name) return targets @@ -329,7 +329,7 @@ class MacosEngine extends Engine { const args = ['-Mode=QueryTargets'] await this.ubt(args, { quiet: true }) try { - const targetInfoJson = path.resolve(`${this.enginePath}/Engine/Intermediate/TargetInfo.json`) + const targetInfoJson = path.resolve(path.join(this.enginePath, 'Engine', 'Intermediate', 'TargetInfo.json')) const { Targets } = JSON.parse(Deno.readTextFileSync(targetInfoJson)) const targets = Targets.map((target: TargetInfo) => target.Name) return targets @@ -392,7 +392,7 @@ class LinuxEngine extends Engine { const args = ['-Mode=QueryTargets'] await this.ubt(args, { quiet: true }) try { - const targetInfoJson = path.resolve(`${this.enginePath}/Engine/Intermediate/TargetInfo.json`) + const targetInfoJson = path.resolve(path.join(this.enginePath, 'Engine', 'Intermediate', 'TargetInfo.json')) const { Targets } = JSON.parse(Deno.readTextFileSync(targetInfoJson)) const targets = Targets.map((target: TargetInfo) => target.Name) return targets From 5acf37616227100f9ab654b84afe44a5be834fb3 Mon Sep 17 00:00:00 2001 From: warman Date: Sun, 4 May 2025 17:07:43 -0400 Subject: [PATCH 2/4] feat: add list-targets cmd --- src/commands/build.ts | 5 ++-- src/commands/list-targets.ts | 47 ++++++++++++++++++++++++++++++++++++ src/index.ts | 2 ++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/commands/list-targets.ts diff --git a/src/commands/build.ts b/src/commands/build.ts index 917e2f2..860c749 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -6,10 +6,9 @@ import type { GlobalOptions } from '../lib/types.ts' import { Config } from '../lib/config.ts' const TargetError = (target: string, targets: string[]) => { - return new ValidationError(`Invalid Target: ${target} -Valid Targets: ${targets.join(', ')} - `) + return new ValidationError(`Invalid Target: ${target}. Run 'runreal list-targets' to see valid targets.`) } + export type BuildOptions = typeof build extends Command ? Options : never diff --git a/src/commands/list-targets.ts b/src/commands/list-targets.ts new file mode 100644 index 0000000..80c66cc --- /dev/null +++ b/src/commands/list-targets.ts @@ -0,0 +1,47 @@ +import { Command } from '@cliffy/command' +import { createEngine } from '../lib/engine.ts' +import type { GlobalOptions } from '../lib/types.ts' +import { Config } from '../lib/config.ts' + +export type ListTargetsOptions = typeof listTargets extends + Command ? Options + : never + +const logTargets = (targets: string[]) => { + return targets.map((target) => { + console.log(target) + }) +} + +export const listTargets = new Command() + .description('list-targets') + .option('-e, --engine-only', 'list only engine targets') + .option('-p, --project-only', 'list only project targets', { conflicts: ['engine-only'] }) + .action(async (options) => { + const { engineOnly, projectOnly } = options as ListTargetsOptions + const config = Config.getInstance() + const { engine: { path: enginePath }, project: { path: projectPath } } = config.mergeConfigCLIConfig({ + cliOptions: options, + }) + + const engine = createEngine(enginePath) + const engineTargets = await engine.parseEngineTargets() + let projectTargets: string[] = [] + + if (projectPath) { + projectTargets = (await engine.parseProjectTargets(projectPath)).filter((target) => + !engineTargets.includes(target) + ) + } + + if (engineOnly) { + return logTargets(engineTargets) + } + + if (projectOnly) { + return logTargets(projectTargets) + } + + const targets = Array.from(new Set([...engineTargets, ...projectTargets])) + return logTargets(targets) + }) diff --git a/src/index.ts b/src/index.ts index bf7b8fd..d714d00 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import { script } from './commands/script.ts' import { runpython } from './commands/runpython.ts' import { uasset } from './commands/uasset/index.ts' import { auth } from './commands/auth.ts' +import { listTargets } from './commands/list-targets.ts' await cmd .name('runreal') @@ -27,6 +28,7 @@ await cmd .command('debug', debug) .command('clean', clean) .command('build', build) + .command('list-targets', listTargets) .command('engine', engine) .command('uat', uat) .command('ubt', ubt) From 0e78ca499f5ddae417634955a1e72236b647f2c5 Mon Sep 17 00:00:00 2001 From: warman Date: Sun, 4 May 2025 17:09:53 -0400 Subject: [PATCH 3/4] fix: add game profile to pkg --- src/commands/pkg.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/commands/pkg.ts b/src/commands/pkg.ts index 5f8cb32..2a78301 100644 --- a/src/commands/pkg.ts +++ b/src/commands/pkg.ts @@ -1,6 +1,7 @@ +import * as path from '@std/path' import { Command, EnumType, ValidationError } from '@cliffy/command' import { createEngine, Engine, EngineConfiguration, EnginePlatform, EngineTarget } from '../lib/engine.ts' -import { findProjectFile } from '../lib/utils.ts' +import { findProjectFile, getProjectName } from '../lib/utils.ts' import { Config } from '../lib/config.ts' import type { GlobalOptions } from '../lib/types.ts' @@ -30,6 +31,11 @@ const clientBCRArgs = [ ...defaultBCRArgs, ] +const gameBCRArgs = [ + '-game', + ...defaultBCRArgs, +] + const serverBCRArgs = [ '-server', '-noclient', @@ -38,9 +44,12 @@ const serverBCRArgs = [ const profiles = { 'client': clientBCRArgs, + 'game': gameBCRArgs, 'server': serverBCRArgs, } +const profileNameMap = { client: 'Client', game: 'Game', server: 'Server' } + export type PkgOptions = typeof pkg extends Command ? Options : never @@ -52,7 +61,7 @@ export const pkg = new Command() .option('-c, --configuration ', 'Configuration', { default: EngineConfiguration.Development, }) - .option('-a, --archive-directory ', 'Path to archive directory') + .option('-a, --archive-directory ', 'Path to archive directory', { default: Deno.cwd() }) .option('-z, --zip', 'Should we zip the archive') .option('-d, --dry-run', 'Dry run') .option('--profile ', 'Build profile', { default: 'client', required: true }) @@ -69,6 +78,8 @@ export const pkg = new Command() const engine = createEngine(enginePath) const projectFile = await findProjectFile(projectPath).catch(() => null) + const projectName = await getProjectName(projectPath) + if (projectFile) { bcrArgs.push(`-project=${projectFile}`) } else { @@ -81,6 +92,9 @@ export const pkg = new Command() if (profile === 'client') { bcrArgs.push(`-clientconfig=${configuration}`) } + if (profile === 'game') { + bcrArgs.push(`-gameconfig=${configuration}`) + } if (archiveDirectory) { bcrArgs.push('-archive') bcrArgs.push(`-archiveDirectory=${archiveDirectory}`) @@ -99,11 +113,11 @@ export const pkg = new Command() // Reverse the EnginePlatform enum to get the build output platform name, ie Win64 => Windows const platformName = Object.keys(EnginePlatform)[Object.values(EnginePlatform).indexOf(platform as EnginePlatform)] - const profileName = profile === 'client' ? 'Client' : 'Server' - const expectedArchivePath = `${archiveDirectory}\\${platformName}${profileName}` + const profileName = profileNameMap[profile as keyof typeof profileNameMap] || '' + const archivePath = path.join(archiveDirectory, `${projectName}-${profileName}-${platformName}`) const zipArgs = [ - `-add=${expectedArchivePath}`, - `-archive=${expectedArchivePath}.zip`, + `-add=${archivePath}`, + `-archive=${archivePath}.zip`, '-compression=5', ] await engine.runUAT(['ZipUtils', ...zipArgs]) From 6055c057f9744868531dea28aec8d282cb951a47 Mon Sep 17 00:00:00 2001 From: warman Date: Sun, 4 May 2025 17:11:30 -0400 Subject: [PATCH 4/4] chore: add .vscode settings --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b943dbc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} \ No newline at end of file