@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.
Files changed (51) hide show
  1. package/README.md +394 -294
  2. package/bin/saltcorn +4 -4
  3. package/npm-shrinkwrap.json +11095 -12264
  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 +9 -6
  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 +7 -7
  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 +3 -3
  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
@@ -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 {
8
7
  maybe_as_tenant,
9
8
  init_some_tenants,
@@ -20,7 +19,7 @@ class SetDailyTimeCommand extends Command {
20
19
  * @returns {Promise<void>}
21
20
  */
22
21
  async run() {
23
- const { args, flags } = this.parse(SetDailyTimeCommand);
22
+ const { args, flags } = await this.parse(SetDailyTimeCommand);
24
23
  if (typeof args.mins === "undefined") {
25
24
  console.error("Must supply minutes value");
26
25
  this.exit(1);
@@ -48,18 +47,17 @@ SetDailyTimeCommand.description = `Set the time the default daily event will run
48
47
  /**
49
48
  * @type {object[]}
50
49
  */
51
- SetDailyTimeCommand.args = [
52
- {
53
- name: "mins",
50
+ SetDailyTimeCommand.args = {
51
+ mins: Args.string({
54
52
  description: "Number of minutes in the futute (negative for past)",
55
- },
56
- ];
53
+ }),
54
+ };
57
55
 
58
56
  /**
59
57
  * @type {object}
60
58
  */
61
59
  SetDailyTimeCommand.flags = {
62
- tenant: flags.string({
60
+ tenant: Flags.string({
63
61
  char: "t",
64
62
  description: "tenant",
65
63
  }),
@@ -2,7 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/setup-benchmark
4
4
  */
5
- const { Command, flags } = require("@oclif/command");
5
+ const { Command, Flags, Args } = require("@oclif/core");
6
6
  const { maybe_as_tenant } = require("../common");
7
7
 
8
8
  /**
@@ -14,8 +14,11 @@ class SetupBenchmarkCommand extends Command {
14
14
  /**
15
15
  * @returns {Promise<void>}
16
16
  */
17
- async install_forum_pack() {
18
- const { fetch_pack_by_name, install_pack } = require("@saltcorn/data/pack");
17
+ async install_forum_pack(flags) {
18
+ const {
19
+ fetch_pack_by_name,
20
+ install_pack,
21
+ } = require("@saltcorn/admin-models/models/pack");
19
22
  const load_plugins = require("@saltcorn/server/load_plugins");
20
23
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
21
24
  const { init_multi_tenant } = require("@saltcorn/data/db/state");
@@ -33,10 +36,10 @@ class SetupBenchmarkCommand extends Command {
33
36
  * @returns {Promise<void>}
34
37
  */
35
38
  async run() {
36
- const { args, flags } = this.parse(SetupBenchmarkCommand);
39
+ const { args, flags } = await this.parse(SetupBenchmarkCommand);
37
40
  await maybe_as_tenant(flags.tenant, async () => {
38
41
  // install pack
39
- await this.install_forum_pack();
42
+ await this.install_forum_pack(flags);
40
43
  // create user if one does not exist
41
44
  const User = require("@saltcorn/data/models/user");
42
45
  const nusers = await User.count();
@@ -77,7 +80,7 @@ class SetupBenchmarkCommand extends Command {
77
80
  }
78
81
 
79
82
  /** @type {object[]} */
80
- SetupBenchmarkCommand.args = [];
83
+ SetupBenchmarkCommand.args = {};
81
84
 
82
85
  /**
83
86
  * @type {string}
@@ -88,10 +91,14 @@ SetupBenchmarkCommand.description = `Setup an instance for benchmarking`;
88
91
  * @type {object}
89
92
  */
90
93
  SetupBenchmarkCommand.flags = {
91
- tenant: flags.string({
94
+ tenant: Flags.string({
92
95
  char: "t",
93
96
  description: "tenant",
94
97
  }),
98
+ name: Flags.string({
99
+ char: "n",
100
+ description: "name",
101
+ }),
95
102
  };
96
103
 
97
104
  const simple_page_pack = {
@@ -3,14 +3,13 @@
3
3
  * @category saltcorn-cli
4
4
  * @module commands/setup
5
5
  */
6
- const { Command, flags } = require("@oclif/command");
6
+ const { Command, Flags, ux } = require("@oclif/core");
7
7
  const {
8
8
  getConnectObject,
9
9
  configFilePath,
10
10
  configFileDir,
11
11
  defaultDataPath,
12
12
  } = require("@saltcorn/data/db/connect");
13
- const { cli } = require("cli-ux");
14
13
  const { is } = require("contractis");
15
14
  const path = require("path");
16
15
  const fs = require("fs");
@@ -169,14 +168,14 @@ const asyncSudoPostgres = (args) => {
169
168
  * @returns {Promise<string>}
170
169
  */
171
170
  const get_password = async (for_who) => {
172
- var password = await cli.prompt(`Set ${for_who} to [auto-generate]`, {
171
+ var password = await ux.prompt(`Set ${for_who} to [auto-generate]`, {
173
172
  type: "hide",
174
173
  required: false,
175
174
  });
176
175
  if (!password) {
177
176
  password = gen_password();
178
177
  console.log(`Setting ${for_who} to:`, password);
179
- await cli.anykey();
178
+ await ux.anykey();
180
179
  }
181
180
  return password;
182
181
  };
@@ -243,17 +242,17 @@ const install_db = async () => {
243
242
  */
244
243
  const prompt_connection = async () => {
245
244
  console.log("Enter database connection parameters");
246
- const host = await cli.prompt("Database host [localhost]", {
245
+ const host = await ux.prompt("Database host [localhost]", {
247
246
  required: false,
248
247
  });
249
- const port = await cli.prompt("Database port [5432]", { required: false });
250
- const database = await cli.prompt("Database name [saltcorn]", {
248
+ const port = await ux.prompt("Database port [5432]", { required: false });
249
+ const database = await ux.prompt("Database name [saltcorn]", {
251
250
  required: false,
252
251
  });
253
- const user = await cli.prompt("Database user [saltcorn]", {
252
+ const user = await ux.prompt("Database user [saltcorn]", {
254
253
  required: false,
255
254
  });
256
- const password = await cli.prompt("Database password", {
255
+ const password = await ux.prompt("Database password", {
257
256
  type: "hide",
258
257
  required: true,
259
258
  });
@@ -353,8 +352,8 @@ const setup_users = async () => {
353
352
  const hasUsers = await User.nonEmpty();
354
353
  if (!hasUsers) {
355
354
  console.log("No users found. Please create an admin user");
356
- const email = await cli.prompt("Email address");
357
- const password = await cli.prompt("Password", { type: "hide" });
355
+ const email = await ux.prompt("Email address");
356
+ const password = await ux.prompt("Password", { type: "hide" });
358
357
  await User.create({ email, password, role_id: 1 });
359
358
  } else {
360
359
  console.log("Users already present");
@@ -400,7 +399,7 @@ configuration file
400
399
  * @type {object}
401
400
  */
402
401
  SetupCommand.flags = {
403
- coverage: flags.boolean({ char: "c", description: "Coverage" }),
402
+ coverage: Flags.boolean({ char: "c", description: "Coverage" }),
404
403
  };
405
404
 
406
405
  module.exports = SetupCommand;
@@ -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 { init_multi_tenant } = require("@saltcorn/data/db/state");
4
4
  const User = require("@saltcorn/data/models/user");
@@ -232,7 +232,7 @@ class SyncUploadData extends Command {
232
232
  async run() {
233
233
  let returnCode = 0,
234
234
  inTransaction = false;
235
- const { flags } = await this.parse(SyncUploadData);
235
+ const { flags } = await await this.parse(SyncUploadData);
236
236
  if (db.is_it_multi_tenant() && flags.tenantAppName) {
237
237
  await init_multi_tenant(loadAllPlugins, true, [flags.tenantAppName]);
238
238
  }
@@ -282,22 +282,22 @@ class SyncUploadData extends Command {
282
282
  SyncUploadData.description = "Runs a sync for data supplied by the mobile app";
283
283
 
284
284
  SyncUploadData.flags = {
285
- tenantAppName: flags.string({
285
+ tenantAppName: Flags.string({
286
286
  name: "tenant",
287
287
  string: "tenant",
288
288
  description: "Optional name of a tenant application",
289
289
  }),
290
- userEmail: flags.string({
290
+ userEmail: Flags.string({
291
291
  name: "user email",
292
292
  string: "userEmail",
293
293
  description: "email of the user running the sync",
294
294
  }),
295
- directory: flags.string({
295
+ directory: Flags.string({
296
296
  name: "directory",
297
297
  string: "directory",
298
298
  description: "directory name for input output data",
299
299
  }),
300
- syncTimestamp: flags.integer({
300
+ syncTimestamp: Flags.integer({
301
301
  name: "syncTimestamp",
302
302
  string: "syncTimestamp",
303
303
  description: "new timestamp for the sync_info rows",
@@ -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, init_some_tenants } = require("../common");
7
7
  const fs = require("fs");
8
8
 
@@ -16,13 +16,12 @@ class TakeSnapshotCommand extends Command {
16
16
  * @returns {Promise<void>}
17
17
  */
18
18
  async run() {
19
- const { flags } = this.parse(TakeSnapshotCommand);
19
+ const { flags } = await this.parse(TakeSnapshotCommand);
20
20
  const Snapshot = require("@saltcorn/admin-models/models/snapshot");
21
21
  await init_some_tenants(flags.tenant);
22
22
 
23
23
  await maybe_as_tenant(flags.tenant, async () => {
24
- if(flags.fresh)
25
- await Snapshot.take_if_changed();
24
+ if (flags.fresh) await Snapshot.take_if_changed();
26
25
  const snps = await Snapshot.latest();
27
26
  console.log(JSON.stringify(snps, null, 2));
28
27
  });
@@ -39,11 +38,11 @@ TakeSnapshotCommand.description = `Print a current snapshout to stdout`;
39
38
  * @type {object}
40
39
  */
41
40
  TakeSnapshotCommand.flags = {
42
- tenant: flags.string({
41
+ tenant: Flags.string({
43
42
  char: "t",
44
43
  description: "tenant",
45
44
  }),
46
- fresh: flags.boolean({
45
+ fresh: Flags.boolean({
47
46
  char: "f",
48
47
  description: "fresh",
49
48
  }),
@@ -2,7 +2,7 @@
2
2
  * @category saltcorn-cli
3
3
  * @module commands/transform-field
4
4
  */
5
- const { Command, flags } = require("@oclif/command");
5
+ const { Command, Flags, Args } = require("@oclif/core");
6
6
 
7
7
  /**
8
8
  * TransformFieldCommand Class
@@ -23,7 +23,7 @@ class TransformFieldCommand extends Command {
23
23
  const {
24
24
  get_async_expression_function,
25
25
  } = require("@saltcorn/data/models/expression");
26
- const { args } = this.parse(TransformFieldCommand);
26
+ const { args } = await this.parse(TransformFieldCommand);
27
27
  await loadAllPlugins();
28
28
  if (args.tenant && db.is_it_multi_tenant()) {
29
29
  const tenants = await getAllTenants();
@@ -54,16 +54,15 @@ class TransformFieldCommand extends Command {
54
54
  /**
55
55
  * @type {object}
56
56
  */
57
- TransformFieldCommand.args = [
58
- {
59
- name: "expression",
57
+ TransformFieldCommand.args = {
58
+ expression: Args.string({
60
59
  required: true,
61
60
  description: "expression to calculate field",
62
- },
63
- { name: "field", required: true, description: "field name" },
64
- { name: "table", required: true, description: "table name" },
65
- { name: "tenant", required: false, description: "tenant name" },
66
- ];
61
+ }),
62
+ field: Args.string({ required: true, description: "field name" }),
63
+ table: Args.string({ required: true, description: "table name" }),
64
+ tenant: Args.string({ required: false, description: "tenant name" }),
65
+ };
67
66
 
68
67
  /**
69
68
  * @type {string}
package/src/index.js CHANGED
@@ -40,4 +40,4 @@
40
40
  * @category saltcorn-cli
41
41
  */
42
42
 
43
- module.exports = require("@oclif/command");
43
+ module.exports = require("@oclif/core");