@saltcorn/cli 1.1.1 → 1.1.2-beta.1
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 +106 -105
- package/npm-shrinkwrap.json +13965 -18219
- package/oclif.manifest.json +1352 -890
- package/package.json +17 -17
- package/src/commands/add-schema.js +11 -5
- package/src/commands/configuration-check-backups.js +1 -1
- package/src/commands/configuration-check.js +1 -1
- package/src/commands/create-user.js +30 -4
- package/src/commands/delete-user.js +14 -7
- package/src/commands/get-cfg.js +1 -1
- package/src/commands/inspect.js +1 -1
- package/src/commands/list-triggers.js +1 -1
- package/src/commands/list-users.js +1 -1
- package/src/commands/modify-user.js +24 -7
- package/src/commands/reset-schema.js +14 -7
- package/src/commands/rm-tenant.js +11 -6
- package/src/commands/run-js.js +1 -1
- package/src/commands/run-sql.js +1 -1
- package/src/commands/run-trigger.js +1 -1
- package/src/commands/set-cfg.js +1 -1
- package/src/commands/set-daily-time.js +1 -1
- package/src/commands/setup.js +79 -29
package/package.json
CHANGED
|
@@ -2,38 +2,38 @@
|
|
|
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": "1.1.1",
|
|
5
|
+
"version": "1.1.2-beta.1",
|
|
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/core": "^2.
|
|
13
|
-
"@oclif/plugin-plugins": "^
|
|
14
|
-
"@saltcorn/admin-models": "1.1.1",
|
|
15
|
-
"@saltcorn/common-code": "1.1.1",
|
|
16
|
-
"@saltcorn/data": "1.1.1",
|
|
17
|
-
"@saltcorn/mobile-app": "1.1.1",
|
|
18
|
-
"@saltcorn/mobile-builder": "1.1.1",
|
|
19
|
-
"@saltcorn/plugins-loader": "1.1.1",
|
|
20
|
-
"@saltcorn/server": "1.1.1",
|
|
12
|
+
"@oclif/core": "^4.2.4",
|
|
13
|
+
"@oclif/plugin-plugins": "^5.4.26",
|
|
14
|
+
"@saltcorn/admin-models": "1.1.2-beta.1",
|
|
15
|
+
"@saltcorn/common-code": "1.1.2-beta.1",
|
|
16
|
+
"@saltcorn/data": "1.1.2-beta.1",
|
|
17
|
+
"@saltcorn/mobile-app": "1.1.2-beta.1",
|
|
18
|
+
"@saltcorn/mobile-builder": "1.1.2-beta.1",
|
|
19
|
+
"@saltcorn/plugins-loader": "1.1.2-beta.1",
|
|
20
|
+
"@saltcorn/server": "1.1.2-beta.1",
|
|
21
21
|
"contractis": "^0.1.0",
|
|
22
|
-
"dateformat": "^
|
|
23
|
-
"inquirer": "^
|
|
22
|
+
"dateformat": "^4.6.3",
|
|
23
|
+
"inquirer": "^12.3.3",
|
|
24
24
|
"js-yaml": "^4.1.0",
|
|
25
25
|
"node-fetch": "2.6.9",
|
|
26
|
-
"node-watch": "^0.7.
|
|
26
|
+
"node-watch": "^0.7.4",
|
|
27
27
|
"source-map-support": "^0.5.21",
|
|
28
28
|
"sudo": "^1.0.3",
|
|
29
|
-
"systeminformation": "^5.
|
|
29
|
+
"systeminformation": "^5.25.11",
|
|
30
30
|
"tcp-port-used": "^1.0.2",
|
|
31
31
|
"wrk": "^1.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"oclif": "
|
|
35
|
-
"globby": "^
|
|
36
|
-
"ts-node": "^9.
|
|
34
|
+
"oclif": "4.17.17",
|
|
35
|
+
"globby": "^11.1.0",
|
|
36
|
+
"ts-node": "^10.9.2"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=18.0.0"
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/add-schema
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
|
+
const inquirer = require("inquirer").default;
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* AddSchemaCommand Class
|
|
@@ -17,10 +18,15 @@ class AddSchemaCommand extends Command {
|
|
|
17
18
|
const { flags } = await this.parse(AddSchemaCommand);
|
|
18
19
|
const reset = require("@saltcorn/data/db/reset_schema");
|
|
19
20
|
if (!flags.force) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const confirmation = await inquirer.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: "confirm",
|
|
24
|
+
name: "continue",
|
|
25
|
+
message: "This adds Saltcorn schema to existing database\nContinue?",
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
if (!confirmation.continue) {
|
|
24
30
|
console.log(`Success: Command execution canceled`);
|
|
25
31
|
this.exit(1);
|
|
26
32
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/configuration-check-backups
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags, Args
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -2,8 +2,36 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/create-user
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
7
|
+
const inquirer = require("inquirer").default;
|
|
8
|
+
|
|
9
|
+
const promptEmailPassword = async (flags) => {
|
|
10
|
+
let email = flags.email;
|
|
11
|
+
let password = flags.password;
|
|
12
|
+
if (!email) {
|
|
13
|
+
const answersEmail = await inquirer.prompt([
|
|
14
|
+
{
|
|
15
|
+
name: "email",
|
|
16
|
+
message: "Email address",
|
|
17
|
+
type: "input",
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
email = answersEmail.email;
|
|
21
|
+
}
|
|
22
|
+
if (!password) {
|
|
23
|
+
const answersPassword = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
name: "password",
|
|
26
|
+
message: "Password",
|
|
27
|
+
type: "password",
|
|
28
|
+
mask: "*",
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
password = answersPassword.password;
|
|
32
|
+
}
|
|
33
|
+
return { email, password };
|
|
34
|
+
};
|
|
7
35
|
|
|
8
36
|
// todo update logic based on modify-user command
|
|
9
37
|
/**
|
|
@@ -38,9 +66,7 @@ class CreateUserCommand extends Command {
|
|
|
38
66
|
}
|
|
39
67
|
role_id = role.id;
|
|
40
68
|
}
|
|
41
|
-
const email
|
|
42
|
-
const password =
|
|
43
|
-
flags.password || (await ux.prompt("Password", { type: "hide" }));
|
|
69
|
+
const { email, password } = await promptEmailPassword(flags);
|
|
44
70
|
const u = await User.create({ email, password, role_id });
|
|
45
71
|
if (u instanceof User)
|
|
46
72
|
console.log(
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// todo support for users without emails (using user.id)
|
|
7
|
-
const { Command, Flags, Args
|
|
7
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
8
8
|
const { maybe_as_tenant } = require("../common");
|
|
9
|
+
const inquirer = require("inquirer").default;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* DeleteUserCommand Class
|
|
@@ -38,12 +39,18 @@ class DeleteUserCommand extends Command {
|
|
|
38
39
|
// make changes
|
|
39
40
|
// todo handle errors
|
|
40
41
|
if (!flags.force) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const confirmation = await inquirer.prompt([
|
|
43
|
+
{
|
|
44
|
+
type: "confirm",
|
|
45
|
+
name: "continue",
|
|
46
|
+
message: `This will delete user ${args.user_email} ${
|
|
47
|
+
typeof flags.tenant !== "undefined" ? "from " + flags.tenant : ""
|
|
48
|
+
}.\nContinue?`,
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
if (!confirmation.continue) {
|
|
47
54
|
console.log(`Success: Command execution canceled`);
|
|
48
55
|
this.exit(1);
|
|
49
56
|
}
|
package/src/commands/get-cfg.js
CHANGED
package/src/commands/inspect.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/create-user
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags, Args
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
7
7
|
|
|
8
8
|
// todo update logic based on modify-user command
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// todo support for users without emails (using user.id)
|
|
7
|
-
const { Command, Flags, Args
|
|
7
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
8
8
|
const { maybe_as_tenant, init_some_tenants } = require("../common");
|
|
9
|
+
const inquirer = require("inquirer").default;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* ModifyUserCommand Class
|
|
@@ -46,10 +47,17 @@ class ModifyUserCommand extends Command {
|
|
|
46
47
|
// email
|
|
47
48
|
let email;
|
|
48
49
|
if (flags.email) email = flags.email;
|
|
49
|
-
else if (flags.imode)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
else if (flags.imode) {
|
|
51
|
+
const emailPrompt = await inquirer.prompt([
|
|
52
|
+
{
|
|
53
|
+
type: "input",
|
|
54
|
+
name: "email",
|
|
55
|
+
message: "New Email address",
|
|
56
|
+
default: args.user_email,
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
email = emailPrompt.email;
|
|
60
|
+
}
|
|
53
61
|
if (email === args.user_email) email = undefined; // little trick - we won't update email if it already same
|
|
54
62
|
if (email)
|
|
55
63
|
if (!User.valid_email(email)) {
|
|
@@ -61,8 +69,17 @@ class ModifyUserCommand extends Command {
|
|
|
61
69
|
// todo check for repeated passwords
|
|
62
70
|
let password;
|
|
63
71
|
if (flags.password) password = flags.password;
|
|
64
|
-
else if (flags.imode)
|
|
65
|
-
|
|
72
|
+
else if (flags.imode) {
|
|
73
|
+
const passwordPrompt = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: "password",
|
|
76
|
+
name: "password",
|
|
77
|
+
message: "New Password",
|
|
78
|
+
mask: "*",
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
password = passwordPrompt.password;
|
|
82
|
+
}
|
|
66
83
|
if (password)
|
|
67
84
|
if (User.unacceptable_password_reason(password)) {
|
|
68
85
|
console.error(
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/reset-schema
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
6
|
const { maybe_as_tenant } = require("../common");
|
|
7
|
+
const inquirer = require("inquirer").default;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* ResetCommand Class
|
|
@@ -23,12 +24,18 @@ class ResetCommand extends Command {
|
|
|
23
24
|
if (flags.force) {
|
|
24
25
|
await reset(false, schema);
|
|
25
26
|
} else {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const confirmation = await inquirer.prompt([
|
|
28
|
+
{
|
|
29
|
+
type: "confirm",
|
|
30
|
+
name: "continue",
|
|
31
|
+
message: `This will wipe all data from database "${
|
|
32
|
+
db.isSQLite ? "SQLite" : db.connectObj.database + "." + schema
|
|
33
|
+
}".\nContinue?`,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
if (confirmation.continue) await reset(false, schema);
|
|
32
39
|
}
|
|
33
40
|
});
|
|
34
41
|
console.log("Successfully ran the 'reset-schema' command");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @category saltcorn-cli
|
|
3
3
|
* @module commands/rm-tenant
|
|
4
4
|
*/
|
|
5
|
-
const { Command, Flags
|
|
6
|
-
|
|
5
|
+
const { Command, Flags } = require("@oclif/core");
|
|
6
|
+
const inquirer = require("inquirer").default;
|
|
7
7
|
/**
|
|
8
8
|
* RmTenantCommand Class
|
|
9
9
|
* @extends oclif.Command
|
|
@@ -19,10 +19,15 @@ class RmTenantCommand extends Command {
|
|
|
19
19
|
const { deleteTenant } = require("@saltcorn/admin-models/models/tenant");
|
|
20
20
|
|
|
21
21
|
if (!flags.force) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const answer = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: "confirm",
|
|
25
|
+
name: "proceed",
|
|
26
|
+
message: `This will delete tenant ${flags.tenant}. Attention! All tenant data will be lost!\nContinue (y/n)?`,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
if (!answer.proceed) {
|
|
26
31
|
console.log(`Success: Command execution canceled`);
|
|
27
32
|
this.exit(1);
|
|
28
33
|
}
|
package/src/commands/run-js.js
CHANGED
package/src/commands/run-sql.js
CHANGED
package/src/commands/set-cfg.js
CHANGED
package/src/commands/setup.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @category saltcorn-cli
|
|
4
4
|
* @module commands/setup
|
|
5
5
|
*/
|
|
6
|
-
const { Command, Flags
|
|
6
|
+
const { Command, Flags } = require("@oclif/core");
|
|
7
7
|
const {
|
|
8
8
|
getConnectObject,
|
|
9
9
|
configFilePath,
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
const { is } = require("contractis");
|
|
14
14
|
const path = require("path");
|
|
15
15
|
const fs = require("fs");
|
|
16
|
-
const inquirer = require("inquirer");
|
|
16
|
+
const inquirer = require("inquirer").default;
|
|
17
17
|
const tcpPortUsed = require("tcp-port-used");
|
|
18
18
|
const { spawnSync } = require("child_process");
|
|
19
19
|
const sudo = require("sudo");
|
|
@@ -168,14 +168,27 @@ const asyncSudoPostgres = (args) => {
|
|
|
168
168
|
* @returns {Promise<string>}
|
|
169
169
|
*/
|
|
170
170
|
const get_password = async (for_who) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
const answers = await inquirer.prompt([
|
|
172
|
+
{
|
|
173
|
+
name: "password",
|
|
174
|
+
message: `Set ${for_who} to [auto-generate]`,
|
|
175
|
+
type: "password",
|
|
176
|
+
mask: "*",
|
|
177
|
+
default: "",
|
|
178
|
+
},
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
let password = answers.password;
|
|
175
182
|
if (!password) {
|
|
176
183
|
password = gen_password();
|
|
177
184
|
console.log(`Setting ${for_who} to:`, password);
|
|
178
|
-
await
|
|
185
|
+
await inquirer.prompt([
|
|
186
|
+
{
|
|
187
|
+
name: "continue",
|
|
188
|
+
message: "Press any key to continue...",
|
|
189
|
+
type: "input",
|
|
190
|
+
},
|
|
191
|
+
]);
|
|
179
192
|
}
|
|
180
193
|
return password;
|
|
181
194
|
};
|
|
@@ -242,28 +255,49 @@ const install_db = async () => {
|
|
|
242
255
|
*/
|
|
243
256
|
const prompt_connection = async () => {
|
|
244
257
|
console.log("Enter database connection parameters");
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
|
|
259
|
+
const answers = await inquirer.prompt([
|
|
260
|
+
{
|
|
261
|
+
type: "input",
|
|
262
|
+
name: "host",
|
|
263
|
+
message: "Database host",
|
|
264
|
+
default: "localhost",
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
type: "input",
|
|
268
|
+
name: "port",
|
|
269
|
+
message: "Database port",
|
|
270
|
+
default: "5432",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
type: "input",
|
|
274
|
+
name: "database",
|
|
275
|
+
message: "Database name",
|
|
276
|
+
default: "saltcorn",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
type: "input",
|
|
280
|
+
name: "user",
|
|
281
|
+
message: "Database user",
|
|
282
|
+
default: "saltcorn",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
type: "password",
|
|
286
|
+
name: "password",
|
|
287
|
+
message: "Database password",
|
|
288
|
+
mask: "*",
|
|
289
|
+
validate: (input) => (input ? true : "Password is required"),
|
|
290
|
+
},
|
|
291
|
+
]);
|
|
292
|
+
|
|
259
293
|
const session_secret = await get_password("session secret");
|
|
260
294
|
const jwt_secret = genJwtSecret();
|
|
261
295
|
return {
|
|
262
|
-
host: host || "localhost",
|
|
263
|
-
port: port || 5432,
|
|
264
|
-
database: database || "saltcorn",
|
|
265
|
-
user: user || "saltcorn",
|
|
266
|
-
password: password,
|
|
296
|
+
host: answers.host || "localhost",
|
|
297
|
+
port: answers.port || 5432,
|
|
298
|
+
database: answers.database || "saltcorn",
|
|
299
|
+
user: answers.user || "saltcorn",
|
|
300
|
+
password: answers.password,
|
|
267
301
|
session_secret,
|
|
268
302
|
jwt_secret,
|
|
269
303
|
multi_tenant: false,
|
|
@@ -352,9 +386,25 @@ const setup_users = async () => {
|
|
|
352
386
|
const hasUsers = await User.nonEmpty();
|
|
353
387
|
if (!hasUsers) {
|
|
354
388
|
console.log("No users found. Please create an admin user");
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
389
|
+
const credentials = await inquirer.prompt([
|
|
390
|
+
{
|
|
391
|
+
type: "input",
|
|
392
|
+
name: "email",
|
|
393
|
+
message: "Email address",
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
type: "password",
|
|
397
|
+
name: "password",
|
|
398
|
+
message: "Password",
|
|
399
|
+
mask: "*",
|
|
400
|
+
},
|
|
401
|
+
]);
|
|
402
|
+
|
|
403
|
+
await User.create({
|
|
404
|
+
email: credentials.email,
|
|
405
|
+
password: credentials.password,
|
|
406
|
+
role_id: 1,
|
|
407
|
+
});
|
|
358
408
|
} else {
|
|
359
409
|
console.log("Users already present");
|
|
360
410
|
}
|