forked from realm/realm-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@realm/tools] Set up the package. Initial import of realm-schema. (r…
…ealm#4538) * [@realm/tools] Set up the package. * Initial import of realm-schema. Co-authored-by: Kræn Hansen <[email protected]>
- Loading branch information
1 parent
5d36b70
commit 838eff8
Showing
13 changed files
with
3,688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/). |
Oops, something went wrong.