poad 2.18.2 → 2.19.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 CHANGED
@@ -4,6 +4,9 @@
4
4
  // poad/migrations/ schéma de la base, appliqué par poad start / poad migrate
5
5
  // poad/.gitignore data/ et secrets.toml
6
6
  // poad/data/ base et fichiers du projet local, hors git
7
+ // .gitignore à la racine (fichiers des systèmes, éditeurs, dépendances,
8
+ // secrets), puis git init si git est installé et que le
9
+ // dossier n'est pas déjà dans un dépôt (aucun commit)
7
10
  module.exports = async () => {
8
11
  const path = require('path');
9
12
  const fs = require('fs');
@@ -39,6 +42,14 @@ module.exports = async () => {
39
42
  console.log(chalk.bold('\n ✅ Your project has been initialized'));
40
43
  console.log(chalk.grey(' poad/config.toml and poad/migrations/ are versioned; poad/secrets.toml and poad/data/ stay on this machine.'));
41
44
 
45
+ // Dépôt git : les migrations suivent les branches
46
+ const repo = require('../utils/git').setupRepo(process.cwd());
47
+ if (repo.gitignore) console.log(chalk.grey(` .gitignore: ${repo.gitignore} entries (macOS, Windows, Linux, editors, dependencies, poad secrets).`));
48
+ if (repo.repo === 'created') console.log(chalk.grey(' git repository created (branch main, nothing committed yet).'));
49
+ else if (repo.repo === 'existing') console.log(chalk.grey(` Already in the git repository ${path.relative(process.cwd(), repo.root) || '.'}: left as is.`));
50
+ else if (repo.repo === 'no-git') console.log(chalk.yellowBright(' git is not installed: no repository created (https://git-scm.com/downloads), then "git init".'));
51
+ else if (repo.repo === 'failed') console.log(chalk.yellowBright(` git init failed: ${repo.error}`));
52
+
42
53
  // Dans un terminal : on enchaîne sur le choix des services (poad setup)
43
54
  if (process.stdin.isTTY && process.stdout.isTTY) {
44
55
  const { confirm } = require('@inquirer/prompts');
package/global/start.js CHANGED
@@ -3,6 +3,12 @@
3
3
  // puis affiche l'état complet (comme poad info)
4
4
  // poad start --all tous les services configurés, autostart ou non
5
5
  // poad start --bare l'engine et Mailpit seulement, cette fois-ci
6
+ /** Crée le dossier s'il manque (un montage Docker d'un dossier absent crée un dossier root) */
7
+ const ensureDir = (dir) => {
8
+ require('fs').mkdirSync(dir, { recursive: true });
9
+ return dir;
10
+ };
11
+
6
12
  module.exports = async (args = {}) => {
7
13
  const chalk = require('chalk-v2');
8
14
  const Docker = require('dockerode');
@@ -81,6 +87,10 @@ module.exports = async (args = {}) => {
81
87
  // Projet local : journaux détaillés (SQL, requêtes lentes dès 100 ms).
82
88
  // Sans cette variable, l'engine démarre en production.
83
89
  'POAD_MODE=development',
90
+ 'POAD_ENGINE_VERSION=' + config.engine,
91
+ // Console d'administration sans mot de passe : seulement si les ports
92
+ // n'écoutent que sur cette machine
93
+ 'POAD_CONSOLE=' + (require('../utils/ports').exposed(config) ? 'off' : 'local'),
84
94
  'POSTGRES_PASSWORD=postgres',
85
95
  'ADMIN_API_KEY=' + config.auth.admin,
86
96
  'JWT_SECRET=' + config.auth.secret,
@@ -97,7 +107,8 @@ module.exports = async (args = {}) => {
97
107
  '8000/tcp': [{ HostIp: require('../utils/ports').hostIp(config), HostPort: config.web.port.toString() }],
98
108
  ...gelf.bindings,
99
109
  },
100
- Binds: [path.dirname(root) + '/data:/data'],
110
+ // poad/migrations monté : la console y écrit les migrations qu'elle crée
111
+ Binds: [path.dirname(root) + '/data:/data', `${ensureDir(path.join(path.dirname(root), 'migrations'))}:/project/migrations`],
101
112
  // Services lancés sur la machine : joignables depuis l'engine, y
102
113
  // compris sous Linux
103
114
  ExtraHosts: ['host.docker.internal:host-gateway'],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poad",
3
- "version": "2.18.2",
4
- "engine": "0.10.1",
3
+ "version": "2.19.0",
4
+ "engine": "0.11.0",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "bin": {
package/project/cli.js CHANGED
@@ -8,12 +8,14 @@
8
8
  */
9
9
  module.exports = {
10
10
  info: `Information about your project`,
11
+ console: 'Open the administration console of the running project in the browser (engine 0.11.0+, no password, this machine only)',
11
12
  kc: 'Keycloak test set of the project (poad/keycloak.json; kc export saves the running realm)',
12
13
  setup: 'Choose what "poad start" starts: e-mails (Mailpit/SMTP), Keycloak, Valkey, migrations (interactive, or kc=on valkey=off, kc=shared|own, --all, --none, --list)',
13
14
  db: {
14
15
  description: 'Local database: db reset (erase, migrate, seed), db seed (apply poad/seed.sql)',
15
16
  reset: 'Erase the database and storage files, restart, apply migrations then poad/seed.sql (--yes outside a terminal)',
16
17
  seed: 'Apply poad/seed.sql (development data)',
18
+ diff: 'Structure changes made outside the migrations (console SQL, psql…): diff to list them, diff <name> to write them as a migration, diff --discard to forget them',
17
19
  },
18
20
  upgrade: 'Upgrade the engine of the project (backs up poad/ first): upgrade, upgrade to=<version>, upgrade --rollback, upgrade --list (--yes outside a terminal)',
19
21
  logs: 'Unified logs of the project: logs [service…] level=warn since=15m request=<id> grep=<text> limit=100 -f --json',
@@ -0,0 +1,32 @@
1
+ // poad console : ouvre la console d'administration du projet lancé
2
+ // (http://localhost:<port web>/console), sans mot de passe en local.
3
+ module.exports = async () => {
4
+ const chalk = require('chalk-v2');
5
+ const { findPoadDir } = require('../utils/findpoad');
6
+ const { isDockerExist } = require('../utils/docker');
7
+ const { supportsConsole, consoleUrl } = require('../utils/engine');
8
+ const root = findPoadDir(process.cwd());
9
+ if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
10
+ const config = require('../utils/config').readConfig(root);
11
+ if (!supportsConsole(config)) {
12
+ process.exitCode = 1;
13
+ return console.log(chalk.redBright(`The console needs engine 0.11.0 or later (this project: ${config.engine}): "poad upgrade".`));
14
+ }
15
+ if (require('../utils/ports').exposed(config)) {
16
+ process.exitCode = 1;
17
+ return console.log(chalk.redBright('The console without password is off while the ports are exposed to the network ([web] expose = true).'));
18
+ }
19
+ if (!(await isDockerExist(config.project_uuid))) {
20
+ process.exitCode = 1;
21
+ return console.log(chalk.redBright('The project is not started: "poad start".'));
22
+ }
23
+ const url = consoleUrl(config);
24
+ console.log(`Console: ${chalk.cyanBright(url)}`);
25
+ const { spawn } = require('child_process');
26
+ const [cmd, args] = process.platform === 'darwin' ? ['open', [url]] : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', url]] : ['xdg-open', [url]];
27
+ try {
28
+ spawn(cmd, args, { stdio: 'ignore', detached: true }).on('error', () => {}).unref();
29
+ } catch {
30
+ /* pas de navigateur : l'URL est affichée */
31
+ }
32
+ };
@@ -0,0 +1,66 @@
1
+ // poad db diff changements de structure faits hors des migrations
2
+ // (console SQL, psql, un outil), notés par le journal
3
+ // poad db diff <nom> les écrit dans poad/migrations/<horodatage>_<nom>.sql
4
+ // (déjà appliqués : ils ne sont pas rejoués)
5
+ // poad db diff --discard les oublie (ils restent dans la base)
6
+ module.exports = async (args = {}) => {
7
+ const chalk = require('chalk-v2');
8
+ const path = require('path');
9
+ const { findPoadDir } = require('../../utils/findpoad');
10
+ const { isDockerExist } = require('../../utils/docker');
11
+ const { readConfig } = require('../../utils/config');
12
+ const migrations = require('../../utils/migrations');
13
+
14
+ const root = findPoadDir(process.cwd());
15
+ if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
16
+ const config = readConfig(root);
17
+ if (!(await isDockerExist(config.project_uuid))) {
18
+ process.exitCode = 1;
19
+ return console.log(chalk.redBright('The project is not started: "poad start".'));
20
+ }
21
+ // Options : --discard, --json (aussi sans tirets) ; le reste forme le nom
22
+ const flag = (f) => Boolean(args[f] || args[`--${f}`]);
23
+ const isFlag = (k) => k.startsWith('-') || ['discard', 'json', 'yes'].includes(k);
24
+ const name = Object.keys(args).filter((k) => !isFlag(k) && args[k] === true).join('_') || (typeof args.name === 'string' ? args.name : '');
25
+
26
+ const client = await migrations.connect(config);
27
+ try {
28
+ const c = await migrations.changes(client);
29
+ if (!c.supported) {
30
+ process.exitCode = 1;
31
+ return console.log(chalk.yellowBright(`The change journal needs engine 0.11.0 or later (this project: ${config.engine}): "poad upgrade".`));
32
+ }
33
+ if (flag('json')) return console.log(JSON.stringify(c, null, 2));
34
+ if (!c.entries.length) {
35
+ if (c.drift) {
36
+ process.exitCode = 1;
37
+ console.log(chalk.yellowBright(' The structure changed without any entry in the journal (restore, change made outside the project schemas…).'));
38
+ return console.log(chalk.grey(' Write the migration by hand: "poad migration new <name>".'));
39
+ }
40
+ return console.log(`${chalk.greenBright('✔')} No structure change outside the migrations.`);
41
+ }
42
+ if (flag('discard')) {
43
+ await migrations.discardChanges(client, c.upTo);
44
+ return console.log(`${chalk.greenBright('✔')} ${c.entries.length} change(s) forgotten ${chalk.grey('(still in the database)')}.`);
45
+ }
46
+ if (!name) {
47
+ console.log(chalk.bold(`${c.entries.length} structure change(s) not in a migration`));
48
+ console.log(' ');
49
+ for (const e of c.entries) {
50
+ const when = new Date(e.at).toLocaleString();
51
+ console.log(chalk.grey(`-- ${when} · ${e.role_name}${e.application ? ' · ' + e.application : ''} · ${(e.commands || []).join(', ')}`));
52
+ console.log(String(e.statement).trim().replace(/;?\s*$/, ';'));
53
+ console.log(' ');
54
+ }
55
+ return console.log(chalk.grey(' "poad db diff <name>" writes them to poad/migrations (not replayed); "poad db diff --discard" forgets them.'));
56
+ }
57
+ const file = await migrations.saveChanges(root, client, name, c.sql, c.upTo);
58
+ console.log(`${chalk.greenBright('✔')} ${chalk.bold(path.relative(process.cwd(), file))} ${chalk.grey(`(${c.entries.length} change(s), already applied here)`)}`);
59
+ console.log(chalk.grey(' Review it, then commit it with your branch.'));
60
+ } catch (err) {
61
+ process.exitCode = 1;
62
+ console.log(chalk.redBright(err.message));
63
+ } finally {
64
+ await client.end().catch(() => {});
65
+ }
66
+ };
@@ -5,6 +5,7 @@ module.exports = async () => {
5
5
  console.log(' ');
6
6
  console.log(` ${chalk.cyanBright('poad db reset')} Erase the database and storage files, restart, apply migrations then poad/seed.sql`);
7
7
  console.log(` ${chalk.cyanBright('poad db seed')} Apply poad/seed.sql (development data)`);
8
+ console.log(` ${chalk.cyanBright('poad db diff')} Structure changes made outside the migrations; "db diff <name>" writes them as a migration`);
8
9
  console.log(` ${chalk.cyanBright('poad migrate')} Apply pending migrations`);
9
10
  console.log(' ');
10
11
  };
package/utils/engine.js CHANGED
@@ -35,6 +35,14 @@ const supportsRealtime = (config) => {
35
35
  return major > 0 || minor >= 10;
36
36
  };
37
37
 
38
+ // Engine 0.11.0 et plus : console d'administration (/console)
39
+ const supportsConsole = (config) => {
40
+ const [major, minor] = String(config.engine || '').split('.').map(Number);
41
+ return major > 0 || minor >= 11;
42
+ };
43
+
44
+ const consoleUrl = (config) => `http://localhost:${config.web.port}/console`;
45
+
38
46
  const dataInfo = (config) =>
39
47
  supportsData(config)
40
48
  ? {
@@ -50,7 +58,7 @@ const dataInfo = (config) =>
50
58
  }
51
59
  : {};
52
60
 
53
- module.exports = { usesMinio, storageInfo, supportsData, supportsRealtime, dataInfo };
61
+ module.exports = { usesMinio, storageInfo, supportsData, supportsRealtime, supportsConsole, consoleUrl, dataInfo };
54
62
 
55
63
  // Projet resté sur un engine plus ancien que celui du CLI : propose de mettre
56
64
  // à jour `engine` dans config.toml. La mise à jour migre poad/data : le projet
package/utils/git.js ADDED
@@ -0,0 +1,73 @@
1
+ // Dépôt git du projet (poad init) : .gitignore à la racine, puis git init si
2
+ // git est installé et que le dossier n'est pas déjà dans un dépôt. Aucun
3
+ // commit n'est fait : le premier commit reste au développeur.
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { spawnSync } = require('child_process');
7
+
8
+ const git = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
9
+
10
+ /** Version de git, ou null s'il n'est pas installé */
11
+ function version() {
12
+ const r = spawnSync('git', ['--version'], { encoding: 'utf8' });
13
+ return r.status === 0 ? r.stdout.trim().replace(/^git version\s*/, '') : null;
14
+ }
15
+
16
+ /** Racine du dépôt qui contient dir, ou null */
17
+ function repoRoot(dir) {
18
+ const r = git(dir, ['rev-parse', '--show-toplevel']);
19
+ return r.status === 0 ? r.stdout.trim() : null;
20
+ }
21
+
22
+ // Fichiers à ne jamais versionner. Les blocs par système couvrent les fichiers
23
+ // que macOS, Windows et Linux (et les éditeurs) déposent d'eux-mêmes.
24
+ const BLOCKS = [
25
+ ['poad : secrets et données locales', ['poad/secrets.toml', 'poad/data/', 'poad/backups/', '.env.local', '.env.*.local']],
26
+ ['Dépendances, constructions, caches', ['node_modules/', 'dist/', 'build/', 'out/', '.angular/', '.cache/', '.turbo/', '.next/', 'coverage/', '*.tsbuildinfo']],
27
+ ['Journaux', ['*.log', 'npm-debug.log*', 'yarn-debug.log*', 'yarn-error.log*', 'bun-debug.log*']],
28
+ ['macOS', ['.DS_Store', '.AppleDouble', '.LSOverride', '._*', '.Spotlight-V100', '.Trashes', '.fseventsd', '.TemporaryItems', '.VolumeIcon.icns', '.DocumentRevisions-V100', '.com.apple.timemachine.donotpresent', '.AppleDB', '.AppleDesktop']],
29
+ ['Windows', ['Thumbs.db', 'Thumbs.db:encryptable', 'ehthumbs.db', 'ehthumbs_vista.db', 'desktop.ini', '$RECYCLE.BIN/', '*.stackdump', '*.lnk']],
30
+ ['Linux', ['*~', '.directory', '.Trash-*', '.nfs*', '.fuse_hidden*']],
31
+ ['Éditeurs', ['.idea/', '*.iml', '.vscode/*', '!.vscode/settings.json', '!.vscode/extensions.json', '!.vscode/launch.json', '.history/', '*.swp', '*.swo', '*.sublime-workspace']],
32
+ ];
33
+
34
+ /**
35
+ * .gitignore à la racine du projet : créé, ou complété des lignes qui lui
36
+ * manquent (ses propres lignes sont gardées). Renvoie le nombre de lignes ajoutées.
37
+ */
38
+ function ensureRootGitignore(dir) {
39
+ const file = path.join(dir, '.gitignore');
40
+ const existing = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
41
+ const have = new Set(existing.split(/\r?\n/).map((l) => l.trim()));
42
+ let out = '';
43
+ let added = 0;
44
+ for (const [title, lines] of BLOCKS) {
45
+ const missing = lines.filter((l) => !have.has(l));
46
+ if (!missing.length) continue;
47
+ out += `\n# ${title}\n${missing.join('\n')}\n`;
48
+ added += missing.length;
49
+ }
50
+ if (!added) return 0;
51
+ const head = existing ? existing.replace(/\s*$/, '\n') : '# Écrit par poad init ; complétez-le librement.\n';
52
+ fs.writeFileSync(file, head + out);
53
+ return added;
54
+ }
55
+
56
+ /**
57
+ * .gitignore puis git init (branche main). Renvoie ce qui a été fait :
58
+ * { gitignore: lignes ajoutées, repo: 'created' | 'existing' | 'no-git', root }
59
+ */
60
+ function setupRepo(dir) {
61
+ const gitignore = ensureRootGitignore(dir);
62
+ const v = version();
63
+ if (!v) return { gitignore, repo: 'no-git' };
64
+ const existing = repoRoot(dir);
65
+ if (existing) return { gitignore, repo: 'existing', root: existing };
66
+ // -b main : git 2.28+ ; plus ancien, la branche par défaut de l'installation
67
+ let r = git(dir, ['init', '-b', 'main']);
68
+ if (r.status !== 0) r = git(dir, ['init']);
69
+ if (r.status !== 0) return { gitignore, repo: 'failed', error: (r.stderr || r.stdout).trim() };
70
+ return { gitignore, repo: 'created', root: dir };
71
+ }
72
+
73
+ module.exports = { version, repoRoot, ensureRootGitignore, setupRepo, BLOCKS };
@@ -73,6 +73,9 @@ async function connect(config) {
73
73
  database: 'postgres',
74
74
  connectionTimeoutMillis: 5000,
75
75
  application_name: 'poad-cli',
76
+ // Ce que le CLI applique (migrations, requêtes nommées) est déjà un
77
+ // fichier : pas d'entrée au journal des changements de structure
78
+ options: '-c poad.migrating=on',
76
79
  });
77
80
  await client.connect();
78
81
  client.on('error', () => {}); // fermeture de la connexion par le serveur
@@ -143,6 +146,8 @@ async function migrate(root, config, { onApply } = {}) {
143
146
  return { applied, failed: { migration: m, message: `${err.message}${where}` }, state };
144
147
  }
145
148
  }
149
+ // Empreinte de la structure après les migrations (journal des changements)
150
+ if (applied.length) await snapshot(client);
146
151
  // Après les migrations : requêtes nommées (poad/queries), puis les tables
147
152
  // exposées sans RLS
148
153
  const queries = await require('./queries').sync(root, client);
@@ -216,4 +221,83 @@ async function waitForServices(config, seconds = 90) {
216
221
  /** Les migrations s'appliquent-elles à poad start ? ([db] auto_migrate, vrai par défaut) */
217
222
  const autoMigrate = (config) => !(config.db && config.db.auto_migrate === false);
218
223
 
219
- module.exports = { dir, files, create, status, migrate, connect, waitForDb, waitForServices, autoMigrate, timestamp, exposedSchemas, unprotectedTables, FILE_RE };
224
+ // ------------------------------------------------ journal des changements
225
+ // Engine 0.11.0 et plus : les changements de structure faits hors des
226
+ // migrations (console SQL, psql, un outil) sont notés dans
227
+ // poad_migrations.journal. poad db diff les écrit en migration.
228
+
229
+ const hasJournal = async (client) => (await client.query("select to_regclass('poad_migrations.journal') is not null as ok")).rows[0].ok;
230
+
231
+ /** Enregistre l'empreinte de la structure (sans effet avant l'engine 0.11.0) */
232
+ async function snapshot(client) {
233
+ if (await hasJournal(client)) await client.query('select poad_migrations.snapshot()');
234
+ }
235
+
236
+ /** Changements non enregistrés : { supported, entries, upTo, drift, sql } */
237
+ async function changes(client) {
238
+ if (!(await hasJournal(client))) return { supported: false, entries: [], upTo: null, drift: false, sql: '' };
239
+ const { rows } = await client.query('select id, at, statement, commands, objects, role_name, application from poad_migrations.journal order by id');
240
+ const st = (await client.query('select poad_migrations.status() as s')).rows[0].s || {};
241
+ return {
242
+ supported: true,
243
+ entries: rows,
244
+ upTo: rows.length ? Number(rows[rows.length - 1].id) : null,
245
+ drift: Boolean(st.drift) && rows.length === 0,
246
+ sql: rows.map((r) => String(r.statement).trim().replace(/;?\s*$/, ';')).join('\n\n'),
247
+ };
248
+ }
249
+
250
+ /**
251
+ * Écrit les changements du journal en migration, SANS les rejouer (ils sont
252
+ * déjà dans la base) : fichier, historique, journal vidé jusqu'à upTo,
253
+ * empreinte. Renvoie le chemin du fichier.
254
+ */
255
+ async function saveChanges(root, client, name, sql, upTo) {
256
+ const file = create(root, name);
257
+ const content = fs.readFileSync(file, 'utf-8').replace('Appliquée une seule fois', 'Changements de structure enregistrés par poad db diff (déjà appliqués à la base locale). Appliquée une seule fois') + sql.trim() + '\n';
258
+ const m = FILE_RE.exec(path.basename(file));
259
+ try {
260
+ await client.query('begin');
261
+ await client.query("select set_config('poad.migrating', 'on', true)");
262
+ await client.query('select pg_advisory_xact_lock($1)', [LOCK_ID]);
263
+ await ensureHistory(client);
264
+ await client.query('insert into poad_migrations.history (version, name, checksum) values ($1, $2, $3)', [m[1], m[2], checksum(content)]);
265
+ await client.query('delete from poad_migrations.journal where id <= $1', [upTo]);
266
+ await client.query('select poad_migrations.snapshot()');
267
+ fs.writeFileSync(file, content);
268
+ await client.query('commit');
269
+ } catch (err) {
270
+ await client.query('rollback').catch(() => {});
271
+ fs.rmSync(file, { force: true });
272
+ throw err;
273
+ }
274
+ return file;
275
+ }
276
+
277
+ /** Oublie les changements du journal jusqu'à upTo (ils restent dans la base) */
278
+ async function discardChanges(client, upTo) {
279
+ await client.query('begin');
280
+ await client.query('delete from poad_migrations.journal where id <= $1', [upTo]);
281
+ await client.query('select poad_migrations.snapshot()');
282
+ await client.query('commit');
283
+ }
284
+
285
+ module.exports = {
286
+ dir,
287
+ files,
288
+ create,
289
+ status,
290
+ migrate,
291
+ connect,
292
+ waitForDb,
293
+ waitForServices,
294
+ autoMigrate,
295
+ timestamp,
296
+ exposedSchemas,
297
+ unprotectedTables,
298
+ FILE_RE,
299
+ snapshot,
300
+ changes,
301
+ saveChanges,
302
+ discardChanges,
303
+ };
package/utils/report.js CHANGED
@@ -6,15 +6,22 @@ const path = require('path');
6
6
  async function migrationsLine(root, config) {
7
7
  const migrations = require('./migrations');
8
8
  const count = migrations.files(root).list.length;
9
- if (!count) return null;
10
9
  let client;
11
10
  try {
12
11
  client = await migrations.connect(config);
13
- const st = await migrations.status(root, client);
14
- const done = st.list.length - st.pending.length;
15
- return `${done} applied${st.pending.length ? `, ${st.pending.length} pending (poad migrate)` : ''}${st.changed.length ? `, ${st.changed.length} changed after apply` : ''}`;
12
+ const parts = [];
13
+ if (count) {
14
+ const st = await migrations.status(root, client);
15
+ const done = st.list.length - st.pending.length;
16
+ parts.push(`${done} applied${st.pending.length ? `, ${st.pending.length} pending (poad migrate)` : ''}${st.changed.length ? `, ${st.changed.length} changed after apply` : ''}`);
17
+ }
18
+ // Changements de structure faits hors des migrations (engine 0.11.0+)
19
+ const c = await migrations.changes(client);
20
+ if (c.entries.length) parts.push(require('chalk-v2').yellowBright(`${c.entries.length} structure change(s) not in a migration (poad db diff)`));
21
+ else if (c.drift) parts.push(require('chalk-v2').yellowBright('structure changed outside the journal (poad db diff)'));
22
+ return parts.length ? parts.join(', ') : null;
16
23
  } catch {
17
- return `${count} file(s), state unknown`;
24
+ return count ? `${count} file(s), state unknown` : null;
18
25
  } finally {
19
26
  if (client) await client.end().catch(() => {});
20
27
  }
@@ -23,12 +30,20 @@ async function migrationsLine(root, config) {
23
30
  async function printProject(root, config) {
24
31
  const chalk = require('chalk-v2');
25
32
  const prettyoutput = require('prettyoutput');
26
- const { storageInfo, dataInfo } = require('./engine');
33
+ const { storageInfo, dataInfo, supportsConsole, consoleUrl } = require('./engine');
27
34
  const mail = require('./mail');
28
35
  console.log(chalk.bold('POAD project'));
29
36
  console.log(' ');
30
37
  const info = {
31
38
  Engine: config.engine,
39
+ // La console d'abord : c'est le point d'entrée du projet
40
+ ...(supportsConsole(config)
41
+ ? {
42
+ Console: require('./ports').exposed(config)
43
+ ? chalk.yellowBright('off while the ports are exposed to the network ([web] expose = true)')
44
+ : `${chalk.bold.cyanBright(consoleUrl(config))} ${chalk.grey('no password, this machine only · poad console opens it')}`,
45
+ }
46
+ : {}),
32
47
  Network: require('./ports').exposed(config)
33
48
  ? chalk.yellowBright('exposed: API, database (postgres/postgres) and Mailpit reachable from the network ([web] expose = true)')
34
49
  : 'this machine only (127.0.0.1)',