poad 2.49.0 → 2.49.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poad",
3
- "version": "2.49.0",
3
+ "version": "2.49.1",
4
4
  "engine": "0.28.0",
5
5
  "runner": "0.2.0",
6
6
  "main": "index.js",
package/project/deploy.js CHANGED
@@ -11,8 +11,8 @@
11
11
  // Production (main) : résumé puis confirmation, sauf --yes (obligatoire hors
12
12
  // terminal). Codes de sortie : 0 déployé, 5 déploiement en échec (erreurs de
13
13
  // migration), 4 confirmation manquante, 3 session, 2 usage, 1 autre erreur.
14
- const DONE = ['succeeded', 'success', 'done', 'deployed', 'completed', 'ok', 'failed', 'error', 'cancelled', 'canceled'];
15
- const FAILED = ['failed', 'error', 'cancelled', 'canceled'];
14
+ const DONE = ['succeeded', 'success', 'refused', 'done', 'deployed', 'completed', 'ok', 'failed', 'error', 'cancelled', 'canceled'];
15
+ const FAILED = ['failed', 'error', 'cancelled', 'canceled', 'refused'];
16
16
 
17
17
  const names = (list) => (Array.isArray(list) ? list : []).map((m) => (typeof m === 'string' ? m : m && (m.name || m.version || m.file || m.migration)) || '?');
18
18
  const errorsOf = (list) =>
@@ -20,9 +20,12 @@ const errorsOf = (list) =>
20
20
 
21
21
  /** Résultat d'un déploiement, ramené aux champs connus */
22
22
  function summarize(d = {}) {
23
- const m = d.migrations || {};
23
+ // poad.io rend { outcome, migrations_applied, migrations_pending, errors } (control/server.mjs, deployView) ;
24
+ // l'ancienne forme { status, migrations: { applied, pending, errors } } reste lue
25
+ const m = d.migrations || { applied: d.migrations_applied, pending: d.migrations_pending, errors: d.errors };
24
26
  const errors = errorsOf(m.errors || d.errors);
25
- const status = typeof d.status === 'string' ? d.status.toLowerCase() : null;
27
+ const raw = typeof d.status === 'string' ? d.status : typeof d.outcome === 'string' ? d.outcome : null;
28
+ const status = raw ? raw.toLowerCase() : null;
26
29
  return {
27
30
  deploy_id: typeof d.deploy_id === 'string' || typeof d.deploy_id === 'number' ? String(d.deploy_id) : typeof d.id === 'string' ? d.id : null,
28
31
  status,
@@ -99,15 +99,16 @@ function fakeCloud(t, behaviour = {}) {
99
99
  const dry = req.headers['x-poad-dry-run'] === '1';
100
100
  if (behaviour.async) {
101
101
  state.deploys.d1 = 0;
102
- return send(res, 202, { deploy_id: 'd1', status: 'running' });
102
+ // La forme réelle de poad.io (control/server.mjs, deployView) : outcome, migrations_applied…
103
+ return send(res, 202, { deploy_id: 'd1', outcome: 'running', migrations_applied: [], migrations_pending: [], errors: [] });
103
104
  }
104
105
  return send(res, 200, { status: 'succeeded', dry_run: dry, migrations: dry ? { applied: [], pending: ['20261101000000_init'], errors: [] } : { applied: ['20261101000000_init'], pending: [], errors: [] } });
105
106
  }
106
107
  const dm = /^\/deploys\/([^/]+)$/.exec(m[2] || '');
107
108
  if (req.method === 'GET' && dm) {
108
109
  state.deploys[dm[1]]++;
109
- if (state.deploys[dm[1]] < 2) return send(res, 200, { deploy_id: dm[1], status: 'running' });
110
- return send(res, 200, { deploy_id: dm[1], status: 'failed', migrations: { applied: [], pending: [], errors: [{ migration: '20261101000000_init', message: 'relation "x" already exists' }] } });
110
+ if (state.deploys[dm[1]] < 2) return send(res, 200, { deploy_id: dm[1], outcome: 'running', migrations_applied: [], migrations_pending: [], errors: [] });
111
+ return send(res, 200, { deploy_id: dm[1], outcome: 'failed', migrations_applied: [], migrations_pending: [], errors: [{ migration: '20261101000000_init', message: 'relation "x" already exists' }] });
111
112
  }
112
113
  }
113
114
  return err(res, 404, 'not_found', `no route ${req.method} ${route}`);