@saltcorn/cli 1.0.0-beta.1 → 1.0.0-beta.10

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.
Files changed (51) hide show
  1. package/README.md +394 -294
  2. package/bin/saltcorn +4 -4
  3. package/npm-shrinkwrap.json +11307 -23249
  4. package/oclif.manifest.json +1619 -1
  5. package/package.json +14 -25
  6. package/src/commands/add-schema.js +7 -8
  7. package/src/commands/backup.js +6 -6
  8. package/src/commands/build-app.js +26 -26
  9. package/src/commands/build-cordova-builder.js +3 -3
  10. package/src/commands/configuration-check-backups.js +7 -9
  11. package/src/commands/configuration-check.js +4 -5
  12. package/src/commands/create-tenant.js +11 -9
  13. package/src/commands/create-user.js +9 -10
  14. package/src/commands/delete-tenants.js +1 -1
  15. package/src/commands/delete-user.js +12 -10
  16. package/src/commands/dev/localize-plugin.js +12 -10
  17. package/src/commands/dev/make-migration.js +1 -1
  18. package/src/commands/dev/plugin-test.js +6 -6
  19. package/src/commands/dev/post-release.js +6 -7
  20. package/src/commands/dev/release.js +14 -7
  21. package/src/commands/dev/test-plugin.js +8 -5
  22. package/src/commands/fixtures.js +4 -4
  23. package/src/commands/get-cfg.js +14 -12
  24. package/src/commands/info.js +8 -8
  25. package/src/commands/inspect.js +9 -12
  26. package/src/commands/install-pack.js +5 -5
  27. package/src/commands/install-plugin.js +6 -6
  28. package/src/commands/list-tenants.js +27 -19
  29. package/src/commands/list-triggers.js +29 -18
  30. package/src/commands/list-users.js +9 -16
  31. package/src/commands/migrate.js +1 -1
  32. package/src/commands/modify-user.js +16 -15
  33. package/src/commands/plugins.js +24 -12
  34. package/src/commands/reset-schema.js +5 -6
  35. package/src/commands/restore.js +6 -6
  36. package/src/commands/rm-tenant.js +7 -9
  37. package/src/commands/run-benchmark.js +17 -14
  38. package/src/commands/run-js.js +5 -6
  39. package/src/commands/run-sql.js +5 -6
  40. package/src/commands/run-tests.js +15 -13
  41. package/src/commands/run-trigger.js +13 -8
  42. package/src/commands/scheduler.js +4 -4
  43. package/src/commands/serve.js +10 -10
  44. package/src/commands/set-cfg.js +14 -13
  45. package/src/commands/set-daily-time.js +7 -9
  46. package/src/commands/setup-benchmark.js +14 -7
  47. package/src/commands/setup.js +11 -12
  48. package/src/commands/sync-upload-data.js +6 -6
  49. package/src/commands/take-snapshot.js +5 -6
  50. package/src/commands/transform-field.js +9 -10
  51. package/src/index.js +1 -1
