diff --git a/build.mjs b/build.mjs index b45245e..72c5e53 100644 --- a/build.mjs +++ b/build.mjs @@ -8,7 +8,8 @@ const __dirname = path.dirname(__filename); const DIST_DIR = path.join(__dirname, 'dist'); const LANDING_SRC = path.join(__dirname, 'landing'); const DASHBOARD_SRC = path.join(__dirname, 'dashboard'); -const DOCS_SRC = path.join(__dirname, 'src', 'docs'); +const DOCS_SRC = path.join(__dirname, 'docs'); +const TORCH_MD_SRC = path.join(__dirname, 'TORCH.md'); const CONSTANTS_SRC = path.join(__dirname, 'src', 'constants.mjs'); const PROMPTS_SRC = path.join(__dirname, 'src', 'prompts', 'META_PROMPTS.md'); const CONFIG_SRC = path.join(__dirname, 'torch-config.json'); @@ -38,10 +39,15 @@ const distDashboard = path.join(DIST_DIR, 'dashboard'); fs.mkdirSync(distDashboard, { recursive: true }); fs.cpSync(DASHBOARD_SRC, distDashboard, { recursive: true }); -// 3. Copy src/docs/ -> dist/src/docs/ +// 3. Copy docs/ -> dist/src/docs/ const distDocs = path.join(DIST_DIR, 'src', 'docs'); fs.mkdirSync(distDocs, { recursive: true }); -fs.cpSync(DOCS_SRC, distDocs, { recursive: true }); +if (fs.existsSync(DOCS_SRC)) { + fs.cpSync(DOCS_SRC, distDocs, { recursive: true }); +} +if (fs.existsSync(TORCH_MD_SRC)) { + fs.copyFileSync(TORCH_MD_SRC, path.join(distDocs, 'TORCH.md')); +} // 3.5. Copy src/constants.mjs -> dist/src/constants.mjs fs.copyFileSync(CONSTANTS_SRC, path.join(DIST_DIR, 'src', 'constants.mjs')); diff --git a/test/build_verification.test.mjs b/test/build_verification.test.mjs new file mode 100644 index 0000000..6a90043 --- /dev/null +++ b/test/build_verification.test.mjs @@ -0,0 +1,34 @@ +import fs from 'fs'; +import path from 'path'; +import { test } from 'node:test'; +import assert from 'node:assert'; + +const DIST_DIR = path.resolve('dist'); + +test('Build artifacts verification', async (t) => { + await t.test('dist directory exists', () => { + assert.strictEqual(fs.existsSync(DIST_DIR), true, 'dist directory should exist'); + }); + + await t.test('Critical files exist in dist', () => { + const criticalFiles = [ + 'index.html', + 'dashboard/index.html', + 'src/docs/TORCH.md', + 'assets/logo.svg', + 'src/constants.mjs', + 'src/prompts/META_PROMPTS.md' + ]; + + criticalFiles.forEach(file => { + const filePath = path.join(DIST_DIR, file); + assert.strictEqual(fs.existsSync(filePath), true, `File ${file} should exist in dist`); + }); + }); + + await t.test('TORCH.md content is not empty', () => { + const torchMdPath = path.join(DIST_DIR, 'src/docs/TORCH.md'); + const content = fs.readFileSync(torchMdPath, 'utf8'); + assert.ok(content.length > 0, 'TORCH.md should not be empty'); + }); +});