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
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ handlers close over. Call it once, before the plugin's hooks can fire.
| `file-format-identify` | `graphEntityById` (handed to `matcher.js`'s own `configure(deps)` on each dynamic import, for `getFileHandleAtPath`) |
| `ca-data-prep` | `writeFileAtPath` |
| `merge` | `readJsonFromFolder`, `graphEntityById` |
| `crate2tables` | `readJsonFromFolder`, `writeFileAtPath`, `getFileHandleAtPath`, `readFileTextFromDirectory` |
| `roctable` | `readJsonFromFolder`, `writeFileAtPath`, `getFileHandleAtPath`, `readFileTextFromDirectory`, `loadCrateFromJson` (lets "Configure tables…" inspect the folder's crate without a build running), `openModal` (the table-selection tree, `config-tree-ui.js`) |
| `validate-crate` | `loadMasp` |
| `ro-crate-json-output` | `crateToJsonString`, `writeFile`, `fileExists` |
| `ro-crate-xlsx-output` | `crateToXlsxBytes`, `writeFile`, `fileExists` |
Expand All @@ -67,21 +67,35 @@ function itself, so `ro-crate-masp` (a heavy validator library) stays
dynamically imported from chaos2crate's own tree instead of becoming a
static import anywhere in this package.

`crate2tables` depends on [`roctable`](https://github.com/ptsefton/roctable),
a WIP library not yet on npm — installed as a git dependency pinned to a
The `roctable` plugin (`src/roctable/`) takes its name from the
[`roctable`](https://github.com/ptsefton/roctable) library it wraps — a WIP
The `roctable` plugin (`src/roctable/`) takes its name from the
[`roctable`](https://github.com/ptsefton/roctable) library it wraps — a WIP
library not yet on npm — installed as a git dependency pinned to a
commit (`"roctable": "github:ptsefton/roctable#<sha>"`), since it isn't
tagged/released. Bump the pinned commit deliberately, not by dropping the
pin — an unpinned `github:ptsefton/roctable` would silently pick up whatever
that repo's default branch has on the next `npm install`. It reuses
roctable's own crate-walking functions directly (`ctx.crate` is already an
`ro-crate` `ROCrate` instance, the same shape roctable expects) — including
tagged or released. Bump the pinned commit deliberately, not by dropping
the pin — an unpinned GitHub dependency would silently pick up whatever
the repository's default branch has on the next `npm install`. It reuses
the library's own crate-walking functions directly (`ctx.crate` is already
an `ro-crate` `ROCrate` instance, the same shape it expects) — including
`load_text`, via a `fileReader` this plugin injects
(`browserFileReader` in `src/crate2tables/index.js`, wrapping
`readFileTextFromDirectory`) rather than roctable's own Node-`fs`-based
default (see roctable's `lib/io.js` and its `SPEC.md` §9.0). Its config
load/save and CSV file writing stay this plugin's own job either way —
roctable's `lib/config.js`/`lib/csv.js` file I/O is Node-`fs`-only and simply
isn't called from here; see `chaos2crate/docs/crate2tables-spec.md`.
(`browserFileReader` in `src/roctable/index.js`, wrapping
`readFileTextFromDirectory`) rather than the library's own Node-`fs`-based
default (see its `lib/io.js` and `SPEC.md` §9.0). Its config load/save and
CSV file writing stay this plugin's own job either way — the library's
`lib/config.js`/`lib/csv.js` file I/O is Node-`fs`-only and simply isn't
called from here; see `chaos2crate/docs/roctable-spec.md`.

The plugin is split across three files: `index.js` (the plugin itself —
hooks, the `optionSchema`, the `roctableConfigure` action), `discover.js`
(inspect the crate and merge onto whatever config already exists — the one
code path both the build-time hook and the standalone action call, plus the
`ldac:mainText`/`indexableText` default-seeding rule), and `config-tree-ui.js`
(the checkbox-tree editor `openModal` renders — a table heading per `@type`,
unrolling to its properties' include/expand/load_text/join). Config lives at
`_config/roctable/config.json`, output at `_outputs/roctable/` — chaos2crate
issue #81's proposed per-plugin directory convention, adopted here ahead of
it becoming repo-wide.

## Writing a new plugin here

Expand Down Expand Up @@ -141,6 +155,14 @@ Rules of thumb:
- **No `outputPaths` at all is correct for a plugin that never writes to the
folder** — `merge`, `austlang`, `validate-crate`, and the input-analysis
half of every plugin all fall here; only the writing side declares.
- **A path under `_config/<slug>/` or `_backup/<slug>/` (chaos2crate issue
#81's proposed per-plugin directories) still gets scan-excluded, but
chaos2crate's "Delete plugin output before rebuilding" skips deleting it**
— those two are meant to persist across builds (standing configuration,
changed-file backups), unlike `_outputs/<slug>/`, which is exactly the
disposable generated content that setting exists to clear. `roctable`
is the first plugin here to use this: config at `_config/roctable/`,
CSVs at `_outputs/roctable/`.

Then register it in this repo's `index.js` (`REGISTRY` for an additive
plugin, `INPUT_REGISTRY` for a mutually-exclusive input mode), and in
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { createPlugin as createFileFormatIdentify } from "./src/file-format-iden
import { createPlugin as createCaDataPrep } from "./src/ca-data-prep/index.js";
import { createPlugin as createChatExport } from "./src/chat-export/index.js";
import { createPlugin as createMerge } from "./src/merge/index.js";
import { createPlugin as createRoctable } from "./src/roctable/index.js";
import { createPlugin as createValidateCrate } from "./src/validate-crate/index.js";
import { createPlugin as createJsonOutput } from "./src/ro-crate-json-output/index.js";
import { createPlugin as createXlsxOutput } from "./src/ro-crate-xlsx-output/index.js";
import { createPlugin as createHtmlOutput } from "./src/ro-crate-html-output/index.js";
import { createPlugin as createCrate2Tables } from "./src/crate2tables/index.js";
import { createPlugin as createGenericInput } from "./src/generic-input/index.js";
import { createPlugin as createDocxInput } from "./src/docx-input/index.js";

Expand All @@ -34,7 +34,7 @@ export const REGISTRY = {
"ca-data-prep": createCaDataPrep,
"chat-export": createChatExport,
"merge": createMerge,
"crate2tables": createCrate2Tables,
"roctable": createRoctable,
"validate-crate": createValidateCrate,
"ro-crate-json-output": createJsonOutput,
"ro-crate-xlsx-output": createXlsxOutput,
Expand Down
136 changes: 0 additions & 136 deletions src/crate2tables/index.js

This file was deleted.

Loading