dbdocs 0.9.0 → 0.9.2
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.
- package/bin/run +0 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/src/utils/error-formatter.js +5 -9
- package/src/utils/parserWorker.js +22 -11
package/bin/run
CHANGED
|
File without changes
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.9.
|
|
1
|
+
{"version":"0.9.2","commands":{"build":{"id":"build","description":"build docs","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","description":"project name","multiple":false},"public":{"name":"public","type":"boolean","description":"anyone with the URL can access","helpGroup":"sharing","allowNo":false,"exclusive":["private","password"]},"private":{"name":"private","type":"boolean","description":"only invited people can access","helpGroup":"sharing","allowNo":false,"exclusive":["public","password"]},"password":{"name":"password","type":"option","char":"p","description":"anyone with the URL + password can access","helpGroup":"sharing","multiple":false,"exclusive":["public","private"]}},"args":[{"name":"filepath","description":"dbml file path"}]},"login":{"id":"login","description":"login to dbdocs\nlogin with your dbdocs credentials\n","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[]},"logout":{"id":"logout","description":"logout\nclears local login credentials\n","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[]},"ls":{"id":"ls","description":"list projects","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[]},"password":{"id":"password","description":"set password for your project or remove password","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"project name","helpValue":"project name","multiple":false},"set":{"name":"set","type":"option","char":"s","description":"password for your project","helpValue":"password","multiple":false},"remove":{"name":"remove","type":"boolean","char":"r","description":"remove password from your project","allowNo":false}},"args":[]},"remove":{"id":"remove","description":"remove project","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"project_name","description":"name of the project which you want to remove"}]},"rename":{"id":"rename","description":"change your username","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[]},"token":{"id":"token","description":"generate or revoke your authentication token","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{"generate":{"name":"generate","type":"boolean","char":"g","description":"generate authentication token","allowNo":false},"revoke":{"name":"revoke","type":"boolean","char":"r","description":"revoke authentication token","allowNo":false}},"args":[]},"validate":{"id":"validate","description":"validate docs content","strict":true,"pluginName":"dbdocs","pluginAlias":"dbdocs","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"filepath","description":"dbml file path"}]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbdocs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"author": "@holistics",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbdocs": "./bin/run"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"oclif/**/ansi-regex": "^3.0.1"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@dbml/core": "
|
|
12
|
+
"@dbml/core": "3.4.1",
|
|
13
13
|
"@oclif/core": "1.12.1",
|
|
14
14
|
"@oclif/plugin-help": "5.1.12",
|
|
15
15
|
"axios": "1.6.0",
|
|
@@ -3,18 +3,14 @@ function createSyntaxErrorMessage (line, column, msg) {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
function formatParserV2ErrorMessage (error) {
|
|
6
|
-
if (!
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return createSyntaxErrorMessage(error.location.start.line, error.location.start.column, error.message);
|
|
6
|
+
if (!error.diags) {
|
|
7
|
+
// this is a runtime error
|
|
8
|
+
return '';
|
|
13
9
|
}
|
|
14
10
|
|
|
15
11
|
const messageList = [];
|
|
16
|
-
error.forEach((
|
|
17
|
-
messageList.push(createSyntaxErrorMessage(
|
|
12
|
+
error.diags.forEach((diag) => {
|
|
13
|
+
messageList.push(createSyntaxErrorMessage(diag.location.start.line, diag.location.start.column, diag.message));
|
|
18
14
|
});
|
|
19
15
|
|
|
20
16
|
return messageList.join('\n');
|
|
@@ -2,18 +2,29 @@ const { parentPort, workerData } = require('worker_threads');
|
|
|
2
2
|
const { Parser } = require('@dbml/core');
|
|
3
3
|
|
|
4
4
|
function parse (content) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
try {
|
|
6
|
+
const parser = new Parser();
|
|
7
|
+
const databaseObject = parser.parse(content, 'dbmlv2');
|
|
8
|
+
const schemas = databaseObject.schemas.map((schema) => ({
|
|
9
|
+
name: schema.name,
|
|
10
|
+
tables: schema.tables.map((table) => table.name),
|
|
11
|
+
}));
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
return {
|
|
14
|
+
name: databaseObject.name,
|
|
15
|
+
description: databaseObject.note,
|
|
16
|
+
schemas,
|
|
17
|
+
};
|
|
18
|
+
} catch (err) {
|
|
19
|
+
// Worker will cast custom error to `Error` type so we map DBML errors to JSON here to fix it.
|
|
20
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types
|
|
21
|
+
const diags = err.diags.map((d) => ({
|
|
22
|
+
location: d.location,
|
|
23
|
+
message: d.message,
|
|
24
|
+
}));
|
|
25
|
+
// eslint-disable-next-line no-throw-literal
|
|
26
|
+
throw { diags };
|
|
27
|
+
}
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
const { content } = workerData;
|