Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env node
/**
* Put a built Programming+ inside a copy of the Quarto extension, so a site renders the rendered views
* ({{< pplus-run >}}, {{< pplus-steps >}}, ...) without a checkout of this repository beside it:
*
* pixi run quarto-engine ../my-site/_extensions/pplus
*
* copies dist/ (without the source maps and the interpreter's test fixture) to <dir>/engine/dist, where pplus.lua
* looks for it after pplus-engine and PPLUS_ENGINE (quarto/README.md). Run it again after rebuilding. The copy is
* the app's compiled JavaScript; the site still needs Node 20 or later on the machine that renders it.
*/
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = fileURLToPath(new URL('..', import.meta.url));
const dir = process.argv[2];
const die = (m) => { console.error(`quarto-engine: ${m}`); process.exit(1); };
if (!dir) die('usage: pixi run quarto-engine <a site\'s _extensions/pplus folder>');
if (!fs.existsSync(path.join(dir, 'pplus.lua'))) die(`${dir} is not the extension's folder (no pplus.lua in it); copy quarto/_extensions/pplus there first`);
const dist = path.join(ROOT, 'dist');
if (!fs.existsSync(path.join(dist, 'quarto', 'render.js'))) die('dist/ is missing; run `pixi run build` first');
const out = path.join(dir, 'engine', 'dist');
fs.rmSync(path.join(dir, 'engine'), { recursive: true, force: true });
let files = 0, bytes = 0;
fs.cpSync(dist, out, {
recursive: true,
filter: (src) => {
const rel = path.relative(dist, src);
if (rel.endsWith('.map') || rel === 'curriculum' || rel.startsWith('curriculum' + path.sep)) return false;
if (fs.statSync(src).isFile()) { files++; bytes += fs.statSync(src).size; }
return true;
},
});
// the extension's own copy of the version, so a page can say which Programming+ rendered it
let version = 'dev';
try { version = fs.readFileSync(path.join(ROOT, '.git', 'HEAD'), 'utf8').trim(); } catch { /* not a checkout */ }
fs.writeFileSync(path.join(dir, 'engine', 'VERSION'), version + '\n');
console.log(`quarto-engine: copied ${files} files (${(bytes / 1e6).toFixed(1)} MB) to ${out}`);