Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
rigs: optional real-file fixtures come from BENTO_XLSX_FIXTURES; example paths are generic (#530)
nyblnet5372b81bebd3
diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex fae5c223..5d60d870 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -179,7 +179,7 @@ matters. Neither needs the signing key.**Build anywhere; publish from a path under `~/devel`.** The shell picksthe `gh` profile by directory (a chpwd hook), and a job or temp worktree- — `~/.claude-andy/jobs/…/tmp`, `/tmp/rel` — maps to the WORK profile,+ — `/tmp/rel`, a tool’s scratch directory — maps to the WORK profile,which cannot create a release on this repo. `publish-site.mjs` checks theactive `gh` account against the repo owner **before it mirrors anything**and, on a mismatch, prints the exact command to run from `~/devel/bento`diff --git a/home/webext/src/route.js b/home/webext/src/route.jsindex a268847e..a93a624f 100644--- a/home/webext/src/route.js+++ b/home/webext/src/route.js@@ -49,7 +49,7 @@ export function pathFromSender(sender) {* It is checked, not guessed. A wrong split point fails at the first missing* segment, and callers re-verify the file it lands on regardless.*- * A folder name can repeat in a path (`/Users/andy/Decks/Decks/Q3.bento.html`),+ * A folder name can repeat in a path (`/Users/you/Decks/Decks/Q3.bento.html`),* so every split point is tried; the caller decides what more than one hit* means.*/diff --git a/scripts/gh-account.mjs b/scripts/gh-account.mjsindex 2cdda555..af67a83a 100644--- a/scripts/gh-account.mjs+++ b/scripts/gh-account.mjs@@ -8,7 +8,7 @@//// WHY THIS EXISTS. Three releases running, publish-site.mjs mirrored and// pushed the site and THEN `gh release create` failed: the release worktree-// lived under ~/.claude-andy/jobs/…/tmp, where the shell's chpwd hook selects+// lived under a temp directory outside ~/devel, where the shell's chpwd hook selects// the WORK gh profile — a different account, no scope for this repo — and// gh's config follows the environment the script was launched from, not the// repo it is pointed at. Each time the lead created the release by hand fromdiff --git a/scripts/test-dash-xlsx.ts b/scripts/test-dash-xlsx.tsindex 12c122bb..0e05e052 100644--- a/scripts/test-dash-xlsx.ts+++ b/scripts/test-dash-xlsx.ts@@ -572,13 +572,12 @@ ok(_internals.safeSheetName('a/b:c', new Set()) === 'a-b-c', 'the forbidden charok(_internals.safeSheetName('Sheet', new Set(['sheet'])) === 'Sheet 2', 'and a duplicate is disambiguated')ok(xlsxFileName('Q1 / plan') === 'Q1 - plan.xlsx', 'the download name is filesystem-safe')-// =========================================== REAL .xlsx FILES OFF THIS MACHINE+// =========================================== REAL .xlsx FIXTURES (BENTO_XLSX_FIXTURES){- const candidates = [- '/Users/andy/devel/sxadc/raw_categories.xlsx',- '/Users/andy/Documents/Digitalise Growth-Initiatives-Cost-Model.xlsx',- '/Users/andy/Downloads/Digital_Sonar_Resource_Validation_v5.xlsx',- ].filter(existsSync)+ // Optional real workbooks, named by BENTO_XLSX_FIXTURES (path-list, ':'+ // separated). Never a path baked into the source: the rig must read only+ // what is checked in or what the operator points it at.+ const candidates = (process.env.BENTO_XLSX_FIXTURES ?? '').split(':').map((p) => p.trim()).filter((p) => p && existsSync(p))if (!candidates.length) console.log(' SKIP no real .xlsx to import')for (const path of candidates) {const short = path.split('/').pop()!diff --git a/scripts/test-dash-zip.ts b/scripts/test-dash-zip.tsindex 58644885..9a1c25e4 100644--- a/scripts/test-dash-zip.ts+++ b/scripts/test-dash-zip.ts@@ -207,13 +207,12 @@ if (havePython) {console.log(' SKIP python3 is not on this machine — the ZIP64 archives need a second implementation to build')}-// ---------------------------------------------------- REAL .xlsx off this disk+// ---------------------------------------------------- REAL .xlsx FIXTURES (BENTO_XLSX_FIXTURES){- const candidates = [- '/Users/andy/Documents/Digitalise Growth-Initiatives-Cost-Model.xlsx',- '/Users/andy/Downloads/Digital_Sonar_Resource_Validation_v5.xlsx',- '/Users/andy/devel/sxadc/raw_categories.xlsx',- ].filter((p) => existsSync(p))+ // Optional real workbooks, named by BENTO_XLSX_FIXTURES (path-list, ':'+ // separated). Never a path baked into the source: the rig must read only+ // what is checked in or what the operator points it at.+ const candidates = (process.env.BENTO_XLSX_FIXTURES ?? '').split(':').map((p) => p.trim()).filter((p) => p && existsSync(p))if (!candidates.length) {console.log(' SKIP no real .xlsx on this machine to read')diff --git a/scripts/test-publish-account.ts b/scripts/test-publish-account.tsindex 230180ce..4801b1d9 100644--- a/scripts/test-publish-account.ts+++ b/scripts/test-publish-account.ts@@ -28,7 +28,7 @@ ok(ownerOfRemote('https://gitlab.com/x/y') === null && ownerOfRemote('') === nulconsole.log('\nactiveAccount')const NEW = `github.com- ✓ Logged in to github.com account work-andy (keyring)+ ✓ Logged in to github.com account work-account (keyring)- Active account: false- Git operations protocol: https✓ Logged in to github.com account nyblnet (keyring)@@ -41,21 +41,21 @@ const OLD = `github.comok(activeAccount(OLD) === 'nyblnet', 'the older single-account format')ok(activeAccount('You are not logged into any GitHub hosts. Run gh auth login to authenticate.') === null && activeAccount('') === null, 'not logged in → null')const WORK = `github.com- ✓ Logged in to github.com account work-andy (keyring)+ ✓ Logged in to github.com account work-account (keyring)- Active account: true`-ok(activeAccount(WORK) === 'work-andy', 'the work profile reads as the work account')+ok(activeAccount(WORK) === 'work-account', 'the work profile reads as the work account')console.log('\naccountMayRelease')ok(accountMayRelease('nyblnet', 'nyblnet') === true && accountMayRelease('NyblNet', 'nyblnet') === true, 'the owner may, case-insensitively')-ok(accountMayRelease('work-andy', 'nyblnet') === false, 'a mismatched owner is REFUSED (the three failed releases)')+ok(accountMayRelease('work-account', 'nyblnet') === false, 'a mismatched owner is REFUSED (the three failed releases)')ok(accountMayRelease(null, 'nyblnet') === false && accountMayRelease('nyblnet', null) === false, 'nobody may; no owner, nobody may')ok(accountMayRelease('helper', 'nyblnet', ['Helper']) === true && accountMayRelease('other', 'nyblnet', ['helper']) === false, 'a listed collaborator may (BENTO_RELEASE_ACCOUNTS), an unlisted one may not')console.log('\nmismatchMessage')-const msg = mismatchMessage({ account: 'work-andy', owner: 'nyblnet', repoRoot: '/Users/andy/devel/bento', cmd: 'node scripts/publish-site.mjs "release v1.2.3"' })-ok(/authenticated as work-andy/.test(msg) && /needs nyblnet/.test(msg), 'names what gh is and what it must be')+const msg = mismatchMessage({ account: 'work-account', owner: 'nyblnet', repoRoot: '/Users/you/devel/bento', cmd: 'node scripts/publish-site.mjs "release v1.2.3"' })+ok(/authenticated as work-account/.test(msg) && /needs nyblnet/.test(msg), 'names what gh is and what it must be')ok(/Nothing was published/.test(msg), 'says nothing was published')-ok(/cd \/Users\/andy\/devel\/bento && node scripts\/publish-site\.mjs "release v1\.2\.3"/.test(msg), 'gives the exact command from the repo root')+ok(/cd \/Users\/you\/devel\/bento && node scripts\/publish-site\.mjs "release v1\.2\.3"/.test(msg), 'gives the exact command from the repo root')ok(/gh auth switch --user nyblnet/.test(msg), 'and the switch alternative')console.log('\npublish-site.mjs — the gate sits before the mirror')diff --git a/scripts/test-webext-route.ts b/scripts/test-webext-route.tsindex e7c8dbce..7100c608 100644--- a/scripts/test-webext-route.ts+++ b/scripts/test-webext-route.ts@@ -64,15 +64,15 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Use// ---- placing a path ---------------------------------------------------------{const dir = dirHandle('Decks', { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Q3.bento.html']) })- const p = await prefixFor(dir, '/Users/andy/Work/Decks/Q3.bento.html')- ok(p === '/Users/andy/Work/Decks', `a document at the grant root places the folder (${p})`)+ const p = await prefixFor(dir, '/Users/you/Work/Decks/Q3.bento.html')+ ok(p === '/Users/you/Work/Decks', `a document at the grant root places the folder (${p})`)}{const dir = dirHandle('Decks', {Clients: { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Clients', 'Q3.bento.html']) },})- const p = await prefixFor(dir, '/Users/andy/Decks/Clients/Q3.bento.html')- ok(p === '/Users/andy/Decks', `a nested document places the folder, not its subfolder (${p})`)+ const p = await prefixFor(dir, '/Users/you/Decks/Clients/Q3.bento.html')+ ok(p === '/Users/you/Decks', `a nested document places the folder, not its subfolder (${p})`)}{// The grant's name repeating in the path. Both split points are tried, and@@ -80,8 +80,8 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Useconst dir = dirHandle('Decks', {Decks: { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Decks', 'Q3.bento.html']) },})- const p = await prefixFor(dir, '/Users/andy/Decks/Decks/Q3.bento.html')- ok(p === '/Users/andy/Decks', `a repeated folder name resolves to the route that exists (${p})`)+ const p = await prefixFor(dir, '/Users/you/Decks/Decks/Q3.bento.html')+ ok(p === '/Users/you/Decks', `a repeated folder name resolves to the route that exists (${p})`)}// ---- what must be REFUSED ---------------------------------------------------@@ -90,11 +90,11 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Use// document in it opens the wrong file, silently.{const dir = dirHandle('Decks', { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Q3.bento.html']) })- ok(await prefixFor(dir, '/Users/andy/Elsewhere/Q3.bento.html') === null,+ ok(await prefixFor(dir, '/Users/you/Elsewhere/Q3.bento.html') === null,'a path whose folder name does not appear is refused')- ok(await prefixFor(dir, '/Users/andy/Decks/Missing.bento.html') === null,+ ok(await prefixFor(dir, '/Users/you/Decks/Missing.bento.html') === null,'a document that is not in the grant is refused, even under the right folder name')- ok(await prefixFor(dir, '/Users/andy/Decks/Sub/Q3.bento.html') === null,+ ok(await prefixFor(dir, '/Users/you/Decks/Sub/Q3.bento.html') === null,'a route through a directory that does not exist is refused')ok(await prefixFor(dir, '/Q3.bento.html') === null,'a path with no folder segment at all is refused')@@ -108,7 +108,7 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Use})// A history entry for a DIFFERENT Q3 at the grant root — the grant has no such// file, only Clients/Q3, so nothing may be learned from it.- ok(await prefixFor(dir, '/Users/andy/Decks/Q3.bento.html') === null,+ ok(await prefixFor(dir, '/Users/you/Decks/Q3.bento.html') === null,'a same-named file at a different depth teaches nothing — resolve() must agree with the tail')}{@@ -117,7 +117,7 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Useconst orphan: any = fileHandle('Q3.bento.html', ['Q3.bento.html'])orphan.__rel = nullconst dir = dirHandle('Decks', { 'Q3.bento.html': orphan })- ok(await prefixFor(dir, '/Users/andy/Decks/Q3.bento.html') === null,+ ok(await prefixFor(dir, '/Users/you/Decks/Q3.bento.html') === null,'a candidate the grant will not resolve is refused')}@@ -130,7 +130,7 @@ ok(pathFromSender({ url: 'file:///Users/x/My%20Decks/Q3.bento.html' }) === '/Useconst dir: any = dirHandle('home', tree)let enumerated = 0dir.entries = async function* () { enumerated++ }- const hits = await locateIn(dir, '/Users/andy/home/Q3.bento.html')+ const hits = await locateIn(dir, '/Users/you/home/Q3.bento.html')ok(hits.length === 1, 'the route finds the file inside a 500-entry grant')ok(enumerated === 0, `and enumerates nothing to do it (${enumerated} scans)`)}