poad 2.57.0 → 2.58.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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poad",
3
- "version": "2.57.0",
3
+ "version": "2.58.1",
4
4
  "engine": "0.28.0",
5
5
  "runner": "0.2.0",
6
6
  "main": "index.js",
@@ -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/deploy.js CHANGED
@@ -1,13 +1,12 @@
1
- // poad deploy [--env <branche>] [--dry-run] [--allow-destructive] [--yes] [--json]
1
+ // poad deploy [--env <branche>] [--dry-run] [--yes] [--json]
2
2
  //
3
3
  // Envoie le dossier poad/ (liste blanche, sans aucun secret : utils/cloud/bundle.js)
4
4
  // à l'environnement du projet poad.io lié :
5
5
  // POST v1/projects/:id/branches/:branch/deploy (application/gzip)
6
6
  // x-poad-sha commit git courant, si poad/ n'a aucun changement non commité
7
7
  // x-poad-dry-run 1 avec --dry-run : le serveur dit ce qu'il ferait, rien ne change
8
- // x-poad-allow-destructive 1 avec --allow-destructive : migrations qui suppriment
9
- // (drop, truncate, delete, rename) permises ; sinon le déploiement est refusé
10
- // réponse : { deploy_id?, status?, migrations: { applied, pending, errors } }
8
+ // réponse : { deploy_id?, status?, migrations: { applied, pending, errors }, warnings }
9
+ // warnings : migrations qui perdent des données (drop table, truncate…), signalées, jamais refusées
11
10
  // asynchrone (deploy_id et état non terminé) : GET …/deploys/:deploy_id jusqu'à la fin
12
11
  //
13
12
  // Production (main) : résumé puis confirmation, sauf --yes (obligatoire hors
@@ -34,6 +33,8 @@ function summarize(d = {}) {
34
33
  dry_run: Boolean(d.dry_run),
35
34
  migrations: { applied: names(m.applied), pending: names(m.pending), errors },
36
35
  message: typeof d.message === 'string' ? d.message : null,
36
+ // Signalé, jamais bloquant : migrations qui perdent des données (drop table, truncate…)
37
+ warnings: (Array.isArray(d.warnings) ? d.warnings : []).map((w) => ({ message: String((w && w.message) || ''), files: Array.isArray(w && w.files) ? w.files.map(String) : [] })),
37
38
  failed: errors.length > 0 || FAILED.includes(status),
38
39
  };
39
40
  }
@@ -70,7 +71,7 @@ module.exports = (args, raw) =>
70
71
  // Tables de référence trop lourdes pour git : hors de l'archive, envoyées au magasin de références
71
72
  const large = refStore.largeFiles(poadDir);
72
73
  const ignored = refStore.ensureGitignore(poadDir, large);
73
- const allowDestructive = Boolean(opts['allow-destructive']);
74
+ // --allow-destructive : accepté, sans effet (poad.io signale les migrations qui perdent des données, sans refuser)
74
75
 
75
76
  const env = await branches.resolve(id, { wanted: opts.env, root });
76
77
  let b;
@@ -96,7 +97,7 @@ module.exports = (args, raw) =>
96
97
  else if (git.empty) out.log(chalk.grey(' git repository without any commit yet: no commit id'));
97
98
  else out.log(chalk.grey(' not in a git repository: no commit id'));
98
99
  for (const s of b.skipped) if (!large.some((f) => f.rel === s.path)) out.log(chalk.grey(` skipped ${s.path}: ${s.reason}`));
99
- for (const f of large) out.log(chalk.grey(` ${f.rel} (${kb(f.size)}): too large for git, goes to the reference store, then is loaded`));
100
+ for (const f of large) out.log(chalk.grey(` ${f.rel} (${kb(f.size)}): too large for git: reference store, sent and loaded only if it changed (sha256)`));
100
101
  for (const f of ignored.tracked) out.log(chalk.yellowBright(` ⚠ poad/${f.rel} is tracked by git although it is too large: git rm --cached poad/${f.rel}`));
101
102
 
102
103
  if (env.production && !dryRun) {
@@ -107,7 +108,6 @@ module.exports = (args, raw) =>
107
108
  const headers = {};
108
109
  if (sha) headers['x-poad-sha'] = sha;
109
110
  if (dryRun) headers['x-poad-dry-run'] = '1';
110
- if (allowDestructive) headers['x-poad-allow-destructive'] = '1';
111
111
  let result = summarize(await api.call('POST', `${route}/deploy`, { body: b.tgz, contentType: 'application/gzip', headers, what: 'deploy', timeout: 300000 }));
112
112
 
113
113
  // Déploiement asynchrone : suivi jusqu'à son terme
@@ -133,6 +133,10 @@ module.exports = (args, raw) =>
133
133
  // Refus pour migrations destructives : lesquelles, et comment confirmer
134
134
  for (const f of e.files || []) out.log(` ${chalk.yellow(f)}`);
135
135
  }
136
+ for (const w of result.warnings || []) {
137
+ out.log(` ${chalk.yellowBright('⚠')} ${w.message}`);
138
+ for (const f of w.files) out.log(` ${chalk.yellow(f)}`);
139
+ }
136
140
  if (!m.applied.length && !m.pending.length && !m.errors.length) out.log(chalk.grey(' No migration to apply.'));
137
141
  // Grosses références : après les migrations (les tables existent), envoi puis chargement
138
142
  let references = null;
@@ -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
+ });
@@ -255,7 +255,7 @@ Object.assign(sheets, {
255
255
  notes: [EXIT_NOTE],
256
256
  },
257
257
  deploy: {
258
- usage: ['poad deploy [--env <name>] [--dry-run] [--allow-destructive] [--yes] [--json]'],
258
+ usage: ['poad deploy [--env <name>] [--dry-run] [--yes] [--json]'],
259
259
  text: [
260
260
  'Send the poad/ folder to an environment of the linked poad.io project, which applies its pending migrations and loads its functions, flows, API, auth and storage settings.',
261
261
  'Sent: migrations, auth, storage, functions, flows, api, reference, variables (defaults, no secret), types, credentials/manifest.json (names and types only, never values), seed.sql, config.toml (without any secret key). Never sent: poad/secrets.toml, .env files, data/, backups/, node_modules, symbolic links. If a value of poad/secrets.toml appears in a file to send, nothing is sent.',
@@ -263,7 +263,6 @@ Object.assign(sheets, {
263
263
  options: [
264
264
  ['--env <name>', 'the environment (default: the current git branch if it exists on poad.io, else main)'],
265
265
  ['--dry-run', 'poad.io says what it would do (migrations to apply), nothing changes'],
266
- ['--allow-destructive', 'allow pending migrations that drop, truncate, delete or rename (refused otherwise, with the files named)'],
267
266
  ['--yes', 'no question for production (required outside a terminal)'],
268
267
  PROJECT_OPT,
269
268
  JSON_OPT,
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/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: (config) => Boolean(config.valkey && config.valkey.autostart === true),
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
- module.exports = { IMAGE, NAMES, ALIAS, URL, containerName, dataDir, wanted, enabled, engineEnv, savePort, containerOptions };
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 };