diff --git a/TarninaHub.slnx b/TarninaHub.slnx new file mode 100644 index 0000000..5c442a9 --- /dev/null +++ b/TarninaHub.slnx @@ -0,0 +1,5 @@ + + + + + diff --git a/scripts/build.mjs b/scripts/build.mjs new file mode 100644 index 0000000..138b354 --- /dev/null +++ b/scripts/build.mjs @@ -0,0 +1,20 @@ +import { spawnSync } from 'node:child_process' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..') + +function run(command) { + console.log(`\n> ${command}`) + const result = spawnSync(command, { cwd: root, stdio: 'inherit', shell: true }) + if (result.status !== 0) { + console.error(`\n[build] Command failed: ${command}`) + process.exit(result.status ?? 1) + } +} + +run('npm --prefix client run build') +run('node scripts/copy-client.mjs') +run('dotnet build HubMi.slnx --configuration Release') + +console.log('\n[build] Done.') diff --git a/scripts/copy-client.mjs b/scripts/copy-client.mjs new file mode 100644 index 0000000..7e8cc31 --- /dev/null +++ b/scripts/copy-client.mjs @@ -0,0 +1,18 @@ +import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs' +import { dirname, join, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..') +const source = join(root, 'client', 'dist') +const target = join(root, 'backend', 'wwwroot') + +if (!existsSync(source)) { + console.error(`[copy] Build output not found: ${source}. Run "npm run build" in client first.`) + process.exit(1) +} + +rmSync(target, { recursive: true, force: true }) +mkdirSync(target, { recursive: true }) +cpSync(source, target, { recursive: true }) + +console.log(`[copy] Copied ${source} -> ${target}`)