poad 2.58.0 → 2.59.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/start.js +1 -1
- package/package.json +1 -1
- package/project/db/reset.js +1 -1
- package/project/upgrade.js +1 -1
- package/test/console-services.test.js +17 -0
- package/utils/report.js +1 -1
- package/utils/runner.js +1 -1
- package/utils/services.js +4 -3
- package/utils/valkey.js +14 -1
package/global/start.js
CHANGED
|
@@ -39,7 +39,7 @@ module.exports = async (args = {}) => {
|
|
|
39
39
|
|
|
40
40
|
// Services optionnels à lancer, puis l'état complet du projet
|
|
41
41
|
const finish = async () => {
|
|
42
|
-
const targets = bare ? [] : all ? SERVICES.filter((s) => s.optional && s.configured(config)) : autostartServices(config);
|
|
42
|
+
const targets = bare ? [] : all ? SERVICES.filter((s) => s.optional && s.configured(config)) : autostartServices(config, root);
|
|
43
43
|
// Groupe « Services » de la console (Mailpit, Keycloak) : ports de cette machine, après leur réattribution
|
|
44
44
|
require('../utils/console-services').write(root);
|
|
45
45
|
if (targets.length) await require('./run')({ services: targets.map((s) => s.id), quiet: true });
|
package/package.json
CHANGED
package/project/db/reset.js
CHANGED
|
@@ -81,7 +81,7 @@ module.exports = async (args = {}) => {
|
|
|
81
81
|
console.log(' ');
|
|
82
82
|
// poad start : base neuve, donc migrations (forcées) puis seed.sql
|
|
83
83
|
const { autostartServices } = require('../../utils/services');
|
|
84
|
-
const auto = new Set(autostartServices(config).map((s) => s.id));
|
|
84
|
+
const auto = new Set(autostartServices(config, root).map((s) => s.id));
|
|
85
85
|
await require('../../global/start')({ forceMigrate: true });
|
|
86
86
|
const again = running.filter((id) => !auto.has(id));
|
|
87
87
|
if (again.length) {
|
package/project/upgrade.js
CHANGED
|
@@ -52,7 +52,7 @@ module.exports = async (args = {}) => {
|
|
|
52
52
|
const startProject = async (running, startArgs) => {
|
|
53
53
|
await require('../global/start')(startArgs);
|
|
54
54
|
const fresh = readConfig(root);
|
|
55
|
-
const auto = new Set(autostartServices(fresh).map((s) => s.id));
|
|
55
|
+
const auto = new Set(autostartServices(fresh, root).map((s) => s.id));
|
|
56
56
|
const again = running.filter((id) => !auto.has(id));
|
|
57
57
|
if (again.length) {
|
|
58
58
|
await require('../global/run')({ services: again, quiet: true });
|
|
@@ -88,3 +88,20 @@ test('sessions longues du realm master : 30 jours et « Se souvenir de moi »',
|
|
|
88
88
|
assert.strictEqual(MASTER_SESSIONS.rememberMe, true);
|
|
89
89
|
for (const k of ['ssoSessionIdleTimeout', 'ssoSessionMaxLifespan', 'ssoSessionIdleTimeoutRememberMe', 'ssoSessionMaxLifespanRememberMe']) assert.strictEqual(MASTER_SESSIONS[k], 30 * 24 * 3600);
|
|
90
90
|
});
|
|
91
|
+
|
|
92
|
+
test('Valkey : lancé par poad start dès que le projet a des flows, sauf autostart = false', () => {
|
|
93
|
+
const fs = require('fs');
|
|
94
|
+
const os = require('os');
|
|
95
|
+
const path = require('path');
|
|
96
|
+
const { autostartServices } = require('../utils/services');
|
|
97
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'poad-flows-'));
|
|
98
|
+
const root = path.join(dir, 'config.toml');
|
|
99
|
+
const cfg = (valkey) => ({ project_uuid: 'x', valkey });
|
|
100
|
+
const ids = (list) => list.map((s) => s.id);
|
|
101
|
+
assert.ok(!ids(autostartServices(cfg({ port: 1234 }), root)).includes('valkey'));
|
|
102
|
+
fs.mkdirSync(path.join(dir, 'flows'));
|
|
103
|
+
fs.writeFileSync(path.join(dir, 'flows', 'accueil.json'), '{}');
|
|
104
|
+
assert.ok(ids(autostartServices(cfg({ port: 1234 }), root)).includes('valkey'));
|
|
105
|
+
assert.ok(!ids(autostartServices(cfg({ port: 1234, autostart: false }), root)).includes('valkey'));
|
|
106
|
+
assert.ok(!ids(autostartServices(cfg(undefined), root)).includes('valkey'));
|
|
107
|
+
});
|
package/utils/report.js
CHANGED
|
@@ -101,7 +101,7 @@ async function printServices(root, config, opts = {}) {
|
|
|
101
101
|
// Keycloak partagé : il peut tourner pour un autre projet sans servir celui-ci
|
|
102
102
|
const sharedKc = s.id === 'keycloak' && require('./keycloak-shared').isShared(config);
|
|
103
103
|
const running = sharedKc ? await require('./keycloak-shared').attached(docker, config) : state === 'running';
|
|
104
|
-
rows.push({ s, configured, running, auto: configured && s.optional && s.autostart(config) });
|
|
104
|
+
rows.push({ s, configured, running, auto: configured && s.optional && s.autostart(config, root) });
|
|
105
105
|
}
|
|
106
106
|
if (!rows.length) return;
|
|
107
107
|
|
package/utils/runner.js
CHANGED
|
@@ -19,7 +19,7 @@ const mail = require('./mail');
|
|
|
19
19
|
const valkey = require('./valkey');
|
|
20
20
|
|
|
21
21
|
// Version de l'image par défaut (aussi dans package.json, champ "runner")
|
|
22
|
-
const RUNNER_VERSION = '0.
|
|
22
|
+
const RUNNER_VERSION = '0.3.0';
|
|
23
23
|
const NAMES = ['runner'];
|
|
24
24
|
const ALIAS = 'runner';
|
|
25
25
|
const DOCKER_SOCKET = '/var/run/docker.sock';
|
package/utils/services.js
CHANGED
|
@@ -70,7 +70,8 @@ const SERVICES = [
|
|
|
70
70
|
section: 'valkey',
|
|
71
71
|
container: (config) => valkey.containerName(config),
|
|
72
72
|
configured: (config) => valkey.enabled(config),
|
|
73
|
-
autostart
|
|
73
|
+
// Lancé si autostart = true, ou si le projet a des flows (ils en ont besoin) sans que poad setup l'ait éteint
|
|
74
|
+
autostart: (config, root) => Boolean(config.valkey && (config.valkey.autostart === true || (config.valkey.autostart !== false && valkey.projectHasFlows(root)))),
|
|
74
75
|
savePort: (root, port) => valkey.savePort(root, port),
|
|
75
76
|
info: (config) => ({ URL: `redis://127.0.0.1:${config.valkey.port}`, 'From the engine': valkey.URL }),
|
|
76
77
|
},
|
|
@@ -109,7 +110,7 @@ const wantedServices = (args = {}) => SERVICES.filter((s) => s.optional && s.nam
|
|
|
109
110
|
/** --all, all : tous les services optionnels configurés */
|
|
110
111
|
const wantsAll = (args = {}) => Boolean(args.all || args['--all'] || args['-a']);
|
|
111
112
|
|
|
112
|
-
/** Services optionnels que poad start lance (autostart = true) */
|
|
113
|
-
const autostartServices = (config) => SERVICES.filter((s) => s.optional && s.configured(config) && s.autostart(config));
|
|
113
|
+
/** Services optionnels que poad start lance (autostart = true ; Valkey aussi dès que le projet a des flows) */
|
|
114
|
+
const autostartServices = (config, root) => SERVICES.filter((s) => s.optional && s.configured(config) && s.autostart(config, root));
|
|
114
115
|
|
|
115
116
|
module.exports = { SERVICES, containerState, wantedServices, wantsAll, autostartServices };
|
package/utils/valkey.js
CHANGED
|
@@ -58,4 +58,17 @@ const containerOptions = (config, root, net) => ({
|
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
/** Le projet a-t-il des flows (poad/flows/*.json) ? root : chemin de poad/config.toml ou du dossier poad */
|
|
62
|
+
const projectHasFlows = (root) => {
|
|
63
|
+
if (!root) return false;
|
|
64
|
+
const fs = require('fs');
|
|
65
|
+
const path = require('path');
|
|
66
|
+
const base = fs.existsSync(root) && fs.statSync(root).isDirectory() ? root : path.dirname(root);
|
|
67
|
+
try {
|
|
68
|
+
return fs.readdirSync(path.join(base, 'flows')).some((f) => f.endsWith('.json'));
|
|
69
|
+
} catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = { projectHasFlows, IMAGE, NAMES, ALIAS, URL, containerName, dataDir, wanted, enabled, engineEnv, savePort, containerOptions };
|