@saltcorn/cli 0.7.2-beta.0 → 0.7.2-beta.10
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.
- package/README.md +244 -49
- package/oclif.manifest.json +1 -1
- package/package.json +10 -7
- package/src/commands/add-schema.js +23 -1
- package/src/commands/backup.js +7 -3
- package/src/commands/create-user.js +14 -8
- package/src/commands/delete-tenants.js +24 -20
- package/src/commands/delete-user.js +105 -0
- package/src/commands/get-cfg.js +63 -0
- package/src/commands/modify-user.js +163 -0
- package/src/commands/release.js +20 -9
- package/src/commands/reset-schema.js +11 -2
- package/src/commands/restore.js +5 -0
- package/src/commands/rm-tenant.js +39 -6
- package/src/commands/run-tests.js +44 -16
- package/src/commands/setup.js +48 -23
- package/src/common.js +13 -5
- package/src/index.js +9 -2
- package/CHANGELOG.md +0 -8
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.2-beta.
|
|
5
|
+
"version": "0.7.2-beta.10",
|
|
6
6
|
"author": "Tom Nielsen @glutamate",
|
|
7
7
|
"bin": {
|
|
8
8
|
"saltcorn": "./bin/saltcorn"
|
|
@@ -11,10 +11,11 @@
|
|
|
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.2-beta.
|
|
16
|
-
"@saltcorn/data": "0.7.2-beta.
|
|
17
|
-
"@saltcorn/server": "0.7.2-beta.
|
|
16
|
+
"@saltcorn/admin-models": "0.7.2-beta.10",
|
|
17
|
+
"@saltcorn/data": "0.7.2-beta.10",
|
|
18
|
+
"@saltcorn/server": "0.7.2-beta.10",
|
|
18
19
|
"cli-ux": "^5.6.7",
|
|
19
20
|
"contractis": "^0.1.0",
|
|
20
21
|
"dateformat": "^3.0.3",
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@oclif/dev-cli": "^1.26.10",
|
|
33
|
-
"globby": "^10.0.2"
|
|
34
|
+
"globby": "^10.0.2",
|
|
35
|
+
"ts-node": "^9.1.1"
|
|
34
36
|
},
|
|
35
37
|
"engines": {
|
|
36
38
|
"node": ">=8.0.0"
|
|
@@ -50,7 +52,8 @@
|
|
|
50
52
|
"commands": "./src/commands",
|
|
51
53
|
"bin": "saltcorn",
|
|
52
54
|
"plugins": [
|
|
53
|
-
"@oclif/plugin-help"
|
|
55
|
+
"@oclif/plugin-help",
|
|
56
|
+
"@oclif/plugin-plugins"
|
|
54
57
|
]
|
|
55
58
|
},
|
|
56
59
|
"repository": "github:saltcorn/saltcorn",
|
|
@@ -65,4 +68,4 @@
|
|
|
65
68
|
"publishConfig": {
|
|
66
69
|
"access": "public"
|
|
67
70
|
}
|
|
68
|
-
}
|
|
71
|
+
}
|
|
@@ -15,9 +15,19 @@ class AddSchemaCommand extends Command {
|
|
|
15
15
|
* @returns {Promise<void>}
|
|
16
16
|
*/
|
|
17
17
|
async run() {
|
|
18
|
+
|
|
19
|
+
const { flags } = this.parse(AddSchemaCommand);
|
|
18
20
|
const reset = require("@saltcorn/data/db/reset_schema");
|
|
21
|
+
if(!flags.force){
|
|
22
|
+
const ans = await cli.confirm(
|
|
23
|
+
`This add Saltcorn schema to existing database\nContinue (y/n)?`);
|
|
24
|
+
if (!ans) {
|
|
25
|
+
console.log(`Success: Command execution canceled`);
|
|
26
|
+
this.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
19
29
|
await reset(true);
|
|
20
|
-
|
|
30
|
+
console.log(`Success: Command execution successfully`);
|
|
21
31
|
this.exit(0);
|
|
22
32
|
}
|
|
23
33
|
}
|
|
@@ -27,4 +37,16 @@ class AddSchemaCommand extends Command {
|
|
|
27
37
|
*/
|
|
28
38
|
AddSchemaCommand.description = `Add Saltcorn schema to existing database`;
|
|
29
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
AddSchemaCommand.help = `Add Saltcorn schema to existing database`;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type {object}
|
|
47
|
+
*/
|
|
48
|
+
AddSchemaCommand.flags = {
|
|
49
|
+
force: flags.boolean({ char: "f", description: "force command execution" }),
|
|
50
|
+
};
|
|
51
|
+
|
|
30
52
|
module.exports = AddSchemaCommand;
|
package/src/commands/backup.js
CHANGED
|
@@ -7,13 +7,12 @@ const { execSync } = require("child_process");
|
|
|
7
7
|
const dateFormat = require("dateformat");
|
|
8
8
|
const os = require("os");
|
|
9
9
|
const { getConnectObject } = require("@saltcorn/data/db/connect");
|
|
10
|
-
const
|
|
11
|
-
var day = dateFormat(new Date(), "yyyymmdd");
|
|
10
|
+
const day = dateFormat(new Date(), "yyyymmdd");
|
|
12
11
|
const connobj = getConnectObject();
|
|
13
12
|
|
|
14
13
|
const pgdb = connobj.database;
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
const default_filenm = `${day}-${pgdb}-${os.hostname}.sqlc`;
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* BackupCommand Class
|
|
@@ -67,6 +66,11 @@ class BackupCommand extends Command {
|
|
|
67
66
|
*/
|
|
68
67
|
BackupCommand.description = `Backup the PostgreSQL database to a file with pg_dump or zip`;
|
|
69
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @type {string}
|
|
71
|
+
*/
|
|
72
|
+
BackupCommand.help = `Backup the PostgreSQL database to a file with pg_dump or zip`;
|
|
73
|
+
|
|
70
74
|
/**
|
|
71
75
|
* @type {object}
|
|
72
76
|
*/
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const { Command, flags } = require("@oclif/command");
|
|
6
6
|
const { cli } = require("cli-ux");
|
|
7
|
-
const { maybe_as_tenant } = require("../common");
|
|
7
|
+
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
8
8
|
|
|
9
|
+
// todo update logic based on modify-user command
|
|
9
10
|
/**
|
|
10
11
|
* CreateUserCommand Class
|
|
11
12
|
* @extends oclif.Command
|
|
@@ -16,6 +17,7 @@ class CreateUserCommand extends Command {
|
|
|
16
17
|
* @returns {Promise<void>}
|
|
17
18
|
*/
|
|
18
19
|
async run() {
|
|
20
|
+
|
|
19
21
|
const User = require("@saltcorn/data/models/user");
|
|
20
22
|
|
|
21
23
|
const { flags } = this.parse(CreateUserCommand);
|
|
@@ -23,12 +25,10 @@ class CreateUserCommand extends Command {
|
|
|
23
25
|
console.error("Error: specify at most one of admin and role");
|
|
24
26
|
this.exit(1);
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const tenants = await getAllTenants();
|
|
31
|
-
await init_multi_tenant(loadAllPlugins, undefined, tenants);
|
|
28
|
+
// init tenant
|
|
29
|
+
await init_some_tenants(flags.tenant);
|
|
30
|
+
|
|
31
|
+
// run function as specified tenant
|
|
32
32
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
33
33
|
let role_id = flags.admin ? 1 : 8;
|
|
34
34
|
if (flags.role) {
|
|
@@ -43,7 +43,13 @@ class CreateUserCommand extends Command {
|
|
|
43
43
|
const email = flags.email || (await cli.prompt("Email address"));
|
|
44
44
|
const password =
|
|
45
45
|
flags.password || (await cli.prompt("Password", { type: "hide" }));
|
|
46
|
-
await User.create({ email, password, role_id });
|
|
46
|
+
const u = await User.create({ email, password, role_id });
|
|
47
|
+
if(u instanceof User)
|
|
48
|
+
console.log(`Success: User ${email} created successfully ${
|
|
49
|
+
typeof flags.tenant !== "undefined" ? "in tenant " + flags.tenant : ""
|
|
50
|
+
}`);
|
|
51
|
+
else
|
|
52
|
+
console.error(`Error: ${u.error}`);
|
|
47
53
|
});
|
|
48
54
|
this.exit(0);
|
|
49
55
|
}
|
|
@@ -27,27 +27,31 @@ class DeleteTenantsCommand extends Command {
|
|
|
27
27
|
|
|
28
28
|
for (const ten of tensExamine) {
|
|
29
29
|
let nusers, ntables, nviews, npages;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
30
|
+
try {
|
|
31
|
+
await db.runWithTenant(ten.subdomain, async () => {
|
|
32
|
+
nusers = await db.count("users");
|
|
33
|
+
ntables = await db.count("_sc_tables");
|
|
34
|
+
nviews = await db.count("_sc_views");
|
|
35
|
+
npages = await db.count("_sc_pages");
|
|
50
36
|
});
|
|
37
|
+
if (nusers < 2 && ntables < 2 && nviews < 1 && npages < 1) {
|
|
38
|
+
console.log("deleting ", ten.subdomain, {
|
|
39
|
+
nusers,
|
|
40
|
+
ntables,
|
|
41
|
+
nviews,
|
|
42
|
+
npages,
|
|
43
|
+
});
|
|
44
|
+
await deleteTenant(ten.subdomain);
|
|
45
|
+
} else {
|
|
46
|
+
console.log("leaving", ten.subdomain, {
|
|
47
|
+
nusers,
|
|
48
|
+
ntables,
|
|
49
|
+
nviews,
|
|
50
|
+
npages,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("Error in tenant", ten.subdomain, e);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
this.exit(0);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-cli
|
|
3
|
+
* @module commands/delete-user
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// todo support for users without emails (using user.id)
|
|
7
|
+
const { Command, flags } = require("@oclif/command");
|
|
8
|
+
const { cli } = require("cli-ux");
|
|
9
|
+
const { maybe_as_tenant } = require("../common");
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* DeleteUserCommand Class
|
|
14
|
+
* @extends oclif.Command
|
|
15
|
+
* @category saltcorn-cli
|
|
16
|
+
*/
|
|
17
|
+
class DeleteUserCommand extends Command {
|
|
18
|
+
/**
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
async run() {
|
|
22
|
+
|
|
23
|
+
const User = require("@saltcorn/data/models/user");
|
|
24
|
+
|
|
25
|
+
const { args } = this.parse(DeleteUserCommand);
|
|
26
|
+
const { flags } = this.parse(DeleteUserCommand);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// run function as specified tenant
|
|
30
|
+
await maybe_as_tenant(flags.tenant, async () => {
|
|
31
|
+
// try to find user
|
|
32
|
+
const u = await User.findOne({email: args.user_email});
|
|
33
|
+
if (u === null) {
|
|
34
|
+
console.error(`Error: User ${args.user_email} is not found`);
|
|
35
|
+
this.exit(1);
|
|
36
|
+
}
|
|
37
|
+
if (!u instanceof User) {
|
|
38
|
+
console.error(`Error: ${u.error}`);
|
|
39
|
+
this.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// make changes
|
|
43
|
+
// todo handle errors
|
|
44
|
+
if (!flags.force) {
|
|
45
|
+
const ans = await cli.confirm(
|
|
46
|
+
`This will delete user ${args.user_email} ${
|
|
47
|
+
typeof flags.tenant !== "undefined" ? "from " + flags.tenant : ""
|
|
48
|
+
}.\nContinue (y/n)?`);
|
|
49
|
+
if (!ans) {
|
|
50
|
+
console.log(`Success: Command execution canceled`);
|
|
51
|
+
this.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// delete user
|
|
57
|
+
await u.delete();
|
|
58
|
+
console.log(`Success: User ${args.user_email} deleted ${
|
|
59
|
+
typeof flags.tenant !== "undefined" ? "from " + flags.tenant : ""
|
|
60
|
+
}`);
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
);
|
|
65
|
+
this.exit(0);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @type {object}
|
|
71
|
+
*/
|
|
72
|
+
DeleteUserCommand.args = [
|
|
73
|
+
{ name: "user_email", required: true, description: "User to delete" },
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @type {string}
|
|
78
|
+
*/
|
|
79
|
+
DeleteUserCommand.description = `Delete user.
|
|
80
|
+
|
|
81
|
+
Command deletes the user specified by USER_EMAIL.
|
|
82
|
+
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @type {string}
|
|
87
|
+
*/
|
|
88
|
+
DeleteUserCommand.help = `Delete user.
|
|
89
|
+
|
|
90
|
+
Command deletes the user specified by USER_EMAIL.
|
|
91
|
+
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @type {object}
|
|
96
|
+
*/
|
|
97
|
+
DeleteUserCommand.flags = {
|
|
98
|
+
force: flags.boolean({ char: "f", description: "force command execution" }),
|
|
99
|
+
tenant: flags.string({
|
|
100
|
+
char: "t",
|
|
101
|
+
description: "tenant",
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = DeleteUserCommand;
|
|
@@ -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;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-cli
|
|
3
|
+
* @module commands/modify-user
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// todo support for users without emails (using user.id)
|
|
7
|
+
const { Command, flags } = require("@oclif/command");
|
|
8
|
+
const { cli } = require("cli-ux");
|
|
9
|
+
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ModifyUserCommand Class
|
|
14
|
+
* @extends oclif.Command
|
|
15
|
+
* @category saltcorn-cli
|
|
16
|
+
*/
|
|
17
|
+
class ModifyUserCommand extends Command {
|
|
18
|
+
/**
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
async run() {
|
|
22
|
+
|
|
23
|
+
const User = require("@saltcorn/data/models/user");
|
|
24
|
+
|
|
25
|
+
const { args } = this.parse(ModifyUserCommand);
|
|
26
|
+
const { flags } = this.parse(ModifyUserCommand);
|
|
27
|
+
|
|
28
|
+
if (flags.admin && flags.role && flags.role !== "admin") {
|
|
29
|
+
console.error("Error: specify at most one of admin and role");
|
|
30
|
+
this.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// init tenant
|
|
34
|
+
await init_some_tenants(flags.tenant);
|
|
35
|
+
|
|
36
|
+
// run function as specified tenant
|
|
37
|
+
await maybe_as_tenant(flags.tenant, async () => {
|
|
38
|
+
// role_id
|
|
39
|
+
let role_id; // = flags.admin ? 1 : 8;
|
|
40
|
+
if (flags.admin) role_id = 1;
|
|
41
|
+
else if (flags.role) {
|
|
42
|
+
const roles = await User.get_roles();
|
|
43
|
+
const role = roles.find((r) => r.role === flags.role);
|
|
44
|
+
if (!role) {
|
|
45
|
+
console.error(`Error: role ${flags.role} not found`);
|
|
46
|
+
this.exit(1);
|
|
47
|
+
}
|
|
48
|
+
role_id = role.id;
|
|
49
|
+
}
|
|
50
|
+
// email
|
|
51
|
+
let email;
|
|
52
|
+
if (flags.email) email = flags.email;
|
|
53
|
+
else if (flags.imode) email = await cli.prompt("New Email address", { default : args.user_email });
|
|
54
|
+
if(email === args.user_email) email = undefined; // little trick - we won't update email if it already same
|
|
55
|
+
if (email)
|
|
56
|
+
if (!User.valid_email(email)){
|
|
57
|
+
console.error(`Error: Email is invalid`);
|
|
58
|
+
this.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// password
|
|
62
|
+
// todo check for repeated passwords
|
|
63
|
+
let password;
|
|
64
|
+
if (flags.password) password = flags.password;
|
|
65
|
+
else if (flags.imode) password = await cli.prompt("New Password", { type: "hide" });
|
|
66
|
+
if (password)
|
|
67
|
+
if (User.unacceptable_password_reason(password)){
|
|
68
|
+
console.error(`Error: ${User.unacceptable_password_reason(password)}`);
|
|
69
|
+
this.exit(1);
|
|
70
|
+
}
|
|
71
|
+
// check that user with new email does not exists
|
|
72
|
+
const u_new_email = await User.findOne({ email });
|
|
73
|
+
if(u_new_email !== null&&args.user_email!==email){
|
|
74
|
+
console.error(`Error: Cannot change email from ${args.user_email} to ${email}. User with email ${email} exists`);
|
|
75
|
+
this.exit(1);
|
|
76
|
+
}
|
|
77
|
+
// try to find user
|
|
78
|
+
const u = await User.findOne({ email: args.user_email });
|
|
79
|
+
if(u === null){
|
|
80
|
+
console.error(`Error: User ${args.user_email} is not found`);
|
|
81
|
+
this.exit(1);
|
|
82
|
+
}
|
|
83
|
+
if(!u instanceof User){
|
|
84
|
+
console.error(`Error: ${u.error}`);
|
|
85
|
+
this.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// make changes
|
|
89
|
+
if (email && role_id)
|
|
90
|
+
await u.update({ email, role_id });
|
|
91
|
+
else if(email)
|
|
92
|
+
await u.update({ email });
|
|
93
|
+
else if(role_id)
|
|
94
|
+
await u.update({ role_id });
|
|
95
|
+
|
|
96
|
+
if (password)
|
|
97
|
+
await u.changePasswordTo(password, false);
|
|
98
|
+
|
|
99
|
+
console.log(`Success: User ${email?email:args.user_email} updated successfully ${
|
|
100
|
+
typeof flags.tenant !== "undefined" ? "in tenant " + flags.tenant : ""
|
|
101
|
+
}`);
|
|
102
|
+
|
|
103
|
+
});
|
|
104
|
+
this.exit(0);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @type {object}
|
|
110
|
+
*/
|
|
111
|
+
ModifyUserCommand.args = [
|
|
112
|
+
{ name: "user_email", required: true, description: "User to modify" },
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @type {string}
|
|
117
|
+
*/
|
|
118
|
+
ModifyUserCommand.description = `Modify (update) user.
|
|
119
|
+
|
|
120
|
+
Command changes the user specified by USER_EMAIL.
|
|
121
|
+
|
|
122
|
+
You can change the user group, password and email.
|
|
123
|
+
|
|
124
|
+
NOTE that -a and -r role (--role=role) can give conflict.
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @type {string}
|
|
129
|
+
*/
|
|
130
|
+
ModifyUserCommand.help = `Modify (update) user.
|
|
131
|
+
|
|
132
|
+
Command changes the user specified by USER_EMAIL.
|
|
133
|
+
|
|
134
|
+
You can change the user group, password and email.
|
|
135
|
+
|
|
136
|
+
NOTE that -a and -r role (--role=role) can give conflict.
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @type {object}
|
|
141
|
+
*/
|
|
142
|
+
ModifyUserCommand.flags = {
|
|
143
|
+
admin: flags.boolean({ char: "a", description: "make user be Admin" }),
|
|
144
|
+
tenant: flags.string({
|
|
145
|
+
char: "t",
|
|
146
|
+
description: "tenant",
|
|
147
|
+
}),
|
|
148
|
+
email: flags.string({
|
|
149
|
+
char: "e",
|
|
150
|
+
description: "new email",
|
|
151
|
+
}),
|
|
152
|
+
role: flags.string({
|
|
153
|
+
char: "r",
|
|
154
|
+
description: "new role (can conflict with -a option)",
|
|
155
|
+
}),
|
|
156
|
+
password: flags.string({
|
|
157
|
+
char: "p",
|
|
158
|
+
description: "new password",
|
|
159
|
+
}),
|
|
160
|
+
imode: flags.boolean({ char: "i", description: "interactive mode" }),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
module.exports = ModifyUserCommand;
|
package/src/commands/release.js
CHANGED
|
@@ -24,6 +24,7 @@ class ReleaseCommand extends Command {
|
|
|
24
24
|
"@saltcorn/e2e": { dir: "e2e" },
|
|
25
25
|
"@saltcorn/db-common": { dir: "db-common", publish: true },
|
|
26
26
|
"@saltcorn/sqlite": { dir: "sqlite", publish: true },
|
|
27
|
+
"@saltcorn/sqlite-mobile": { dir: "sqlite-mobile", publish: true },
|
|
27
28
|
"@saltcorn/postgres": { dir: "postgres", publish: true },
|
|
28
29
|
"@saltcorn/types": { dir: "saltcorn-types", publish: true },
|
|
29
30
|
"@saltcorn/builder": { dir: "saltcorn-builder", publish: true },
|
|
@@ -37,28 +38,38 @@ class ReleaseCommand extends Command {
|
|
|
37
38
|
"@saltcorn/base-plugin": { dir: "saltcorn-base-plugin", publish: true },
|
|
38
39
|
//"saltcorn-cli", publish: true},
|
|
39
40
|
"@saltcorn/markup": { dir: "saltcorn-markup", publish: true },
|
|
41
|
+
"@saltcorn/mobile-app": { dir: "saltcorn-mobile-app", publish: true },
|
|
42
|
+
"@saltcorn/mobile-builder": {
|
|
43
|
+
dir: "saltcorn-mobile-builder",
|
|
44
|
+
publish: true,
|
|
45
|
+
},
|
|
40
46
|
"@saltcorn/sbadmin2": { dir: "saltcorn-sbadmin2", publish: true },
|
|
41
47
|
};
|
|
42
48
|
|
|
49
|
+
const updateDependencies = (json, dpkgnm, version) => {
|
|
50
|
+
if (json.dependencies && json.dependencies[dpkgnm])
|
|
51
|
+
json.dependencies[dpkgnm] = version;
|
|
52
|
+
if (json.devDependencies && json.devDependencies[dpkgnm])
|
|
53
|
+
json.devDependencies[dpkgnm] = version;
|
|
54
|
+
if (json.optionalDependencies && json.optionalDependencies[dpkgnm])
|
|
55
|
+
json.optionalDependencies[dpkgnm] = version;
|
|
56
|
+
};
|
|
57
|
+
|
|
43
58
|
const updatePkgJson = (dir) => {
|
|
44
59
|
const json = require(`../../../${dir}/package.json`);
|
|
45
60
|
json.version = version;
|
|
46
61
|
if (json.dependencies || json.devDependencies)
|
|
47
62
|
Object.keys(pkgs).forEach((dpkgnm) => {
|
|
48
|
-
|
|
49
|
-
json.dependencies[dpkgnm] = version;
|
|
50
|
-
if (json.devDependencies && json.devDependencies[dpkgnm])
|
|
51
|
-
json.devDependencies[dpkgnm] = version;
|
|
52
|
-
if (json.optionalDependencies && json.optionalDependencies[dpkgnm])
|
|
53
|
-
json.optionalDependencies[dpkgnm] = version;
|
|
63
|
+
updateDependencies(json, dpkgnm, version);
|
|
54
64
|
});
|
|
65
|
+
updateDependencies(json, "@saltcorn/cli", version);
|
|
55
66
|
fs.writeFileSync(
|
|
56
67
|
`packages/${dir}/package.json`,
|
|
57
68
|
JSON.stringify(json, null, 2)
|
|
58
69
|
);
|
|
59
70
|
};
|
|
60
71
|
const compileTsFiles = () => {
|
|
61
|
-
spawnSync("npm", ["install"], {
|
|
72
|
+
spawnSync("npm", ["install", "--legacy-peer-deps"], {
|
|
62
73
|
stdio: "inherit",
|
|
63
74
|
cwd: ".",
|
|
64
75
|
});
|
|
@@ -78,7 +89,7 @@ class ReleaseCommand extends Command {
|
|
|
78
89
|
// 1. update version
|
|
79
90
|
// 2. update dependencies for other packages
|
|
80
91
|
// 3. publish
|
|
81
|
-
spawnSync("npm", ["install"], {
|
|
92
|
+
spawnSync("npm", ["install", "--legacy-peer-deps"], {
|
|
82
93
|
stdio: "inherit",
|
|
83
94
|
cwd: `packages/saltcorn-cli/`,
|
|
84
95
|
});
|
|
@@ -93,7 +104,7 @@ class ReleaseCommand extends Command {
|
|
|
93
104
|
// 3. run npm update
|
|
94
105
|
// 3. publish
|
|
95
106
|
updatePkgJson("saltcorn-cli");
|
|
96
|
-
spawnSync("npm", ["update"], {
|
|
107
|
+
spawnSync("npm", ["update","--legacy-peer-deps"], {
|
|
97
108
|
stdio: "inherit",
|
|
98
109
|
cwd: `packages/saltcorn-cli/`,
|
|
99
110
|
});
|
|
@@ -17,7 +17,7 @@ class ResetCommand extends Command {
|
|
|
17
17
|
*/
|
|
18
18
|
async run() {
|
|
19
19
|
const reset = require("@saltcorn/data/db/reset_schema");
|
|
20
|
-
const db = require("@saltcorn/data/db
|
|
20
|
+
const db = require("@saltcorn/data/db");
|
|
21
21
|
const { flags } = this.parse(ResetCommand);
|
|
22
22
|
await maybe_as_tenant(flags.tenant, async () => {
|
|
23
23
|
const schema = db.getTenantSchema();
|
|
@@ -32,6 +32,7 @@ class ResetCommand extends Command {
|
|
|
32
32
|
if (ans) await reset(false, schema);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
console.log(`Success: Command execution successfully`);
|
|
35
36
|
this.exit(0);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -44,11 +45,19 @@ ResetCommand.description = `Reset the database
|
|
|
44
45
|
This will delete all existing information
|
|
45
46
|
`;
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
ResetCommand.help = `Reset the database
|
|
52
|
+
...
|
|
53
|
+
This will delete all existing information
|
|
54
|
+
`;
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* @type {object}
|
|
49
58
|
*/
|
|
50
59
|
ResetCommand.flags = {
|
|
51
|
-
force: flags.boolean({ char: "f", description: "force" }),
|
|
60
|
+
force: flags.boolean({ char: "f", description: "force command execution" }),
|
|
52
61
|
tenant: flags.string({
|
|
53
62
|
char: "t",
|
|
54
63
|
description: "tenant",
|
package/src/commands/restore.js
CHANGED
|
@@ -91,6 +91,11 @@ RestoreCommand.args = [
|
|
|
91
91
|
*/
|
|
92
92
|
RestoreCommand.description = `Restore a previously backed up database (zip or sqlc format)`;
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @type {string}
|
|
96
|
+
*/
|
|
97
|
+
RestoreCommand.help = `Restore a previously backed up database (zip or sqlc format)`;
|
|
98
|
+
|
|
94
99
|
/**
|
|
95
100
|
* @type {object}
|
|
96
101
|
*/
|