poad 2.5.11 → 2.6.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.
- package/global/init.js +2 -11
- package/global/start.js +13 -8
- package/package.json +2 -2
- package/project/info.js +2 -4
- package/utils/engine.js +26 -0
package/global/init.js
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = async (args) => {
|
|
|
23
23
|
config.project_id = path.basename(process.cwd());
|
|
24
24
|
config.project_uuid = generateUniqueId();
|
|
25
25
|
await fs.mkdir(path.join(process.cwd(), 'poad', 'data'), { recursive: true });
|
|
26
|
-
const ports = await findFreePorts(
|
|
26
|
+
const ports = await findFreePorts(3);
|
|
27
27
|
config.engine = global.package.engine;
|
|
28
28
|
config.db = {
|
|
29
29
|
port: ports[0],
|
|
@@ -31,11 +31,8 @@ module.exports = async (args) => {
|
|
|
31
31
|
config.web = {
|
|
32
32
|
port: ports[1],
|
|
33
33
|
};
|
|
34
|
-
config.s3 = {
|
|
35
|
-
port: ports[2],
|
|
36
|
-
};
|
|
37
34
|
config.inbucket = {
|
|
38
|
-
port: ports[
|
|
35
|
+
port: ports[2],
|
|
39
36
|
};
|
|
40
37
|
const key = generateSecret();
|
|
41
38
|
config.auth = {
|
|
@@ -45,12 +42,6 @@ module.exports = async (args) => {
|
|
|
45
42
|
service: jwt.sign(service, key),
|
|
46
43
|
admin: jwt.sign(admin, key),
|
|
47
44
|
};
|
|
48
|
-
config.s3 = {
|
|
49
|
-
port: config.s3.port,
|
|
50
|
-
access_key: generateSecret(),
|
|
51
|
-
secret_key: generateSecret(),
|
|
52
|
-
region: 'local',
|
|
53
|
-
};
|
|
54
45
|
const toml = json2toml(config);
|
|
55
46
|
const isInstalled = await fs
|
|
56
47
|
.stat(path.join(process.cwd(), 'poad', 'config.toml'))
|
package/global/start.js
CHANGED
|
@@ -9,9 +9,11 @@ module.exports = async (args) => {
|
|
|
9
9
|
const prettyoutput = require('prettyoutput');
|
|
10
10
|
const { findPoadDir } = require('../utils/findpoad');
|
|
11
11
|
const { isDockerExist } = require('../utils/docker');
|
|
12
|
+
const { usesMinio, storageInfo } = require('../utils/engine');
|
|
12
13
|
const root = findPoadDir(process.cwd());
|
|
13
14
|
const config = toml.parse(await fs.readFile(root, 'utf-8'));
|
|
14
15
|
const containerName = config.project_uuid;
|
|
16
|
+
const minio = usesMinio(config);
|
|
15
17
|
console.log(' ');
|
|
16
18
|
if (await isDockerExist(containerName)) {
|
|
17
19
|
return console.log(chalk.bold('Container already started'));
|
|
@@ -30,15 +32,21 @@ module.exports = async (args) => {
|
|
|
30
32
|
'JWT_SECRET=' + config.auth.secret,
|
|
31
33
|
'ANON_KEY=' + config.auth.anon,
|
|
32
34
|
'SERVICE_ROLE_KEY=' + config.auth.service,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
...(minio
|
|
36
|
+
? [
|
|
37
|
+
'S3_ACCESS_KEY=' + config.s3.access_key,
|
|
38
|
+
'S3_SECRET_KEY=' + config.s3.secret_key,
|
|
39
|
+
'S3_REGION=local',
|
|
40
|
+
]
|
|
41
|
+
: []),
|
|
36
42
|
],
|
|
37
43
|
HostConfig: {
|
|
38
44
|
PortBindings: {
|
|
39
45
|
'5432/tcp': [{ HostPort: config.db.port.toString() }],
|
|
40
46
|
'8000/tcp': [{ HostPort: config.web.port.toString() }],
|
|
41
|
-
|
|
47
|
+
...(minio
|
|
48
|
+
? { '9500/tcp': [{ HostPort: config.s3.port.toString() }] }
|
|
49
|
+
: {}),
|
|
42
50
|
'9000/tcp': [{ HostPort: config.inbucket.port.toString() }],
|
|
43
51
|
},
|
|
44
52
|
Binds: [path.dirname(root) + '/data:/data'],
|
|
@@ -57,10 +65,7 @@ module.exports = async (args) => {
|
|
|
57
65
|
const info = {
|
|
58
66
|
'API URL': `http://localhost:${config.web.port}`,
|
|
59
67
|
'DB URL': `postgres://postgres:postgres@localhost:${config.db.port}/postgres`,
|
|
60
|
-
|
|
61
|
-
'S3 ACCESS KEY': config.s3.access_key,
|
|
62
|
-
'S3 SECRET KEY': config.s3.secret_key,
|
|
63
|
-
'S3 REGION': 'local',
|
|
68
|
+
...storageInfo(config),
|
|
64
69
|
'Inbucket URL': `http://localhost:${config.inbucket.port}`,
|
|
65
70
|
'JWT secret': `${config.auth.secret}`,
|
|
66
71
|
'anon key': config.auth.anon,
|
package/package.json
CHANGED
package/project/info.js
CHANGED
|
@@ -6,6 +6,7 @@ module.exports = async (args) => {
|
|
|
6
6
|
const prettyoutput = require('prettyoutput');
|
|
7
7
|
const { findPoadDir } = require('../utils/findpoad');
|
|
8
8
|
const { isDockerExist } = require('../utils/docker');
|
|
9
|
+
const { storageInfo } = require('../utils/engine');
|
|
9
10
|
const root = findPoadDir(process.cwd());
|
|
10
11
|
const config = toml.parse(await fs.readFile(root, 'utf-8'));
|
|
11
12
|
console.log(' ');
|
|
@@ -17,10 +18,7 @@ module.exports = async (args) => {
|
|
|
17
18
|
const info = {
|
|
18
19
|
'API URL': `http://localhost:${config.web.port}`,
|
|
19
20
|
'DB URL': `postgres://postgres:postgres@localhost:${config.db.port}/postgres`,
|
|
20
|
-
|
|
21
|
-
'S3 ACCESS KEY': config.s3.access_key,
|
|
22
|
-
'S3 SECRET KEY': config.s3.secret_key,
|
|
23
|
-
'S3 REGION': 'local',
|
|
21
|
+
...storageInfo(config),
|
|
24
22
|
'Inbucket URL': `http://localhost:${config.inbucket.port}`,
|
|
25
23
|
'JWT secret': `${config.auth.secret}`,
|
|
26
24
|
'anon key': config.auth.anon,
|
package/utils/engine.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Engines before 0.6.0 ship Kong + MinIO: S3 is served on its own port (9500).
|
|
2
|
+
// From 0.6.0 on, the gateway is APISIX and storage is served by the gateway
|
|
3
|
+
// under /storage/v1.
|
|
4
|
+
const usesMinio = (config) => {
|
|
5
|
+
const [major, minor] = String(config.engine || '')
|
|
6
|
+
.split('.')
|
|
7
|
+
.map(Number);
|
|
8
|
+
return Boolean(config.s3) && major === 0 && minor < 6;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Storage lines shown by `poad start` and `poad info`.
|
|
12
|
+
const storageInfo = (config) => {
|
|
13
|
+
if (usesMinio(config)) {
|
|
14
|
+
return {
|
|
15
|
+
'S3 URL': `http://localhost:${config.s3.port}/`,
|
|
16
|
+
'S3 ACCESS KEY': config.s3.access_key,
|
|
17
|
+
'S3 SECRET KEY': config.s3.secret_key,
|
|
18
|
+
'S3 REGION': 'local',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
'Storage URL': `http://localhost:${config.web.port}/storage/v1`,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = { usesMinio, storageInfo };
|