@dbml/cli 2.6.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/__test__/dbml2sql/filename --mysql --out-file/dbml-error.log +36 -0
  2. package/__test__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +1 -1
  3. package/__test__/dbml2sql/filename --out-file/dbml-error.log +36 -0
  4. package/__test__/dbml2sql/filename --out-file/out-files/schema.sql +1 -1
  5. package/__test__/dbml2sql/filename --postgres --out-file/dbml-error.log +24 -0
  6. package/__test__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +1 -1
  7. package/__test__/dbml2sql/filenames --mysql --out-file/dbml-error.log +24 -0
  8. package/__test__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +1 -1
  9. package/__test__/dbml2sql/filenames --out-file/dbml-error.log +24 -0
  10. package/__test__/dbml2sql/filenames --out-file/out-files/schema.sql +1 -1
  11. package/__test__/dbml2sql/filenames --postgres --out-file/dbml-error.log +24 -0
  12. package/__test__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +1 -1
  13. package/__test__/dbml2sql/multiple_schema_mssql/dbml-error.log +24 -0
  14. package/__test__/dbml2sql/multiple_schema_mssql/expect-out-files/multiple_schema.out.sql +4 -4
  15. package/__test__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +5 -5
  16. package/__test__/dbml2sql/multiple_schema_mysql/dbml-error.log +24 -0
  17. package/__test__/dbml2sql/multiple_schema_mysql/expect-out-files/multiple_schema.out.sql +4 -4
  18. package/__test__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +5 -5
  19. package/__test__/dbml2sql/multiple_schema_pg/dbml-error.log +24 -0
  20. package/__test__/dbml2sql/multiple_schema_pg/expect-out-files/multiple_schema.out.sql +4 -4
  21. package/__test__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +5 -5
  22. package/__test__/dbml2sql/syntax-error/dbml-error.log +2126 -1066
  23. package/__test__/dbml2sql/syntax-error/stdout.txt +4 -2
  24. package/__test__/sql2dbml/filename --mssql --out-file/dbml-error.log +51 -0
  25. package/__test__/sql2dbml/filename --mysql --out-file/dbml-error.log +24 -0
  26. package/__test__/sql2dbml/filename --out-file/dbml-error.log +24 -0
  27. package/__test__/sql2dbml/filename --postgres --out-file/dbml-error.log +24 -0
  28. package/__test__/sql2dbml/filenames --mysql --out-file/dbml-error.log +239 -0
  29. package/__test__/sql2dbml/filenames --mysql --out-file/expect-out-files/schema.dbml +1 -1
  30. package/__test__/sql2dbml/filenames --mysql --out-file/in-files/business.sql +1 -1
  31. package/__test__/sql2dbml/filenames --mysql --out-file/out-files/schema.dbml +1 -1
  32. package/__test__/sql2dbml/filenames --mysql stdout/dbml-error.log +218 -0
  33. package/__test__/sql2dbml/filenames --mysql stdout/in-files/business.sql +1 -1
  34. package/__test__/sql2dbml/filenames --mysql stdout/stdout.txt +1 -1
  35. package/__test__/sql2dbml/filenames --out-file/dbml-error.log +24 -0
  36. package/__test__/sql2dbml/filenames --postgres --out-file/dbml-error.log +24 -0
  37. package/__test__/sql2dbml/multiple_schema_mssql/dbml-error.log +121 -0
  38. package/__test__/sql2dbml/multiple_schema_mysql/dbml-error.log +104 -0
  39. package/__test__/sql2dbml/multiple_schema_mysql/expect-out-files/multiple_schema.out.dbml +75 -32
  40. package/__test__/sql2dbml/multiple_schema_mysql/in-files/multiple_schema.in.sql +36 -3
  41. package/__test__/sql2dbml/multiple_schema_mysql/out-files/multiple_schema.out.dbml +75 -32
  42. package/__test__/sql2dbml/multiple_schema_pg/dbml-error.log +163 -32
  43. package/__test__/sql2dbml/syntax-error/dbml-error.log +2679 -1062
  44. package/__test__/sql2dbml/syntax-error/stdout.txt +3 -2
  45. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +1774 -1058
  46. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mssql/stdout.txt +1 -1
  47. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +1766 -1050
  48. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mysql/stdout.txt +1 -1
  49. package/bin/dbml-error.log +0 -0
  50. package/bin/dbml2sql.js +0 -0
  51. package/bin/sql2dbml.js +0 -0
  52. package/dbml-error.log +322 -258
  53. package/lib/cli/config.js +3 -0
  54. package/lib/cli/export.js +4 -2
  55. package/lib/cli/import.js +3 -0
  56. package/lib/cli/index.js +1 -1
  57. package/lib/cli/utils.js +4 -1
  58. package/package.json +3 -3
  59. package/src/cli/config.js +3 -0
  60. package/src/cli/export.js +2 -2
  61. package/src/cli/import.js +1 -0
  62. package/src/cli/index.js +1 -0
  63. package/src/cli/utils.js +4 -1
  64. package/yarn-error.log +0 -87
