Registry / devops / generate-terriajs-schema

generate-terriajs-schema

JSON →
library1.5.0jsnpmunverified

CLI tool that scans TerriaJS source code to generate JSON Schema files for catalog init files. It parses JSDoc-style tags (@type, @editortype, @editorformat, etc.) to produce schemas used by DataSourceEditor for automatic form generation and catalog validation. Current version 1.5.0, released on npm. Key differentiator: schema generation is driven directly from TypeScript source annotations, ensuring schema stays in sync with code. Alternative to manual schema authoring. Low release cadence.

npm install generate-terriajs-schema
INSTALL
IMPORT
SIG · GENERATE-TERRIAJS-
G
generate-terriajs-schema
devopsjavascriptv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generateSchema
import { generateSchema } from 'generate-terriajs-schema'
const generateSchema = require('generate-terriajs-schema')
ESM module; CommonJS require will not work.
compileSchema
import { compileSchema } from 'generate-terriajs-schema'
Used to compile generated JSON Schema into editor configuration.
parseTags
import { parseTags } from 'generate-terriajs-schema'
import parseTags from 'generate-terriajs-schema'
Named export, not default.
default
import genSchema from 'generate-terriajs-schema'
import { genSchema } from 'generate-terriajs-schema'
Default export is the main generateSchema function, but named import generateSchema is preferred for clarity.

Demonstrates programmatic usage: generate a JSON Schema with editor-friendly extensions from a local TerriaJS installation and write to file.

import { generateSchema } from 'generate-terriajs-schema'; import { writeJSON } from 'fs-extra'; async function main() { const schema = await generateSchema({ source: './node_modules/terriajs', editor: true, minify: false, noversionsubdir: true }); await writeJSON('./schema/catalog-schema.json', schema, { spaces: 2 }); } main().catch(console.error);
Debug
Known issues
breakingrequire('generate-terriajs-schema') no longer works; package is ESM-only.
fix
Use import or dynamic import.
affects: >=1.0.0
deprecatedThe --editor flag changes schema output structure; future versions may remove it.
fix
Use editor: true in programmatic API.
affects: >=1.5.0
gotchaSchema generation depends on source code annotations; missing @type will skip properties.
fix
Ensure JSDoc tags are present in TerriaJS source properties.
affects: >=0.0.1
gotchaOutput schema references TerriaJS version as subdirectory by default; can cause path issues.
fix
Use --noversionsubdir or noversionsubdir: true.
affects: >=0.0.1
breakingCommander v9+ dropped support for boolean options with defaults; CLI may fail with older Node.
fix
Use Node 14+ or pin commander to v8.
affects: >=1.4.0
Errors
Common errors & fixes
Cannot find module 'generate-terriajs-schema'
Package not installed or ESM import used without proper setup.
fix
Install: npm install generate-terriajs-schema and ensure package.json has 'type': 'module' or use .mjs extension.
TypeError: generateSchema is not a function
Importing default as named export.
fix
Use import generateSchema from 'generate-terriajs-schema' (default) or import { generateSchema } from 'generate-terriajs-schema' (named).
Error: Source directory does not contain TerriaJS source
Provided source path does not have expected structure.
fix
Point --source to a directory containing lib/ or src/ with TypeScript files.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies
commanderrequiredCLI argument parsing
fs-extrarequiredFile system operations
globrequiredFile globbing for source scanning
typescriptrequiredParsing TypeScript source to extract type information
Agent activity
14 hits · last 30 days
node
14
Resources
generate-terriajs-schema — npm install generate-terriajs-schema · libregistry