@saltcorn/cli 0.6.2-beta.3 → 0.6.3-beta.0

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.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":[]},"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":[]},"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}},"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.3-beta.0","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,19 +2,19 @@
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.2-beta.3",
5
+ "version": "0.6.3-beta.0",
6
6
  "author": "Tom Nielsen @glutamate",
7
7
  "bin": {
8
8
  "saltcorn": "./bin/saltcorn"
9
9
  },
10
10
  "bugs": "https://github.com/saltcorn/saltcorn/issues",
11
11
  "dependencies": {
12
- "@oclif/command": "^1.8.9",
12
+ "@oclif/command": "^1.8.16",
13
13
  "@oclif/config": "^1.18.2",
14
- "@oclif/plugin-help": "^3.2.14",
15
- "@saltcorn/data": "0.6.2-beta.3",
16
- "@saltcorn/server": "0.6.2-beta.3",
17
- "cli-ux": "^5.6.6",
14
+ "@oclif/plugin-help": "^3.3.1",
15
+ "@saltcorn/data": "0.6.3-beta.0",
16
+ "@saltcorn/server": "0.6.3-beta.0",
17
+ "cli-ux": "^5.6.7",
18
18
  "contractis": "^0.1.0",
19
19
  "dateformat": "^3.0.3",
20
20
  "inquirer": "^7.3.3",
@@ -27,7 +27,7 @@
27
27
  "wrk": "^1.2.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@oclif/dev-cli": "^1.26.8",
30
+ "@oclif/dev-cli": "^1.26.10",
31
31
  "globby": "^10.0.2"
32
32
  },