package/lib/cli/config.js CHANGED
@@ -8,6 +8,9 @@ var _default = {
8
8
  mysql: {
9
9
  name: 'MySQL'
10
10
  },
11
+ mysqlLegacy: {
12
+ name: 'MySQL'
13
+ },
11
14
  postgres: {
12
15
  name: 'PostgreSQL'
13
16
  },
package/lib/cli/export.js CHANGED
@@ -28,7 +28,9 @@ async function exportHandler(program) {
28
28
  (0, _utils.generate)(inputPaths, dbml => _core.exporter.export(dbml, format), new _outputFilePlugin.default((0, _utils.resolvePaths)(opts.outFile), header));
29
29
  console.log(` ${_chalk.default.green(_figures.default.main.tick)} Generated SQL dump file (${_config.default[format].name}): ${_path.default.basename(opts.outFile)}`);
30
30
  }
31
- } catch (err) {
32
- _logger.default.error(err);
31
+ } catch (errors) {
32
+ _logger.default.error(`\n ${errors.map(({
33
+ message
34
+ }) => message).join('\n ')}`);
33
35
  }
34
36
  }
package/lib/cli/import.js CHANGED
@@ -28,6 +28,9 @@ async function importHandler(program) {
28
28
  console.log(` ${_chalk.default.green(_figures.default.main.tick)} Generated DBML file from SQL file (${_config.default[format].name}): ${_path.default.basename(opts.outFile)}`);
29
29
  }
30
30
  } catch (err) {
31
+ if (err instanceof Array) return _logger.default.error(`\n ${err.map(({
32
+ message
33
+ }) => message).join('\n ')}`);
31
34
  _logger.default.error(err);
32
35
  }
33
36
  }
package/lib/cli/index.js CHANGED
@@ -20,7 +20,7 @@ function dbml2sql(args) {
20
20
  }
21
21
  function sql2dbml(args) {
22
22
  _commander.default.version(_package.default.version);
23
- _commander.default.usage('[options] <files...>').option('--mysql').option('--postgres').option('--postgres-legacy').option('--mssql').option('-o, --out-file <pathspec>', 'compile all input files into a single files');
23
+ _commander.default.usage('[options] <files...>').option('--mysql').option('--mysql-legacy').option('--postgres').option('--postgres-legacy').option('--mssql').option('-o, --out-file <pathspec>', 'compile all input files into a single files');
24
24
  // .option('-d, --out-dir <pathspec>', 'compile an input directory of sql files into an output directory');
25
25
 
26
26
  _commander.default.parse(args);
package/lib/cli/utils.js CHANGED
@@ -22,7 +22,7 @@ function validateInputFilePaths(paths, validatePlugin) {
22
22
  }
23
23
  function getFormatOpt(opts) {
24
24
  const formatOpts = Object.keys(opts).filter(opt => {
25
- return ['postgres', 'mysql', 'mssql', 'postgresLegacy'].includes(opt);
25
+ return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy'].includes(opt);
26
26
  });
27
27
  let format = 'postgres';
28
28
  let cnt = 0;
@@ -42,6 +42,9 @@ function generate(inputPaths, transform, outputPlugin) {
42
42
  const content = transform(source);
43
43
  outputPlugin.write(content);
44
44
  } catch (err) {
45
+ if (Array.isArray(err)) {
46
+ throw err.map(e => new _errors.SyntaxError(_path2.default.basename(_path), e));
47
+ }
45
48
  throw new _errors.SyntaxError(_path2.default.basename(_path), err);
46
49
  }
47
50
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbml/cli",
3
- "version": "2.6.1",
3
+ "version": "3.1.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@babel/cli": "^7.21.0",
28
- "@dbml/core": "^2.6.1",
28
+ "@dbml/core": "^3.1.0",
29
29
  "bluebird": "^3.5.5",
30
30
  "chalk": "^2.4.2",
31
31
  "commander": "^2.20.0",
@@ -53,5 +53,5 @@
53
53
  "^.+\\.js$": "babel-jest"
54
54
  }
55
55
  },
56
- "gitHead": "54ed18bb2232c6143992aa3d81f4a2b48c36a249"
56
+ "gitHead": "a8c31e65df64b80342dab379c2889b3dca92ac3c"
57
57
  }
package/src/cli/config.js CHANGED
@@ -2,6 +2,9 @@ export default {
2
2
  mysql: {
3
3
  name: 'MySQL',
4
4
  },
5
+ mysqlLegacy: {
6
+ name: 'MySQL',
7
+ },
5
8
  postgres: {
6
9
  name: 'PostgreSQL',
7
10
  },
package/src/cli/export.js CHANGED
@@ -36,7 +36,7 @@ export default async function exportHandler (program) {
36
36
 
37
37
  console.log(` ${chalk.green(figures.main.tick)} Generated SQL dump file (${config[format].name}): ${path.basename(opts.outFile)}`);
38
38
  }
39
- } catch (err) {
40
- logger.error(err);
39
+ } catch (errors) {
40
+ logger.error(`\n ${errors.map(({ message }) => message).join('\n ')}`);
41
41
  }
42
42
  }
