diff --git a/deno.jsonc b/deno.jsonc index 1893a42..3613a64 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -36,6 +36,7 @@ "@std/jsonc": "jsr:@std/jsonc@^1.0.1", "@std/path": "jsr:@std/path@^1.0.7", "@std/streams": "jsr:@std/streams@^1.0.7", - "@std/testing": "jsr:@std/testing@^1.0.5" + "@std/testing": "jsr:@std/testing@^1.0.5", + "ueblueprint":"npm:ueblueprint@2.0.0" } } diff --git a/deno.lock b/deno.lock index 46c9cbb..6837bf5 100644 --- a/deno.lock +++ b/deno.lock @@ -65,6 +65,7 @@ "npm:@types/node@*": "22.5.4", "npm:esbuild@0.20.2": "0.20.2", "npm:esbuild@0.24.0": "0.24.0", + "npm:ueblueprint@2.0.0": "2.0.0", "npm:zod-to-json-schema@*": "3.23.5_zod@3.23.8" }, "jsr": { @@ -418,12 +419,24 @@ "@esbuild/win32-x64@0.24.0": { "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==" }, + "@lit-labs/ssr-dom-shim@1.3.0": { + "integrity": "sha512-nQIWonJ6eFAvUUrSlwyHDm/aE8PBDu5kRpL0vHMg6K8fK3Diq1xdPjTnsJSwxABhaZ+5eBi1btQB5ShUTKo4nQ==" + }, + "@lit/reactive-element@1.6.3": { + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "dependencies": [ + "@lit-labs/ssr-dom-shim" + ] + }, "@types/node@22.5.4": { "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", "dependencies": [ "undici-types" ] }, + "@types/trusted-types@2.0.7": { + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + }, "esbuild@0.20.2": { "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", "dependencies": [ @@ -481,6 +494,38 @@ "@esbuild/win32-x64@0.24.0" ] }, + "lit-element@3.3.3": { + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "dependencies": [ + "@lit-labs/ssr-dom-shim", + "@lit/reactive-element", + "lit-html" + ] + }, + "lit-html@2.8.0": { + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "dependencies": [ + "@types/trusted-types" + ] + }, + "lit@2.8.0": { + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "dependencies": [ + "@lit/reactive-element", + "lit-element", + "lit-html" + ] + }, + "parsernostrum@1.2.6": { + "integrity": "sha512-Ho+y3yoqVCHRtqsKVqltsv17MgjP8Np+VIC8nd2cyEAsko5hNiZZpA6mi0krvfv8XmrS+tOpra83d4UctJtmQg==" + }, + "ueblueprint@2.0.0": { + "integrity": "sha512-M9xIAAl7H6pqkkwJ5pyDLiOUkMq7ti75RiD6W20Sp3e+VW1KhQ3M9H9BXyw61qF8hKjD2Y+CYTd260hGFWjJpg==", + "dependencies": [ + "lit", + "parsernostrum" + ] + }, "undici-types@6.19.8": { "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, @@ -680,7 +725,8 @@ "jsr:@std/jsonc@^1.0.1", "jsr:@std/path@^1.0.7", "jsr:@std/streams@^1.0.7", - "jsr:@std/testing@^1.0.5" + "jsr:@std/testing@^1.0.5", + "npm:ueblueprint@2.0.0" ] } } diff --git a/src/commands/asset.ts b/src/commands/asset.ts new file mode 100644 index 0000000..4290727 --- /dev/null +++ b/src/commands/asset.ts @@ -0,0 +1,78 @@ +import { Command } from '../deps.ts' +import type { CliOptions, GlobalOptions } from '../lib/types.ts' + +const url = Deno.env.get('RENDER_URL') || 'http://localhost:8787' + +const blueprint = new Command().description('Visualize your blueprint') + .option( + '-b, --blueprint ', + 'Path to the input file', + { required: true }, + ) + .option('-o, --output ', 'Path to the output in local', { + default: 'index.html', + }) + .option('-l, --local', 'Local export', { default: true }) + .action( + async (options) => { + if (!options.blueprint) { + console.log('Input file path is required') + return + } + const data = Deno.readFileSync(options.blueprint) + const decoder = new TextDecoder('utf-8') + const bluePrint = decoder.decode(data) + if (!options.local) { + // Send bluePrint to the server + + const res = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ blueprint: bluePrint }), + }) + const blob = await res.blob() + + Deno.writeFileSync('result.png', await blob.bytes()) + } else { + const encoder = new TextEncoder() + const html = ` + + + + + UE Blueprint + + + + + + + + + + + + + + ` + + Deno.writeFileSync(options.output, encoder.encode(html)) + } + }, + ) + +export const asset = new Command().description('View uasset').action(function () { + this.showHelp() +}).command('blueprint', blueprint) diff --git a/src/commands/pkg.ts b/src/commands/pkg.ts index fe9e8a9..ca38273 100644 --- a/src/commands/pkg.ts +++ b/src/commands/pkg.ts @@ -58,7 +58,7 @@ export const pkg = new Command() .option('--profile ', 'Build profile', { default: 'client', required: true }) .action(async (options) => { const { platform, configuration, dryRun, profile, archiveDirectory, zip } = options as PkgOptions - const cfg = await Config.getInstance() + const cfg = Config.getInstance() const { engine: { path: enginePath }, project: { path: projectPath } } = cfg.mergeConfigCLIConfig({ cliOptions: options, }) diff --git a/src/commands/script.ts b/src/commands/script.ts index 41a9c7d..642aeca 100644 --- a/src/commands/script.ts +++ b/src/commands/script.ts @@ -4,7 +4,7 @@ import { logger } from '../lib/logger.ts' import * as esbuild from 'https://deno.land/x/esbuild@v0.24.0/mod.js' -import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@0.11.0' +import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@0.11.1' import { Config } from '../lib/config.ts' export const script = new Command() @@ -42,7 +42,7 @@ export const script = new Command() const script = (await import(builtOutput)) as Script await script.main(context) - } catch (e) { + } catch (e: any) { logger.error(e) Deno.exit(1) } diff --git a/src/index.ts b/src/index.ts index 12efa62..5ccb0ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ import { workflow } from './commands/workflow/index.ts' import { clean } from './commands/clean.ts' import { cmd } from './cmd.ts' import { script } from './commands/script.ts' +import { asset } from './commands/asset.ts' await cmd .name('runreal') @@ -31,4 +32,5 @@ await cmd .command('buildgraph', buildgraph) .command('workflow', workflow) .command('script', script) + .command('asset', asset) .parse(Deno.args) diff --git a/src/lib/logger.ts b/src/lib/logger.ts index 45a16c5..36a0bcc 100644 --- a/src/lib/logger.ts +++ b/src/lib/logger.ts @@ -49,10 +49,10 @@ class Logger { this.logLevel = level } - private formatMessage(level: LogLevel, message: any) { + private formatMessage(level: LogLevel, message: string) { const timestamp = new Date().toISOString() const messageStr = typeof message === 'object' ? `\n${Deno.inspect(message, { colors: true })}` : message - let levelStr + let levelStr: string switch (level) { case LogLevel.INFO: levelStr = fmt.bold(fmt.green(level)) @@ -93,21 +93,21 @@ class Logger { return level >= this.logLevel } - info(message: any) { + info(message: string) { if (!this.shouldLog(LogLevel.INFO)) return const formatted = this.formatMessage(LogLevel.INFO, message) console.log(formatted) this.writeToFile(formatted) } - error(message: any) { + error(message: string) { if (!this.shouldLog(LogLevel.ERROR)) return const formatted = this.formatMessage(LogLevel.ERROR, message) console.error(formatted) this.writeToFile(formatted) } - debug(message: any) { + debug(message: string) { if (!this.shouldLog(LogLevel.DEBUG)) return const formatted = this.formatMessage(LogLevel.DEBUG, message) console.log(formatted)