@wpmoo/odoo 0.8.61 → 0.8.62

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/README.md CHANGED
@@ -162,6 +162,7 @@ npx @wpmoo/odoo pot sale devel i18n/sale.pot
162
162
 
163
163
  npx @wpmoo/odoo resetdb devel sale
164
164
  npx @wpmoo/odoo snapshot devel before-update
165
+ npx @wpmoo/odoo restore-snapshot --dry-run before-update devel
165
166
  npx @wpmoo/odoo restore-snapshot before-update devel
166
167
  ```
167
168
 
@@ -229,10 +230,17 @@ cp .env.example .env
229
230
  ./moo pot sale devel i18n/sale.pot
230
231
 
231
232
  ./moo snapshot devel before-update
233
+ ./moo restore-snapshot --dry-run before-update devel
232
234
  ./moo restore-snapshot before-update devel
233
235
  ./moo resetdb devel sale
234
236
  ```
235
237
 
238
+ `restore-snapshot --dry-run` validates the selected snapshot and prints the
239
+ restore plan without changing the database or filestore. Generated environments
240
+ also support `WPMOO_SNAPSHOT_RETENTION_COUNT` for pruning old snapshot files.
241
+ When `WPMOO_ENV=stage` or `WPMOO_ENV=prod`, destructive database actions such
242
+ as `resetdb` and real `restore-snapshot` require `WPMOO_ALLOW_DESTRUCTIVE=1`.
243
+
236
244
  Use `npx @wpmoo/odoo ...` for package/operator commands such as `create`, `add-repo`, `remove-repo`, `add-module`, `remove-module`, `status`, `doctor`, and `reset`. Use `./moo ...` inside a generated environment for local daily Compose commands.
237
245
 
238
246
  ## Repository and Module Management
@@ -387,6 +395,7 @@ Recommended recovery pattern:
387
395
  npx @wpmoo/odoo reset --dry-run
388
396
  npx @wpmoo/odoo reset
389
397
  npx @wpmoo/odoo doctor --fix
398
+ ./moo restore-snapshot --dry-run before-reset devel
390
399
  ./moo restore-snapshot before-reset devel
