Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore linting #43

Closed
wants to merge 1 commit into from
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
37 changes: 36 additions & 1 deletion deno.lock

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

8 changes: 3 additions & 5 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { Command, EnumType, ValidationError } from '../deps.ts'
import { createEngine, Engine, EngineConfiguration, EnginePlatform, EngineTarget } from '../lib/engine.ts'
import { findProjectFile, getProjectName } from '../lib/utils.ts'
import { config } from '../lib/config.ts'
import { CliOptions, GlobalOptions } from '../lib/types.ts'
import type { CliOptions, GlobalOptions } from '../lib/types.ts'

const TargetError = (target: string, targets: string[]) => {
return new ValidationError(`Invalid Target: ${target}
Valid Targets: ${targets.join(', ')}
`)
}
export type BuildOptions = typeof build extends Command<any, any, infer Options, any, any> ? Options
: never

export const build = new Command<GlobalOptions>()
.description('build')
Expand All @@ -23,8 +21,8 @@ export const build = new Command<GlobalOptions>()
})
.option('-d, --dry-run', 'Dry run')
.arguments('<target:string>')
.action(async (options: unknown, target = EngineTarget.Editor) => {
const { platform, configuration, dryRun } = options as BuildOptions
.action(async (options, target = EngineTarget.Editor) => {
const { platform, configuration, dryRun } = options
const { engine: { path: enginePath }, project: { path: projectPath } } = config.get(options as CliOptions)

const engine = createEngine(enginePath)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/buildgraph/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '../../deps.ts'
import { GlobalOptions } from '../../lib/types.ts'
import type { GlobalOptions } from '../../lib/types.ts'

import { run } from './run.ts'

Expand Down
6 changes: 2 additions & 4 deletions src/commands/buildgraph/run.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { cmd } from '../../cmd.ts'
import { Command, path, readNdjson } from '../../deps.ts'
import { config } from '../../lib/config.ts'
import { CliOptions, GlobalOptions } from '../../lib/types.ts'
import { createEngine } from '../../lib/engine.ts'

export type RunOptions = typeof run extends Command<any, any, infer Options, any, any> ? Options
: never
import type { CliOptions, GlobalOptions } from '../../lib/types.ts'

interface AutomationToolLogs {
time: string
Expand Down
1 change: 1 addition & 0 deletions src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Engine } from '../lib/engine.ts'
import { Command } from '../deps.ts'

export const clean = new Command()
.description('Clean')
.option('--dry-run', 'Dry run', { default: false })
.action(async (options) => {
await Engine.runClean(options)
Expand Down
10 changes: 4 additions & 6 deletions src/commands/debug/debug-config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { cmd } from '../../cmd.ts'
import { Command } from '../../deps.ts'
import { config } from '../../lib/config.ts'
import { CliOptions, GlobalOptions } from '../../lib/types.ts'

export type DebugConfigOptions = typeof debugConfig extends Command<any, any, infer Options, any, any> ? Options
: never
import type { CliOptions, GlobalOptions } from '../../lib/types.ts'

export const debugConfig = new Command<GlobalOptions>()
.option('-r, --render', 'Render the config with substitutions')
.description('debug config')
.option('-r, --render', 'Render the config with substitutions')
.action((options) => {
const { render } = options as DebugConfigOptions & GlobalOptions
const { render } = options
const cfg = config.get(options as CliOptions)

if (render) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '../../deps.ts'
import { GlobalOptions } from '../../lib/types.ts'
import type { GlobalOptions } from '../../lib/types.ts'

import { debugConfig } from './debug-config.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/commands/engine/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Command } from '../../deps.ts'

import { GlobalOptions } from '../../lib/types.ts'
import { install } from './install.ts'
import { update } from './update.ts'
import { setup } from './setup.ts'
import { version } from './version.ts'
import type { GlobalOptions } from '../../lib/types.ts'

export const engine = new Command<GlobalOptions>()
.description('engine')
Expand Down
29 changes: 14 additions & 15 deletions src/commands/engine/install.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Command, ValidationError } from '../../deps.ts'
import { cloneRepo, runEngineSetup } from '../../lib/utils.ts'
import { CliOptions } from '../../lib/types.ts'
import type { CliOptions } from '../../lib/types.ts'
import { config } from '../../lib/config.ts'

export type InstallOptions = typeof install extends Command<any, any, infer Options, any, any> ? Options
: never
import { cmd } from '../../cmd.ts'

export const install = new Command()
.description('install engine from a source repository')
Expand Down Expand Up @@ -38,36 +36,37 @@ export const install = new Command()
force,
dryRun,
setup,
} = options as InstallOptions
} = options
const cfg = config.get(options as CliOptions)
source = source || cfg.engine.gitSource
destination = destination || cfg.engine.path

if (!source) {
const newSource = source || cfg.engine.gitSource
const newDestination = destination || cfg.engine.path

if (!newSource) {
throw new ValidationError('missing source')
}
if (!destination) {
if (!newDestination) {
throw new ValidationError('missing destination')
}
try {
await Deno.mkdir(destination)
await Deno.mkdir(newDestination)
} catch (e) {
if (e instanceof Deno.errors.AlreadyExists) {
if (force && !dryRun) {
console.log(`Deleting ${destination}`)
await Deno.remove(destination, { recursive: true })
console.log(`Deleting ${newDestination}`)
await Deno.remove(newDestination, { recursive: true })
} else {
// Exit with a message instead of error so we can chain this install command
console.log(
`Destination ${destination} already exists, use --force to overwrite.`,
`Destination ${newDestination} already exists, use --force to overwrite.`,
)
return
}
}
}
const clonedPath = await cloneRepo({
source,
destination,
source: newSource,
destination: newDestination,
branch,
useMirror: false,
dryRun,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/engine/setup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from '../../deps.ts'
import { config } from '../../lib/config.ts'
import { CliOptions, GlobalOptions } from '../../lib/types.ts'
import type { CliOptions, GlobalOptions } from '../../lib/types.ts'
import { runEngineSetup } from '../../lib/utils.ts'

export type SetupOptions = typeof setup extends Command<any, any, infer Options, any, any> ? Options
export type SetupOptions = typeof setup extends Command<void, void, infer Options, [string, string?], void> ? Options
: never

export const setup = new Command<GlobalOptions>()
export const setup = new Command()
.description('run a managed engine setup')
.option('-s, --gitdepends', 'install git dependencies (ie Setup.bat)')
.option(
Expand Down
9 changes: 3 additions & 6 deletions src/commands/engine/update.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Command, ValidationError } from '../../deps.ts'
import { deleteEngineHooks, exec, isGitRepo, runEngineSetup } from '../../lib/utils.ts'
import { config } from '../../lib/config.ts'
import { CliOptions, GlobalOptions } from '../../lib/types.ts'
import type { CliOptions, GlobalOptions } from '../../lib/types.ts'

export type UpdateOptions = typeof update extends Command<any, any, infer Options, any, any> ? Options
: never

export const update = new Command<GlobalOptions>()
export const update = new Command()
.description('update engine to a specific checkout')
.env(
'RUNREAL_GIT_CLEAN_FLAGS=<flags:string>',
Expand Down Expand Up @@ -38,7 +35,7 @@ export const update = new Command<GlobalOptions>()
setup,
gitCleanFlags,
dryRun,
} = options as UpdateOptions
} = options
const cfg = config.get(options as CliOptions)
const isRepo = await isGitRepo(cfg.engine.path)
if (!isRepo) {
Expand Down
6 changes: 2 additions & 4 deletions src/commands/engine/version.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Command } from '../../deps.ts'
import { config } from '../../lib/config.ts'
import { CliOptions, GlobalOptions } from '../../lib/types.ts'
import type { GlobalOptions, CliOptions } from '../../lib/types.ts'
import { createEngine } from '../../lib/engine.ts'
import { logger } from '../../lib/logger.ts'

export type VersionOptions = typeof version extends Command<any, any, infer Options, any, any> ? Options
: never
import { cmd } from '../../cmd.ts'

export const version = new Command<GlobalOptions>()
.description('print the engine version')
Expand Down
4 changes: 0 additions & 4 deletions src/commands/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { Command } from '../deps.ts'
import { createEngine, Engine } from '../lib/engine.ts'
import { exec, findProjectFile } from '../lib/utils.ts'

export type GenOptions = typeof gen extends Command<void, void, infer Options extends Record<string, unknown>, [], void>
? Options
: never

export const gen = new Command()
.description('generate')
.option('-p, --project-path <project-path:file>', 'Path to project folder', {
Expand Down
6 changes: 2 additions & 4 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { cmd } from '../cmd.ts'
import { Command, ValidationError } from '../deps.ts'
import { createEngine } from '../lib/engine.ts'
import { GlobalOptions } from '../lib/types.ts'
import type { GlobalOptions } from '../lib/types.ts'
import { findProjectFile, getProjectName, writeConfigFile } from '../lib/utils.ts'

export type InitOptions = typeof init extends Command<any, any, infer Options, any, any> ? Options
: never

export const init = new Command<GlobalOptions>()
.description('init')
.action(async ({ projectPath, enginePath }) => {
Expand Down
15 changes: 6 additions & 9 deletions src/commands/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command, EnumType, ValidationError } from '../deps.ts'
import { createEngine, Engine, EngineConfiguration, EnginePlatform, EngineTarget } from '../lib/engine.ts'
import { findProjectFile } from '../lib/utils.ts'
import { config } from '../lib/config.ts'
import { CliOptions, GlobalOptions } from '../lib/types.ts'
import type { CliOptions, GlobalOptions } from '../lib/types.ts'

const defaultBCRArgs = [
'-build',
Expand Down Expand Up @@ -41,9 +41,6 @@ const profiles = {
'server': serverBCRArgs,
}

export type PkgOptions = typeof pkg extends Command<any, any, infer Options, any, any> ? Options
: never

export const pkg = new Command<GlobalOptions>()
.description('package')
.type('Configuration', new EnumType(EngineConfiguration))
Expand All @@ -57,7 +54,7 @@ export const pkg = new Command<GlobalOptions>()
.option('-d, --dry-run', 'Dry run')
.option('--profile <profile:string>', 'Build profile', { default: 'client', required: true })
.action(async (options) => {
const { platform, configuration, dryRun, profile, archiveDirectory, zip } = options as PkgOptions
const { platform, configuration, dryRun, profile, archiveDirectory, zip } = options
const { engine: { path: enginePath }, project: { path: projectPath } } = config.get(options as CliOptions)

const literal = pkg.getLiteralArgs().map((arg) => arg.toLowerCase())
Expand All @@ -79,13 +76,13 @@ export const pkg = new Command<GlobalOptions>()
bcrArgs.push(`-clientconfig=${configuration}`)
}
if (archiveDirectory) {
bcrArgs.push(`-archive`)
bcrArgs.push('-archive')
bcrArgs.push(`-archiveDirectory=${archiveDirectory}`)
bcrArgs.push(`-archivemetadata`)
bcrArgs.push('-archivemetadata')
}
if (dryRun) {
console.log(`[package] package ${profile} ${configuration} ${platform}`)
console.log(`[package] BCR args:`)
console.log('[package] BCR args:')
console.log(bcrArgs)
return
}
Expand All @@ -101,7 +98,7 @@ export const pkg = new Command<GlobalOptions>()
const zipArgs = [
`-add=${expectedArchivePath}`,
`-archive=${expectedArchivePath}.zip`,
`-compression=5`,
'-compression=5',
]
await engine.runUAT(['ZipUtils', ...zipArgs])
}
Expand Down
5 changes: 1 addition & 4 deletions src/commands/uat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { Command } from '../deps.ts'
import { createEngine, EngineConfiguration, EnginePlatform, EngineTarget } from '../lib/engine.ts'
import { findProjectFile } from '../lib/utils.ts'
import { config } from '../lib/config.ts'
import { CliOptions, GlobalOptions } from '../lib/types.ts'

export type UatOptions = typeof uat extends Command<any, any, infer Options, any, any> ? Options
: never
import type { CliOptions, GlobalOptions } from '../lib/types.ts'

export const uat = new Command<GlobalOptions>()
.description('uat')
Expand Down
8 changes: 3 additions & 5 deletions src/commands/ubt.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Command } from '../deps.ts'
import { createEngine, EngineConfiguration, EnginePlatform, EngineTarget } from '../lib/engine.ts'
import { createEngine } from '../lib/engine.ts'
import { findProjectFile } from '../lib/utils.ts'
import { config } from '../lib/config.ts'
import { CliOptions, GlobalOptions } from '../lib/types.ts'

export type UbtOptions = typeof ubt extends Command<any, any, infer Options, any, any> ? Options
: never
import type { CliOptions, GlobalOptions } from '../lib/types.ts'
import { cmd } from '../cmd.ts'

export const ubt = new Command<GlobalOptions>()
.description('ubt')
Expand Down
Loading