Skip to content

Commit

Permalink
Add bin field of package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
youngkiu committed Sep 25, 2022
1 parent e66279c commit 46f5336
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Generate ERD UML file from Schema DDL file
## Installation

```sh
npm i schema-to-erd
$ npm i schema-to-erd
```

## Usage
Expand All @@ -24,6 +24,10 @@ const { schemaToErd } = require('schema-to-erd');
schemaToErd('./schema_samples/sakila-schema.sql');
```

```shell
$ schema2erd -s ./schema_samples/sakila-schema.sql
```

### Sample Schema files

1. [Sakila Sample Database](https://dev.mysql.com/doc/index-other.html)
Expand Down
21 changes: 21 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
import { program } from 'commander';
import { schemaToErd } from '../dist/main.mjs';
import fs from 'fs';

program
.requiredOption('-s, --schema-file <sql file path>', 'schema.sql file path')
.option('-o, --output-dir <output directory path>', 'output directory of uml file');

program.parse();

const options = program.opts();
if (!(fs.existsSync(options.schemaFile))) {
console.error(`Not exist the schema.sql file(${options.schemaFile})`);
process.exit(1);
}

(async () => {
const pumlFilePath = await schemaToErd(options.schemaFile, options.outputDir);
console.info(`Generate the plantuml file of ${pumlFilePath}`);
})();
35 changes: 27 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schema-to-erd",
"version": "1.3.0",
"version": "1.4.0",
"description": "Generate ERD UML file from Schema DDL file",
"type": "module",
"main": "dist/main.cjs",
Expand All @@ -23,12 +23,16 @@
"UML"
],
"author": "[email protected]",
"bin": {
"schema2erd": "bin/cli.js"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/youngkiu/schema-to-erd/issues"
},
"homepage": "https://github.com/youngkiu/schema-to-erd#readme",
"dependencies": {
"commander": "^9.4.0",
"glob": "^8.0.3",
"lodash": "^4.17.21",
"sql-ddl-to-json-schema": "^4.0.6"
Expand Down

0 comments on commit 46f5336

Please sign in to comment.