Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
5 changes: 2 additions & 3 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void, void, infer Options, infer Argument, GlobalOptions>
? Options
: never
Expand Down
47 changes: 47 additions & 0 deletions src/commands/list-targets.ts
Original file line number Diff line number Diff line change
@@ -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<void, void, infer Options, infer Argument, GlobalOptions> ? Options
: never

const logTargets = (targets: string[]) => {
return targets.map((target) => {
console.log(target)
})
}

export const listTargets = new Command<GlobalOptions>()
.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)
})
26 changes: 20 additions & 6 deletions src/commands/pkg.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -30,6 +31,11 @@ const clientBCRArgs = [
...defaultBCRArgs,
]

const gameBCRArgs = [
'-game',
...defaultBCRArgs,
]

const serverBCRArgs = [
'-server',
'-noclient',
Expand All @@ -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<void, void, infer Options, [], GlobalOptions> ? Options
: never

Expand All @@ -52,7 +61,7 @@ export const pkg = new Command<GlobalOptions>()
.option('-c, --configuration <configuration:Configuration>', 'Configuration', {
default: EngineConfiguration.Development,
})
.option('-a, --archive-directory <path:file>', 'Path to archive directory')
.option('-a, --archive-directory <path:file>', 'Path to archive directory', { default: Deno.cwd() })
.option('-z, --zip', 'Should we zip the archive')
.option('-d, --dry-run', 'Dry run')
.option('--profile <profile:string>', 'Build profile', { default: 'client', required: true })
Expand All @@ -69,6 +78,8 @@ export const pkg = new Command<GlobalOptions>()

const engine = createEngine(enginePath)
const projectFile = await findProjectFile(projectPath).catch(() => null)
const projectName = await getProjectName(projectPath)

if (projectFile) {
bcrArgs.push(`-project=${projectFile}`)
} else {
Expand All @@ -81,6 +92,9 @@ export const pkg = new Command<GlobalOptions>()
if (profile === 'client') {
bcrArgs.push(`-clientconfig=${configuration}`)
}
if (profile === 'game') {
bcrArgs.push(`-gameconfig=${configuration}`)
}
if (archiveDirectory) {
bcrArgs.push('-archive')
bcrArgs.push(`-archiveDirectory=${archiveDirectory}`)
Expand All @@ -99,11 +113,11 @@ export const pkg = new Command<GlobalOptions>()
// 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])
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/lib/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down