@saltcorn/cli 1.1.0-beta.9 → 1.1.1-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.
@@ -6,6 +6,7 @@ const { Command, Flags, Args } = require("@oclif/core");
6
6
  const { spawnSync } = require("child_process");
7
7
  const path = require("path");
8
8
  const { maybe_as_tenant } = require("../common");
9
+ const fs = require("fs");
9
10
 
10
11
  /**
11
12
  * RestoreCommand Class
@@ -72,6 +73,32 @@ class RestoreCommand extends Command {
72
73
  case ".zip":
73
74
  this.zip_restore(args.file, flags.tenant);
74
75
  break;
76
+ case ".json":
77
+ if (!args.file.includes("domain_files.json")) {
78
+ console.error("unknown filetype: " + path.extname(args.file));
79
+ this.exit(1);
80
+ }
81
+ const fileConts = fs.readFileSync(args.file);
82
+ const domain_files = JSON.parse(fileConts);
83
+ const {
84
+ insertTenant,
85
+ getAllTenants,
86
+ switchToTenant,
87
+ } = require("@saltcorn/admin-models/models/tenant");
88
+ const { add_tenant } = require("@saltcorn/data/db/state");
89
+
90
+ let existing_tenants = new Set(await getAllTenants());
91
+ existing_tenants.add("public");
92
+ for (const [tenant, fnm] of Object.entries(domain_files)) {
93
+ console.log("restore", tenant, "from", fnm);
94
+ if (!existing_tenants.has(tenant)) {
95
+ const tenrow = await insertTenant(tenant);
96
+ add_tenant(tenant);
97
+ await switchToTenant(tenrow);
98
+ }
99
+ await this.zip_restore(fnm, tenant === "public" ? undefined : tenant);
100
+ }
101
+ break;
75
102
  default:
76
103
  console.error("unknown filetype: " + path.extname(args.file));
77
104
  this.exit(1);
@@ -232,7 +232,7 @@ class SyncUploadData extends Command {
232
232
  async run() {
233
233
  let returnCode = 0,
234
234
  inTransaction = false;
235
- const { flags } = await await this.parse(SyncUploadData);
235
+ const { flags } = await this.parse(SyncUploadData);
236
236
  if (db.is_it_multi_tenant() && flags.tenantAppName) {
237
237
  await init_multi_tenant(loadAllPlugins, true, [flags.tenantAppName]);
238
238
  }
@@ -1,50 +0,0 @@
1
- const { Command, Flags } = require("@oclif/core");
2
- const { join } = require("path");
3
- const { spawnSync } = require("child_process");
4
-
5
- /**
6
- * This is a oclif command to build the 'saltcorn/cordova-builder' docker image.
7
- * The image is used in the 'build-app' command to run the cordova commands.
8
- * Please make sure docker is callable without sudo (see rootless mode, or add the user to the docker group).
9
- */
10
- class BuildCordovaBuilder extends Command {
11
- async run() {
12
- const { flags } = await this.parse(BuildCordovaBuilder);
13
- const dockerDir = join(
14
- require.resolve("@saltcorn/mobile-builder"),
15
- "..",
16
- "..",
17
- "docker"
18
- );
19
- const dArgs = ["build", dockerDir, "--network", "host"];
20
- if (flags.buildClean) dArgs.push("--no-cache");
21
- dArgs.push(
22
- "-f",
23
- join(dockerDir, "Dockerfile"),
24
- "-t",
25
- "saltcorn/cordova-builder",
26
- "--progress=plain"
27
- );
28
- const result = spawnSync("docker", dArgs, { cwd: ".", stdio: "inherit" });
29
- if (result.error) console.log(result.error.toString());
30
- }
31
- }
32
-
33
- BuildCordovaBuilder.description =
34
- "Build the 'saltcorn/cordova-builder' docker image";
35
-
36
- BuildCordovaBuilder.help =
37
- "Build the 'saltcorn/cordova-builder' docker image. " +
38
- "This image is used in the 'build-app' command to run the cordova commands. " +
39
- "Please make sure docker is callable without using root (see rootless mode, or add the user to the docker group).";
40
-
41
- BuildCordovaBuilder.flags = {
42
- buildClean: Flags.boolean({
43
- name: "build clean",
44
- string: "clean",
45
- description: "run a clean build with --no-cache",
46
- default: false,
47
- }),
48
- };
49
-
50
- module.exports = BuildCordovaBuilder;