@@ -1,4 +1,4 @@
1
- const { Command, flags } = require("@oclif/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: flags.string({
197
+ directory: Flags.string({
198
198
  char: "d",
199
199
  description: "Directory of local plugin",
200
200
  }),
201
- name: flags.string({
201
+ name: Flags.string({
202
202
  char: "n",
203
203
  description: "Plugin name in store of a released plugin",
204
204
  }),
205
- backupFile: flags.string({
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: flags.string({
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, flags } = require("@oclif/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, flags } = require("@oclif/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: ".",
@@ -125,8 +125,12 @@ class ReleaseCommand extends Command {
125
125
  });
126
126
  for (const p of Object.values(pkgs)) {
127
127
  updatePkgJson(p.dir);
128
- if (p.publish) publish(p.dir);
128
+ if (p.publish) {
129
+ publish(p.dir);
130
+ await sleep(3000);
131
+ }
129
132
  }
133
+ await sleep(5000);
130
134
 
131
135
  // for cli:
132
136
  // 1. update version
@@ -192,12 +196,15 @@ ReleaseCommand.description = `Release a new saltcorn version`;
192
196
  /**
193
197
  * @type {object}
194
198
  */
195
- ReleaseCommand.args = [
196
- { name: "version", required: true, description: "New version number" },
197
- ];
199
+ ReleaseCommand.args = {
200
+ version: Args.string({
201
+ required: true,
202
+ description: "New version number",
203
+ }),
204
+ };
198
205
 
199
206
  ReleaseCommand.flags = {
200
- tag: flags.string({
207
+ tag: Flags.string({
201
208
  char: "t",
202
209
  description: "NPM tag",
203
210
  }),
@@ -2,7 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/test-plugin
4
4
  */
5
- const { Command, flags } = require("@oclif/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
- { name: "path", description: "path to plugin package", required: true },
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}
@@ -2,7 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/fixtures
4
4
  */
5
- const { Command, flags } = require("@oclif/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: flags.boolean({ char: "r", description: "Also reset schema" }),
52
- tenant: flags.string({
51
+ reset: Flags.boolean({ char: "r", description: "Also reset schema" }),
52
+ tenant: Flags.string({
53
53
  char: "t",
54
54
  description: "tenant",
55
55
  }),
@@ -2,8 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/set-cfg
4
4
  */
5
- const { Command, flags } = require("@oclif/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 SetCfgCommand extends Command {
13
+ class GetCfgCommand extends Command {
15
14
  /**
16
15
  * @returns {Promise<void>}
17
16
  */
18
17
  async run() {
19
- const { args, flags } = this.parse(SetCfgCommand);
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
- SetCfgCommand.description = `Get a configuration value. The value is printed to stdout as a JSON value`;
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
- SetCfgCommand.args = [
58
- { name: "key", required: false, description: "Configuration key" },
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
- SetCfgCommand.flags = {
65
- tenant: flags.string({
66
+ GetCfgCommand.flags = {
67
+ tenant: Flags.string({
66
68
  char: "t",
67
69
  description: "tenant",
68
70
  }),
69
- plugin: flags.string({
71
+ plugin: Flags.string({
70
72
  char: "p",
71
73
  description: "plugin",
72
74
  }),
73
75
  };
74
76
 
75
- module.exports = SetCfgCommand;
77
+ module.exports = GetCfgCommand;
@@ -2,14 +2,13 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/info
4
4
  */
5
- const { Command, flags } = require("@oclif/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 = "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
- );
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: flags.boolean({ char: "j", description: "json format" }),
72
+ json: Flags.boolean({ char: "j", description: "json format" }),
73
73
  };
74
74
 
75
75
  module.exports = InfoCommand;
@@ -2,8 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/create-user
4
4
  */
5
- const { Command, flags } = require("@oclif/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: flags.string({
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, flags } = require("@oclif/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: flags.string({
75
+ tenant: Flags.string({
76
76
  char: "t",
77
77
  description: "tenant",
78
78
  }),
79
- name: flags.string({
79
+ name: Flags.string({
80
80
  char: "n",
81
81
  description: "Pack name in store",
82
82
  }),
83
- file: flags.string({
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, flags } = require("@oclif/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: flags.string({
87
+ tenant: Flags.string({
88
88
  char: "t",
89
89
  description: "tenant",
90
90
  }),
91
- name: flags.string({
91
+ name: Flags.string({
92
92
  char: "n",
93
93
  description: "Plugin name in store",
94
94
  }),
95
- directory: flags.string({
95
+ directory: Flags.string({
96
96
  char: "d",
97
97
  description: "Directory with local plugin",
98
98
  }),
99
- unsafe: flags.boolean({
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, flags } = require("@oclif/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 db.count ("_sc_tags"),
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(tenantDetails,
53
- ["domain","users","roles","tables","views","pages", "files","triggers", "tags"],
54
- flags.json);
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: flags.string({
83
+ tenant: Flags.string({
76
84
  name: "tenant",
77
85
  char: "t",
78
86
  description: "tenant",
79
87
  required: false,
80
88
  }),
81
- verbose: flags.boolean({
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: flags.boolean({ char: "j", description: "json format" }),
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, flags } = require("@oclif/command");
6
- const { cli } = require("cli-ux");
7
- const { maybe_as_tenant, init_some_tenants, print_table} = require("../common");
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: flags.string({
66
+ tenant: Flags.string({
56
67
  name: "tenant",
57
68
  char: "t",
58
69
  description: "tenant",
59
70
  required: false,
60
71
  }),
61
- verbose: flags.boolean({
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: flags.boolean({ char: "j", description: "json format" }),
78
+ json: Flags.boolean({ char: "j", description: "json format" }),
68
79
  };
69
80
 
70
81
  module.exports = ListTriggersCommand;