391
400
  ```
392
401
 
@@ -62,7 +62,7 @@ function usage(command) {
62
62
  if (command === 'snapshot')
63
63
  return 'Usage: wpmoo snapshot [db] [snapshot-name]';
64
64
  if (command === 'restore-snapshot')
65
- return 'Usage: wpmoo restore-snapshot <snapshot-name> [db]';
65
+ return 'Usage: wpmoo restore-snapshot [--dry-run] <snapshot-name> [db]';
66
66
  if (command === 'lint')
67
67
  return 'Usage: wpmoo lint';
68
68
  return 'Usage: wpmoo pot <module[,module]> [db] [output]';
@@ -89,6 +89,17 @@ function positionalArgs(command, argv, min, max) {
89
89
  }
90
90
  return argv;
91
91
  }
92
+ function restoreSnapshotArgs(argv) {
93
+ const args = [...argv];
94
+ const dryRun = args[0] === '--dry-run';
95
+ if (dryRun) {
96
+ args.shift();
97
+ }
98
+ if (args.length < 1 || args.length > 2 || args.some((arg) => arg.startsWith('-'))) {
99
+ throw new Error(usage('restore-snapshot'));
100
+ }
101
+ return dryRun ? ['--dry-run', ...args] : args;
102
+ }
92
103
  function testArgs(argv) {
93
104
  const [modules, ...rest] = argv;
94
105
  if (!modules || modules.startsWith('-'))
@@ -129,7 +140,7 @@ function scriptArgs(command, argv) {
129
140
  if (command === 'snapshot')
130
141
  return positionalArgs(command, argv, 0, 2);
131
142
  if (command === 'restore-snapshot')
132
- return positionalArgs(command, argv, 1, 2);
143
+ return restoreSnapshotArgs(argv);
133
144
  if (command === 'lint')
134
145
  return ensureNoArgs(command, argv);
135
146
  return positionalArgs(command, argv, 1, 3);
@@ -37,6 +37,12 @@ export function renderComposeEnvExample(options) {
37
37
  'POSTGRES_PASSWORD=odoo',
38
38
  'ODOO_MASTER_PASSWORD=admin',
39
39
  `ODOO_TEST_MODULE=${defaultTestModule(options)}`,
40
+ 'WPMOO_ENV=dev',
41
+ 'WPMOO_SNAPSHOT_RETENTION_COUNT=0',
42
+ '',
43
+ '# Required only when intentionally running destructive database actions',
44
+ '# such as resetdb or restore-snapshot with WPMOO_ENV=stage or WPMOO_ENV=prod.',
45
+ '# WPMOO_ALLOW_DESTRUCTIVE=1',
40
46
  '',
41
47
  ].join('\n');
42
48
  }
package/dist/help.js CHANGED
@@ -28,7 +28,7 @@ Usage:
28
28
  npx @wpmoo/odoo test <module[,module]> [--db <db>] [--mode init|update] [--tags <tags>]
29
29
  npx @wpmoo/odoo resetdb [db] [module[,module]]
30
30
  npx @wpmoo/odoo snapshot [db] [snapshot-name]
31
- npx @wpmoo/odoo restore-snapshot <snapshot-name> [db]
31
+ npx @wpmoo/odoo restore-snapshot [--dry-run] <snapshot-name> [db]
32
32
  npx @wpmoo/odoo lint
33
33
  npx @wpmoo/odoo pot <module[,module]> [db] [output]
34
34
 
@@ -108,6 +108,7 @@ Task recipes:
108
108
  npx @wpmoo/odoo snapshot [db] [snapshot-name]
109
109
  npx @wpmoo/odoo reset --dry-run
110
110
  npx @wpmoo/odoo reset
111
+ npx @wpmoo/odoo restore-snapshot --dry-run <snapshot-name> [db]
111
112
  npx @wpmoo/odoo restore-snapshot <snapshot-name> [db]
112
113
  Daily command checks:
113
114
  npx @wpmoo/odoo status
package/dist/templates.js CHANGED
@@ -243,6 +243,7 @@ cp .env.example .env
243
243
 
244
244
  \`\`\`bash
245
245
  ./moo snapshot devel before-update
246
+ ./moo restore-snapshot --dry-run before-update devel
246
247
  ./moo restore-snapshot before-update devel
247
248
  \`\`\`
248
249
 
@@ -371,7 +372,7 @@ usage() {
371
372
  "test") echo "Usage: ./moo test <module[,module]> [--db <db>] [--mode init|update] [--tags <tags>]" ;;
372
373
  "resetdb") echo "Usage: ./moo resetdb [db] [module[,module]]" ;;
373
374
  "snapshot") echo "Usage: ./moo snapshot [db] [snapshot-name]" ;;
374
- "restore-snapshot") echo "Usage: ./moo restore-snapshot <snapshot-name> [db]" ;;
375
+ "restore-snapshot") echo "Usage: ./moo restore-snapshot [--dry-run] <snapshot-name> [db]" ;;
375
376
  "lint") echo "Usage: ./moo lint" ;;
376
377
  "pot") echo "Usage: ./moo pot <module[,module]> [db] [output]" ;;
377
378
  esac
@@ -526,8 +527,14 @@ case "$command" in
526
527
  ;;
527
528
  "restore-snapshot")
528
529
  shift
530
+ restore_args=()
531
+ if [[ "\${1:-}" == "--dry-run" ]]; then
532
+ restore_args+=("--dry-run")
533
+ shift
534
+ fi
529
535
  positional_args "$command" 1 2 "$@"
530
- run_script ./scripts/restore-snapshot.sh "$@"
536
+ restore_args+=("$@")
537
+ run_script ./scripts/restore-snapshot.sh "\${restore_args[@]}"
531
538
  ;;
532
539
  "lint")
533
540
  shift
@@ -692,7 +699,7 @@ Useful maintenance commands:
692
699
  ./moo lint
693
700
  ./moo resetdb [db] [module[,module]]
694
701
  ./moo snapshot [db] [snapshot-name]
695
- ./moo restore-snapshot <snapshot-name> [db]
702
+ ./moo restore-snapshot [--dry-run] <snapshot-name> [db]
696
703
  ./moo pot <module[,module]> [db] [output]
697
704
  \`\`\`
698
705
 
@@ -27,7 +27,7 @@ not validate staging or production deployments.
27
27
  | Source manifest sync | Source repo metadata, `.gitmodules`, and `odoo/custom/manifests/sources.yaml` stay aligned. | `npx @wpmoo/odoo source list`, `npx @wpmoo/odoo source sync` |
28
28
  | Module add/remove | Module registration changes are applied to the selected source repo config. | `npx @wpmoo/odoo add-module ...`, `npx @wpmoo/odoo remove-module ...` |
29
29
  | Safe reset | Generated files are refreshed (including `compose.yaml` overlays and env example) without deleting source module code. Local runtime/data directories and custom source layout content are preserved; legacy user-editable paths from older templates may remain and are reported for manual cleanup. | `npx @wpmoo/odoo reset --dry-run`, `npx @wpmoo/odoo reset` |
30
- | Snapshot/restore and lint/pot | These actions are delegated by `./moo` to compose scripts without extra package-side logic. | `./moo snapshot ...`, `./moo restore-snapshot ...`, `./moo lint`, `./moo pot ...` |
30
+ | Snapshot/restore and lint/pot | These actions are delegated by `./moo` to compose scripts. Restore preview, snapshot retention, and stage/prod destructive guards are preserved by the package argument layer. | `./moo snapshot ...`, `./moo restore-snapshot --dry-run ...`, `./moo restore-snapshot ...`, `./moo lint`, `./moo pot ...` |
31
31
 
32
32
  ## Compact compose checks
33
33
 
@@ -46,6 +46,10 @@ Default local development uses `compose.yaml` plus `compose/dev.yaml`.
46
46
  `WPMOO_ENV=stage` or `WPMOO_ENV=prod` must only be used after production-grade
47
47
  secrets and volumes are configured.
48
48
 
49
+ When `WPMOO_ENV=stage` or `WPMOO_ENV=prod`, generated compose scripts refuse
50
+ destructive database actions such as `resetdb` and real `restore-snapshot`
51
+ unless `.env` explicitly sets `WPMOO_ALLOW_DESTRUCTIVE=1`.
52
+
49
53
  For PostgreSQL 18 environments (including `POSTGRES_IMAGE=postgres:18`), ensure db
50
54
  volume and tmpfs mount targets use `/var/lib/postgresql` directly:
51
55
 
@@ -88,6 +92,18 @@ odoo/custom/manifests/
88
92
  Run `npx @wpmoo/odoo reset --dry-run` before writing changes when you need to
89
93
  review the generated file refresh plan.
90
94
 
95
+ ## Snapshot policy
96
+
97
+ Use restore preview before a destructive restore:
98
+
99
+ ```bash
100
+ ./moo restore-snapshot --dry-run <snapshot-name> [db]
101
+ ```
102
+
103
+ `WPMOO_SNAPSHOT_RETENTION_COUNT` may be set to a positive integer to prune old
104
+ snapshot manifests and their matching dump/filestore files after a new snapshot
105
+ is written.
106
+
91
107
  ## Source manifest checks
92
108
 
93
109
  Generated environments include `odoo/custom/manifests/sources.yaml`. The manifest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpmoo/odoo",
3
- "version": "0.8.61",
3
+ "version": "0.8.62",
4
4
  "description": "WPMoo Odoo lifecycle tooling for development, staging, and production workflows.",
5
5
  "type": "module",
6
6
  "repository": {