package/src/cli/import.js CHANGED
@@ -31,6 +31,7 @@ export default async function importHandler (program) {
31
31
  console.log(` ${chalk.green(figures.main.tick)} Generated DBML file from SQL file (${config[format].name}): ${path.basename(opts.outFile)}`);
32
32
  }
33
33
  } catch (err) {
34
+ if (err instanceof Array) return logger.error(`\n ${err.map(({ message }) => message).join('\n ')}`);
34
35
  logger.error(err);
35
36
  }
36
37
  }
package/src/cli/index.js CHANGED
@@ -25,6 +25,7 @@ function sql2dbml (args) {
25
25
  program
26
26
  .usage('[options] <files...>')
27
27
  .option('--mysql')
28
+ .option('--mysql-legacy')
28
29
  .option('--postgres')
29
30
  .option('--postgres-legacy')
30
31
  .option('--mssql')
package/src/cli/utils.js CHANGED
@@ -15,7 +15,7 @@ function validateInputFilePaths (paths, validatePlugin) {
15
15
 
16
16
  function getFormatOpt (opts) {
17
17
  const formatOpts = Object.keys(opts).filter((opt) => {
18
- return ['postgres', 'mysql', 'mssql', 'postgresLegacy'].includes(opt);
18
+ return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy'].includes(opt);
19
19
  });
20
20
 
21
21
  let format = 'postgres';
@@ -39,6 +39,9 @@ function generate (inputPaths, transform, outputPlugin) {
39
39
  const content = transform(source);
40
40
  outputPlugin.write(content);
41
41
  } catch (err) {
42
+ if (Array.isArray(err)) {
43
+ throw err.map((e) => new SyntaxError(path.basename(_path), e));
44
+ }
42
45
  throw new SyntaxError(path.basename(_path), err);
43
46
  }
44
47
  });
package/yarn-error.log DELETED
@@ -1,87 +0,0 @@
1
- Arguments:
2
- /usr/local/bin/node /usr/local/bin/yarn install
3
-
4
- PATH:
5
- /opt/homebrew/opt/openjdk/bin:/opt/homebrew/opt/postgresql@13/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/opt/postgresql@13/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/nguyenhoang/.cargo/bin
6
-
7
- Yarn version:
8
- 1.22.18
9
-
10
- Node version:
11
- 16.18.0
12
-
13
- Platform:
14
- darwin arm64
15
-
16
- Trace:
17
- SyntaxError: /Users/nguyenhoang/Documents/workspace/dbx/dbml/package.json: Unexpected token } in JSON at position 130
18
- at JSON.parse (<anonymous>)
19
- at /usr/local/lib/node_modules/yarn/lib/cli.js:1625:59
20
- at Generator.next (<anonymous>)
21
- at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
22
- at /usr/local/lib/node_modules/yarn/lib/cli.js:321:13
23
-
24
- npm manifest:
25
- {
26
- "name": "@dbml/cli",
27
- "version": "2.5.3",
28
- "description": "",
29
- "main": "lib/index.js",
30
- "license": "Apache-2.0",
31
- "scripts": {
32
- "test": "jest",
33
- "build": "babel src --out-dir lib --copy-files",
34
- "prepublish": "npm run build"
35
- },
36
- "publishConfig": {
37
- "access": "public"
38
- },
39
- "bin": {
40
- "dbml2sql": "bin/dbml2sql.js",
41
- "sql2dbml": "bin/sql2dbml.js"
42
- },
43
- "author": "Holistics <dev@holistics.io>",
44
- "homepage": "https://dbml.dbdiagram.io",
45
- "repository": "https://github.com/holistics/dbml/tree/master/packages/dbml-cli",
46
- "keywords": [
47
- "dbml",
48
- "dbml-cli"
49
- ],
50
- "dependencies": {
51
- "@babel/cli": "^7.21.0",
52
- "@dbml/core": "^2.5.3",
53
- "bluebird": "^3.5.5",
54
- "chalk": "^2.4.2",
55
- "commander": "^2.20.0",
56
- "esm": "^3.2.25",
57
- "figures": "^3.2.0",
58
- "lodash": "^4.17.15",
59
- "pegjs-require-import": "^0.0.2",
60
- "strip-ansi": "^5.2.0",
61
- "winston": "^3.2.1"
62
- },
63
- "devDependencies": {
64
- "@babel/core": "^7.21.4",
65
- "@babel/node": "^7.20.7",
66
- "@babel/plugin-transform-runtime": "^7.21.4",
67
- "@babel/preset-env": "^7.21.4",
68
- "@babel/runtime": "^7.21.0",
69
- "babel-jest": "^29.5.0",
70
- "jest": "^29.5.0"
71
- },
72
- "jest": {
73
- "setupFiles": [
74
- "./jestHelpers.js"
75
- ],
76
- "transform": {
77
- "^.+\\.js$": "babel-jest"
78
- }
79
- },
80
- "gitHead": "5cb80e1aa38fb9a4dbe3079e39c9ef93cd4dc556"
81
- }
82
-
83
- yarn manifest:
84
- No manifest
85
-
86
- Lockfile:
87
- No lockfile