@saltcorn/cli 1.0.0-beta.2 → 1.0.0-beta.5
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/README.md +394 -294
- package/bin/saltcorn +4 -4
- package/npm-shrinkwrap.json +11095 -12264
- package/oclif.manifest.json +1619 -1
- package/package.json +14 -25
- package/src/commands/add-schema.js +7 -8
- package/src/commands/backup.js +6 -6
- package/src/commands/build-app.js +26 -26
- package/src/commands/build-cordova-builder.js +3 -3
- package/src/commands/configuration-check-backups.js +7 -9
- package/src/commands/configuration-check.js +4 -5
- package/src/commands/create-tenant.js +11 -9
- package/src/commands/create-user.js +9 -10
- package/src/commands/delete-tenants.js +1 -1
- package/src/commands/delete-user.js +12 -10
- package/src/commands/dev/localize-plugin.js +12 -10
- package/src/commands/dev/make-migration.js +1 -1
- package/src/commands/dev/plugin-test.js +6 -6
- package/src/commands/dev/post-release.js +6 -7
- package/src/commands/dev/release.js +9 -6
- package/src/commands/dev/test-plugin.js +8 -5
- package/src/commands/fixtures.js +4 -4
- package/src/commands/get-cfg.js +14 -12
- package/src/commands/info.js +8 -8
- package/src/commands/inspect.js +9 -12
- package/src/commands/install-pack.js +5 -5
- package/src/commands/install-plugin.js +6 -6
- package/src/commands/list-tenants.js +27 -19
- package/src/commands/list-triggers.js +29 -18
- package/src/commands/list-users.js +9 -16
- package/src/commands/migrate.js +1 -1
- package/src/commands/modify-user.js +16 -15
- package/src/commands/plugins.js +7 -7
- package/src/commands/reset-schema.js +5 -6
- package/src/commands/restore.js +6 -6
- package/src/commands/rm-tenant.js +7 -9
- package/src/commands/run-benchmark.js +17 -14
- package/src/commands/run-js.js +5 -6
- package/src/commands/run-sql.js +5 -6
- package/src/commands/run-tests.js +15 -13
- package/src/commands/run-trigger.js +13 -8
- package/src/commands/scheduler.js +3 -3
- package/src/commands/serve.js +10 -10
- package/src/commands/set-cfg.js +14 -13
- package/src/commands/set-daily-time.js +7 -9
- package/src/commands/setup-benchmark.js +14 -7
- package/src/commands/setup.js +11 -12
- package/src/commands/sync-upload-data.js +6 -6
- package/src/commands/take-snapshot.js +5 -6
- package/src/commands/transform-field.js +9 -10
- package/src/index.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Command,
|
|
1
|
+
const { Command, Flags } = require("@oclif/core");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const { spawnSync } = require("child_process");
|
|
4
4
|
const { getState } = require("@saltcorn/data/db/state");
|
|
@@ -148,7 +148,7 @@ const testReleasedPlugin = async (pluginName, env, backupFile) => {
|
|
|
148
148
|
*/
|
|
149
149
|
class PluginTestCommand extends Command {
|
|
150
150
|
async run() {
|
|
151
|
-
const { flags } = this.parse(PluginTestCommand);
|
|
151
|
+
const { flags } = await this.parse(PluginTestCommand);
|
|
152
152
|
const dbname = flags.database ? flags.database : "saltcorn_test";
|
|
153
153
|
let env = null;
|
|
154
154
|
const db = require("@saltcorn/data/db");
|
|
@@ -194,20 +194,20 @@ class PluginTestCommand extends Command {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
PluginTestCommand.flags = {
|
|
197
|
-
directory:
|
|
197
|
+
directory: Flags.string({
|
|
198
198
|
char: "d",
|
|
199
199
|
description: "Directory of local plugin",
|
|
200
200
|
}),
|
|
201
|
-
name:
|
|
201
|
+
name: Flags.string({
|
|
202
202
|
char: "n",
|
|
203
203
|
description: "Plugin name in store of a released plugin",
|
|
204
204
|
}),
|
|
205
|
-
backupFile:
|
|
205
|
+
backupFile: Flags.string({
|
|
206
206
|
char: "f",
|
|
207
207
|
description:
|
|
208
208
|
"Optional name of a backup file in the tests folder. If you ommit this, then the test has to create its own data.",
|
|
209
209
|
}),
|
|
210
|
-
database:
|
|
210
|
+
database: Flags.string({
|
|
211
211
|
string: "database",
|
|
212
212
|
description: "Run on specified database. Default is 'saltcorn_test''",
|
|
213
213
|
}),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/post-release
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const fsp = fs.promises;
|
|
8
8
|
const { spawnSync, spawn } = require("child_process");
|
|
@@ -124,7 +124,7 @@ class PostReleaseCommand extends Command {
|
|
|
124
124
|
async run() {
|
|
125
125
|
const {
|
|
126
126
|
args: { task },
|
|
127
|
-
} = this.parse(PostReleaseCommand);
|
|
127
|
+
} = await this.parse(PostReleaseCommand);
|
|
128
128
|
this.version = require(path.join(
|
|
129
129
|
__dirname,
|
|
130
130
|
"..",
|
|
@@ -149,12 +149,11 @@ PostReleaseCommand.description = `Post-release tasks: docker and vagrant builds`
|
|
|
149
149
|
/**
|
|
150
150
|
* @type {object}
|
|
151
151
|
*/
|
|
152
|
-
PostReleaseCommand.args =
|
|
153
|
-
{
|
|
154
|
-
name: "task",
|
|
152
|
+
PostReleaseCommand.args = {
|
|
153
|
+
task: Args.string({
|
|
155
154
|
options: ["docker", "vagrant", "all", "none"],
|
|
156
155
|
description: "What to do",
|
|
157
|
-
},
|
|
158
|
-
|
|
156
|
+
}),
|
|
157
|
+
};
|
|
159
158
|
|
|
160
159
|
module.exports = PostReleaseCommand;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/release
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const { spawnSync } = require("child_process");
|
|
8
8
|
const { sleep } = require("../../common");
|
|
@@ -20,7 +20,7 @@ class ReleaseCommand extends Command {
|
|
|
20
20
|
const {
|
|
21
21
|
args: { version },
|
|
22
22
|
flags,
|
|
23
|
-
} = this.parse(ReleaseCommand);
|
|
23
|
+
} = await this.parse(ReleaseCommand);
|
|
24
24
|
spawnSync("git", ["pull"], {
|
|
25
25
|
stdio: "inherit",
|
|
26
26
|
cwd: ".",
|
|
@@ -192,12 +192,15 @@ ReleaseCommand.description = `Release a new saltcorn version`;
|
|
|
192
192
|
/**
|
|
193
193
|
* @type {object}
|
|
194
194
|
*/
|
|
195
|
-
ReleaseCommand.args =
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
ReleaseCommand.args = {
|
|
196
|
+
version: Args.string({
|
|
197
|
+
required: true,
|
|
198
|
+
description: "New version number",
|
|
199
|
+
}),
|
|
200
|
+
};
|
|
198
201
|
|
|
199
202
|
ReleaseCommand.flags = {
|
|
200
|
-
tag:
|
|
203
|
+
tag: Flags.string({
|
|
201
204
|
char: "t",
|
|
202
205
|
description: "NPM tag",
|
|
203
206
|
}),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/test-plugin
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -27,7 +27,7 @@ class TestPluginCommand extends Command {
|
|
|
27
27
|
const { auto_test_plugin } = require("@saltcorn/data/plugin-testing");
|
|
28
28
|
const db = require("@saltcorn/data/db");
|
|
29
29
|
const { requirePlugin } = require("@saltcorn/server/load_plugins");
|
|
30
|
-
const { args } = this.parse(TestPluginCommand);
|
|
30
|
+
const { args } = await this.parse(TestPluginCommand);
|
|
31
31
|
await db.changeConnection({ database: "saltcorn_test" });
|
|
32
32
|
await reset();
|
|
33
33
|
await fixtures();
|
|
@@ -52,9 +52,12 @@ class TestPluginCommand extends Command {
|
|
|
52
52
|
/**
|
|
53
53
|
* @type {object}
|
|
54
54
|
*/
|
|
55
|
-
TestPluginCommand.args =
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
TestPluginCommand.args = {
|
|
56
|
+
path: Args.string({
|
|
57
|
+
required: true,
|
|
58
|
+
description: "path to plugin package",
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
58
61
|
|
|
59
62
|
/**
|
|
60
63
|
* @type {string}
|
package/src/commands/fixtures.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/fixtures
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant, parseJSONorString } = require("../common");
|
|
7
7
|
/**
|
|
8
8
|
* FixturesCommand Class
|
|
@@ -16,7 +16,7 @@ class FixturesCommand extends Command {
|
|
|
16
16
|
async run() {
|
|
17
17
|
const fixtures = require("@saltcorn/data/db/fixtures");
|
|
18
18
|
const reset = require("@saltcorn/data/db/reset_schema");
|
|
19
|
-
const { flags } = this.parse(FixturesCommand);
|
|
19
|
+
const { flags } = await this.parse(FixturesCommand);
|
|
20
20
|
if (flags.tenant) {
|
|
21
21
|
const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
|
|
22
22
|
const { init_multi_tenant } = require("@saltcorn/data/db/state");
|
|
@@ -48,8 +48,8 @@ This manual step it is never required for users and rarely required for develope
|
|
|
48
48
|
* @type {object}
|
|
49
49
|
*/
|
|
50
50
|
FixturesCommand.flags = {
|
|
51
|
-
reset:
|
|
52
|
-
tenant:
|
|
51
|
+
reset: Flags.boolean({ char: "r", description: "Also reset schema" }),
|
|
52
|
+
tenant: Flags.string({
|
|
53
53
|
char: "t",
|
|
54
54
|
description: "tenant",
|
|
55
55
|
}),
|
package/src/commands/get-cfg.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/set-cfg
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const { cli } = require("cli-ux");
|
|
5
|
+
const { Command, Flags, Args, ux } = require("@oclif/core");
|
|
7
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -11,12 +10,12 @@ const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
|
11
10
|
* @extends oclif.Command
|
|
12
11
|
* @category saltcorn-cli
|
|
13
12
|
*/
|
|
14
|
-
class
|
|
13
|
+
class GetCfgCommand extends Command {
|
|
15
14
|
/**
|
|
16
15
|
* @returns {Promise<void>}
|
|
17
16
|
*/
|
|
18
17
|
async run() {
|
|
19
|
-
const { args, flags } = this.parse(
|
|
18
|
+
const { args, flags } = await this.parse(GetCfgCommand);
|
|
20
19
|
await init_some_tenants(flags.tenant);
|
|
21
20
|
|
|
22
21
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
@@ -49,27 +48,30 @@ class SetCfgCommand extends Command {
|
|
|
49
48
|
/**
|
|
50
49
|
* @type {string}
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
GetCfgCommand.description = `Get a configuration value. The value is printed to stdout as a JSON value`;
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* @type {object[]}
|
|
56
55
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
GetCfgCommand.args = {
|
|
57
|
+
key: Args.string({
|
|
58
|
+
required: false,
|
|
59
|
+
description: "Configuration key",
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
64
|
* @type {object}
|
|
63
65
|
*/
|
|
64
|
-
|
|
65
|
-
tenant:
|
|
66
|
+
GetCfgCommand.flags = {
|
|
67
|
+
tenant: Flags.string({
|
|
66
68
|
char: "t",
|
|
67
69
|
description: "tenant",
|
|
68
70
|
}),
|
|
69
|
-
plugin:
|
|
71
|
+
plugin: Flags.string({
|
|
70
72
|
char: "p",
|
|
71
73
|
description: "plugin",
|
|
72
74
|
}),
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
module.exports =
|
|
77
|
+
module.exports = GetCfgCommand;
|
package/src/commands/info.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/info
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const {
|
|
7
7
|
configFilePath,
|
|
8
8
|
getConnectObject,
|
|
9
9
|
} = require("@saltcorn/data/db/connect");
|
|
10
10
|
const packagejson = require("../../package.json");
|
|
11
|
-
const {print_it} = require("../common");
|
|
12
|
-
|
|
11
|
+
const { print_it } = require("../common");
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* InfoCommand Class
|
|
@@ -26,7 +25,7 @@ class InfoCommand extends Command {
|
|
|
26
25
|
* @returns {Promise<void>}
|
|
27
26
|
*/
|
|
28
27
|
async run() {
|
|
29
|
-
const { flags } = this.parse(InfoCommand);
|
|
28
|
+
const { flags } = await this.parse(InfoCommand);
|
|
30
29
|
const db = require("@saltcorn/data/db");
|
|
31
30
|
const cliPath = __dirname;
|
|
32
31
|
const conn = getConnectObject();
|
|
@@ -45,9 +44,10 @@ class InfoCommand extends Command {
|
|
|
45
44
|
res.connectionError = e.message;
|
|
46
45
|
}
|
|
47
46
|
res.environmentVariables = {};
|
|
48
|
-
const envVars =
|
|
49
|
-
" "
|
|
50
|
-
|
|
47
|
+
const envVars =
|
|
48
|
+
"DATABASE_URL SQLITE_FILEPATH PGDATABASE PGUSER PGHOST PGPORT PGPASSWORD PGDATABASE SALTCORN_SESSION_SECRET SALTCORN_MULTI_TENANT SALTCORN_FILE_STORE SALTCORN_DEFAULT_SCHEMA SALTCORN_FIXED_CONFIGURATION SALTCORN_INHERIT_CONFIGURATION SALTCORN_SERVE_ADDITIONAL_DIR SALTCORN_NWORKERS SALTCORN_DISABLE_UPGRADE PUPPETEER_CHROMIUM_BIN".split(
|
|
49
|
+
" "
|
|
50
|
+
);
|
|
51
51
|
envVars.forEach((v) => {
|
|
52
52
|
if (process.env[v]) res.environmentVariables[v] = process.env[v];
|
|
53
53
|
else res.environmentVariables[v] = "";
|
|
@@ -69,7 +69,7 @@ Show configuration and file store paths
|
|
|
69
69
|
* @type {object}
|
|
70
70
|
*/
|
|
71
71
|
InfoCommand.flags = {
|
|
72
|
-
json:
|
|
72
|
+
json: Flags.boolean({ char: "j", description: "json format" }),
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
module.exports = InfoCommand;
|
package/src/commands/inspect.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/create-user
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const { cli } = require("cli-ux");
|
|
5
|
+
const { Command, Flags, Args, ux } = require("@oclif/core");
|
|
7
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
8
7
|
|
|
9
8
|
// todo update logic based on modify-user command
|
|
@@ -19,7 +18,7 @@ class InspectCommand extends Command {
|
|
|
19
18
|
async run() {
|
|
20
19
|
const User = require("@saltcorn/data/models/user");
|
|
21
20
|
|
|
22
|
-
const { flags, args } = this.parse(InspectCommand);
|
|
21
|
+
const { flags, args } = await this.parse(InspectCommand);
|
|
23
22
|
|
|
24
23
|
// init tenant
|
|
25
24
|
await init_some_tenants(flags.tenant);
|
|
@@ -53,23 +52,21 @@ InspectCommand.description = `Inspect an entity's JSON representation, or list e
|
|
|
53
52
|
* @type {object}
|
|
54
53
|
*/
|
|
55
54
|
InspectCommand.flags = {
|
|
56
|
-
tenant:
|
|
55
|
+
tenant: Flags.string({
|
|
57
56
|
char: "t",
|
|
58
57
|
description: "tenant",
|
|
59
58
|
}),
|
|
60
59
|
};
|
|
61
60
|
|
|
62
|
-
InspectCommand.args =
|
|
63
|
-
{
|
|
64
|
-
name: "type",
|
|
61
|
+
InspectCommand.args = {
|
|
62
|
+
type: Args.string({
|
|
65
63
|
required: true,
|
|
66
64
|
description: "Entity type",
|
|
67
65
|
options: ["view", "page", "trigger", "table"],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "name",
|
|
66
|
+
}),
|
|
67
|
+
name: Args.string({
|
|
71
68
|
description: "Entity name. If not supplied, list all names",
|
|
72
|
-
},
|
|
73
|
-
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
74
71
|
|
|
75
72
|
module.exports = InspectCommand;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/install-pack
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant } = require("../common");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ class InstallPackCommand extends Command {
|
|
|
16
16
|
* @returns {Promise<void>}
|
|
17
17
|
*/
|
|
18
18
|
async run() {
|
|
19
|
-
const { flags } = this.parse(InstallPackCommand);
|
|
19
|
+
const { flags } = await this.parse(InstallPackCommand);
|
|
20
20
|
const {
|
|
21
21
|
fetch_pack_by_name,
|
|
22
22
|
install_pack,
|
|
@@ -72,15 +72,15 @@ InstallPackCommand.description = `Install a pack or restore a snapshot`;
|
|
|
72
72
|
* @type {object}
|
|
73
73
|
*/
|
|
74
74
|
InstallPackCommand.flags = {
|
|
75
|
-
tenant:
|
|
75
|
+
tenant: Flags.string({
|
|
76
76
|
char: "t",
|
|
77
77
|
description: "tenant",
|
|
78
78
|
}),
|
|
79
|
-
name:
|
|
79
|
+
name: Flags.string({
|
|
80
80
|
char: "n",
|
|
81
81
|
description: "Pack name in store",
|
|
82
82
|
}),
|
|
83
|
-
file:
|
|
83
|
+
file: Flags.string({
|
|
84
84
|
char: "f",
|
|
85
85
|
description: "File with pack JSON",
|
|
86
86
|
}),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/install-plugin
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
|
@@ -17,7 +17,7 @@ class InstallPluginCommand extends Command {
|
|
|
17
17
|
* @returns {Promise<void>}
|
|
18
18
|
*/
|
|
19
19
|
async run() {
|
|
20
|
-
const { flags } = this.parse(InstallPluginCommand);
|
|
20
|
+
const { flags } = await this.parse(InstallPluginCommand);
|
|
21
21
|
const {
|
|
22
22
|
fetch_pack_by_name,
|
|
23
23
|
install_pack,
|
|
@@ -84,19 +84,19 @@ InstallPluginCommand.description = `Install a plugin`;
|
|
|
84
84
|
* @type {object}
|
|
85
85
|
*/
|
|
86
86
|
InstallPluginCommand.flags = {
|
|
87
|
-
tenant:
|
|
87
|
+
tenant: Flags.string({
|
|
88
88
|
char: "t",
|
|
89
89
|
description: "tenant",
|
|
90
90
|
}),
|
|
91
|
-
name:
|
|
91
|
+
name: Flags.string({
|
|
92
92
|
char: "n",
|
|
93
93
|
description: "Plugin name in store",
|
|
94
94
|
}),
|
|
95
|
-
directory:
|
|
95
|
+
directory: Flags.string({
|
|
96
96
|
char: "d",
|
|
97
97
|
description: "Directory with local plugin",
|
|
98
98
|
}),
|
|
99
|
-
unsafe:
|
|
99
|
+
unsafe: Flags.boolean({
|
|
100
100
|
char: "u",
|
|
101
101
|
description: "Allow unsafe plugins on tenants",
|
|
102
102
|
}),
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/list-tenants
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const db = require("@saltcorn/data/db");
|
|
7
|
-
const {print_table} = require("../common");
|
|
8
|
-
|
|
7
|
+
const { print_table } = require("../common");
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* ListTenantsCommand Class
|
|
@@ -17,19 +16,18 @@ class ListTenantsCommand extends Command {
|
|
|
17
16
|
* @returns {Promise<void>}
|
|
18
17
|
*/
|
|
19
18
|
async run() {
|
|
20
|
-
const {flags, args} = this.parse(ListTenantsCommand);
|
|
19
|
+
const { flags, args } = await this.parse(ListTenantsCommand);
|
|
21
20
|
|
|
22
21
|
const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
|
|
23
|
-
let tenantList = flags.tenant? [flags.tenant] : await getAllTenants();
|
|
22
|
+
let tenantList = flags.tenant ? [flags.tenant] : await getAllTenants();
|
|
24
23
|
|
|
25
24
|
let tenantDetails = new Object();
|
|
26
25
|
|
|
27
|
-
let index=0;
|
|
26
|
+
let index = 0;
|
|
28
27
|
for (const domain of tenantList) {
|
|
29
28
|
index++;
|
|
30
29
|
await db.runWithTenant(domain, async () => {
|
|
31
|
-
if (!flags.verbose)
|
|
32
|
-
tenantDetails[index] = { domain : domain };
|
|
30
|
+
if (!flags.verbose) tenantDetails[index] = { domain: domain };
|
|
33
31
|
else
|
|
34
32
|
tenantDetails[index] = {
|
|
35
33
|
domain: domain,
|
|
@@ -40,18 +38,29 @@ class ListTenantsCommand extends Command {
|
|
|
40
38
|
pages: await db.count("_sc_pages"),
|
|
41
39
|
files: await db.count("_sc_files"),
|
|
42
40
|
triggers: await db.count("_sc_triggers"),
|
|
43
|
-
tags: await
|
|
44
|
-
}
|
|
41
|
+
tags: await db.count("_sc_tags"),
|
|
42
|
+
};
|
|
45
43
|
});
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
// print
|
|
49
|
-
if(!flags.verbose)
|
|
50
|
-
print_table(tenantDetails,["domain"],flags.json);
|
|
47
|
+
if (!flags.verbose) print_table(tenantDetails, ["domain"], flags.json);
|
|
51
48
|
else
|
|
52
|
-
print_table(
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
print_table(
|
|
50
|
+
tenantDetails,
|
|
51
|
+
[
|
|
52
|
+
"domain",
|
|
53
|
+
"users",
|
|
54
|
+
"roles",
|
|
55
|
+
"tables",
|
|
56
|
+
"views",
|
|
57
|
+
"pages",
|
|
58
|
+
"files",
|
|
59
|
+
"triggers",
|
|
60
|
+
"tags",
|
|
61
|
+
],
|
|
62
|
+
flags.json
|
|
63
|
+
);
|
|
55
64
|
this.exit(0);
|
|
56
65
|
}
|
|
57
66
|
}
|
|
@@ -67,24 +76,23 @@ ListTenantsCommand.description = `List tenants in CSV format`;
|
|
|
67
76
|
*/
|
|
68
77
|
ListTenantsCommand.help = "Extra help here";
|
|
69
78
|
|
|
70
|
-
|
|
71
79
|
/**
|
|
72
80
|
* @type {object}
|
|
73
81
|
*/
|
|
74
82
|
ListTenantsCommand.flags = {
|
|
75
|
-
tenant:
|
|
83
|
+
tenant: Flags.string({
|
|
76
84
|
name: "tenant",
|
|
77
85
|
char: "t",
|
|
78
86
|
description: "tenant",
|
|
79
87
|
required: false,
|
|
80
88
|
}),
|
|
81
|
-
verbose:
|
|
89
|
+
verbose: Flags.boolean({
|
|
82
90
|
name: "verbose",
|
|
83
91
|
char: "v",
|
|
84
92
|
description: "verbose output",
|
|
85
93
|
required: false,
|
|
86
94
|
}),
|
|
87
|
-
json:
|
|
95
|
+
json: Flags.boolean({ char: "j", description: "json format" }),
|
|
88
96
|
};
|
|
89
97
|
|
|
90
98
|
module.exports = ListTenantsCommand;
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/run-trigger
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const {
|
|
7
|
-
|
|
5
|
+
const { Command, Flags, ux } = require("@oclif/core");
|
|
6
|
+
const {
|
|
7
|
+
maybe_as_tenant,
|
|
8
|
+
init_some_tenants,
|
|
9
|
+
print_table,
|
|
10
|
+
} = require("../common");
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* ListTriggerCommand Class
|
|
@@ -16,10 +19,10 @@ class ListTriggersCommand extends Command {
|
|
|
16
19
|
* @returns {Promise<void>}
|
|
17
20
|
*/
|
|
18
21
|
async run() {
|
|
19
|
-
const {flags, args} = this.parse(ListTriggersCommand);
|
|
22
|
+
const { flags, args } = await this.parse(ListTriggersCommand);
|
|
20
23
|
await init_some_tenants(flags.tenant);
|
|
21
24
|
|
|
22
|
-
const {mockReqRes} = require("@saltcorn/data/tests/mocks");
|
|
25
|
+
const { mockReqRes } = require("@saltcorn/data/tests/mocks");
|
|
23
26
|
const Trigger = require(`@saltcorn/data/models/trigger`);
|
|
24
27
|
//const that = this;
|
|
25
28
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
@@ -28,16 +31,25 @@ class ListTriggersCommand extends Command {
|
|
|
28
31
|
console.log(`There are no triggers`);
|
|
29
32
|
this.exit(1);
|
|
30
33
|
}
|
|
31
|
-
if(!flags.verbose){
|
|
32
|
-
print_table(triggers,["name"], flags.json);
|
|
34
|
+
if (!flags.verbose) {
|
|
35
|
+
print_table(triggers, ["name"], flags.json);
|
|
36
|
+
} else {
|
|
37
|
+
print_table(
|
|
38
|
+
triggers,
|
|
39
|
+
[
|
|
40
|
+
"id",
|
|
41
|
+
"name",
|
|
42
|
+
"action",
|
|
43
|
+
"when_trigger",
|
|
44
|
+
"min_role",
|
|
45
|
+
"channel",
|
|
46
|
+
"table_id",
|
|
47
|
+
"table_name",
|
|
48
|
+
"description",
|
|
49
|
+
],
|
|
50
|
+
flags.json
|
|
51
|
+
);
|
|
33
52
|
}
|
|
34
|
-
else {
|
|
35
|
-
print_table(triggers,
|
|
36
|
-
["id","name","action","when_trigger","min_role",
|
|
37
|
-
"channel","table_id","table_name","description"],
|
|
38
|
-
flags.json);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
53
|
});
|
|
42
54
|
this.exit(0);
|
|
43
55
|
}
|
|
@@ -47,24 +59,23 @@ class ListTriggersCommand extends Command {
|
|
|
47
59
|
*/
|
|
48
60
|
ListTriggersCommand.description = `List triggers`;
|
|
49
61
|
|
|
50
|
-
|
|
51
62
|
/**
|
|
52
63
|
* @type {object}
|
|
53
64
|
*/
|
|
54
65
|
ListTriggersCommand.flags = {
|
|
55
|
-
tenant:
|
|
66
|
+
tenant: Flags.string({
|
|
56
67
|
name: "tenant",
|
|
57
68
|
char: "t",
|
|
58
69
|
description: "tenant",
|
|
59
70
|
required: false,
|
|
60
71
|
}),
|
|
61
|
-
verbose:
|
|
72
|
+
verbose: Flags.boolean({
|
|
62
73
|
name: "verbose",
|
|
63
74
|
char: "v",
|
|
64
75
|
description: "verbose output",
|
|
65
76
|
required: false,
|
|
66
77
|
}),
|
|
67
|
-
json:
|
|
78
|
+
json: Flags.boolean({ char: "j", description: "json format" }),
|
|
68
79
|
};
|
|
69
80
|
|
|
70
81
|
module.exports = ListTriggersCommand;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/run-trigger
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const { cli } = require("cli-ux");
|
|
5
|
+
const { Command, Flags, ux } = require("@oclif/core");
|
|
7
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -16,10 +15,10 @@ class ListUsersCommand extends Command {
|
|
|
16
15
|
* @returns {Promise<void>}
|
|
17
16
|
*/
|
|
18
17
|
async run() {
|
|
19
|
-
const {flags, args} = this.parse(ListUsersCommand);
|
|
18
|
+
const { flags, args } = await this.parse(ListUsersCommand);
|
|
20
19
|
await init_some_tenants(flags.tenant);
|
|
21
20
|
|
|
22
|
-
const {mockReqRes} = require("@saltcorn/data/tests/mocks");
|
|
21
|
+
const { mockReqRes } = require("@saltcorn/data/tests/mocks");
|
|
23
22
|
const User = require(`@saltcorn/data/models/user`);
|
|
24
23
|
//const that = this;
|
|
25
24
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
@@ -29,17 +28,11 @@ class ListUsersCommand extends Command {
|
|
|
29
28
|
this.exit(1);
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
if(!flags.verbose){
|
|
33
|
-
console.table(users,
|
|
34
|
-
|
|
35
|
-
);
|
|
31
|
+
if (!flags.verbose) {
|
|
32
|
+
console.table(users, ["email"]);
|
|
33
|
+
} else {
|
|
34
|
+
console.table(users, ["id", "email", "language", "role_id"]);
|
|
36
35
|
}
|
|
37
|
-
else {
|
|
38
|
-
console.table(users,
|
|
39
|
-
["id","email","language","role_id"]
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
36
|
});
|
|
44
37
|
this.exit(0);
|
|
45
38
|
}
|
|
@@ -57,13 +50,13 @@ ListUsersCommand.help = `List users`;
|
|
|
57
50
|
* @type {object}
|
|
58
51
|
*/
|
|
59
52
|
ListUsersCommand.flags = {
|
|
60
|
-
tenant:
|
|
53
|
+
tenant: Flags.string({
|
|
61
54
|
name: "tenant",
|
|
62
55
|
char: "t",
|
|
63
56
|
description: "tenant",
|
|
64
57
|
required: false,
|
|
65
58
|
}),
|
|
66
|
-
verbose:
|
|
59
|
+
verbose: Flags.boolean({
|
|
67
60
|
name: "verbose",
|
|
68
61
|
char: "v",
|
|
69
62
|
description: "verbose output",
|
package/src/commands/migrate.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/migrate
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const db = require("@saltcorn/data/db");
|
|
7
7
|
const { eachTenant } = require("@saltcorn/admin-models/models/tenant");
|
|
8
8
|
// todo add dryrun mode
|