33
33
  "engines": {
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @category saltcorn-cli
3
+ * @module commands/delete-tenants
4
+ */
5
+ const { Command, flags } = require("@oclif/command");
6
+
7
+ /**
8
+ * DeleteTenantsCommand Class
9
+ * @extends oclif.Command
10
+ * @category saltcorn-cli
11
+ */
12
+ class DeleteTenantsCommand extends Command {
13
+ /**
14
+ * @returns {Promise<void>}
15
+ */
16
+ async run() {
17
+ const {
18
+ getAllTenantRows,
19
+ deleteTenant,
20
+ } = require("@saltcorn/data/models/tenant");
21
+ const db = require("@saltcorn/data/db");
22
+ const tenantList = await getAllTenantRows();
23
+ const tensExamine = tenantList.slice(
24
+ 0,
25
+ Math.round(tenantList.length * 0.8)
26
+ );
27
+
28
+ for (const ten of tensExamine) {
29
+ let nusers, ntables, nviews, npages;
30
+ await db.runWithTenant(ten.subdomain, async () => {
31
+ nusers = await db.count("users");
32
+ ntables = await db.count("_sc_tables");
33
+ nviews = await db.count("_sc_views");
34
+ npages = await db.count("_sc_pages");
35
+ });
36
+ if (nusers < 2 && ntables < 2 && nviews < 1 && npages < 1) {
37
+ console.log("deleting ", ten.subdomain, {
38
+ nusers,
39
+ ntables,
40
+ nviews,
41
+ npages,
42
+ });
43
+ await deleteTenant(ten.subdomain);
44
+ } else {
45
+ console.log("leaving", ten.subdomain, {
46
+ nusers,
47
+ ntables,
48
+ nviews,
49
+ npages,
50
+ });
51
+ }
52
+ }
53
+ this.exit(0);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * @type {string}
59
+ */
60
+ DeleteTenantsCommand.description = `Delete inactive tenants`;
61
+
62
+ module.exports = DeleteTenantsCommand;
@@ -3,7 +3,7 @@
3
3
  * @module commands/fixtures
4
4
  */
5
5
  const { Command, flags } = require("@oclif/command");
6
-
6
+ const { maybe_as_tenant, parseJSONorString } = require("../common");
7
7
  /**
8
8
  * FixturesCommand Class
9
9
  * @extends oclif.Command
@@ -17,12 +17,20 @@ class FixturesCommand extends Command {
17
17
  const fixtures = require("@saltcorn/data/db/fixtures");
18
18
  const reset = require("@saltcorn/data/db/reset_schema");
19
19
  const { flags } = this.parse(FixturesCommand);
20
- if (flags.reset) {
21
- await reset();
20
+ if (flags.tenant) {
21
+ const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
22
+ const { init_multi_tenant } = require("@saltcorn/data/db/state");
23
+ await loadAllPlugins();
24
+ await init_multi_tenant(loadAllPlugins);
22
25
  }
23
- await fixtures();
24
- this.exit(0);
26
+ await maybe_as_tenant(flags.tenant, async () => {
27
+ if (flags.reset) {
28
+ await reset();
29
+ }
30
+ await fixtures();
31
+ });
25
32
 
33
+ this.exit(0);
26
34
  }
27
35
  }
28
36
 
@@ -39,6 +47,10 @@ This manual step it is never required for users and rarely required for develope
39
47
  */
40
48
  FixturesCommand.flags = {
41
49
  reset: flags.boolean({ char: "r", description: "Also reset schema" }),
50
+ tenant: flags.string({
51
+ char: "t",
52
+ description: "tenant",
53
+ }),
42
54
  };
43
55
 
44
56
  module.exports = FixturesCommand;
@@ -28,16 +28,23 @@ class PluginsCommand extends Command {
28
28
 
29
29
  for (const domain of tenantList) {
30
30
  await db.runWithTenant(domain, async () => {
31
- const myplugins = await Plugin.find( flags.name? { name : flags.name} : {});
31
+ const myplugins = await Plugin.find(
32
+ flags.name ? { name: flags.name } : {}
33
+ );
32
34
  myplugins.forEach((plugin) => {
33
-
34
35
  if (
35
36
  plugin.source === "npm" &&
36
37
  !plugins.map((p) => p.location).includes(plugin.location)
37
38
  ) {
38
39
  plugins.push(plugin);
39
- if(flags.verbose)
40
- console.log("%s\t%s\t%s\t%s", plugin.location, plugin.name, plugin.version, plugin.source);
40
+ if (flags.verbose)
41
+ console.log(
42
+ "%s\t%s\t%s\t%s",
43
+ plugin.location,
44
+ plugin.name,
45
+ plugin.version,
46
+ plugin.source
47
+ );
41
48
  else console.log(plugin.location);
42
49
  }
43
50
  });
@@ -58,24 +65,26 @@ class PluginsCommand extends Command {
58
65
  for (let plugin of myplugins) {
59
66
  if (plugin.source === "npm" && new_versions[plugin.location]) {
60
67
  // the plugin can be up to date
61
- if(!flags.force&&plugin.version===new_versions[plugin.location])
62
- console.log("Plugin %s is up to date", plugin.location);
63
- else if (flags.dryRun) {
68
+ if (
69
+ !flags.force &&
70
+ plugin.version === new_versions[plugin.location]
71
+ ) {
72
+ } else if (flags.dryRun) {
64
73
  console.log(
65
- `Would upgrade ${domain}'s plugin ${
66
- plugin.location
67
- } version from ${plugin.version} to ${new_versions[plugin.location]}`
68
- );
69
- }
70
- else {
71
- plugin.version = new_versions[plugin.location];
72
-
73
- const sql_logging = db.get_sql_logging();
74
- if(flags.verbose) db.set_sql_logging(true);
75
- await plugin.upsert();
76
- if(flags.verbose) db.set_sql_logging(sql_logging);
77
- }
74
+ `Would upgrade ${domain}'s plugin ${
75
+ plugin.location
76
+ } version from ${plugin.version} to ${
77
+ new_versions[plugin.location]
78
+ }`
79
+ );
80
+ } else {
81
+ plugin.version = new_versions[plugin.location];
78
82
 
83
+ const sql_logging = db.get_sql_logging();
84
+ if (flags.verbose) db.set_sql_logging(true);
85
+ await plugin.upsert();
86
+ if (flags.verbose) db.set_sql_logging(sql_logging);
87
+ }
79
88
  }
80
89
  }
81
90
  });
@@ -93,13 +102,20 @@ PluginsCommand.flags = {
93
102
  //list: flags.boolean({ char: "l", description: "List" }),
94
103
  upgrade: flags.boolean({ char: "u", description: "Upgrade" }),
95
104
  dryRun: flags.boolean({ char: "d", description: "Upgrade dry-run" }),
96
- verbose: flags.boolean({ char: "v", description: "Verbose output", default: false }),
97
- force: flags.boolean({ char: "f", description: "Force update", default: false }),
105
+ verbose: flags.boolean({
106
+ char: "v",
107
+ description: "Verbose output",
108
+ default: false,
109
+ }),
110
+ force: flags.boolean({
111
+ char: "f",
112
+ description: "Force update",
113
+ default: false,
114
+ }),
98
115
  name: flags.string({
99
116
  char: "n",
100
117
  description: "Plugin name",
101
118
  }),
102
-
103
119
  };
104
120
 
105
121
  // TODO Extra documentation goes here
@@ -114,17 +130,18 @@ Extra documentation goes here
114
130
  /**
115
131
  * @type {string}
116
132
  */
117
- PluginsCommand.examples = [ //"plugins -l - outputs detailed information about plugins",
133
+ PluginsCommand.examples = [
134
+ //"plugins -l - outputs detailed information about plugins",
118
135
  "plugins -v - verbose output of commands",
119
136
  "plugins -u -d - dry-run for plugin update",
120
- "plugins -u -f - force plugin update"
137
+ "plugins -u -f - force plugin update",
121
138
  ];
122
139
 
123
140
  // TODO Extra help here
124
141
  /**
125
142
  * @type {string}
126
143
  */
127
- PluginsCommand.help= "Extra help here"
144
+ PluginsCommand.help = "Extra help here";
128
145
 
129
146
  // PluginsCommand.usage
130
147
 
@@ -90,6 +90,11 @@ class RunTestsCommand extends Command {
90
90
  const { args, flags } = this.parse(RunTestsCommand);
91
91
  this.validateCall(args, flags);
92
92
  var env;
93
+
94
+ spawnSync("npm", ["run", "tsc"], {
95
+ stdio: "inherit",
96
+ });
97
+
93
98
  const db = require("@saltcorn/data/db");
94
99
 
95
100
  if (db.isSQLite) {