@saltcorn/cli 0.7.1 → 0.7.2-beta.3

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.
@@ -1 +1 @@
1
- {"version":"0.7.1","commands":{"add-schema":{"id":"add-schema","description":"Add Saltcorn schema to existing database","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"backup":{"id":"backup","description":"Backup the PostgreSQL database to a file with pg_dump or zip","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"output filename"},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"zip":{"name":"zip","type":"boolean","char":"z","description":"zip format","allowNo":false}},"args":[]},"configuration-check":{"id":"configuration-check","description":"Check configuration","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"create-tenant":{"id":"create-tenant","description":"Create a tenant","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"email":{"name":"email","type":"option","char":"e","description":"Email of owner of tenant"},"description":{"name":"description","type":"option","char":"d","description":"Description of tenant"}},"args":[{"name":"tenant","description":"Tenant subdomain to create","required":true}]},"create-user":{"id":"create-user","description":"Create a new user","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"admin":{"name":"admin","type":"boolean","char":"a","description":"Admin user","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"email":{"name":"email","type":"option","char":"e","description":"email"},"role":{"name":"role","type":"option","char":"r","description":"role"},"password":{"name":"password","type":"option","char":"p","description":"password"}},"args":[]},"delete-tenants":{"id":"delete-tenants","description":"Delete inactive tenants","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"fixtures":{"id":"fixtures","description":"Load fixtures for testing\n...\nThis manual step it is never required for users and rarely required for developers\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"reset":{"name":"reset","type":"boolean","char":"r","description":"Also reset schema","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"info":{"id":"info","description":"Show paths\n...\nShow configuration and file store paths\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":["paths"],"flags":{"json":{"name":"json","type":"boolean","char":"j","description":"json format","allowNo":false}},"args":[]},"install-pack":{"id":"install-pack","description":"Install a pack","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"name":{"name":"name","type":"option","char":"n","description":"Pack name in store"},"file":{"name":"file","type":"option","char":"f","description":"File with pack JSON"}},"args":[]},"install-plugin":{"id":"install-plugin","description":"Install a plugin","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"name":{"name":"name","type":"option","char":"n","description":"Plugin name in store"},"directory":{"name":"directory","type":"option","char":"d","description":"Directory with local plugin"}},"args":[]},"list-tenants":{"id":"list-tenants","description":"List tenants in CSV format","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"localize-plugin":{"id":"localize-plugin","description":"Convert plugin to local plugin","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[{"name":"plugin","description":"Current plugin name","required":true},{"name":"path","description":"Absolute path to local plugin","required":true}]},"make-migration":{"id":"make-migration","description":"Create a new blank Database structure migration file.\nThese migrations update database structure.\nYou should not normally need to run this\nunless you are a developer.\n","usage":"make-migration","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"migrate":{"id":"migrate","description":"Run Database structure migrations\n...\nNOTE!\n- Please stop Saltcorn before run DB migrations.\n- Please make db backup before migration.\n- There are no way to rollback migration if you doesn't make backup.\n\nThis is not normally required as migrations will be run when the server starts.\nHowever, this command may be useful if you are running multiple application\nservers and need to control when the migrations are run.\n","usage":"saltcorn migrate","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"plugins":{"id":"plugins","description":"List and upgrade plugins for tenants\n...\nExtra documentation goes here\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"examples":["plugins -v - verbose output of commands","plugins -u -d - dry-run for plugin update","plugins -u -f - force plugin update"],"flags":{"upgrade":{"name":"upgrade","type":"boolean","char":"u","description":"Upgrade","allowNo":false},"dryRun":{"name":"dryRun","type":"boolean","char":"d","description":"Upgrade dry-run","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose output","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Force update","allowNo":false},"name":{"name":"name","type":"option","char":"n","description":"Plugin name"}},"args":[]},"release":{"id":"release","description":"Release a new saltcorn version","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"version","description":"New version number","required":true}]},"reset-schema":{"id":"reset-schema","description":"Reset the database\n...\nThis will delete all existing information\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"force","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"restore":{"id":"restore","description":"Restore a previously backed up database (zip or sqlc format)","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[{"name":"file","description":"backup file to restore","required":true}]},"rm-tenant":{"id":"rm-tenant","description":"Remove a tenant","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"tenant","description":"Tenant to remove","required":true}]},"run-benchmark":{"id":"run-benchmark","description":"Run benchmark","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"token":{"name":"token","type":"option","char":"t","description":"API Token for reporting results"},"benchmark":{"name":"benchmark","type":"option","char":"b","description":"Which benchmark to run"},"delay":{"name":"delay","type":"option","char":"d","description":"delay between runs (s)","default":30}},"args":[{"name":"baseurl","description":"Base URL","required":false}]},"run-tests":{"id":"run-tests","description":"Run test suites","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"coverage":{"name":"coverage","type":"boolean","char":"c","description":"Coverage","allowNo":false},"testFilter":{"name":"testFilter","type":"option","char":"t","description":"Filter tests by suite or test name"},"watch":{"name":"watch","type":"boolean","description":"Watch files for changes and rerun tests related to changed files.","allowNo":false},"watchAll":{"name":"watchAll","type":"boolean","description":"Watch files for changes and rerun all tests.","allowNo":false}},"args":[{"name":"package","description":"which package to run tests for"}]},"scheduler":{"id":"scheduler","description":"Run the Saltcorn scheduler","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Start the Saltcorn server","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":3000},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose","allowNo":false},"watchReaper":{"name":"watchReaper","type":"boolean","char":"r","description":"Watch reaper","allowNo":false},"dev":{"name":"dev","type":"boolean","char":"d","description":"Run in dev mode and re-start on file changes","allowNo":false},"addschema":{"name":"addschema","type":"boolean","char":"a","description":"Add schema if missing","allowNo":false},"nomigrate":{"name":"nomigrate","type":"boolean","char":"n","description":"No migrations","allowNo":false},"noscheduler":{"name":"noscheduler","type":"boolean","char":"s","description":"No scheduler","allowNo":false}},"args":[]},"set-cfg":{"id":"set-cfg","description":"Set a configuration value","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"plugin":{"name":"plugin","type":"option","char":"p","description":"plugin"}},"args":[{"name":"key","description":"Configuration key","required":true},{"name":"value","description":"Configuration value (JSON or string)","required":true}]},"setup-benchmark":{"id":"setup-benchmark","description":"Setup an instance for benchmarking","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"setup":{"id":"setup","description":"Set up a new system\n...\nThis will attempt to install or connect a database, and set up a \nconfiguration file\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"coverage":{"name":"coverage","type":"boolean","char":"c","description":"Coverage","allowNo":false}},"args":[]},"test-plugin":{"id":"test-plugin","description":"Test a plugin\n...\nExtra documentation goes here\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"path","description":"path to plugin package","required":true}]},"transform-field":{"id":"transform-field","description":"transform an existing field by applying a calculated expression","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"expression","description":"expression to calculate field","required":true},{"name":"field","description":"field name","required":true},{"name":"table","description":"table name","required":true},{"name":"tenant","description":"tenant name","required":false}]}}}
1
+ {"version":"0.7.2-beta.3","commands":{"add-schema":{"id":"add-schema","description":"Add Saltcorn schema to existing database","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"backup":{"id":"backup","description":"Backup the PostgreSQL database to a file with pg_dump or zip","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"output filename"},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"zip":{"name":"zip","type":"boolean","char":"z","description":"zip format","allowNo":false}},"args":[]},"configuration-check":{"id":"configuration-check","description":"Check configuration","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"create-tenant":{"id":"create-tenant","description":"Create a tenant","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"email":{"name":"email","type":"option","char":"e","description":"Email of owner of tenant"},"description":{"name":"description","type":"option","char":"d","description":"Description of tenant"}},"args":[{"name":"tenant","description":"Tenant subdomain to create","required":true}]},"create-user":{"id":"create-user","description":"Create a new user","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"admin":{"name":"admin","type":"boolean","char":"a","description":"Admin user","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"email":{"name":"email","type":"option","char":"e","description":"email"},"role":{"name":"role","type":"option","char":"r","description":"role"},"password":{"name":"password","type":"option","char":"p","description":"password"}},"args":[]},"delete-tenants":{"id":"delete-tenants","description":"Delete inactive tenants","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"fixtures":{"id":"fixtures","description":"Load fixtures for testing\n...\nThis manual step it is never required for users and rarely required for developers\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"reset":{"name":"reset","type":"boolean","char":"r","description":"Also reset schema","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"get-cfg":{"id":"get-cfg","description":"Get a configuration value","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"plugin":{"name":"plugin","type":"option","char":"p","description":"plugin"}},"args":[{"name":"key","description":"Configuration key","required":true}]},"info":{"id":"info","description":"Show paths\n...\nShow configuration and file store paths\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":["paths"],"flags":{"json":{"name":"json","type":"boolean","char":"j","description":"json format","allowNo":false}},"args":[]},"install-pack":{"id":"install-pack","description":"Install a pack","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"name":{"name":"name","type":"option","char":"n","description":"Pack name in store"},"file":{"name":"file","type":"option","char":"f","description":"File with pack JSON"}},"args":[]},"install-plugin":{"id":"install-plugin","description":"Install a plugin","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"name":{"name":"name","type":"option","char":"n","description":"Plugin name in store"},"directory":{"name":"directory","type":"option","char":"d","description":"Directory with local plugin"}},"args":[]},"list-tenants":{"id":"list-tenants","description":"List tenants in CSV format","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"localize-plugin":{"id":"localize-plugin","description":"Convert plugin to local plugin","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[{"name":"plugin","description":"Current plugin name","required":true},{"name":"path","description":"Absolute path to local plugin","required":true}]},"make-migration":{"id":"make-migration","description":"Create a new blank Database structure migration file.\nThese migrations update database structure.\nYou should not normally need to run this\nunless you are a developer.\n","usage":"make-migration","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"migrate":{"id":"migrate","description":"Run Database structure migrations\n...\nNOTE!\n- Please stop Saltcorn before run DB migrations.\n- Please make db backup before migration.\n- There are no way to rollback migration if you doesn't make backup.\n\nThis is not normally required as migrations will be run when the server starts.\nHowever, this command may be useful if you are running multiple application\nservers and need to control when the migrations are run.\n","usage":"saltcorn migrate","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"plugins":{"id":"plugins","description":"List and upgrade plugins for tenants\n...\nExtra documentation goes here\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"examples":["plugins -v - verbose output of commands","plugins -u -d - dry-run for plugin update","plugins -u -f - force plugin update"],"flags":{"upgrade":{"name":"upgrade","type":"boolean","char":"u","description":"Upgrade","allowNo":false},"dryRun":{"name":"dryRun","type":"boolean","char":"d","description":"Upgrade dry-run","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose output","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Force update","allowNo":false},"name":{"name":"name","type":"option","char":"n","description":"Plugin name"}},"args":[]},"release":{"id":"release","description":"Release a new saltcorn version","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"version","description":"New version number","required":true}]},"reset-schema":{"id":"reset-schema","description":"Reset the database\n...\nThis will delete all existing information\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"force","allowNo":false},"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"restore":{"id":"restore","description":"Restore a previously backed up database (zip or sqlc format)","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[{"name":"file","description":"backup file to restore","required":true}]},"rm-tenant":{"id":"rm-tenant","description":"Remove a tenant","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"tenant","description":"Tenant to remove","required":true}]},"run-benchmark":{"id":"run-benchmark","description":"Run benchmark","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"token":{"name":"token","type":"option","char":"t","description":"API Token for reporting results"},"benchmark":{"name":"benchmark","type":"option","char":"b","description":"Which benchmark to run"},"delay":{"name":"delay","type":"option","char":"d","description":"delay between runs (s)","default":30}},"args":[{"name":"baseurl","description":"Base URL","required":false}]},"run-tests":{"id":"run-tests","description":"Run test suites","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"coverage":{"name":"coverage","type":"boolean","char":"c","description":"Coverage","allowNo":false},"testFilter":{"name":"testFilter","type":"option","char":"t","description":"Filter tests by suite or test name"},"watch":{"name":"watch","type":"boolean","description":"Watch files for changes and rerun tests related to changed files.","allowNo":false},"watchAll":{"name":"watchAll","type":"boolean","description":"Watch files for changes and rerun all tests.","allowNo":false}},"args":[{"name":"package","description":"which package to run tests for"}]},"scheduler":{"id":"scheduler","description":"Run the Saltcorn scheduler","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Start the Saltcorn server","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":3000},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Verbose","allowNo":false},"watchReaper":{"name":"watchReaper","type":"boolean","char":"r","description":"Watch reaper","allowNo":false},"dev":{"name":"dev","type":"boolean","char":"d","description":"Run in dev mode and re-start on file changes","allowNo":false},"addschema":{"name":"addschema","type":"boolean","char":"a","description":"Add schema if missing","allowNo":false},"nomigrate":{"name":"nomigrate","type":"boolean","char":"n","description":"No migrations","allowNo":false},"noscheduler":{"name":"noscheduler","type":"boolean","char":"s","description":"No scheduler","allowNo":false}},"args":[]},"set-cfg":{"id":"set-cfg","description":"Set a configuration value","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"},"plugin":{"name":"plugin","type":"option","char":"p","description":"plugin"}},"args":[{"name":"key","description":"Configuration key","required":true},{"name":"value","description":"Configuration value (JSON or string)","required":true}]},"setup-benchmark":{"id":"setup-benchmark","description":"Setup an instance for benchmarking","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"tenant":{"name":"tenant","type":"option","char":"t","description":"tenant"}},"args":[]},"setup":{"id":"setup","description":"Set up a new system\n...\nThis will attempt to install or connect a database, and set up a \nconfiguration file\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{"coverage":{"name":"coverage","type":"boolean","char":"c","description":"Coverage","allowNo":false}},"args":[]},"test-plugin":{"id":"test-plugin","description":"Test a plugin\n...\nExtra documentation goes here\n","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"path","description":"path to plugin package","required":true}]},"transform-field":{"id":"transform-field","description":"transform an existing field by applying a calculated expression","pluginName":"@saltcorn/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"expression","description":"expression to calculate field","required":true},{"name":"field","description":"field name","required":true},{"name":"table","description":"table name","required":true},{"name":"tenant","description":"tenant name","required":false}]}}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@saltcorn/cli",
3
3
  "description": "Command-line interface for Saltcorn, open-source no-code platform",
4
4
  "homepage": "https://saltcorn.com",
5
- "version": "0.7.1",
5
+ "version": "0.7.2-beta.3",
6
6
  "author": "Tom Nielsen @glutamate",
7
7
  "bin": {
8
8
  "saltcorn": "./bin/saltcorn"
@@ -11,10 +11,12 @@
11
11
  "dependencies": {
12
12
  "@oclif/command": "^1.8.16",
13
13
  "@oclif/config": "^1.18.3",
14
+ "@oclif/plugin-plugins": "^2.1.0",
14
15
  "@oclif/plugin-help": "^3.3.1",
15
- "@saltcorn/admin-models": "0.7.1",
16
- "@saltcorn/data": "0.7.1",
17
- "@saltcorn/server": "0.7.1",
16
+ "@saltcorn/admin-models": "0.7.2-beta.3",
17
+ "@saltcorn/data": "0.7.2-beta.3",
18
+ "@saltcorn/mobile-builder": "0.7.2-beta.0",
19
+ "@saltcorn/server": "0.7.2-beta.3",
18
20
  "cli-ux": "^5.6.7",
19
21
  "contractis": "^0.1.0",
20
22
  "dateformat": "^3.0.3",
@@ -24,7 +26,7 @@
24
26
  "node-watch": "^0.7.3",
25
27
  "source-map-support": "^0.5.21",
26
28
  "sudo": "^1.0.3",
27
- "systeminformation": "^5.11.9",
29
+ "systeminformation": "^5.11.12",
28
30
  "tcp-port-used": "^1.0.2",
29
31
  "wrk": "^1.2.1"
30
32
  },
@@ -50,7 +52,9 @@
50
52
  "commands": "./src/commands",
51
53
  "bin": "saltcorn",
52
54
  "plugins": [
53
- "@oclif/plugin-help"
55
+ "@oclif/plugin-help",
56
+ "@oclif/plugin-plugins",
57
+ "@saltcorn/mobile-builder"
54
58
  ]
55
59
  },
56
60
  "repository": "github:saltcorn/saltcorn",
@@ -65,4 +69,4 @@
65
69
  "publishConfig": {
66
70
  "access": "public"
67
71
  }
68
- }
72
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @category saltcorn-cli
3
+ * @module commands/set-cfg
4
+ */
5
+ const { Command, flags } = require("@oclif/command");
6
+ const { cli } = require("cli-ux");
7
+ const { maybe_as_tenant, init_some_tenants } = require("../common");
8
+
9
+ /**
10
+ * SetCfgCommand Class
11
+ * @extends oclif.Command
12
+ * @category saltcorn-cli
13
+ */
14
+ class SetCfgCommand extends Command {
15
+ /**
16
+ * @returns {Promise<void>}
17
+ */
18
+ async run() {
19
+ const { args, flags } = this.parse(SetCfgCommand);
20
+ await init_some_tenants(flags.tenant);
21
+
22
+ await maybe_as_tenant(flags.tenant, async () => {
23
+ if (flags.plugin) {
24
+ const Plugin = require("@saltcorn/data/models/plugin");
25
+ const plugin = await Plugin.findOne({ name: flags.plugin });
26
+ console.log(JSON.stringify(plugin.configuration[args.key], null, 2));
27
+ await plugin.upsert();
28
+ } else {
29
+ const { getState } = require("@saltcorn/data/db/state");
30
+ console.log(JSON.stringify(getState().getConfig(args.key), null, 2));
31
+ }
32
+ });
33
+ this.exit(0);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * @type {string}
39
+ */
40
+ SetCfgCommand.description = `Get a configuration value`;
41
+
42
+ /**
43
+ * @type {object[]}
44
+ */
45
+ SetCfgCommand.args = [
46
+ { name: "key", required: true, description: "Configuration key" },
47
+ ];
48
+
49
+ /**
50
+ * @type {object}
51
+ */
52
+ SetCfgCommand.flags = {
53
+ tenant: flags.string({
54
+ char: "t",
55
+ description: "tenant",
56
+ }),
57
+ plugin: flags.string({
58
+ char: "p",
59
+ description: "plugin",
60
+ }),
61
+ };
62
+
63
+ module.exports = SetCfgCommand;
@@ -58,7 +58,7 @@ class ReleaseCommand extends Command {
58
58
  );
59
59
  };
60
60
  const compileTsFiles = () => {
61
- spawnSync("npm", ["install"], {
61
+ spawnSync("npm", ["install","--legacy-peer-deps"], {
62
62
  stdio: "inherit",
63
63
  cwd: ".",
64
64
  });
@@ -78,7 +78,7 @@ class ReleaseCommand extends Command {
78
78
  // 1. update version
79
79
  // 2. update dependencies for other packages
80
80
  // 3. publish
81
- spawnSync("npm", ["install"], {
81
+ spawnSync("npm", ["install", "--legacy-peer-deps"], {
82
82
  stdio: "inherit",
83
83
  cwd: `packages/saltcorn-cli/`,
84
84
  });
@@ -32,26 +32,34 @@ class RunTestsCommand extends Command {
32
32
  return res;
33
33
  }
34
34
 
35
- /**
36
- *
37
- * @param {*} env
38
- * @returns {Promise<void>}
39
- */
40
- async e2etest(env) {
35
+ async prepareTestServer(env, port) {
36
+ let serverEnv = JSON.parse(JSON.stringify(env));
37
+ serverEnv.SQLITE_FILEPATH = "/tmp/sctestdb_server";
41
38
  spawnSync("packages/saltcorn-cli/bin/saltcorn", ["fixtures", "-r"], {
42
39
  stdio: "inherit",
43
- env,
40
+ env: serverEnv,
44
41
  });
45
42
 
46
43
  const server = spawn(
47
44
  "packages/saltcorn-cli/bin/saltcorn",
48
- ["serve", "-p", "2987"],
45
+ ["serve", "-p", port],
49
46
  {
50
47
  stdio: "inherit",
51
- env,
48
+ env: serverEnv,
52
49
  }
53
50
  );
54
51
  await sleep(2000);
52
+ return server;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param {*} env
58
+ * @returns {Promise<void>}
59
+ */
60
+ async e2etest(env) {
61
+ const port = 2987;
62
+ const server = await this.prepareTestServer(env, port);
55
63
  const res = await this.do_test(
56
64
  "npm",
57
65
  ["run", "gotest"],
@@ -63,6 +71,23 @@ class RunTestsCommand extends Command {
63
71
  if (res.status !== 0) this.exit(res.status);
64
72
  }
65
73
 
74
+ /**
75
+ *
76
+ * @param {*} env
77
+ */
78
+ async remoteQueryTest(env, jestParams) {
79
+ const port = 3000;
80
+ env.jwt_secret = require("@saltcorn/data/db").connectObj.jwt_secret;
81
+ const server = await this.prepareTestServer(env, port);
82
+ const res = await this.do_test(
83
+ "npm",
84
+ ["run", "remote-queries-test", ...jestParams],
85
+ env,
86
+ "packages/saltcorn-data"
87
+ );
88
+ server.kill();
89
+ if (res.status !== 0) this.exit(res.status);
90
+ }
66
91
  /**
67
92
  *
68
93
  * @param {object} args
@@ -91,9 +116,6 @@ class RunTestsCommand extends Command {
91
116
  this.validateCall(args, flags);
92
117
  var env;
93
118
 
94
- spawnSync("npm", ["run", "tsc"], {
95
- stdio: "inherit",
96
- });
97
119
  const db = require("@saltcorn/data/db");
98
120
  if (db.isSQLite) {
99
121
  const testdbpath = "/tmp/sctestdb";
@@ -103,6 +125,9 @@ class RunTestsCommand extends Command {
103
125
  await db.changeConnection({ database: "saltcorn_test" });
104
126
  env = { ...process.env, PGDATABASE: "saltcorn_test" };
105
127
  }
128
+ spawnSync("npm", ["run", "tsc"], {
129
+ stdio: "inherit",
130
+ });
106
131
  const fixtures = require("@saltcorn/data/db/fixtures");
107
132
  const reset = require("@saltcorn/data/db/reset_schema");
108
133
  await reset();
@@ -123,6 +148,8 @@ class RunTestsCommand extends Command {
123
148
  }
124
149
  if (args.package === "core") {
125
150
  await this.do_test("npm", ["run", "test", ...jestParams], env);
151
+ } else if (args.package === "view-queries") {
152
+ await this.remoteQueryTest(env, jestParams);
126
153
  } else if (args.package === "e2e") {
127
154
  await this.e2etest(env);
128
155
  } else if (args.package) {
@@ -14,12 +14,13 @@ const { is } = require("contractis");
14
14
  const path = require("path");
15
15
  const fs = require("fs");
16
16
  const inquirer = require("inquirer");
17
- var tcpPortUsed = require("tcp-port-used");
17
+ const tcpPortUsed = require("tcp-port-used");
18
18
  const { spawnSync } = require("child_process");
19
- var sudo = require("sudo");
19
+ const sudo = require("sudo");
20
+ const crypto = require("crypto");
20
21
 
21
22
  /**
22
- *
23
+ *
23
24
  * @returns {string}
24
25
  */
25
26
  const gen_password = () => {
@@ -28,8 +29,12 @@ const gen_password = () => {
28
29
  else return gen_password();
29
30
  };
30
31
 
32
+ const genJwtSecret = () => {
33
+ return crypto.randomBytes(64).toString("hex");
34
+ };
35
+
31
36
  /**
32
- *
37
+ *
33
38
  * @returns {Promise<object>}
34
39
  */
35
40
  const askDevServer = async () => {
@@ -58,8 +63,8 @@ const askDevServer = async () => {
58
63
  };
59
64
 
60
65
  /**
61
- *
62
- * @param {*} mod
66
+ *
67
+ * @param {*} mod
63
68
  */
64
69
  const unloadModule = (mod) => {
65
70
  var name = require.resolve(mod);
@@ -73,7 +78,12 @@ const setupDevMode = async () => {
73
78
  const dbPath = path.join(defaultDataPath, "scdb.sqlite");
74
79
  fs.promises.mkdir(defaultDataPath, { recursive: true });
75
80
  const session_secret = gen_password();
76
- await write_connection_config({ sqlite_path: dbPath, session_secret });
81
+ const jwt_secret = genJwtSecret();
82
+ await write_connection_config({
83
+ sqlite_path: dbPath,
84
+ session_secret,
85
+ jwt_secret,
86
+ });
77
87
 
78
88
  if (!fs.existsSync(dbPath)) {
79
89
  unloadModule("@saltcorn/data/db");
@@ -115,8 +125,8 @@ const check_db = async () => {
115
125
  };
116
126
 
117
127
  /**
118
- *
119
- * @param {*} args
128
+ *
129
+ * @param {*} args
120
130
  * @returns {Promise<void>}
121
131
  */
122
132
  const asyncSudo = (args) => {
@@ -136,8 +146,8 @@ const asyncSudo = (args) => {
136
146
  };
137
147
 
138
148
  /**
139
- *
140
- * @param {*} args
149
+ *
150
+ * @param {*} args
141
151
  * @returns {Promise<void>}
142
152
  */
143
153
  const asyncSudoPostgres = (args) => {
@@ -145,8 +155,8 @@ const asyncSudoPostgres = (args) => {
145
155
  };
146
156
 
147
157
  /**
148
- *
149
- * @param {string} for_who
158
+ *
159
+ * @param {string} for_who
150
160
  * @returns {Promise<string>}
151
161
  */
152
162
  const get_password = async (for_who) => {
@@ -204,6 +214,7 @@ const install_db = async () => {
204
214
  `ALTER SCHEMA public OWNER TO ${user};`,
205
215
  ]);
206
216
  const session_secret = await get_password("session secret");
217
+ const jwt_secret = genJwtSecret();
207
218
  await write_connection_config({
208
219
  host: "localhost",
209
220
  port: 5432,
@@ -211,12 +222,13 @@ const install_db = async () => {
211
222
  user,
212
223
  password: scpass,
213
224
  session_secret,
225
+ jwt_secret,
214
226
  multi_tenant: false,
215
227
  });
216
228
  };
217
229
 
218
230
  /**
219
- *
231
+ *
220
232
  * @returns {Promise<object>}
221
233
  */
222
234
  const prompt_connection = async () => {
@@ -236,6 +248,7 @@ const prompt_connection = async () => {
236
248
  required: true,
237
249
  });
238
250
  const session_secret = await get_password("session secret");
251
+ const jwt_secret = genJwtSecret();
239
252
  return {
240
253
  host: host || "localhost",
241
254
  port: port || 5432,
@@ -243,6 +256,7 @@ const prompt_connection = async () => {
243
256
  user: user || "saltcorn",
244
257
  password: password,
245
258
  session_secret,
259
+ jwt_secret,
246
260
  multi_tenant: false,
247
261
  };
248
262
  };
@@ -256,8 +270,8 @@ const setup_connection_config = async () => {
256
270
  };
257
271
 
258
272
  /**
259
- *
260
- * @param {object} connobj
273
+ *
274
+ * @param {object} connobj
261
275
  * @returns {Promise<void>}
262
276
  */
263
277
  const write_connection_config = async (connobj) => {
@@ -290,9 +304,9 @@ const setup_connection = async () => {
290
304
  };
291
305
 
292
306
  /**
293
- *
294
- * @param {object} db
295
- * @param {string} tblname
307
+ *
308
+ * @param {object} db
309
+ * @param {string} tblname
296
310
  * @returns {Promise<boolean>}
297
311
  */
298
312
  const table_exists = async (db, tblname) => {
@@ -346,7 +360,7 @@ class SetupCommand extends Command {
346
360
  * @returns {Promise<void>}
347
361
  */
348
362
  async run() {
349
- console.log("Run setip");
363
+ console.log("Run setup");
350
364
  const mode = await askDevServer();
351
365
  if (mode == "server") {
352
366
  // check if i already know how to connect
package/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.4.5](https://github.com/saltcorn/saltcorn/compare/v0.4.5-beta.1...v0.4.5) (2021-05-07)
7
-
8
- **Note:** Version bump only for package @saltcorn/cli