@mimsy-cms/cli
v1.3.1
Published
A command-line interface for the Mimsy CMS SDK that provides utilities for working with collection schemas and more.
Readme
Mimsy CLI
A command-line interface for the Mimsy CMS SDK that provides utilities for working with collection schemas and more.
Installation
# Install globally
pnpm install -g @mimsy-cms/cli
# Or run directly with pnpm
pnpm dlx @mimsy-cms/cliCommands
update
Updates the mimsy.schema.json file with the current collection definitions. The mimsy.schema.json file is used by Mimsy as a schema reference for the structure of your collections.
Usage
msy update [options]Options
-o, --output <path>- Output file path (default: "schema.json")-i, --import <path>- Import collections from a TypeScript or JavaScript file before exporting--pretty- Pretty print the JSON output (default: false)--clear- Clear the registry before importing (useful for testing) (default: false)-h, --help- Display help for command
Examples
Basic usage:
# Export current registry to schema.json
msy update
# Export with pretty formatting
msy update --prettyImport collections and export:
# Import TypeScript collections and export
msy update --import ./collections/blog.ts --pretty --output blog-schema.json
# Import JavaScript collections and export
msy update --import ./collections/blog.js --output blog-schema.json
# Clear registry first, then import and export
msy update --import ./collections/blog.ts --clear --prettyCollection File Examples
TypeScript Example (collections/blog.ts):
import { collection, fields, builtins, type Collection } from "@mimsy-cms/sdk";
export const Tags: Collection<any> = collection("tags", {
name: fields.shortString({
description: "The name of the tag",
constraints: {
minLength: 2,
maxLength: 50,
},
}),
color: fields.shortString({
description: "The color of the tag, in hexadecimal format",
constraints: {
minLength: 6,
maxLength: 6,
},
}),
});
export const Posts: Collection<any> = collection("posts", {
title: fields.shortString({
description: "The title of the post",
constraints: {
minLength: 5,
maxLength: 100,
},
}),
author: fields.relation({
description: "The author of the post",
relatesTo: builtins.User,
constraints: {
required: true,
},
}),
tags: fields.multiRelation({
description: "The tags associated with the post",
relatesTo: Tags,
constraints: {
required: true,
},
}),
coverImage: fields.media({
description: "The cover image of the post",
constraints: {
required: true,
},
}),
});JavaScript Example (collections/blog.js):
const { collection, fields, builtins } = require("@mimsy-cms/sdk");
const Tags = collection("tags", {
name: fields.shortString({
description: "The name of the tag",
constraints: {
minLength: 2,
maxLength: 50,
},
}),
color: fields.shortString({
description: "The color of the tag, in hexadecimal format",
constraints: {
minLength: 6,
maxLength: 6,
},
}),
});
const Posts = collection("posts", {
title: fields.shortString({
description: "The title of the post",
constraints: {
minLength: 5,
maxLength: 100,
},
}),
author: fields.relation({
description: "The author of the post",
relatesTo: builtins.User,
constraints: {
required: true,
},
}),
tags: fields.multiRelation({
description: "The tags associated with the post",
relatesTo: Tags,
constraints: {
required: true,
},
}),
coverImage: fields.media({
description: "The cover image of the post",
constraints: {
required: true,
},
}),
});
module.exports = { Tags, Posts };Output Schema Format
The exported JSON schema has the following structure:
{
"collections": [
{
"name": "collection-name",
"schema": {
"fieldName": {
"type": "field-type",
"relatesTo": "related-collection-name",
"options": {
"description": "Field description",
"constraints": {
"required": true,
"minLength": 5
}
}
}
}
}
],
"generatedAt": "2025-07-22T11:52:56.435Z"
}Development
Building
pnpm buildTesting
pnpm testDevelopment Mode
pnpm devTypeScript Support
The CLI supports importing TypeScript files directly thanks to esbuild-register. No compilation step is required - just point to your .ts files and they'll be transpiled on the fly.
Workspace Integration
This CLI is designed to work within the Mimsy monorepo workspace. Collections are automatically registered when created using the collection() function from the SDK, making schema export seamless.
Contributing
Please see the main CONTRIBUTING.md for contribution guidelines.
License
See LICENSE for more information.
