@schemacompany/cli
v0.1.1
Published
CLI for injecting JSON-LD schemas into HTML files
Downloads
14
Readme
@schemacompany/cli
CLI for injecting JSON-LD schemas into static HTML files at build time.
Installation
npm install -D @schemacompany/cliUsage
Using a Configuration File
Create a schemas.json file:
{
"baseUrl": "https://assets.theschemacompany.com",
"pages": [
{ "path": "index.html", "hash": "your-64-char-hash..." },
{ "path": "about/index.html", "hash": "another-hash..." },
{ "glob": "products/**/*.html", "hash": "product-schema-hash..." }
],
"options": {
"position": "head-end",
"pretty": true
}
}Run the inject command:
npx schemacompany inject ./dist --config schemas.jsonUsing CLI Options
npx schemacompany inject ./dist --hash abc123... --pages "index.html,about.html"Validate Configuration
npx schemacompany validate --config schemas.jsonCommands
inject <directory>
Inject schemas into HTML files.
| Option | Description | Default |
|--------|-------------|---------|
| -c, --config <path> | Config file path | schemas.json |
| -h, --hash <hash> | Single hash to inject | - |
| -p, --pages <pages> | Comma-separated page paths | - |
| --base-url <url> | Override base URL | Production |
| --position <pos> | Injection position | head-end |
| --dry-run | Show changes without writing | false |
| -v, --verbose | Verbose output | false |
Position options: head-start, head-end, body-end
validate
Validate a configuration file.
| Option | Description | Default |
|--------|-------------|---------|
| -c, --config <path> | Config file path | schemas.json |
Configuration Schema
interface Config {
baseUrl?: string;
pages: Array<
| { path: string; hash: string }
| { glob: string; hash: string }
>;
options?: {
position?: "head-start" | "head-end" | "body-end";
pretty?: boolean;
};
}License
MIT
