@saltcorn/cli 0.6.3 → 0.6.4-beta.4

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.6.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":[]},"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":"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.6.4-beta.4","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":[]},"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":"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.6.3",
5
+ "version": "0.6.4-beta.4",
6
6
  "author": "Tom Nielsen @glutamate",
7
7
  "bin": {
8
8
  "saltcorn": "./bin/saltcorn"
@@ -10,19 +10,22 @@
10
10
  "bugs": "https://github.com/saltcorn/saltcorn/issues",
11
11
  "dependencies": {
12
12
  "@oclif/command": "^1.8.16",
13
- "@oclif/config": "^1.18.2",
13
+ "@oclif/config": "^1.18.3",
14
14
  "@oclif/plugin-help": "^3.3.1",
15
- "@saltcorn/data": "0.6.3",
16
- "@saltcorn/server": "0.6.3",
15
+ "@saltcorn/admin-models": "0.6.4-beta.4",
16
+ "@saltcorn/data": "0.6.4-beta.4",
17
+ "@saltcorn/server": "0.6.4-beta.4",
17
18
  "cli-ux": "^5.6.7",
18
19
  "contractis": "^0.1.0",
19
20
  "dateformat": "^3.0.3",
20
21
  "inquirer": "^7.3.3",
21
22
  "js-yaml": "^4.1.0",
22
23
  "node-fetch": "2.6.2",
23
- "node-watch": "^0.7.2",
24
+ "node-sass": "^6.0.1",
25
+ "node-watch": "^0.7.3",
26
+ "source-map-support": "^0.5.21",
24
27
  "sudo": "^1.0.3",
25
- "systeminformation": "^5.10.0",
28
+ "systeminformation": "^5.11.1",
26
29
  "tcp-port-used": "^1.0.2",
27
30
  "wrk": "^1.2.1"
28
31
  },
@@ -28,20 +28,21 @@ class BackupCommand extends Command {
28
28
  const { flags } = this.parse(BackupCommand);
29
29
 
30
30
  if (flags.tenant) {
31
- const { create_backup } = require("@saltcorn/data/models/backup");
31
+ const { create_backup } = require("@saltcorn/admin-models/models/backup");
32
32
 
33
33
  const db = require("@saltcorn/data/db");
34
34
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
35
35
  const { init_multi_tenant } = require("@saltcorn/data/db/state");
36
-
36
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
37
37
  await loadAllPlugins();
38
- await init_multi_tenant(loadAllPlugins);
38
+ const tenants = await getAllTenants();
39
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
39
40
  await db.runWithTenant(flags.tenant, async () => {
40
41
  const fnm = await create_backup(flags.output);
41
42
  console.log(fnm);
42
43
  });
43
44
  } else if (flags.zip) {
44
- const { create_backup } = require("@saltcorn/data/models/backup");
45
+ const { create_backup } = require("@saltcorn/admin-models/models/backup");
45
46
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
46
47
  await loadAllPlugins();
47
48
  const fnm = await create_backup(flags.output);
@@ -13,7 +13,7 @@ const { Command, flags } = require("@oclif/command");
13
13
  * @extends oclif.Command
14
14
  * @category saltcorn-cli
15
15
  */
16
- class CreateTenantCommand extends Command {
16
+ class CreateTenantCommand extends Command {
17
17
  /**
18
18
  * @returns {Promise<void>}
19
19
  */
@@ -26,14 +26,14 @@ class CreateTenantCommand extends Command {
26
26
  this.exit(0);
27
27
  return;
28
28
  }
29
- const { createTenant } = require("@saltcorn/data/models/tenant");
29
+ const { insertTenant, switchToTenant } = require("@saltcorn/admin-models/models/tenant");
30
30
  //const url = typeof flags.url !== `undefined`? flags.url : "";
31
31
  //const email = typeof flags.email !== `undefined`? flags.email : "";
32
32
  //const description = flags.description !== `undefined` ? flags.description : "";
33
33
  // TODO Do we need to set default value for base url or not? And what is correct way to get domain of base_url here?
34
34
  // const base = await db.getgetConfig("base_url");
35
- await createTenant(args.tenant, flags.url, flags.email, flags.description);
36
- console.log()
35
+ await switchToTenant(await insertTenant(args.tenant, flags.email, flags.description), flags.url);
36
+ console.log();
37
37
  this.exit(0);
38
38
  }
39
39
  }
@@ -17,7 +17,7 @@ class DeleteTenantsCommand extends Command {
17
17
  const {
18
18
  getAllTenantRows,
19
19
  deleteTenant,
20
- } = require("@saltcorn/data/models/tenant");
20
+ } = require("@saltcorn/admin-models/models/tenant");
21
21
  const db = require("@saltcorn/data/db");
22
22
  const tenantList = await getAllTenantRows();
23
23
  const tensExamine = tenantList.slice(
@@ -20,8 +20,10 @@ class FixturesCommand extends Command {
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");
23
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
23
24
  await loadAllPlugins();
24
- await init_multi_tenant(loadAllPlugins);
25
+ const tenants = await getAllTenants();
26
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
25
27
  }
26
28
  await maybe_as_tenant(flags.tenant, async () => {
27
29
  if (flags.reset) {
@@ -20,7 +20,7 @@ class InstallPackCommand extends Command {
20
20
  const {
21
21
  fetch_pack_by_name,
22
22
  install_pack,
23
- } = require("@saltcorn/data/models/pack");
23
+ } = require("@saltcorn/admin-models/models/pack");
24
24
  const load_plugins = require("@saltcorn/server/load_plugins");
25
25
 
26
26
  if (!flags.name && !flags.file) {
@@ -31,8 +31,10 @@ class InstallPackCommand extends Command {
31
31
  }
32
32
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
33
33
  const { init_multi_tenant } = require("@saltcorn/data/db/state");
34
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
34
35
  await loadAllPlugins();
35
- await init_multi_tenant(loadAllPlugins);
36
+ const tenants = await getAllTenants();
37
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
36
38
 
37
39
  await maybe_as_tenant(flags.tenant, async () => {
38
40
  if (flags.name) {
@@ -21,7 +21,7 @@ class InstallPluginCommand extends Command {
21
21
  const {
22
22
  fetch_pack_by_name,
23
23
  install_pack,
24
- } = require("@saltcorn/data/models/pack");
24
+ } = require("@saltcorn/admin-models/models/pack");
25
25
  const load_plugins = require("@saltcorn/server/load_plugins");
26
26
 
27
27
  if (!flags.name && !flags.directory) {
@@ -32,8 +32,10 @@ class InstallPluginCommand extends Command {
32
32
  }
33
33
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
34
34
  const { init_multi_tenant } = require("@saltcorn/data/db/state");
35
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
35
36
  await loadAllPlugins();
36
- await init_multi_tenant(loadAllPlugins);
37
+ const tenants = await getAllTenants();
38
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
37
39
 
38
40
  const Plugin = require("@saltcorn/data/models/plugin");
39
41
 
@@ -4,7 +4,6 @@
4
4
  */
5
5
  const { Command, flags } = require("@oclif/command");
6
6
 
7
-
8
7
  /**
9
8
  * ListTenantsCommand Class
10
9
  * @extends oclif.Command
@@ -15,19 +14,22 @@ class ListTenantsCommand extends Command {
15
14
  * @returns {Promise<void>}
16
15
  */
17
16
  async run() {
18
- const { getAllTenants } = require("@saltcorn/data/models/tenant");
17
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
19
18
  const db = require("@saltcorn/data/db");
20
19
  const tenantList = await getAllTenants();
21
- console.log("domain , files, users, tables, views, pages");
20
+ console.log(
21
+ "domain , files, users, tables, views, pages"
22
+ );
22
23
  for (const domain of tenantList)
23
24
  await db.runWithTenant(domain, async () => {
24
- console.log("%s, %s, %s, %s, %s, %s",
25
+ console.log(
26
+ "%s, %s, %s, %s, %s, %s",
25
27
  domain.padEnd(24),
26
- (await db.count("_sc_files" )).toString().padStart(8),
27
- (await db.count("users" )).toString().padStart(8),
28
+ (await db.count("_sc_files")).toString().padStart(8),
29
+ (await db.count("users")).toString().padStart(8),
28
30
  (await db.count("_sc_tables")).toString().padStart(8),
29
- (await db.count("_sc_views" )).toString().padStart(8),
30
- (await db.count("_sc_pages" )).toString().padStart(8)
31
+ (await db.count("_sc_views")).toString().padStart(8),
32
+ (await db.count("_sc_pages")).toString().padStart(8)
31
33
  );
32
34
  });
33
35
  this.exit(0);
@@ -43,6 +45,6 @@ ListTenantsCommand.description = `List tenants in CSV format`;
43
45
  /**
44
46
  * @type {string}
45
47
  */
46
- ListTenantsCommand.help= "Extra help here"
48
+ ListTenantsCommand.help = "Extra help here";
47
49
 
48
50
  module.exports = ListTenantsCommand;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  const { Command, flags } = require("@oclif/command");
6
6
  const db = require("@saltcorn/data/db");
7
- const { eachTenant } = require("@saltcorn/data/models/tenant");
7
+ const { eachTenant } = require("@saltcorn/admin-models/models/tenant");
8
8
  // todo add dryrun mode
9
9
 
10
10
  /**
@@ -16,7 +16,7 @@ class PluginsCommand extends Command {
16
16
  async run() {
17
17
  const db = require("@saltcorn/data/db");
18
18
  const { requirePlugin } = require("@saltcorn/server/load_plugins");
19
- const { getAllTenants } = require("@saltcorn/data/models/tenant");
19
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
20
20
  const Plugin = require("@saltcorn/data/models/plugin");
21
21
  var plugins = [];
22
22
  const { flags } = this.parse(PluginsCommand);
@@ -28,6 +28,10 @@ class ReleaseCommand extends Command {
28
28
  "@saltcorn/types": { dir: "saltcorn-types", publish: true },
29
29
  "@saltcorn/builder": { dir: "saltcorn-builder", publish: true },
30
30
  "@saltcorn/data": { dir: "saltcorn-data", publish: true },
31
+ "@saltcorn/admin-models": {
32
+ dir: "saltcorn-admin-models",
33
+ publish: true,
34
+ },
31
35
  "@saltcorn/random-tests": { dir: "saltcorn-random-tests" },
32
36
  "@saltcorn/server": { dir: "server", publish: true },
33
37
  "@saltcorn/base-plugin": { dir: "saltcorn-base-plugin", publish: true },
@@ -64,7 +68,7 @@ class ReleaseCommand extends Command {
64
68
  });
65
69
  };
66
70
  const publish = (dir) =>
67
- spawnSync("npm", ["publish"], {
71
+ spawnSync("npm", ["publish", "--access=public"], {
68
72
  stdio: "inherit",
69
73
  cwd: `packages/${dir}/`,
70
74
  });
@@ -14,8 +14,8 @@ const { maybe_as_tenant } = require("../common");
14
14
  */
15
15
  class RestoreCommand extends Command {
16
16
  /**
17
- *
18
- * @param {string} fnm
17
+ *
18
+ * @param {string} fnm
19
19
  * @returns {Promise<void>}
20
20
  */
21
21
  async pg_restore(fnm) {
@@ -35,13 +35,13 @@ class RestoreCommand extends Command {
35
35
  }
36
36
 
37
37
  /**
38
- *
39
- * @param {string} fnm
40
- * @param {object} tenant
38
+ *
39
+ * @param {string} fnm
40
+ * @param {object} tenant
41
41
  * @returns {Promise<void>}
42
42
  */
43
43
  async zip_restore(fnm, tenant) {
44
- const { restore } = require("@saltcorn/data/models/backup");
44
+ const { restore } = require("@saltcorn/admin-models/models/backup");
45
45
  const User = require("@saltcorn/data/models/user");
46
46
  const load_plugins = require("@saltcorn/server/load_plugins");
47
47
  await maybe_as_tenant(tenant, async () => {
@@ -15,7 +15,7 @@ class RmTenantCommand extends Command {
15
15
  */
16
16
  async run() {
17
17
  const { args } = this.parse(RmTenantCommand);
18
- const { deleteTenant } = require("@saltcorn/data/models/tenant");
18
+ const { deleteTenant } = require("@saltcorn/admin-models/models/tenant");
19
19
  await deleteTenant(args.tenant);
20
20
  this.exit(0);
21
21
  }
@@ -94,9 +94,7 @@ class RunTestsCommand extends Command {
94
94
  spawnSync("npm", ["run", "tsc"], {
95
95
  stdio: "inherit",
96
96
  });
97
-
98
97
  const db = require("@saltcorn/data/db");
99
-
100
98
  if (db.isSQLite) {
101
99
  const testdbpath = "/tmp/sctestdb";
102
100
  await db.changeConnection({ sqlite_path: testdbpath });
@@ -15,21 +15,20 @@ class SetupBenchmarkCommand extends Command {
15
15
  * @returns {Promise<void>}
16
16
  */
17
17
  async install_forum_pack() {
18
- const {
19
- fetch_pack_by_name,
20
- install_pack,
21
- } = require("@saltcorn/data/models/pack");
18
+ const { fetch_pack_by_name, install_pack } = require("@saltcorn/data/pack");
22
19
  const load_plugins = require("@saltcorn/server/load_plugins");
23
20
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
24
21
  const { init_multi_tenant } = require("@saltcorn/data/db/state");
22
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
25
23
  await loadAllPlugins();
26
- await init_multi_tenant(loadAllPlugins);
24
+ const tenants = await getAllTenants();
25
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
27
26
  const pack = await fetch_pack_by_name("Forum");
28
27
  await install_pack(pack.pack, flags.name, (p) =>
29
28
  load_plugins.loadAndSaveNewPlugin(p)
30
29
  );
31
30
  }
32
-
31
+
33
32
  /**
34
33
  * @returns {Promise<void>}
35
34
  */
@@ -68,12 +67,11 @@ class SetupBenchmarkCommand extends Command {
68
67
  thread: thread_id,
69
68
  });
70
69
  // install page
71
- const { install_pack } = require("@saltcorn/data/models/pack");
70
+ const { install_pack } = require("@saltcorn/admin-models/models/pack");
72
71
  await install_pack(simple_page_pack, flags.name, () => {});
73
72
  // install file
74
73
  const { rick_file } = require("@saltcorn/data/tests/mocks");
75
74
  await rick_file();
76
-
77
75
  });
78
76
  }
79
77
  }
@@ -8,7 +8,7 @@ const { Command, flags } = require("@oclif/command");
8
8
  * TransformFieldCommand Class
9
9
  * @extends oclif.Command
10
10
  * @category saltcorn-cli
11
- */
11
+ */
12
12
  class TransformFieldCommand extends Command {
13
13
  /**
14
14
  * @returns {Promise<void>}
@@ -18,14 +18,17 @@ class TransformFieldCommand extends Command {
18
18
  const Table = require("@saltcorn/data/models/table");
19
19
  const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
20
20
  const { getState, init_multi_tenant } = require("@saltcorn/data/db/state");
21
+ const { getAllTenants } = require("@saltcorn/admin-models/models/tenant");
21
22
 
22
23
  const {
23
24
  get_async_expression_function,
24
25
  } = require("@saltcorn/data/models/expression");
25
26
  const { args } = this.parse(TransformFieldCommand);
26
27
  await loadAllPlugins();
27
- if (args.tenant && db.is_it_multi_tenant())
28
- await init_multi_tenant(loadAllPlugins);
28
+ if (args.tenant && db.is_it_multi_tenant()) {
29
+ const tenants = await getAllTenants();
30
+ await init_multi_tenant(loadAllPlugins, undefined, tenants);
31
+ }
29
32
  const tenant = args.tenant || db.connectObj.default_schema;
30
33
  await db.runWithTenant(tenant, async () => {
31
34
  const table = await Table.findOne({ name: args.table });