archivo del paquete→ .shtukbase/packages/ontology/actions/graph.ts
actions/graph.ts
31 líneas, 1.5 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // Action `graph`: writes the static lens base/ontology/graph.html, one graph of all layers' types and links,
- // with the kit embedded. The kit comes with the lenses package (kit/ there; an install puts it at
- // .shtukbase/packages/lenses/kit/); SHTUK_KIT, when set, points to another copy. Without a kit the action says
- // what is missing and exits non-zero. Run from the project root; the one option is --out <file>.
- import { existsSync } from 'node:fs';
- import { join, resolve } from 'node:path';
- import { outOption } from './lib/lenscommon.ts';
- import { main } from './lib/render_layer_ontology.ts';
- // the lenses package next to this one: .shtukbase/packages/lenses/kit in a project, packages/lenses/kit in the standard
- const PLACES = [join(import.meta.dir, '..', '..', 'lenses', 'kit'), join('.shtukbase', 'packages', 'lenses', 'kit')];
- /** The kit folder: SHTUK_KIT when set, else the copy the lenses package brought; null when there is none. */
- function findKit(): string | null {
- const given = process.env.SHTUK_KIT ?? '';
- const kit = (given ? [given] : PLACES).find((k) => existsSync(join(k, 'kit', 'kit.js')));
- return kit ? resolve(kit) : null;
- }
- const kit = findKit();
- if (!kit) {
- console.log('kit not found: the ontology graph embeds the kit; it comes with the lenses package - install it '
- + '(or point SHTUK_KIT to another copy of the kit)');
- process.exit(2);
- }
- try {
- console.log('wrote', main('.', kit, outOption(process.argv.slice(2))));
- } catch (err) {
- console.error((err as Error).message);
- process.exit(1);
- }