dbdocs 0.7.5 → 0.8.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.
- package/oclif.manifest.json +1 -1
- package/package.json +8 -4
- package/src/commands/build.js +26 -11
- package/src/commands/ls.js +4 -5
- package/src/hooks/init/checkUpdate.js +8 -2
- package/src/utils/constants.js +16 -0
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.8.0","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},"restricted":{"name":"restricted","type":"boolean","char":"r","description":"restrict access to project","allowNo":false},"password":{"name":"password","type":"option","char":"p","description":"password for project","multiple":false,"exclusive":["restricted"]}},"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 docs","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.8.0",
|
|
4
4
|
"author": "@holistics",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbdocs": "./bin/run"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"netrc-parser": "^3.1.6",
|
|
20
20
|
"open": "^7.0.0",
|
|
21
21
|
"ora": "^4.0.3",
|
|
22
|
-
"update-notifier": "^
|
|
22
|
+
"update-notifier": "^6.0.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@oclif/test": "2.1.1",
|
|
@@ -44,8 +44,12 @@
|
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"main": "src/index.js",
|
|
46
46
|
"oclif": {
|
|
47
|
-
"additionalHelpFlags": [
|
|
48
|
-
|
|
47
|
+
"additionalHelpFlags": [
|
|
48
|
+
"help"
|
|
49
|
+
],
|
|
50
|
+
"additionalVersionFlags": [
|
|
51
|
+
"version"
|
|
52
|
+
],
|
|
49
53
|
"commands": "./src/commands",
|
|
50
54
|
"bin": "dbdocs",
|
|
51
55
|
"plugins": [
|
package/src/commands/build.js
CHANGED
|
@@ -11,6 +11,7 @@ const { getOrg } = require('../utils/org');
|
|
|
11
11
|
const { shouldAskForFeedback } = require('../utils/feedback');
|
|
12
12
|
const { isValidName } = require('../validators/projectName');
|
|
13
13
|
const parse = require('../utils/parse');
|
|
14
|
+
const { PROJECT_GENERAL_ACCESS_TYPE } = require('../utils/constants');
|
|
14
15
|
|
|
15
16
|
async function build (project, authConfig) {
|
|
16
17
|
const res = await axios.post(`${vars.apiUrl}/projects`, project, authConfig);
|
|
@@ -36,9 +37,9 @@ class BuildCommand extends Command {
|
|
|
36
37
|
|
|
37
38
|
try {
|
|
38
39
|
const authConfig = await verifyToken();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const { flags, args } = await this.parse(BuildCommand);
|
|
41
|
+
const { restricted, password } = flags;
|
|
42
|
+
let { project } = flags;
|
|
42
43
|
|
|
43
44
|
const { filepath } = args;
|
|
44
45
|
let content = '';
|
|
@@ -70,6 +71,7 @@ class BuildCommand extends Command {
|
|
|
70
71
|
|
|
71
72
|
while (!isValidName(project)) {
|
|
72
73
|
spinner.warn('Invalid project name! Project name can only contain only alphabets, numbers, space, "-" or "_" and can not be blanked!');
|
|
74
|
+
// eslint-disable-next-line no-await-in-loop
|
|
73
75
|
project = await enterProjectName();
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -77,8 +79,10 @@ class BuildCommand extends Command {
|
|
|
77
79
|
spinner.text = `Pushing new database to project ${project}`;
|
|
78
80
|
spinner.start();
|
|
79
81
|
try {
|
|
80
|
-
const { newProject
|
|
82
|
+
const { newProject } = await build({
|
|
81
83
|
projectName: project,
|
|
84
|
+
// 'undefined' means not update isPublic value
|
|
85
|
+
isPublic: restricted ? false : undefined,
|
|
82
86
|
password,
|
|
83
87
|
orgName: org,
|
|
84
88
|
doc: {
|
|
@@ -86,12 +90,18 @@ class BuildCommand extends Command {
|
|
|
86
90
|
},
|
|
87
91
|
shallowSchema: model.schemas,
|
|
88
92
|
}, authConfig);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
spinner.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
switch (newProject.generalAccessType) {
|
|
94
|
+
case PROJECT_GENERAL_ACCESS_TYPE.public:
|
|
95
|
+
spinner.warn(`Project '${newProject.name}' is public, consider setting password or restricting access to it`);
|
|
96
|
+
break;
|
|
97
|
+
case PROJECT_GENERAL_ACCESS_TYPE.protected:
|
|
98
|
+
spinner.succeed(`Project '${newProject.name}' is protected with password`);
|
|
99
|
+
break;
|
|
100
|
+
case PROJECT_GENERAL_ACCESS_TYPE.restricted:
|
|
101
|
+
spinner.succeed(`Restricted access to project '${newProject.name}'`);
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
break;
|
|
95
105
|
}
|
|
96
106
|
spinner.succeed(`Done. Visit: ${chalk.cyan(`${vars.hostUrl}/${newProject.org.name}/${newProject.urlName}`)}\n`);
|
|
97
107
|
if (shouldAskForFeedback()) {
|
|
@@ -136,9 +146,14 @@ class BuildCommand extends Command {
|
|
|
136
146
|
|
|
137
147
|
BuildCommand.description = 'build docs';
|
|
138
148
|
|
|
149
|
+
// Not allow using both --password and --restricted flags at the same time. For example:
|
|
150
|
+
// dbdocs build ./abc.dbml --project abc --password 123456 # works
|
|
151
|
+
// dbdocs build ./abc.dbml --project abc --restricted # works
|
|
152
|
+
// dbdocs build ./abc.dbml --project abc --password 123456 --restricted # error
|
|
139
153
|
BuildCommand.flags = {
|
|
140
154
|
project: Flags.string({ description: 'project name' }),
|
|
141
|
-
|
|
155
|
+
restricted: Flags.boolean({ char: 'r', description: 'restrict access to project' }),
|
|
156
|
+
password: Flags.string({ char: 'p', description: 'password for project', exclusive: ['restricted'] }),
|
|
142
157
|
};
|
|
143
158
|
|
|
144
159
|
BuildCommand.args = [
|
package/src/commands/ls.js
CHANGED
|
@@ -4,6 +4,7 @@ const { vars } = require('../vars');
|
|
|
4
4
|
const verifyToken = require('../utils/verifyToken');
|
|
5
5
|
const { getProjectsByOrg } = require('../utils/org');
|
|
6
6
|
const { getOrg } = require('../utils/org');
|
|
7
|
+
const { PROJECT_SHARING_TEXT } = require('../utils/constants');
|
|
7
8
|
|
|
8
9
|
class LsCommand extends Command {
|
|
9
10
|
async run () {
|
|
@@ -26,11 +27,9 @@ class LsCommand extends Command {
|
|
|
26
27
|
name: {
|
|
27
28
|
minWidth: 20,
|
|
28
29
|
},
|
|
29
|
-
|
|
30
|
-
minWidth:
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line no-confusing-arrow
|
|
33
|
-
get: (project) => project.isPublic ? 'No' : 'Yes',
|
|
30
|
+
sharing: {
|
|
31
|
+
minWidth: 23,
|
|
32
|
+
get: (project) => PROJECT_SHARING_TEXT[project.generalAccessType],
|
|
34
33
|
},
|
|
35
34
|
url: {
|
|
36
35
|
minWidth: maxUrlWidth + 2,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
const updateNotifier = require('update-notifier');
|
|
2
1
|
const pkg = require('../../../package.json');
|
|
3
2
|
|
|
4
3
|
module.exports = async function () {
|
|
5
|
-
|
|
4
|
+
// update-notifier v6.x is pure ESM, can not use require() to load it,
|
|
5
|
+
// see: https://github.com/yeoman/update-notifier/releases/tag/v6.0.0
|
|
6
|
+
const updateNotifier = (await import('update-notifier')).default;
|
|
7
|
+
const notifier = updateNotifier({ pkg });
|
|
8
|
+
|
|
9
|
+
notifier.notify({ isGlobal: true });
|
|
10
|
+
// uncomment to check the update information
|
|
11
|
+
// console.log(await notifier.fetchInfo());
|
|
6
12
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const PROJECT_GENERAL_ACCESS_TYPE = {
|
|
2
|
+
public: 'public',
|
|
3
|
+
protected: 'protected',
|
|
4
|
+
restricted: 'restricted',
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const PROJECT_SHARING_TEXT = {
|
|
8
|
+
public: 'Shared URL',
|
|
9
|
+
protected: 'Shared URL & password',
|
|
10
|
+
restricted: 'Only invited',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
PROJECT_GENERAL_ACCESS_TYPE,
|
|
15
|
+
PROJECT_SHARING_TEXT,
|
|
16
|
+
};
|