content: add approved public portfolio projection

This commit is contained in:
2026-09-02 01:00:36 +03:00
parent 6428b5dcd6
commit 49a4f75c8d
11 changed files with 460 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
import { lstat, mkdir, readFile, readdir } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const manifestPath = resolve(repositoryRoot, 'content/public/asset-manifest.json');
const preparedAssetsPath = resolve(repositoryRoot, 'inputs/prepared-assets');
const readEmptyManifest = async () => {
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
if (Object.keys(manifest).length !== 1 || !Array.isArray(manifest.assets) || manifest.assets.length !== 0) {
throw new Error('Phase 1 asset manifest must contain exactly zero assets.');
}
};
const ensureEmptyPreparedAssetDirectory = async () => {
try {
const stats = await lstat(preparedAssetsPath);
if (stats.isSymbolicLink() || !stats.isDirectory()) {
throw new Error('Prepared asset path must be a non-symlink directory.');
}
} catch (error) {
if ((error).code !== 'ENOENT') throw error;
await mkdir(preparedAssetsPath, { recursive: true });
}
if ((await readdir(preparedAssetsPath)).length !== 0) {
throw new Error('Prepared asset directory must be empty during Phase 1.');
}
};
await readEmptyManifest();
await ensureEmptyPreparedAssetDirectory();