dbdocs 0.8.5 → 0.9.1
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/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.9.1","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.
|
|
3
|
+
"version": "0.9.1",
|
|
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": "^2.
|
|
12
|
+
"@dbml/core": "^3.2.0",
|
|
13
13
|
"@oclif/core": "1.12.1",
|
|
14
14
|
"@oclif/plugin-help": "5.1.12",
|
|
15
15
|
"axios": "1.6.0",
|
package/src/commands/build.js
CHANGED
|
@@ -15,6 +15,7 @@ const parse = require('../utils/parse');
|
|
|
15
15
|
const { PROJECT_GENERAL_ACCESS_TYPE, FLAG_HELP_GROUP } = require('../utils/constants');
|
|
16
16
|
const { getProjectUrl } = require('../utils/helper');
|
|
17
17
|
const { getIsPublicValueFromBuildFlag } = require('../utils/helper');
|
|
18
|
+
const { formatParserV2ErrorMessage } = require('../utils/error-formatter');
|
|
18
19
|
|
|
19
20
|
async function build (project, authConfig) {
|
|
20
21
|
const res = await axios.post(`${vars.apiUrl}/projects`, project, authConfig);
|
|
@@ -62,8 +63,8 @@ class BuildCommand extends Command {
|
|
|
62
63
|
}
|
|
63
64
|
spinner.succeed('Parsing file content');
|
|
64
65
|
} catch (error) {
|
|
65
|
-
|
|
66
|
-
const message = `You have syntax error in ${path.basename(filepath)}
|
|
66
|
+
const rawMessage = formatParserV2ErrorMessage(error);
|
|
67
|
+
const message = rawMessage ? `You have syntax error(s) in ${path.basename(filepath)}\n${rawMessage}` : 'Something wrong :( Please try again.';
|
|
67
68
|
throw new Error(message);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -116,7 +117,7 @@ class BuildCommand extends Command {
|
|
|
116
117
|
if (err.response) {
|
|
117
118
|
const { error } = err.response.data;
|
|
118
119
|
if (error.name === 'SyntaxError') {
|
|
119
|
-
message = `You have syntax error in ${path.basename(filepath)} line ${error.location.start.line} column ${error.location.start.column}. ${error.message}`;
|
|
120
|
+
message = `You have syntax error(s) in ${path.basename(filepath)} line ${error.location.start.line} column ${error.location.start.column}. ${error.message}`;
|
|
120
121
|
} else if (error.name === 'AccessDenied') {
|
|
121
122
|
message = error.message;
|
|
122
123
|
}
|
package/src/commands/validate.js
CHANGED
|
@@ -3,6 +3,7 @@ const fs = require('fs');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const ora = require('ora');
|
|
5
5
|
const parse = require('../utils/parse');
|
|
6
|
+
const { formatParserV2ErrorMessage } = require('../utils/error-formatter');
|
|
6
7
|
|
|
7
8
|
class ValidateCommand extends Command {
|
|
8
9
|
async run () {
|
|
@@ -21,13 +22,14 @@ class ValidateCommand extends Command {
|
|
|
21
22
|
spinner.succeed('Validating file content');
|
|
22
23
|
spinner.succeed('Done. Parse succeeded without errors.');
|
|
23
24
|
} catch (error) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const rawMessage = formatParserV2ErrorMessage(error);
|
|
26
|
+
const message = rawMessage ? `You have syntax error(s) in ${path.basename(filepath)}\n${rawMessage}` : rawMessage;
|
|
27
|
+
|
|
26
28
|
if (spinner.isSpinning) {
|
|
27
29
|
spinner.fail(`Failed: ${message}`);
|
|
28
|
-
|
|
29
|
-
this.error(message);
|
|
30
|
+
return;
|
|
30
31
|
}
|
|
32
|
+
this.error(message);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function createSyntaxErrorMessage (line, column, msg) {
|
|
2
|
+
return `Syntax error at line ${line} column ${column}. ${msg}`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function formatParserV2ErrorMessage (error) {
|
|
6
|
+
if (!Array.isArray(error)) {
|
|
7
|
+
if (!error.location) {
|
|
8
|
+
// this is a runtime error
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return createSyntaxErrorMessage(error.location.start.line, error.location.start.column, error.message);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const messageList = [];
|
|
16
|
+
error.forEach((err) => {
|
|
17
|
+
messageList.push(createSyntaxErrorMessage(err.location.start.line, err.location.start.column, err.message));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return messageList.join('\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
formatParserV2ErrorMessage,
|
|
25
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const { parentPort, workerData } = require(
|
|
2
|
-
const { Parser } = require(
|
|
1
|
+
const { parentPort, workerData } = require('worker_threads');
|
|
2
|
+
const { Parser } = require('@dbml/core');
|
|
3
3
|
|
|
4
4
|
function parse (content) {
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const parser = new Parser();
|
|
6
|
+
const databaseObject = parser.parse(content, 'dbmlv2');
|
|
7
|
+
const schemas = databaseObject.schemas.map((schema) => ({
|
|
8
|
+
name: schema.name,
|
|
9
|
+
tables: schema.tables.map((table) => table.name),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
12
|
return {
|
|
13
13
|
name: databaseObject.name,
|
|
14
14
|
description: databaseObject.note,
|