Skip to content
Merged
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
7 changes: 5 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install Playwright
run: npx playwright install --with-deps
- name: Install Typst
run: |
curl -sL https://github.com/typst/typst/releases/download/v0.14.2/typst-x86_64-unknown-linux-musl.tar.xz \
| tar -xJ -C "$HOME/.local/bin" --strip-components=1 typst-x86_64-unknown-linux-musl/typst
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build all branches
run: npm run build:all-branches
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/build-pdf-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install Playwright
run: npx playwright install --with-deps
- name: Install Typst
run: |
curl -sL https://github.com/typst/typst/releases/download/v0.14.2/typst-x86_64-unknown-linux-musl.tar.xz \
| tar -xJ -C "$HOME/.local/bin" --strip-components=1 typst-x86_64-unknown-linux-musl/typst
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build PDFs
run: npm run build:pdf
env:
NODE_ENV: production
HIDE_ONLINE_CV_LINK: 'true'
FORCE_FLAT_PDF_OUTPUT: 'true'
run: npm run build:pdf:typst

- name: Commit generated PDFs
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ index.html
*.min.css
*.min.js

# Typst — preprocessed data (generated from locales/*.yml)
typst/data-*.json

# Legacy (to be removed after migration)
exports
export
Expand Down
6 changes: 0 additions & 6 deletions build-all-branches.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ async function buildBranch(branchName, branchConfig) {
console.log(`\n📦 Installing dependencies...`);
exec('npm ci', { cwd: worktreePath });

// Install Playwright in CI
if (isCI()) {
console.log(`\n🎭 Installing Playwright browsers...`);
exec('npx playwright install --with-deps', { cwd: worktreePath });
}

// Build in worktree
console.log(`\n🔨 Building...`);
const outputPath = branchConfig.outputPath;
Expand Down
181 changes: 181 additions & 0 deletions build-pdf-typst.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/**
* =============================================================================
* BUILD PDF — TYPST PIPELINE
* =============================================================================
*
* Generates all CV PDF variants via Typst:
* - fr × dark / light
* - en × dark / light
*
* Steps:
* 1. Run typst/preprocess.js for each locale → typst/data-{locale}.json
* 2. Call `typst compile` for each (locale × theme) combination
* 3. Output to dist/pdf/
*
* Usage:
* node build-pdf-typst.js
* node build-pdf-typst.js --locale fr --theme dark (single variant)
* node build-pdf-typst.js --locale fr (both themes for fr)
*
* Requirements:
* typst binary available on PATH (or at ~/.local/bin/typst)
*/

'use strict';

const { execFileSync, spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');

// ─── Config ───────────────────────────────────────────────────────────────────

const ROOT = __dirname;
const TYPST_DIR = path.join(ROOT, 'typst');
const FONT_DIR = path.join(ROOT, 'fonts', 'Inter', 'extras', 'otf');
// OUTPUT_DIR env var allows build.js / CI to redirect output (e.g. dist/pdf/short)
// Always resolve to absolute path — Typst runs with cwd=typst/ so relative paths break
const OUT_DIR = path.resolve(process.env.OUTPUT_DIR || path.join(ROOT, 'dist', 'pdf'));
const TEMPLATE = path.join(TYPST_DIR, 'cv.typ');
const CV_URL = 'https://etiennelescot.github.io/cv/';

const LOCALES = ['fr', 'en'];
const THEMES = ['dark', 'light'];

// ─── Argument parsing ─────────────────────────────────────────────────────────

const args = process.argv.slice(2);

function getArg(flag) {
const idx = args.indexOf(flag);
return idx > -1 ? args[idx + 1] : null;
}

const filterLocale = getArg('--locale');
const filterTheme = getArg('--theme');

const locales = filterLocale ? [filterLocale] : LOCALES;
const themes = filterTheme ? [filterTheme] : THEMES;

// ─── Find typst binary ────────────────────────────────────────────────────────

function findTypst() {
const candidates = [
'typst', // on PATH
path.join(process.env.HOME || '', '.local', 'bin', 'typst'),
'/usr/local/bin/typst',
'/usr/bin/typst',
];
for (const bin of candidates) {
const result = spawnSync(bin, ['--version'], { encoding: 'utf8' });
if (result.status === 0) {
console.log(`[typst] Found: ${bin} (${result.stdout.trim()})`);
return bin;
}
}
throw new Error(
'typst binary not found.\n' +
'Install it from https://github.com/typst/typst/releases\n' +
'or run: curl -sL https://github.com/typst/typst/releases/download/v0.14.2/typst-x86_64-unknown-linux-musl.tar.xz | tar -xJ -C ~/.local/bin --strip-components=1'
);
}

// ─── Preprocess ───────────────────────────────────────────────────────────────

function preprocess(locale) {
const script = path.join(TYPST_DIR, 'preprocess.js');
console.log(`[preprocess] ${locale} ...`);
execFileSync(process.execPath, [script, locale], {
cwd : ROOT,
stdio : 'inherit',
});
}

// ─── Compile ──────────────────────────────────────────────────────────────────

function compile(typstBin, locale, theme) {
fs.mkdirSync(OUT_DIR, { recursive: true });
const outFile = path.join(OUT_DIR, `cv-${locale}-${theme}.pdf`);
console.log(`[typst] Compiling cv-${locale}-${theme}.pdf ...`);

const t0 = Date.now();
const result = spawnSync(
typstBin,
[
'compile',
'--font-path', FONT_DIR,
'--input', `locale=${locale}`,
'--input', `theme=${theme}`,
'--input', `cv-url=${CV_URL}`,
TEMPLATE,
outFile,
],
{
cwd : TYPST_DIR,
encoding: 'utf8',
stdio : ['ignore', 'pipe', 'pipe'],
}
);

if (result.status !== 0) {
const errMsg = (result.stderr || result.stdout || '').trim();
throw new Error(`Typst compilation failed for ${locale}-${theme}:\n${errMsg}`);
}

const elapsed = Date.now() - t0;
const size = Math.round(fs.statSync(outFile).size / 1024);
console.log(`[typst] ✓ cv-${locale}-${theme}.pdf (${size} KB, ${elapsed}ms)`);
return outFile;
}

// ─── Main ─────────────────────────────────────────────────────────────────────

async function main() {
console.log('\n══════════════════════════════════════════');
console.log(' CV PDF Generator — Typst');
console.log('══════════════════════════════════════════\n');

// Find typst binary
const typstBin = findTypst();

// Preprocess each needed locale (deduplicated)
const preprocessedLocales = new Set();
for (const locale of locales) {
if (!preprocessedLocales.has(locale)) {
preprocess(locale);
preprocessedLocales.add(locale);
}
}

console.log();

// Compile each (locale × theme) variant
const generated = [];
const errors = [];

for (const locale of locales) {
for (const theme of themes) {
try {
const file = compile(typstBin, locale, theme);
generated.push(file);
} catch (err) {
errors.push({ locale, theme, err });
console.error(`[error] ${err.message}`);
}
}
}

console.log('\n──────────────────────────────────────────');
console.log(`Generated: ${generated.length} PDF(s)`);
if (errors.length) {
console.error(`Failed: ${errors.length} variant(s)`);
process.exitCode = 1;
} else {
console.log('All variants generated successfully.');
}
console.log('──────────────────────────────────────────\n');
}

main().catch(err => {
console.error('\n[fatal]', err.message);
process.exit(1);
});
33 changes: 23 additions & 10 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,29 @@ async function build() {
if (!webOnly) {
console.log('\n📄 Building PDFs...\n');

execSync('node generate-pdf.js --all --vector', {
stdio: 'inherit',
env: {
...process.env,
HTML_DIR: webOutputDir,
OUTPUT_DIR: pdfOutputDir,
BASE_PATH: basePath,
BRANCH_NAME: currentBranch
}
});
// Use Typst pipeline if available, fall back to Puppeteer otherwise
const typstBuildScript = path.join(__dirname, 'build-pdf-typst.js');
if (fs.existsSync(typstBuildScript)) {
execSync(`node ${typstBuildScript}`, {
stdio: 'inherit',
env: {
...process.env,
OUTPUT_DIR: pdfOutputDir,
}
});
} else {
// Legacy fallback
execSync('node generate-pdf.js --all --vector', {
stdio: 'inherit',
env: {
...process.env,
HTML_DIR: webOutputDir,
OUTPUT_DIR: pdfOutputDir,
BASE_PATH: basePath,
BRANCH_NAME: currentBranch
}
});
}

// Copy PDFs to web directory for GitHub Pages serving
const webPdfDir = path.join(webOutputDir, 'pdf');
Expand Down
Binary file modified dist/pdf/cv-en-dark.pdf
Binary file not shown.
Binary file modified dist/pdf/cv-en-light.pdf
Binary file not shown.
Binary file modified dist/pdf/cv-fr-dark.pdf
Binary file not shown.
Binary file added dist/pdf/cv-fr-light.pdf
Binary file not shown.
Binary file removed dist/pdf/cv-fr.pdf
Binary file not shown.
Binary file removed dist/pdf/short/cv-en-dark.pdf
Binary file not shown.
Binary file removed dist/pdf/short/cv-en-light.pdf
Binary file not shown.
Binary file removed dist/pdf/short/cv-fr-dark.pdf
Binary file not shown.
Binary file removed dist/pdf/short/cv-fr-light.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ exp-fractional-opensource-stimm: |
exp-fractional-opensource-stimm-stack: |
Stack: Voice AI, WebRTC, real‑time processing
exp-fractional-opensource-stimm-link: |
github.com/stimm-ai/stimm
https://github.com/stimm-ai/stimm
exp-fractional-opensource-n8n-title: |
n8n‑as‑code
exp-fractional-opensource-n8n: |
Bidirectional n8n - VS Code synchronization. AI‑driven workflow generation and GitOps. Stop clicking, start coding.
exp-fractional-opensource-n8n-stack: |
Stack: n8n, VS Code extension, AI workflow generation
exp-fractional-opensource-n8n-link: |
github.com/EtienneLescot/n8n-as-code
https://github.com/EtienneLescot/n8n-as-code
exp-fractional-missions-heading: |
CTO & Co‑founding Missions
exp1-title: |
Expand Down
4 changes: 2 additions & 2 deletions locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ exp-fractional-opensource-stimm: |
exp-fractional-opensource-stimm-stack: |
Stack : Voice AI, WebRTC, real-time processing
exp-fractional-opensource-stimm-link: |
github.com/stimm-ai/stimm
https://github.com/stimm-ai/stimm
exp-fractional-opensource-n8n-title: |
n8n-as-code
exp-fractional-opensource-n8n: |
Synchronisation bidirectionnelle n8n - VS Code. Génération de workflows via IA et GitOps. Stop clicking, start coding.
exp-fractional-opensource-n8n-stack: |
Stack : n8n, VS Code extension, AI workflow generation
exp-fractional-opensource-n8n-link: |
github.com/EtienneLescot/n8n-as-code
https://github.com/EtienneLescot/n8n-as-code
exp-fractional-missions-heading: |
Missions CTO & Cofondations
exp1-title: |
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"build:web": "node build.js --web-only",
"build:pdf": "node build.js --pdf-only",
"build:all-branches": "node build-all-branches.js",
"build:pdf:typst": "node build-pdf-typst.js",
"build:pdf:typst:fr": "node build-pdf-typst.js --locale fr",
"build:pdf:typst:en": "node build-pdf-typst.js --locale en",
"clean": "node scripts/clean.js",
"clean:web": "node scripts/clean.js --web",
"clean:pdf": "node scripts/clean.js --pdf",
Expand Down
Loading
Loading