Skip to content

Commit

Permalink
[@realm/tools] Set up the package. Initial import of realm-schema. (r…
Browse files Browse the repository at this point in the history
…ealm#4538)

* [@realm/tools] Set up the package. 
* Initial import of realm-schema.

Co-authored-by: Kræn Hansen <[email protected]>
  • Loading branch information
kneth and kraenhansen committed May 25, 2022
1 parent 5d36b70 commit 838eff8
Show file tree
Hide file tree
Showing 13 changed files with 3,688 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/realm-tools/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist/
9 changes: 9 additions & 0 deletions packages/realm-tools/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off"
}
}
1 change: 1 addition & 0 deletions packages/realm-tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
13 changes: 13 additions & 0 deletions packages/realm-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
x.x.x Release notes (yyyy-MM-dd)
=============================================================
### Breaking changes
* None

### Enhancement
* Added the tool `realm-schema` to inspect the schema in a Realm file.

### Fixes
* None

### Internal
* None
1 change: 1 addition & 0 deletions packages/realm-tools/LICENSE
68 changes: 68 additions & 0 deletions packages/realm-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Tools for Realm

## Introduction

This package contains various tools for working with Realm files. Each tool is briefly documented here.

## Installation

The prerequisite for installing the `@realm/tools` package is a working [node.js](https://nodejs.org/en/) and a package manager.

npm:

```sh
npm install -g @realm/tools
```

yarn:

```sh
yarn global add @realm/tools
```

## Building

Source code for all tools are found in `src`. The output of the build process is found in `dist`.

```sh
npm install
npm run build
```

You can run the transpiled tools directly e.g.,

```sh
node dist/realm-schema.js -h
```

## `realm-schema`

The `realm-schema` can read a local Realm file and export the schema. The support output formats are:

* JSON
* [Mermaid](https://mermaid-js.github.io/mermaid/#/) compatible class diagram

Example:

```sh
npx realm-schema -i samples/default.realm -o MyClasses.mmd -f mermaid
```

The output will look like

```mermaid
classDiagram
class Child {
+string name
+int age
}
class Parent {
+string name
+string city
+Parent marriedTo
+list~Child~ children
}
Parent <-- Parent
Child <-- Parent
```
If you plan to use the JSON output, it is recommended to use it with [jq](https://stedolan.github.io/jq/).
Loading

0 comments on commit 838eff8

Please sign in to comment.