@saltcorn/cli 1.0.0-beta.1 → 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 +11899 -29030
- 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
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// todo support for users without emails (using user.id)
|
|
7
|
-
const { Command,
|
|
8
|
-
const { cli } = require("cli-ux");
|
|
7
|
+
const { Command, Flags, Args, ux } = require("@oclif/core");
|
|
9
8
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -20,8 +19,7 @@ class ModifyUserCommand extends Command {
|
|
|
20
19
|
async run() {
|
|
21
20
|
const User = require("@saltcorn/data/models/user");
|
|
22
21
|
|
|
23
|
-
const { args } = this.parse(ModifyUserCommand);
|
|
24
|
-
const { flags } = this.parse(ModifyUserCommand);
|
|
22
|
+
const { args, flags } = await this.parse(ModifyUserCommand);
|
|
25
23
|
|
|
26
24
|
if (flags.admin && flags.role && flags.role !== "admin") {
|
|
27
25
|
console.error("Error: specify at most one of admin and role");
|
|
@@ -49,7 +47,7 @@ class ModifyUserCommand extends Command {
|
|
|
49
47
|
let email;
|
|
50
48
|
if (flags.email) email = flags.email;
|
|
51
49
|
else if (flags.imode)
|
|
52
|
-
email = await
|
|
50
|
+
email = await ux.prompt("New Email address", {
|
|
53
51
|
default: args.user_email,
|
|
54
52
|
});
|
|
55
53
|
if (email === args.user_email) email = undefined; // little trick - we won't update email if it already same
|
|
@@ -64,7 +62,7 @@ class ModifyUserCommand extends Command {
|
|
|
64
62
|
let password;
|
|
65
63
|
if (flags.password) password = flags.password;
|
|
66
64
|
else if (flags.imode)
|
|
67
|
-
password = await
|
|
65
|
+
password = await ux.prompt("New Password", { type: "hide" });
|
|
68
66
|
if (password)
|
|
69
67
|
if (User.unacceptable_password_reason(password)) {
|
|
70
68
|
console.error(
|
|
@@ -113,9 +111,12 @@ class ModifyUserCommand extends Command {
|
|
|
113
111
|
/**
|
|
114
112
|
* @type {object}
|
|
115
113
|
*/
|
|
116
|
-
ModifyUserCommand.args =
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
ModifyUserCommand.args = {
|
|
115
|
+
user_email: Args.string({
|
|
116
|
+
required: true,
|
|
117
|
+
description: "User to modify",
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
122
|
* @type {string}
|
|
@@ -145,24 +146,24 @@ NOTE that -a and -r role (--role=role) can give conflict.
|
|
|
145
146
|
* @type {object}
|
|
146
147
|
*/
|
|
147
148
|
ModifyUserCommand.flags = {
|
|
148
|
-
admin:
|
|
149
|
-
tenant:
|
|
149
|
+
admin: Flags.boolean({ char: "a", description: "make user be Admin" }),
|
|
150
|
+
tenant: Flags.string({
|
|
150
151
|
char: "t",
|
|
151
152
|
description: "tenant",
|
|
152
153
|
}),
|
|
153
|
-
email:
|
|
154
|
+
email: Flags.string({
|
|
154
155
|
char: "e",
|
|
155
156
|
description: "new email",
|
|
156
157
|
}),
|
|
157
|
-
role:
|
|
158
|
+
role: Flags.string({
|
|
158
159
|
char: "r",
|
|
159
160
|
description: "new role (can conflict with -a option)",
|
|
160
161
|
}),
|
|
161
|
-
password:
|
|
162
|
+
password: Flags.string({
|
|
162
163
|
char: "p",
|
|
163
164
|
description: "new password",
|
|
164
165
|
}),
|
|
165
|
-
imode:
|
|
166
|
+
imode: Flags.boolean({ char: "i", description: "interactive mode" }),
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
module.exports = ModifyUserCommand;
|
package/src/commands/plugins.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/plugins
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Plugins list and update command
|
|
@@ -19,7 +19,7 @@ class PluginsCommand extends Command {
|
|
|
19
19
|
const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
|
|
20
20
|
const Plugin = require("@saltcorn/data/models/plugin");
|
|
21
21
|
var plugins = [];
|
|
22
|
-
const { flags } = this.parse(PluginsCommand);
|
|
22
|
+
const { flags } = await this.parse(PluginsCommand);
|
|
23
23
|
|
|
24
24
|
const tenantList = [
|
|
25
25
|
db.connectObj.default_schema,
|
|
@@ -109,19 +109,19 @@ class PluginsCommand extends Command {
|
|
|
109
109
|
*/
|
|
110
110
|
PluginsCommand.flags = {
|
|
111
111
|
//list: flags.boolean({ char: "l", description: "List" }),
|
|
112
|
-
upgrade:
|
|
113
|
-
dryRun:
|
|
114
|
-
verbose:
|
|
112
|
+
upgrade: Flags.boolean({ char: "u", description: "Upgrade" }),
|
|
113
|
+
dryRun: Flags.boolean({ char: "d", description: "Upgrade dry-run" }),
|
|
114
|
+
verbose: Flags.boolean({
|
|
115
115
|
char: "v",
|
|
116
116
|
description: "Verbose output",
|
|
117
117
|
default: false,
|
|
118
118
|
}),
|
|
119
|
-
force:
|
|
119
|
+
force: Flags.boolean({
|
|
120
120
|
char: "f",
|
|
121
121
|
description: "Force update",
|
|
122
122
|
default: false,
|
|
123
123
|
}),
|
|
124
|
-
name:
|
|
124
|
+
name: Flags.string({
|
|
125
125
|
char: "n",
|
|
126
126
|
description: "Plugin name",
|
|
127
127
|
}),
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/reset-schema
|
|
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 } = require("../common");
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -18,13 +17,13 @@ class ResetCommand extends Command {
|
|
|
18
17
|
async run() {
|
|
19
18
|
const reset = require("@saltcorn/data/db/reset_schema");
|
|
20
19
|
const db = require("@saltcorn/data/db");
|
|
21
|
-
const { flags } = this.parse(ResetCommand);
|
|
20
|
+
const { flags } = await this.parse(ResetCommand);
|
|
22
21
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
23
22
|
const schema = db.getTenantSchema();
|
|
24
23
|
if (flags.force) {
|
|
25
24
|
await reset(false, schema);
|
|
26
25
|
} else {
|
|
27
|
-
const ans = await
|
|
26
|
+
const ans = await ux.confirm(
|
|
28
27
|
`This will wipe all data from database "${
|
|
29
28
|
db.isSQLite ? "SQLite" : db.connectObj.database + "." + schema
|
|
30
29
|
}".\nContinue (y/n)?`
|
|
@@ -57,8 +56,8 @@ This will delete all existing information
|
|
|
57
56
|
* @type {object}
|
|
58
57
|
*/
|
|
59
58
|
ResetCommand.flags = {
|
|
60
|
-
force:
|
|
61
|
-
tenant:
|
|
59
|
+
force: Flags.boolean({ char: "f", description: "force command execution" }),
|
|
60
|
+
tenant: Flags.string({
|
|
62
61
|
char: "t",
|
|
63
62
|
description: "tenant",
|
|
64
63
|
}),
|
package/src/commands/restore.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/restore
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const { spawnSync } = require("child_process");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const { maybe_as_tenant } = require("../common");
|
|
@@ -60,7 +60,7 @@ class RestoreCommand extends Command {
|
|
|
60
60
|
* @returns {Promise<void>}
|
|
61
61
|
*/
|
|
62
62
|
async run() {
|
|
63
|
-
const { args, flags } = this.parse(RestoreCommand);
|
|
63
|
+
const { args, flags } = await this.parse(RestoreCommand);
|
|
64
64
|
switch (path.extname(args.file)) {
|
|
65
65
|
case ".sqlc":
|
|
66
66
|
if (flags.tenant) {
|
|
@@ -82,9 +82,9 @@ class RestoreCommand extends Command {
|
|
|
82
82
|
/**
|
|
83
83
|
* @type {object}
|
|
84
84
|
*/
|
|
85
|
-
RestoreCommand.args =
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
RestoreCommand.args = {
|
|
86
|
+
file: Args.string({ required: true, description: "backup file to restore" }),
|
|
87
|
+
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* @type {string}
|
|
@@ -100,7 +100,7 @@ RestoreCommand.help = `Restore a previously backed up database (zip or sqlc form
|
|
|
100
100
|
* @type {object}
|
|
101
101
|
*/
|
|
102
102
|
RestoreCommand.flags = {
|
|
103
|
-
tenant:
|
|
103
|
+
tenant: Flags.string({
|
|
104
104
|
char: "t",
|
|
105
105
|
description: "tenant",
|
|
106
106
|
}),
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/rm-tenant
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const {cli} = require("cli-ux");
|
|
5
|
+
const { Command, Flags, ux } = require("@oclif/core");
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* RmTenantCommand Class
|
|
@@ -15,15 +14,14 @@ class RmTenantCommand extends Command {
|
|
|
15
14
|
* @returns {Promise<void>}
|
|
16
15
|
*/
|
|
17
16
|
async run() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const { flags } = this.parse(RmTenantCommand);
|
|
17
|
+
const { flags } = await this.parse(RmTenantCommand);
|
|
21
18
|
|
|
22
19
|
const { deleteTenant } = require("@saltcorn/admin-models/models/tenant");
|
|
23
20
|
|
|
24
21
|
if (!flags.force) {
|
|
25
|
-
const ans = await
|
|
26
|
-
`This will delete tenant ${flags.tenant}. Attention! All tenant data will be lost!\nContinue (y/n)?`
|
|
22
|
+
const ans = await ux.confirm(
|
|
23
|
+
`This will delete tenant ${flags.tenant}. Attention! All tenant data will be lost!\nContinue (y/n)?`
|
|
24
|
+
);
|
|
27
25
|
if (!ans) {
|
|
28
26
|
console.log(`Success: Command execution canceled`);
|
|
29
27
|
this.exit(1);
|
|
@@ -63,8 +61,8 @@ It recommended to make backup of tenant before perform this command.
|
|
|
63
61
|
* @type {object}
|
|
64
62
|
*/
|
|
65
63
|
RmTenantCommand.flags = {
|
|
66
|
-
force:
|
|
67
|
-
tenant:
|
|
64
|
+
force: Flags.boolean({ char: "f", description: "force command execution" }),
|
|
65
|
+
tenant: Flags.string({
|
|
68
66
|
char: "t",
|
|
69
67
|
description: "tenant",
|
|
70
68
|
required: true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/run-benchmark
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const si = require("systeminformation");
|
|
7
7
|
const fetch = require("node-fetch");
|
|
8
8
|
|
|
@@ -11,16 +11,16 @@ const { sleep } = require("../common");
|
|
|
11
11
|
const packagejson = require("../../package.json");
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {string} s
|
|
14
|
+
*
|
|
15
|
+
* @param {string} s
|
|
16
16
|
* @returns {number}
|
|
17
17
|
*/
|
|
18
18
|
const parseMillisecs = (s) =>
|
|
19
19
|
s.endsWith("ms") ? parseFloat(s) : parseFloat(s) * 1000;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {*} args
|
|
22
|
+
*
|
|
23
|
+
* @param {*} args
|
|
24
24
|
* @returns {Promise<object>}
|
|
25
25
|
*/
|
|
26
26
|
const wrk = (args) =>
|
|
@@ -37,8 +37,8 @@ const wrk = (args) =>
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {string} s
|
|
40
|
+
*
|
|
41
|
+
* @param {string} s
|
|
42
42
|
* @returns {string}
|
|
43
43
|
*/
|
|
44
44
|
const ensure_no_final_slash = (s) => (s.endsWith("/") ? s.slice(0, -1) : s);
|
|
@@ -56,7 +56,7 @@ class RunBenchmarkCommand extends Command {
|
|
|
56
56
|
const {
|
|
57
57
|
args: { baseurl },
|
|
58
58
|
flags: { token, delay, benchmark },
|
|
59
|
-
} = this.parse(RunBenchmarkCommand);
|
|
59
|
+
} = await this.parse(RunBenchmarkCommand);
|
|
60
60
|
const File = require("@saltcorn/data/models/file");
|
|
61
61
|
const file = await File.findOne({ filename: "rick.png" });
|
|
62
62
|
if (!file) {
|
|
@@ -138,9 +138,12 @@ class RunBenchmarkCommand extends Command {
|
|
|
138
138
|
/**
|
|
139
139
|
* @type {object}
|
|
140
140
|
*/
|
|
141
|
-
RunBenchmarkCommand.args =
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
RunBenchmarkCommand.args = {
|
|
142
|
+
baseurl: Args.string({
|
|
143
|
+
required: false,
|
|
144
|
+
description: "Base URL",
|
|
145
|
+
}),
|
|
146
|
+
};
|
|
144
147
|
|
|
145
148
|
/**
|
|
146
149
|
* @type {string}
|
|
@@ -151,15 +154,15 @@ RunBenchmarkCommand.description = `Run benchmark`;
|
|
|
151
154
|
* @type {object}
|
|
152
155
|
*/
|
|
153
156
|
RunBenchmarkCommand.flags = {
|
|
154
|
-
token:
|
|
157
|
+
token: Flags.string({
|
|
155
158
|
char: "t",
|
|
156
159
|
description: "API Token for reporting results",
|
|
157
160
|
}),
|
|
158
|
-
benchmark:
|
|
161
|
+
benchmark: Flags.string({
|
|
159
162
|
char: "b",
|
|
160
163
|
description: "Which benchmark to run",
|
|
161
164
|
}),
|
|
162
|
-
delay:
|
|
165
|
+
delay: Flags.integer({
|
|
163
166
|
char: "d",
|
|
164
167
|
description: "delay between runs (s)",
|
|
165
168
|
default: 30,
|
package/src/commands/run-js.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/run-js
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const { cli } = require("cli-ux");
|
|
5
|
+
const { Command, Flags, ux } = require("@oclif/core");
|
|
7
6
|
const {
|
|
8
7
|
maybe_as_tenant,
|
|
9
8
|
init_some_tenants,
|
|
@@ -24,7 +23,7 @@ class RunJSCommand extends Command {
|
|
|
24
23
|
* @returns {Promise<void>}
|
|
25
24
|
*/
|
|
26
25
|
async run() {
|
|
27
|
-
const { flags, args } = this.parse(RunJSCommand);
|
|
26
|
+
const { flags, args } = await this.parse(RunJSCommand);
|
|
28
27
|
await init_some_tenants(flags.tenant);
|
|
29
28
|
|
|
30
29
|
const that = this;
|
|
@@ -58,17 +57,17 @@ RunJSCommand.description = `Run javascript code`;
|
|
|
58
57
|
* @type {object}
|
|
59
58
|
*/
|
|
60
59
|
RunJSCommand.flags = {
|
|
61
|
-
tenant:
|
|
60
|
+
tenant: Flags.string({
|
|
62
61
|
name: "tenant",
|
|
63
62
|
char: "t",
|
|
64
63
|
description: "tenant name",
|
|
65
64
|
}),
|
|
66
|
-
code:
|
|
65
|
+
code: Flags.string({
|
|
67
66
|
name: "code",
|
|
68
67
|
char: "c",
|
|
69
68
|
description: "js code",
|
|
70
69
|
}),
|
|
71
|
-
file:
|
|
70
|
+
file: Flags.string({
|
|
72
71
|
name: "file",
|
|
73
72
|
char: "f",
|
|
74
73
|
description: "path to script file",
|
package/src/commands/run-sql.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/run-sql
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
6
|
-
const { cli } = require("cli-ux");
|
|
5
|
+
const { Command, Flags, ux } = require("@oclif/core");
|
|
7
6
|
const {
|
|
8
7
|
maybe_as_tenant,
|
|
9
8
|
init_some_tenants,
|
|
@@ -21,7 +20,7 @@ class RunSQLCommand extends Command {
|
|
|
21
20
|
* @returns {Promise<void>}
|
|
22
21
|
*/
|
|
23
22
|
async run() {
|
|
24
|
-
const { flags, args } = this.parse(RunSQLCommand);
|
|
23
|
+
const { flags, args } = await this.parse(RunSQLCommand);
|
|
25
24
|
|
|
26
25
|
if (!flags.sql && !flags.file) {
|
|
27
26
|
console.log(
|
|
@@ -79,17 +78,17 @@ RunSQLCommand.description = `Run sql expression`;
|
|
|
79
78
|
* @type {object}
|
|
80
79
|
*/
|
|
81
80
|
RunSQLCommand.flags = {
|
|
82
|
-
tenant:
|
|
81
|
+
tenant: Flags.string({
|
|
83
82
|
name: "tenant",
|
|
84
83
|
char: "t",
|
|
85
84
|
description: "tenant name",
|
|
86
85
|
}),
|
|
87
|
-
sql:
|
|
86
|
+
sql: Flags.string({
|
|
88
87
|
name: "sql",
|
|
89
88
|
char: "s",
|
|
90
89
|
description: "sql statement",
|
|
91
90
|
}),
|
|
92
|
-
file:
|
|
91
|
+
file: Flags.string({
|
|
93
92
|
name: "file",
|
|
94
93
|
char: "f",
|
|
95
94
|
description: "path to sql file name",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @category saltcorn-cli
|
|
5
5
|
* @module commands/run-tests
|
|
6
6
|
*/
|
|
7
|
-
const { Command,
|
|
7
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
8
8
|
|
|
9
9
|
const { spawnSync, spawn } = require("child_process");
|
|
10
10
|
const path = require("path");
|
|
@@ -121,7 +121,7 @@ class RunTestsCommand extends Command {
|
|
|
121
121
|
* @returns {Promise<void>}
|
|
122
122
|
*/
|
|
123
123
|
async run() {
|
|
124
|
-
const { args, flags } = this.parse(RunTestsCommand);
|
|
124
|
+
const { args, flags } = await this.parse(RunTestsCommand);
|
|
125
125
|
this.validateCall(args, flags);
|
|
126
126
|
let env;
|
|
127
127
|
|
|
@@ -195,9 +195,11 @@ class RunTestsCommand extends Command {
|
|
|
195
195
|
/**
|
|
196
196
|
* @type {object}
|
|
197
197
|
*/
|
|
198
|
-
RunTestsCommand.args =
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
RunTestsCommand.args = {
|
|
199
|
+
package: Args.string({
|
|
200
|
+
description: "which package to run tests for",
|
|
201
|
+
}),
|
|
202
|
+
};
|
|
201
203
|
|
|
202
204
|
/**
|
|
203
205
|
* @type {string}
|
|
@@ -208,27 +210,27 @@ RunTestsCommand.description = `Run test suites`;
|
|
|
208
210
|
* @type {object}
|
|
209
211
|
*/
|
|
210
212
|
RunTestsCommand.flags = {
|
|
211
|
-
coverage:
|
|
212
|
-
listTests:
|
|
213
|
-
verbose:
|
|
214
|
-
detectOpenHandles:
|
|
213
|
+
coverage: Flags.boolean({ char: "c", description: "Coverage" }),
|
|
214
|
+
listTests: Flags.boolean({ char: "l", description: "List tests" }),
|
|
215
|
+
verbose: Flags.boolean({ char: "v", description: "Verbose" }),
|
|
216
|
+
detectOpenHandles: Flags.boolean({
|
|
215
217
|
char: "d",
|
|
216
218
|
description: "Detect Open Handles",
|
|
217
219
|
}),
|
|
218
|
-
testFilter:
|
|
220
|
+
testFilter: Flags.string({
|
|
219
221
|
char: "t",
|
|
220
222
|
description: "Filter tests by suite or test name",
|
|
221
223
|
}),
|
|
222
|
-
watch:
|
|
224
|
+
watch: Flags.boolean({
|
|
223
225
|
string: "watch",
|
|
224
226
|
description:
|
|
225
227
|
"Watch files for changes and rerun tests related to changed files.",
|
|
226
228
|
}),
|
|
227
|
-
watchAll:
|
|
229
|
+
watchAll: Flags.boolean({
|
|
228
230
|
string: "watchAll",
|
|
229
231
|
description: "Watch files for changes and rerun all tests.",
|
|
230
232
|
}),
|
|
231
|
-
database:
|
|
233
|
+
database: Flags.string({
|
|
232
234
|
string: "database",
|
|
233
235
|
description: "Run on specified database. Default is saltcorn_test",
|
|
234
236
|
}),
|
|
@@ -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, Args, ux } = require("@oclif/core");
|
|
7
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -16,7 +15,7 @@ class RunTriggerCommand extends Command {
|
|
|
16
15
|
* @returns {Promise<void>}
|
|
17
16
|
*/
|
|
18
17
|
async run() {
|
|
19
|
-
const { flags, args } = this.parse(RunTriggerCommand);
|
|
18
|
+
const { flags, args } = await this.parse(RunTriggerCommand);
|
|
20
19
|
await init_some_tenants(flags.tenant);
|
|
21
20
|
|
|
22
21
|
const { mockReqRes } = require("@saltcorn/data/tests/mocks");
|
|
@@ -37,16 +36,22 @@ class RunTriggerCommand extends Command {
|
|
|
37
36
|
*/
|
|
38
37
|
RunTriggerCommand.description = `Run a trigger`;
|
|
39
38
|
|
|
40
|
-
RunTriggerCommand.args =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
RunTriggerCommand.args = {
|
|
40
|
+
trigger: Args.string({
|
|
41
|
+
required: true,
|
|
42
|
+
description: "trigger name",
|
|
43
|
+
}),
|
|
44
|
+
// tenant: Args.string({
|
|
45
|
+
// required: false,
|
|
46
|
+
// description: "tenant",
|
|
47
|
+
// }),
|
|
48
|
+
};
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* @type {object}
|
|
47
52
|
*/
|
|
48
53
|
RunTriggerCommand.flags = {
|
|
49
|
-
tenant:
|
|
54
|
+
tenant: Flags.string({
|
|
50
55
|
name: "tenant",
|
|
51
56
|
char: "t",
|
|
52
57
|
description: "tenant",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/scheduler
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ScheduleCommand Class
|
|
@@ -14,7 +14,7 @@ class ScheduleCommand extends Command {
|
|
|
14
14
|
* @returns {Promise<void>}
|
|
15
15
|
*/
|
|
16
16
|
async run() {
|
|
17
|
-
const { flags } = this.parse(ScheduleCommand);
|
|
17
|
+
const { flags } = await this.parse(ScheduleCommand);
|
|
18
18
|
if (flags.verbose) {
|
|
19
19
|
const db = require("@saltcorn/data/db");
|
|
20
20
|
db.set_sql_logging();
|
|
@@ -33,7 +33,7 @@ ScheduleCommand.description = `Run the Saltcorn scheduler`;
|
|
|
33
33
|
* @type {object}
|
|
34
34
|
*/
|
|
35
35
|
ScheduleCommand.flags = {
|
|
36
|
-
verbose:
|
|
36
|
+
verbose: Flags.boolean({ char: "v", description: "Verbose" }),
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
module.exports = ScheduleCommand;
|
package/src/commands/serve.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/serve
|
|
4
4
|
*/
|
|
5
|
-
const { Command,
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const si = require("systeminformation");
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -15,7 +15,7 @@ class ServeCommand extends Command {
|
|
|
15
15
|
* @returns {Promise<void>}
|
|
16
16
|
*/
|
|
17
17
|
async run() {
|
|
18
|
-
const { flags } = this.parse(ServeCommand);
|
|
18
|
+
const { flags } = await this.parse(ServeCommand);
|
|
19
19
|
const cpu = await si.cpu();
|
|
20
20
|
const serveArgs = {
|
|
21
21
|
defaultNCPUs: cpu.performanceCores || cpu.physicalCores,
|
|
@@ -61,18 +61,18 @@ ServeCommand.description = `Start the Saltcorn server`;
|
|
|
61
61
|
* @type {object}
|
|
62
62
|
*/
|
|
63
63
|
ServeCommand.flags = {
|
|
64
|
-
port:
|
|
65
|
-
verbose:
|
|
66
|
-
watchReaper:
|
|
67
|
-
dev:
|
|
64
|
+
port: Flags.integer({ char: "p", description: "port", default: 3000 }),
|
|
65
|
+
verbose: Flags.boolean({ char: "v", description: "Verbose" }),
|
|
66
|
+
watchReaper: Flags.boolean({ char: "r", description: "Watch reaper" }),
|
|
67
|
+
dev: Flags.boolean({
|
|
68
68
|
string: "dev",
|
|
69
69
|
char: "d",
|
|
70
70
|
description: "Run in dev mode and re-start on file changes",
|
|
71
71
|
}),
|
|
72
|
-
addschema:
|
|
73
|
-
nomigrate:
|
|
74
|
-
noscheduler:
|
|
75
|
-
subdomain_offset:
|
|
72
|
+
addschema: Flags.boolean({ char: "a", description: "Add schema if missing" }),
|
|
73
|
+
nomigrate: Flags.boolean({ char: "n", description: "No migrations" }),
|
|
74
|
+
noscheduler: Flags.boolean({ char: "s", description: "No scheduler" }),
|
|
75
|
+
subdomain_offset: Flags.integer({
|
|
76
76
|
string: "subdomain_offset",
|
|
77
77
|
description:
|
|
78
78
|
"Number of parts to remove to access subdomain in 'multi_tenant' mode",
|
package/src/commands/set-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 {
|
|
8
7
|
maybe_as_tenant,
|
|
9
8
|
init_some_tenants,
|
|
@@ -20,7 +19,7 @@ class SetCfgCommand extends Command {
|
|
|
20
19
|
* @returns {Promise<void>}
|
|
21
20
|
*/
|
|
22
21
|
async run() {
|
|
23
|
-
const { args, flags } = this.parse(SetCfgCommand);
|
|
22
|
+
const { args, flags } = await this.parse(SetCfgCommand);
|
|
24
23
|
if (args.key && !!args.value + !!flags.stdin + !!flags.file !== 1) {
|
|
25
24
|
console.error(
|
|
26
25
|
"Must supply one value, as argument, stdin (with -i), or file (with -f)"
|
|
@@ -68,31 +67,33 @@ SetCfgCommand.description = `Set a configuration value. The supplied value (argu
|
|
|
68
67
|
/**
|
|
69
68
|
* @type {object[]}
|
|
70
69
|
*/
|
|
71
|
-
SetCfgCommand.args =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
SetCfgCommand.args = {
|
|
71
|
+
key: Args.string({
|
|
72
|
+
required: false,
|
|
73
|
+
description: "Configuration key",
|
|
74
|
+
}),
|
|
75
|
+
value: Args.string({
|
|
75
76
|
description: "Configuration value (JSON or string)",
|
|
76
|
-
},
|
|
77
|
-
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* @type {object}
|
|
81
82
|
*/
|
|
82
83
|
SetCfgCommand.flags = {
|
|
83
|
-
tenant:
|
|
84
|
+
tenant: Flags.string({
|
|
84
85
|
char: "t",
|
|
85
86
|
description: "tenant",
|
|
86
87
|
}),
|
|
87
|
-
plugin:
|
|
88
|
+
plugin: Flags.string({
|
|
88
89
|
char: "p",
|
|
89
90
|
description: "plugin",
|
|
90
91
|
}),
|
|
91
|
-
file:
|
|
92
|
+
file: Flags.string({
|
|
92
93
|
char: "f",
|
|
93
94
|
description: "file",
|
|
94
95
|
}),
|
|
95
|
-
stdin:
|
|
96
|
+
stdin: Flags.boolean({
|
|
96
97
|
char: "i",
|
|
97
98
|
description: "read value from stdin",
|
|
98
99
|
}),
|