poad 2.13.0 → 2.14.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/bun.lock CHANGED
@@ -5,12 +5,12 @@
5
5
  "": {
6
6
  "name": "poad",
7
7
  "dependencies": {
8
- "@inquirer/prompts": "^8.8.0",
8
+ "@inquirer/prompts": "^7.10.1",
9
9
  "axios": "^1.7.7",
10
10
  "boxen": "^5.1.2",
11
11
  "chalk-v2": "^1.0.2",
12
12
  "cli-progress": "^3.12.0",
13
- "dockerode": "^4.0.2",
13
+ "dockerode": "^5.0.1",
14
14
  "figlet": "^1.7.0",
15
15
  "generate-unique-id": "^2.0.3",
16
16
  "json2toml": "^6.1.1",
@@ -27,40 +27,66 @@
27
27
  "packages": {
28
28
  "@balena/dockerignore": ["@balena/dockerignore@1.0.2", "", {}, "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q=="],
29
29
 
30
- "@inquirer/ansi": ["@inquirer/ansi@2.1.0", "", {}, "sha512-63GU5AD9KhNbWM0jlhHoMJTEFck2upFOPxHlnCKf3xYTV3rjTUUQfodihmTnfYQzMLS29oy8lK/gA1eJgu4bhA=="],
30
+ "@grpc/grpc-js": ["@grpc/grpc-js@1.14.7", "", { "dependencies": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-W4W/fcBMGRVtG6dW2c7cw2mnpS3hvbBd+oQXjh2iYFTZDk1JJmcNqkM5KSaPubQpamlUUurrlb7G1s9NJeERmQ=="],
31
31
 
32
- "@inquirer/checkbox": ["@inquirer/checkbox@5.3.0", "", { "dependencies": { "@inquirer/ansi": "^2.1.0", "@inquirer/core": "^12.1.0", "@inquirer/figures": "^2.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-3QQSO87A+JoRtOtjtsgX2enwTL+3+VBVrkUpdqrIxMOgn5+W5sE57PcCPAiNUIESHxV4Q6mNEGxq2xLmRa0/yw=="],
32
+ "@grpc/proto-loader": ["@grpc/proto-loader@0.7.15", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.2.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ=="],
33
33
 
34
- "@inquirer/confirm": ["@inquirer/confirm@6.4.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-+DCZxrOF01Q/1SzTQkgycAQPS/Jf+Yol0h1P/MVmopukTsxGOu1h/LKqf30y0eHKFZYYrgUMVhGDhEbPmSPi9A=="],
34
+ "@inquirer/ansi": ["@inquirer/ansi@1.0.2", "", {}, "sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ=="],
35
35
 
36
- "@inquirer/core": ["@inquirer/core@12.1.0", "", { "dependencies": { "@inquirer/ansi": "^2.1.0", "@inquirer/figures": "^2.1.0", "@inquirer/type": "4.3.0", "cli-width": "^4.1.0", "fast-wrap-ansi": "^0.2.0", "mute-stream": "^4.0.0", "signal-exit": "^4.1.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-6H7usRWw4Gdjgpaem10CA5MfZ/xoYPGyInriR1Xubqjv+SVo8LIJ1erpFxW5JgCza6VZVZiKLTko7RtUU3AQMg=="],
36
+ "@inquirer/checkbox": ["@inquirer/checkbox@4.3.2", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/core": "^10.3.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-VXukHf0RR1doGe6Sm4F0Em7SWYLTHSsbGfJdS9Ja2bX5/D5uwVOEjr07cncLROdBvmnvCATYEWlHqYmXv2IlQA=="],
37
37
 
38
- "@inquirer/editor": ["@inquirer/editor@5.4.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/external-editor": "^3.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-L7vdCe4jnMpzhDisu1tAnr4WGvfPOVz+vNFXyIIL7O2Ycn/n90sn1ARvg+4cwzLf+us51BE/cX7uhnrLcal3+g=="],
38
+ "@inquirer/confirm": ["@inquirer/confirm@5.1.21", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-KR8edRkIsUayMXV+o3Gv+q4jlhENF9nMYUZs9PA2HzrXeHI8M5uDag70U7RJn9yyiMZSbtF5/UexBtAVtZGSbQ=="],
39
39
 
40
- "@inquirer/expand": ["@inquirer/expand@5.2.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-AOp2KQk7QojUyWOP7VkqdBWmxLRaVH58wQMx3N4//P530EDtpVp1EWIjAJubx9ZohWS/UCEpIkA1TuiNki0iOA=="],
40
+ "@inquirer/core": ["@inquirer/core@10.3.2", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "cli-width": "^4.1.0", "mute-stream": "^2.0.0", "signal-exit": "^4.1.0", "wrap-ansi": "^6.2.0", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A=="],
41
41
 
42
- "@inquirer/external-editor": ["@inquirer/external-editor@3.1.0", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.2" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-27JAkF38nXqXaoveU28iA/+Z8nutnF8B3JsbdToPHn9WnkrsMtZ0/YoJ29YwbtFexYIo+tIy6ikMvTdHKjjmGA=="],
42
+ "@inquirer/editor": ["@inquirer/editor@4.2.23", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/external-editor": "^1.0.3", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-aLSROkEwirotxZ1pBaP8tugXRFCxW94gwrQLxXfrZsKkfjOYC1aRvAZuhpJOb5cu4IBTJdsCigUlf2iCOu4ZDQ=="],
43
43
 
44
- "@inquirer/figures": ["@inquirer/figures@2.1.0", "", {}, "sha512-CR9u2PME23jxy2SOyTb117efwAAPm98Zr+LoWI+PiQ55D6U8Yeu/HyFTxwytKhPa6oxAGzdsm2Kg7oLS6B9z8w=="],
44
+ "@inquirer/expand": ["@inquirer/expand@4.0.23", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-nRzdOyFYnpeYTTR2qFwEVmIWypzdAx/sIkCMeTNTcflFOovfqUk+HcFhQQVBftAh9gmGrpFj6QcGEqrDMDOiew=="],
45
45
 
46
- "@inquirer/input": ["@inquirer/input@5.2.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-sIUPnN2X7M+7dq3RUd+e9QRacYnM+6B+kSucwQgj5VC5Eo/f+CIr2NyPBumxsViI+wzfokkgop/3x3KfHxNyJw=="],
46
+ "@inquirer/external-editor": ["@inquirer/external-editor@1.0.3", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA=="],
47
47
 
48
- "@inquirer/number": ["@inquirer/number@4.3.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-xYkX4sPVgox0F7yQwpz/MByWjOGdLEf1pdjH+Lji2gAzSs2xezz5bN5YgS1n0tx9wo0mRhGvq1KJGtvDZ9XXcQ=="],
48
+ "@inquirer/figures": ["@inquirer/figures@1.0.15", "", {}, "sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g=="],
49
49
 
50
- "@inquirer/password": ["@inquirer/password@5.3.0", "", { "dependencies": { "@inquirer/ansi": "^2.1.0", "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-KVqW4G/UbMK06uBN76xF89JKYC9YBWU7v+Kc2tUwMCO8pg3ASBr0HVabl1KaSqF94O2KiRu8aKx4EicN78PK+A=="],
50
+ "@inquirer/input": ["@inquirer/input@4.3.1", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-kN0pAM4yPrLjJ1XJBjDxyfDduXOuQHrBB8aLDMueuwUGn+vNpF7Gq7TvyVxx8u4SHlFFj4trmj+a2cbpG4Jn1g=="],
51
51
 
52
- "@inquirer/prompts": ["@inquirer/prompts@8.8.0", "", { "dependencies": { "@inquirer/checkbox": "^5.3.0", "@inquirer/confirm": "^6.4.0", "@inquirer/editor": "^5.4.0", "@inquirer/expand": "^5.2.0", "@inquirer/input": "^5.2.0", "@inquirer/number": "^4.3.0", "@inquirer/password": "^5.3.0", "@inquirer/rawlist": "^5.4.0", "@inquirer/search": "^4.4.0", "@inquirer/select": "^5.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-yYVT2Eo3mafb9tnU2Mr3+wh5wLCWyspExqVoPSMCIfBIn3ZUTE4IDfbCMbMgXaOH0tH+JZEhOtfczQhDzOjIGg=="],
52
+ "@inquirer/number": ["@inquirer/number@3.0.23", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-5Smv0OK7K0KUzUfYUXDXQc9jrf8OHo4ktlEayFlelCjwMXz0299Y8OrI+lj7i4gCBY15UObk76q0QtxjzFcFcg=="],
53
53
 
54
- "@inquirer/rawlist": ["@inquirer/rawlist@5.4.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-x42wcy465GM5/mHNKBFdAJbLlLyzmYqr/DEa6F49nHpI+03EFwRCRKeLGQakx5XqZ4unc2yFuS78qAD4Rb0iFA=="],
54
+ "@inquirer/password": ["@inquirer/password@4.0.23", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-zREJHjhT5vJBMZX/IUbyI9zVtVfOLiTO66MrF/3GFZYZ7T4YILW5MSkEYHceSii/KtRk+4i3RE7E1CUXA2jHcA=="],
55
55
 
56
- "@inquirer/search": ["@inquirer/search@4.4.0", "", { "dependencies": { "@inquirer/core": "^12.1.0", "@inquirer/figures": "^2.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-UJ+9tkzPT1AjnvjuPFYcOdO3BVeN28bfSXajYRFZTRgA9OiNl4k2Nn2cHHPwiIDyPHlvOnmE9ZOHyXhPHtvb+A=="],
56
+ "@inquirer/prompts": ["@inquirer/prompts@7.10.1", "", { "dependencies": { "@inquirer/checkbox": "^4.3.2", "@inquirer/confirm": "^5.1.21", "@inquirer/editor": "^4.2.23", "@inquirer/expand": "^4.0.23", "@inquirer/input": "^4.3.1", "@inquirer/number": "^3.0.23", "@inquirer/password": "^4.0.23", "@inquirer/rawlist": "^4.1.11", "@inquirer/search": "^3.2.2", "@inquirer/select": "^4.4.2" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-Dx/y9bCQcXLI5ooQ5KyvA4FTgeo2jYj/7plWfV5Ak5wDPKQZgudKez2ixyfz7tKXzcJciTxqLeK7R9HItwiByg=="],
57
57
 
58
- "@inquirer/select": ["@inquirer/select@5.3.0", "", { "dependencies": { "@inquirer/ansi": "^2.1.0", "@inquirer/core": "^12.1.0", "@inquirer/figures": "^2.1.0", "@inquirer/type": "4.3.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-Fmgfl0qjqCQo+/tjQpgnRXKh5N7/VpYcJh+AlYU2eHmHZLMGUBDzo+Gwc2ODzWJfXNRZmgaMhz4qULcO/C/rXg=="],
58
+ "@inquirer/rawlist": ["@inquirer/rawlist@4.1.11", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/type": "^3.0.10", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-+LLQB8XGr3I5LZN/GuAHo+GpDJegQwuPARLChlMICNdwW7OwV2izlCSCxN6cqpL0sMXmbKbFcItJgdQq5EBXTw=="],
59
59
 
60
- "@inquirer/type": ["@inquirer/type@4.3.0", "", { "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-/IA8q2nyjgyl0NGSjqiRXB8gh3We7Pzx9C0c+6Zoolu905jFc79anerrUG7+n65+qs310DRK43yi2WDI8nY59A=="],
60
+ "@inquirer/search": ["@inquirer/search@3.2.2", "", { "dependencies": { "@inquirer/core": "^10.3.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-p2bvRfENXCZdWF/U2BXvnSI9h+tuA8iNqtUKb9UWbmLYCRQxd8WkvwWvYn+3NgYaNwdUkHytJMGG4MMLucI1kA=="],
61
+
62
+ "@inquirer/select": ["@inquirer/select@4.4.2", "", { "dependencies": { "@inquirer/ansi": "^1.0.2", "@inquirer/core": "^10.3.2", "@inquirer/figures": "^1.0.15", "@inquirer/type": "^3.0.10", "yoctocolors-cjs": "^2.1.3" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-l4xMuJo55MAe+N7Qr4rX90vypFwCajSakx59qe/tMaC1aEHWLyw68wF4o0A4SLAY4E0nd+Vt+EyskeDIqu1M6w=="],
63
+
64
+ "@inquirer/type": ["@inquirer/type@3.0.10", "", { "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA=="],
65
+
66
+ "@js-sdsl/ordered-map": ["@js-sdsl/ordered-map@4.4.2", "", {}, "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw=="],
67
+
68
+ "@protobufjs/aspromise": ["@protobufjs/aspromise@1.1.2", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="],
69
+
70
+ "@protobufjs/base64": ["@protobufjs/base64@1.1.2", "", {}, "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="],
71
+
72
+ "@protobufjs/codegen": ["@protobufjs/codegen@2.0.5", "", {}, "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g=="],
73
+
74
+ "@protobufjs/eventemitter": ["@protobufjs/eventemitter@1.1.1", "", {}, "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg=="],
75
+
76
+ "@protobufjs/fetch": ["@protobufjs/fetch@1.1.1", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.1" } }, "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw=="],
77
+
78
+ "@protobufjs/float": ["@protobufjs/float@1.0.2", "", {}, "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="],
79
+
80
+ "@protobufjs/path": ["@protobufjs/path@1.1.2", "", {}, "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="],
81
+
82
+ "@protobufjs/pool": ["@protobufjs/pool@1.1.0", "", {}, "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="],
83
+
84
+ "@protobufjs/utf8": ["@protobufjs/utf8@1.1.2", "", {}, "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug=="],
61
85
 
62
86
  "@samverschueren/stream-to-observable": ["@samverschueren/stream-to-observable@0.3.1", "", { "dependencies": { "any-observable": "^0.3.0" } }, "sha512-c/qwwcHyafOQuVQJj0IlBjf5yYgBI7YPJ77k4fOJYesb41jio65eaJODRUmfYKhTOFBrIZ66kgvGPlNbjuoRdQ=="],
63
87
 
88
+ "@types/node": ["@types/node@26.6.6", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog=="],
89
+
64
90
  "ansi-align": ["ansi-align@3.0.1", "", { "dependencies": { "string-width": "^4.1.0" } }, "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w=="],
65
91
 
66
92
  "ansi-escapes": ["ansi-escapes@3.2.0", "", {}, "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ=="],
@@ -113,6 +139,8 @@
113
139
 
114
140
  "cli-width": ["cli-width@4.1.0", "", {}, "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ=="],
115
141
 
142
+ "cliui": ["cliui@8.0.1", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ=="],
143
+
116
144
  "clone": ["clone@1.0.4", "", {}, "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg=="],
117
145
 
118
146
  "code-point-at": ["code-point-at@1.1.0", "", {}, "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA=="],
@@ -139,9 +167,9 @@
139
167
 
140
168
  "delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
141
169
 
142
- "docker-modem": ["docker-modem@5.0.3", "", { "dependencies": { "debug": "^4.1.1", "readable-stream": "^3.5.0", "split-ca": "^1.0.1", "ssh2": "^1.15.0" } }, "sha512-89zhop5YVhcPEt5FpUFGr3cDyceGhq/F9J+ZndQ4KfqNvfbJpPMfgeixFgUj5OjCYAboElqODxY5Z1EBsSa6sg=="],
170
+ "docker-modem": ["docker-modem@5.0.7", "", { "dependencies": { "debug": "^4.1.1", "readable-stream": "^3.5.0", "split-ca": "^1.0.1", "ssh2": "^1.15.0" } }, "sha512-XJgGhoR/CLpqshm4d3L7rzH6t8NgDFUIIpztYlLHIApeJjMZKYJMz2zxPsYxnejq5h3ELYSw/RBsi3t5h7gNTA=="],
143
171
 
144
- "dockerode": ["dockerode@4.0.2", "", { "dependencies": { "@balena/dockerignore": "^1.0.2", "docker-modem": "^5.0.3", "tar-fs": "~2.0.1" } }, "sha512-9wM1BVpVMFr2Pw3eJNXrYYt6DT9k0xMcsSCjtPvyQ+xa1iPg/Mo3T/gUcwI0B2cczqCeCYRPF8yFYDwtFXT0+w=="],
172
+ "dockerode": ["dockerode@5.0.1", "", { "dependencies": { "@balena/dockerignore": "^1.0.2", "@grpc/grpc-js": "^1.11.1", "@grpc/proto-loader": "^0.7.13", "docker-modem": "^5.0.7", "protobufjs": "^7.3.2", "tar-fs": "^2.1.4" } }, "sha512-avsq/xk4YPIrn0CgleX5bjT9Y8IT1p9PxrNQ++RBQ2WEyFfHCTDsT9kmyxz+H/axnjAwg8wJWEIuPGOUuNupiA=="],
145
173
 
146
174
  "ecdsa-sig-formatter": ["ecdsa-sig-formatter@1.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="],
147
175
 
@@ -151,13 +179,9 @@
151
179
 
152
180
  "end-of-stream": ["end-of-stream@1.4.4", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q=="],
153
181
 
154
- "escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg=="],
155
-
156
- "fast-string-truncated-width": ["fast-string-truncated-width@3.0.3", "", {}, "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g=="],
157
-
158
- "fast-string-width": ["fast-string-width@3.0.2", "", { "dependencies": { "fast-string-truncated-width": "^3.0.2" } }, "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg=="],
182
+ "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
159
183
 
160
- "fast-wrap-ansi": ["fast-wrap-ansi@0.2.2", "", { "dependencies": { "fast-string-width": "^3.0.2" } }, "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q=="],
184
+ "escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg=="],
161
185
 
162
186
  "figlet": ["figlet@1.7.0", "", { "bin": "bin/index.js" }, "sha512-gO8l3wvqo0V7wEFLXPbkX83b7MVjRrk1oRLfYlZXol8nEpb/ON9pcKLI4qpBv5YtOTfrINtqb7b40iYY2FTWFg=="],
163
187
 
@@ -171,6 +195,8 @@
171
195
 
172
196
  "generate-unique-id": ["generate-unique-id@2.0.3", "", {}, "sha512-oADhkjv6nsiHNJNa+kCe/h6vqgooEPmASHU40hWGbhDODb/xKp5ej7l+7BNs3bQ/v8DCbaVJ42//kN2umQfr6A=="],
173
197
 
198
+ "get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
199
+
174
200
  "has-ansi": ["has-ansi@2.0.0", "", { "dependencies": { "ansi-regex": "^2.0.0" } }, "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg=="],
175
201
 
176
202
  "has-flag": ["has-flag@4.0.0", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],
@@ -213,6 +239,8 @@
213
239
 
214
240
  "lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="],
215
241
 
242
+ "lodash.camelcase": ["lodash.camelcase@4.3.0", "", {}, "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="],
243
+
216
244
  "lodash.includes": ["lodash.includes@4.3.0", "", {}, "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="],
217
245
 
218
246
  "lodash.isboolean": ["lodash.isboolean@3.0.3", "", {}, "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="],
@@ -237,6 +265,8 @@
237
265
 
238
266
  "log-update": ["log-update@2.3.0", "", { "dependencies": { "ansi-escapes": "^3.0.0", "cli-cursor": "^2.0.0", "wrap-ansi": "^3.0.1" } }, "sha512-vlP11XfFGyeNQlmEn9tJ66rEW1coA/79m5z6BCkudjbAGE83uhAcGYrBFwfs3AdLiLzGRusRPAbSPK9xZteCmg=="],
239
267
 
268
+ "long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
269
+
240
270
  "mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
241
271
 
242
272
  "mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
@@ -247,7 +277,7 @@
247
277
 
248
278
  "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
249
279
 
250
- "mute-stream": ["mute-stream@4.0.0", "", {}, "sha512-gSrprq0fJ3EiOErzjdIZrjysVVmJ4uu1QWfCDss5LypA5OXvrMje5Ym5z6V6RLyJ2eF87lasX7t6a0AnFvZblg=="],
280
+ "mute-stream": ["mute-stream@2.0.0", "", {}, "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA=="],
251
281
 
252
282
  "nan": ["nan@2.20.0", "", {}, "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw=="],
253
283
 
@@ -289,12 +319,16 @@
289
319
 
290
320
  "prettyoutput": ["prettyoutput@1.2.0", "", { "dependencies": { "colors": "1.3.x", "commander": "2.19.x", "lodash": "4.17.x" }, "bin": "bin/prettyoutput" }, "sha512-G2gJwLzLcYS+2m6bTAe+CcDpwak9YpcvpScI0tE4WYb2O3lEZD/YywkMNpGqsSx5wttGvh2UXaKROTKKCyM2dw=="],
291
321
 
322
+ "protobufjs": ["protobufjs@7.6.6", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.5", "@protobufjs/eventemitter": "^1.1.1", "@protobufjs/fetch": "^1.1.1", "@protobufjs/float": "^1.0.2", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.1", "@types/node": ">=13.7.0", "long": "^5.3.2" }, "hasInstallScript": true }, "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg=="],
323
+
292
324
  "proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
293
325
 
294
326
  "pump": ["pump@3.0.2", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw=="],
295
327
 
296
328
  "readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],
297
329
 
330
+ "require-directory": ["require-directory@2.1.1", "", {}, "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q=="],
331
+
298
332
  "restore-cursor": ["restore-cursor@3.1.0", "", { "dependencies": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" } }, "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA=="],
299
333
 
300
334
  "rxjs": ["rxjs@6.6.7", "", { "dependencies": { "tslib": "^1.9.0" } }, "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ=="],
@@ -327,7 +361,7 @@
327
361
 
328
362
  "symbol-observable": ["symbol-observable@1.2.0", "", {}, "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="],
329
363
 
330
- "tar-fs": ["tar-fs@2.0.1", "", { "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^2.0.0" } }, "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA=="],
364
+ "tar-fs": ["tar-fs@2.1.5", "", { "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^2.1.4" } }, "sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw=="],
331
365
 
332
366
  "tar-stream": ["tar-stream@2.2.0", "", { "dependencies": { "bl": "^4.0.3", "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^3.1.1" } }, "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ=="],
333
367
 
@@ -339,6 +373,8 @@
339
373
 
340
374
  "type-fest": ["type-fest@0.20.2", "", {}, "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ=="],
341
375
 
376
+ "undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
377
+
342
378
  "util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
343
379
 
344
380
  "wcwidth": ["wcwidth@1.0.1", "", { "dependencies": { "defaults": "^1.0.3" } }, "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg=="],
@@ -351,6 +387,18 @@
351
387
 
352
388
  "xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="],
353
389
 
390
+ "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
391
+
392
+ "yargs": ["yargs@17.7.3", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g=="],
393
+
394
+ "yargs-parser": ["yargs-parser@21.1.1", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="],
395
+
396
+ "yoctocolors-cjs": ["yoctocolors-cjs@2.1.3", "", {}, "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw=="],
397
+
398
+ "@grpc/grpc-js/@grpc/proto-loader": ["@grpc/proto-loader@0.8.1", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg=="],
399
+
400
+ "@inquirer/core/wrap-ansi": ["wrap-ansi@6.2.0", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA=="],
401
+
354
402
  "cli-truncate/string-width": ["string-width@1.0.2", "", { "dependencies": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", "strip-ansi": "^3.0.0" } }, "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw=="],
355
403
 
356
404
  "has-ansi/ansi-regex": ["ansi-regex@2.1.1", "", {}, "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA=="],
package/global/start.js CHANGED
@@ -50,6 +50,11 @@ module.exports = async (args = {}) => {
50
50
  }
51
51
  if (mailpit && !(await pullIfMissing(docker, mail.MAILPIT_IMAGE))) return;
52
52
 
53
+ // Base neuve (premier démarrage, poad db reset) : seed.sql après les migrations
54
+ const fsSync = require('fs');
55
+ const pgDir = path.join(path.dirname(root), 'data', 'postgres');
56
+ const fresh = !fsSync.existsSync(pgDir) || !fsSync.readdirSync(pgDir).length;
57
+
53
58
  const progress = ora('Starting containers').start();
54
59
  try {
55
60
  // Réseau du projet : l'engine y joint Mailpit (« mail ») et Keycloak
@@ -96,20 +101,28 @@ module.exports = async (args = {}) => {
96
101
  }
97
102
  progress.succeed(chalk.bold('containers started.'));
98
103
  // Migrations en attente de poad/migrations ([db] auto_migrate = false pour
99
- // les appliquer à la main avec poad migrate)
104
+ // les appliquer à la main avec poad migrate ; poad db reset les applique
105
+ // toujours), puis seed.sql sur une base neuve
100
106
  const migrations = require('../utils/migrations');
101
- if (migrations.files(root).list.length) {
102
- if (!migrations.autoMigrate(config)) {
103
- console.log(chalk.grey(' auto_migrate is off: run "poad migrate" to apply pending migrations.'));
107
+ const { seedFile, runSeed } = require('../utils/seed');
108
+ const hasMigrations = migrations.files(root).list.length > 0;
109
+ const migrate = hasMigrations && (migrations.autoMigrate(config) || args.forceMigrate);
110
+ const seed = fresh && fsSync.existsSync(seedFile(root));
111
+ if (hasMigrations && !migrate) console.log(chalk.grey(' auto_migrate is off: run "poad migrate" to apply pending migrations.'));
112
+ if (migrate || seed) {
113
+ const waiting = ora(fresh ? 'Waiting for the new database' : 'Waiting for the database to apply migrations').start();
114
+ const ready = (await migrations.waitForDb(config)) && (await migrations.waitForServices(config));
115
+ if (!ready) {
116
+ waiting.fail(chalk.redBright('The engine does not answer: migrations and seed not applied (poad migrate, poad db seed later).'));
117
+ process.exitCode = 1;
104
118
  } else {
105
- const waiting = ora('Waiting for the database to apply migrations').start();
106
- const ready = (await migrations.waitForDb(config)) && (await migrations.waitForServices(config));
107
- if (!ready) {
108
- waiting.fail(chalk.redBright('Migrations not applied: the engine does not answer (poad migrate later).'));
109
- } else {
110
- waiting.stop();
111
- await require('../utils/migrate-run')(root, config, { quietWhenNone: false });
112
- }
119
+ waiting.stop();
120
+ const migrated = migrate ? await require('../utils/migrate-run')(root, config, { quietWhenNone: false }) : true;
121
+ // Code de sortie 1 si une migration ou le seed échoue (scripts, CI)
122
+ if (!migrated) process.exitCode = 1;
123
+ if (seed && !migrated) console.log(chalk.yellowBright(' Seed skipped: a migration failed. Fix it, "poad migrate", then "poad db seed".'));
124
+ else if (seed && !migrations.autoMigrate(config) && !args.forceMigrate && hasMigrations) console.log(chalk.grey(' Seed skipped: migrations are manual here ("poad migrate" then "poad db seed").'));
125
+ else if (seed && !(await runSeed(root, config))) process.exitCode = 1;
113
126
  }
114
127
  }
115
128
 
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "poad",
3
- "version": "2.13.0",
4
- "engine": "0.7.1",
3
+ "version": "2.14.1",
4
+ "engine": "0.7.2",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "bin": {
8
- "poad": "./poad.js"
8
+ "poad": "poad.js"
9
9
  },
10
10
  "scripts": {
11
11
  "build": "bun install"
12
12
  },
13
13
  "dependencies": {
14
- "@inquirer/prompts": "^8.8.0",
14
+ "@inquirer/prompts": "^7.10.1",
15
15
  "axios": "^1.7.7",
16
16
  "boxen": "^5.1.2",
17
17
  "chalk-v2": "^1.0.2",
18
18
  "cli-progress": "^3.12.0",
19
- "dockerode": "^4.0.2",
19
+ "dockerode": "^5.0.1",
20
20
  "figlet": "^1.7.0",
21
21
  "generate-unique-id": "^2.0.3",
22
22
  "json2toml": "^6.1.1",
package/project/cli.js CHANGED
@@ -10,6 +10,12 @@ module.exports = {
10
10
  info: `Information about your project`,
11
11
  kc: 'Keycloak test set of the project (poad/keycloak.json; kc export saves the running realm)',
12
12
  setup: 'Choose what "poad start" starts: e-mails (Mailpit/SMTP), Keycloak, Valkey, migrations (interactive, or kc=on valkey=off, --all, --none, --list)',
13
+ db: {
14
+ description: 'Local database: db reset (erase, migrate, seed), db seed (apply poad/seed.sql)',
15
+ reset: 'Erase the database and storage files, restart, apply migrations then poad/seed.sql (--yes outside a terminal)',
16
+ seed: 'Apply poad/seed.sql (development data)',
17
+ },
18
+ upgrade: 'Upgrade the engine of the project (backs up poad/ first): upgrade, upgrade to=<version>, upgrade --rollback, upgrade --list (--yes outside a terminal)',
13
19
  migrate: 'Apply pending migrations of poad/migrations (poad start does it too)',
14
20
  migration: 'Database migrations: migration new <name>, migration list',
15
21
  /* status: `[AI] Vérification du statut de l'environnement`,
@@ -0,0 +1,10 @@
1
+ // poad db : aide des commandes de la base
2
+ module.exports = async () => {
3
+ const chalk = require('chalk-v2');
4
+ console.log(`${chalk.bold(' Usage :')}`);
5
+ console.log(' ');
6
+ console.log(` ${chalk.cyanBright('poad db reset')} Erase the database and storage files, restart, apply migrations then poad/seed.sql`);
7
+ console.log(` ${chalk.cyanBright('poad db seed')} Apply poad/seed.sql (development data)`);
8
+ console.log(` ${chalk.cyanBright('poad migrate')} Apply pending migrations`);
9
+ console.log(' ');
10
+ };
@@ -0,0 +1,92 @@
1
+ // poad db reset : repart d'une base neuve
2
+ // 1. arrête le projet (engine, Mailpit, services) ;
3
+ // 2. efface les données de l'engine dans poad/data : base PostgreSQL et
4
+ // fichiers du storage. Keycloak (jeu de test, identifiants) et Valkey
5
+ // sont gardés ;
6
+ // 3. redémarre, applique toutes les migrations puis poad/seed.sql, et
7
+ // relance les services qui tournaient.
8
+ // Sans retour possible : confirmation demandée, ou --yes hors terminal.
9
+ module.exports = async (args = {}) => {
10
+ const chalk = require('chalk-v2');
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const Docker = require('dockerode');
14
+ const docker = new Docker();
15
+ const { findPoadDir } = require('../../utils/findpoad');
16
+ const { isDockerExist } = require('../../utils/docker');
17
+ const { readConfig } = require('../../utils/config');
18
+ const { SERVICES, containerState } = require('../../utils/services');
19
+ const { pullIfMissing } = require('../../utils/pull');
20
+
21
+ // Ce que poad db reset garde dans poad/data (services gérés par le CLI)
22
+ const KEEP = new Set(['keycloak', 'valkey']);
23
+
24
+ const root = findPoadDir(process.cwd());
25
+ if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
26
+ const config = readConfig(root);
27
+ const dataDir = path.join(path.dirname(root), 'data');
28
+ const erase = fs.existsSync(dataDir) ? fs.readdirSync(dataDir).filter((d) => !KEEP.has(d) && !d.startsWith('.')) : [];
29
+ const rel = path.relative(process.cwd(), dataDir) || dataDir;
30
+
31
+ console.log(' ');
32
+ console.log(chalk.bold('Reset the local database'));
33
+ console.log(chalk.grey(` Erased: ${erase.length ? erase.map((d) => `${rel}/${d}`).join(', ') : '(nothing yet)'} — users, tables, files, providers set in the database`));
34
+ console.log(chalk.grey(` Kept: poad/migrations, poad/seed.sql, poad/keycloak.json, ${[...KEEP].map((d) => `${rel}/${d}`).join(', ')}`));
35
+ console.log(' ');
36
+
37
+ const yes = Boolean(args.yes || args['--yes'] || args['-y']);
38
+ if (!yes) {
39
+ if (!process.stdin.isTTY) {
40
+ process.exitCode = 1;
41
+ return console.log(chalk.redBright('Not a terminal: confirm with "poad db reset --yes".'));
42
+ }
43
+ const { confirm } = require('@inquirer/prompts');
44
+ const ok = await confirm({ message: 'Erase the local database and start again? This cannot be undone.', default: false }).catch(() => false);
45
+ if (!ok) return console.log(chalk.grey(' Nothing changed.'));
46
+ }
47
+
48
+ // Services optionnels qui tournent : relancés après le redémarrage
49
+ const running = [];
50
+ for (const s of SERVICES.filter((x) => x.optional && x.configured(config))) {
51
+ if ((await containerState(docker, s.container(config))) === 'running') running.push(s.id);
52
+ }
53
+ if (await isDockerExist(config.project_uuid)) await require('../../global/stop')({});
54
+
55
+ // Effacement depuis un conteneur : sous Linux, les fichiers de la base
56
+ // appartiennent à l'utilisateur postgres du conteneur
57
+ if (erase.length) {
58
+ const ora = require('ora');
59
+ const progress = ora('Erasing the database').start();
60
+ const image = `poadio/engine:${config.engine}`;
61
+ try {
62
+ if (!(await pullIfMissing(docker, image))) throw new Error(`image ${image} unavailable`);
63
+ const container = await docker.createContainer({
64
+ Image: image,
65
+ Entrypoint: ['sh', '-c'],
66
+ Cmd: [erase.map((d) => `rm -rf "/data/${d.replace(/"/g, '')}"`).join(' && ')],
67
+ HostConfig: { Binds: [`${dataDir}:/data`], AutoRemove: false },
68
+ });
69
+ await container.start();
70
+ const { StatusCode } = await container.wait();
71
+ await container.remove().catch(() => {});
72
+ if (StatusCode !== 0) throw new Error(`exit ${StatusCode}`);
73
+ progress.succeed(chalk.bold('Database erased.'));
74
+ } catch (err) {
75
+ progress.fail(chalk.redBright(`Erase failed: ${err.message}. Nothing restarted.`));
76
+ process.exitCode = 1;
77
+ return;
78
+ }
79
+ }
80
+
81
+ console.log(' ');
82
+ // poad start : base neuve, donc migrations (forcées) puis seed.sql
83
+ const { autostartServices } = require('../../utils/services');
84
+ const auto = new Set(autostartServices(config).map((s) => s.id));
85
+ await require('../../global/start')({ forceMigrate: true });
86
+ const again = running.filter((id) => !auto.has(id));
87
+ if (again.length) {
88
+ await require('../../global/run')({ services: again, quiet: true });
89
+ console.log(' ');
90
+ await require('../../utils/report').printServices(root, readConfig(root));
91
+ }
92
+ };
@@ -0,0 +1,19 @@
1
+ // poad db seed : applique poad/seed.sql (données de développement)
2
+ module.exports = async () => {
3
+ const chalk = require('chalk-v2');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { findPoadDir } = require('../../utils/findpoad');
7
+ const { isDockerExist } = require('../../utils/docker');
8
+ const { readConfig } = require('../../utils/config');
9
+ const { seedFile, runSeed } = require('../../utils/seed');
10
+
11
+ const root = findPoadDir(process.cwd());
12
+ if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
13
+ const config = readConfig(root);
14
+ if (!fs.existsSync(seedFile(root))) {
15
+ return console.log(chalk.grey(` No ${path.relative(process.cwd(), seedFile(root))}: write your development data there (applied after migrations on a new database).`));
16
+ }
17
+ if (!(await isDockerExist(config.project_uuid))) return console.log(chalk.redBright('The project is not started: "poad start".'));
18
+ if (!(await runSeed(root, config))) process.exitCode = 1;
19
+ };
@@ -0,0 +1,126 @@
1
+ // poad upgrade passe le projet sur l'engine du CLI : sauvegarde
2
+ // (poad/backups), arrêt, mise à jour de config.toml,
3
+ // redémarrage (l'engine migre poad/data) et migrations
4
+ // poad upgrade to=<version> vers une version précise (plus récente)
5
+ // poad upgrade --rollback revient à la dernière sauvegarde (file=<nom> : une autre)
6
+ // poad upgrade --list liste les sauvegardes
7
+ // --yes : sans question (obligatoire hors terminal)
8
+ module.exports = async (args = {}) => {
9
+ const chalk = require('chalk-v2');
10
+ const path = require('path');
11
+ const Docker = require('dockerode');
12
+ const docker = new Docker();
13
+ const { findPoadDir } = require('../utils/findpoad');
14
+ const { isDockerExist } = require('../utils/docker');
15
+ const { readConfig } = require('../utils/config');
16
+ const { SERVICES, containerState, autostartServices } = require('../utils/services');
17
+ const { pullIfMissing } = require('../utils/pull');
18
+ const { isNewerVersion } = require('../utils/engine');
19
+ const backup = require('../utils/backup');
20
+
21
+ const root = findPoadDir(process.cwd());
22
+ if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
23
+ const config = readConfig(root);
24
+ const flag = (name) => Boolean(args[name] || args[`--${name}`]);
25
+ const yes = flag('yes') || Boolean(args['-y']);
26
+ const rel = (p) => path.relative(process.cwd(), p) || p;
27
+
28
+ const confirm = async (message) => {
29
+ if (yes) return true;
30
+ if (!process.stdin.isTTY) {
31
+ console.log(chalk.redBright('Not a terminal: confirm with --yes.'));
32
+ process.exitCode = 1;
33
+ return false;
34
+ }
35
+ const { confirm: ask } = require('@inquirer/prompts');
36
+ const ok = await ask({ message, default: false }).catch(() => false);
37
+ if (!ok) console.log(chalk.grey(' Nothing changed.'));
38
+ return ok;
39
+ };
40
+
41
+ // Arrête le projet en notant les services optionnels lancés à la main,
42
+ // pour les relancer après (ceux en autostart repartent avec poad start)
43
+ const stopProject = async () => {
44
+ const running = [];
45
+ for (const s of SERVICES.filter((x) => x.optional && x.configured(config))) {
46
+ if ((await containerState(docker, s.container(config))) === 'running') running.push(s.id);
47
+ }
48
+ if (await isDockerExist(config.project_uuid)) await require('../global/stop')({});
49
+ return running;
50
+ };
51
+ const startProject = async (running, startArgs) => {
52
+ await require('../global/start')(startArgs);
53
+ const fresh = readConfig(root);
54
+ const auto = new Set(autostartServices(fresh).map((s) => s.id));
55
+ const again = running.filter((id) => !auto.has(id));
56
+ if (again.length) {
57
+ await require('../global/run')({ services: again, quiet: true });
58
+ console.log(' ');
59
+ await require('../utils/report').printServices(root, readConfig(root));
60
+ }
61
+ };
62
+
63
+ // --list
64
+ if (flag('list')) {
65
+ const all = backup.list(root);
66
+ if (!all.length) return console.log(chalk.grey(` No backup in ${rel(backup.backupsDir(root))} yet: "poad upgrade" creates one before upgrading.`));
67
+ console.log(chalk.bold(`Backups (${rel(backup.backupsDir(root))})`));
68
+ all.forEach((b, i) => console.log(` ${b.file} ${chalk.grey(`engine ${b.engine}, ${backup.humanSize(b.size)}`)}${i === 0 ? chalk.cyan(' ← --rollback') : ''}`));
69
+ return;
70
+ }
71
+
72
+ // --rollback
73
+ if (flag('rollback')) {
74
+ const all = backup.list(root);
75
+ const chosen = args.file ? all.find((b) => b.file === String(args.file) || b.file === `${args.file}.tgz`) : all[0];
76
+ if (!chosen) {
77
+ return console.log(chalk.redBright(args.file ? `No backup named ${args.file}: "poad upgrade --list".` : 'No backup to go back to.'));
78
+ }
79
+ console.log(chalk.bold('Roll back the project'));
80
+ console.log(chalk.grey(` From: ${chosen.file} (engine ${chosen.engine})`));
81
+ console.log(chalk.grey(` Replaces poad/config.toml and poad/data: changes made since the backup (data, users, files) are lost.`));
82
+ console.log(' ');
83
+ if (!(await confirm(`Go back to engine ${chosen.engine} and the data of ${chosen.file}?`))) return;
84
+ const running = await stopProject();
85
+ const ora = require('ora');
86
+ const image = `poadio/engine:${config.engine}`;
87
+ let progress = null;
88
+ try {
89
+ if (!(await pullIfMissing(docker, image))) throw new Error(`image ${image} unavailable`);
90
+ progress = ora('Restoring the backup').start();
91
+ await backup.restore(docker, root, image, chosen);
92
+ progress.succeed(chalk.bold(`Restored ${chosen.file} (engine ${chosen.engine}).`));
93
+ } catch (err) {
94
+ const msg = chalk.redBright(`Restore failed: ${err.message}. Nothing restarted.`);
95
+ if (progress) progress.fail(msg);
96
+ else console.log(msg);
97
+ process.exitCode = 1;
98
+ return;
99
+ }
100
+ console.log(' ');
101
+ return startProject(running, { noOffer: true });
102
+ }
103
+
104
+ // Mise à jour
105
+ const target = String(args.to || global.package.engine || '');
106
+ const current = config.engine;
107
+ if (!target) return console.log(chalk.redBright('No target engine version.'));
108
+ if (target === current) return console.log(chalk.green(` This project already uses engine ${current}.`));
109
+ if (!isNewerVersion(target, current)) {
110
+ return console.log(chalk.yellow(` Engine ${target} is older than ${current}: "poad upgrade --rollback" restores a backup instead.`));
111
+ }
112
+ console.log(chalk.bold(`Upgrade the project: engine ${current} → ${target}`));
113
+ console.log(chalk.grey(` 1. Back up poad/config.toml and poad/data to ${rel(backup.backupsDir(root))}`));
114
+ console.log(chalk.grey(' 2. Restart on the new engine, which migrates the database, then apply poad/migrations'));
115
+ console.log(chalk.grey(' Something wrong after? "poad upgrade --rollback" puts everything back.'));
116
+ console.log(' ');
117
+ // L'image d'abord : rien n'est arrêté si elle n'existe pas
118
+ if (!(await pullIfMissing(docker, `poadio/engine:${target}`))) {
119
+ process.exitCode = 1;
120
+ return;
121
+ }
122
+ if (!(await confirm(`Upgrade to engine ${target}?`))) return;
123
+ const running = await stopProject();
124
+ await startProject(running, { upgrade: true, allowMinor: true, target });
125
+ if (readConfig(root).engine !== target) process.exitCode = 1;
126
+ };
@@ -0,0 +1,74 @@
1
+ // Sauvegardes du projet local, prises avant une mise à jour de l'engine :
2
+ // poad/backups/<YYYYMMDDHHMMSS>-engine-<version>.tgz
3
+ // Elles contiennent poad/config.toml et poad/data (base, fichiers du storage,
4
+ // Keycloak, Valkey). Hors git (poad/.gitignore), et hors de poad/data pour
5
+ // survivre à poad db reset.
6
+ // tar tourne dans un conteneur : sous Linux, les fichiers de la base
7
+ // appartiennent à l'utilisateur postgres du conteneur.
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const backupsDir = (root) => path.join(path.dirname(root), 'backups');
12
+
13
+ // Heure locale, comme les noms de migrations
14
+ const stamp = () => {
15
+ const d = new Date();
16
+ const p = (n) => String(n).padStart(2, '0');
17
+ return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
18
+ };
19
+
20
+ /** Sauvegardes existantes, la plus récente en premier */
21
+ const list = (root) => {
22
+ const dir = backupsDir(root);
23
+ if (!fs.existsSync(dir)) return [];
24
+ return fs
25
+ .readdirSync(dir)
26
+ .filter((f) => /^\d{14}-engine-.+\.tgz$/.test(f))
27
+ .sort()
28
+ .reverse()
29
+ .map((file) => {
30
+ const full = path.join(dir, file);
31
+ return { file, path: full, engine: /-engine-(.+)\.tgz$/.exec(file)[1], size: fs.statSync(full).size };
32
+ });
33
+ };
34
+
35
+ /** Lance une commande shell dans un conteneur jetable, poad/ monté sur /poad */
36
+ const runInContainer = async (docker, image, root, script) => {
37
+ const container = await docker.createContainer({
38
+ Image: image,
39
+ Entrypoint: ['sh', '-c'],
40
+ Cmd: [script],
41
+ HostConfig: { Binds: [`${path.dirname(root)}:/poad`] },
42
+ });
43
+ try {
44
+ await container.start();
45
+ const { StatusCode } = await container.wait();
46
+ if (StatusCode !== 0) throw new Error(`exit ${StatusCode}`);
47
+ } finally {
48
+ await container.remove().catch(() => {});
49
+ }
50
+ };
51
+
52
+ /** Sauvegarde config.toml + data ; renvoie le chemin du fichier créé */
53
+ const create = async (docker, root, image, engine) => {
54
+ require('./config').ensureGitignore(root);
55
+ const file = `${stamp()}-engine-${engine}.tgz`;
56
+ const owner = '$(stat -c %u:%g /poad/config.toml)';
57
+ const parts = fs.existsSync(path.join(path.dirname(root), 'data')) ? 'config.toml data' : 'config.toml';
58
+ await runInContainer(
59
+ docker,
60
+ image,
61
+ root,
62
+ `mkdir -p /poad/backups && tar czf /poad/backups/${file} -C /poad ${parts} && chown ${owner} /poad/backups /poad/backups/${file}`
63
+ );
64
+ return path.join(backupsDir(root), file);
65
+ };
66
+
67
+ /** Remet config.toml et data tels qu'ils étaient dans la sauvegarde */
68
+ const restore = async (docker, root, image, backup) => {
69
+ await runInContainer(docker, image, root, `rm -rf /poad/data && tar xzf "/poad/backups/${path.basename(backup.path)}" -C /poad`);
70
+ };
71
+
72
+ const humanSize = (n) => (n > 1e9 ? `${(n / 1e9).toFixed(1)} GB` : n > 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.ceil(n / 1e3)} KB`);
73
+
74
+ module.exports = { backupsDir, list, create, restore, humanSize };
package/utils/config.js CHANGED
@@ -16,6 +16,7 @@ const SECRET_KEYS = ['secret', 'anon', 'service', 'admin'];
16
16
  const GITIGNORE = `# Généré par poad : propre à chaque machine, jamais versionné
17
17
  data/
18
18
  secrets.toml
19
+ backups/
19
20
  `;
20
21
 
21
22
  const poadDir = (root) => path.dirname(root);
@@ -51,12 +52,12 @@ function writeSmtpPass(root, pass) {
51
52
  setKeys(file, 'smtp', { pass }, { mode: 0o600 });
52
53
  }
53
54
 
54
- /** poad/.gitignore : data/ et secrets.toml (complète un fichier existant) */
55
+ /** poad/.gitignore : data/, secrets.toml et backups/ (complète un fichier existant) */
55
56
  function ensureGitignore(root) {
56
57
  const file = path.join(poadDir(root), '.gitignore');
57
58
  if (!fs.existsSync(file)) return fs.writeFileSync(file, GITIGNORE);
58
59
  const text = fs.readFileSync(file, 'utf-8');
59
- const missing = ['data/', 'secrets.toml'].filter((l) => !text.split(/\r?\n/).includes(l));
60
+ const missing = ['data/', 'secrets.toml', 'backups/'].filter((l) => !text.split(/\r?\n/).includes(l));
60
61
  if (missing.length) fs.writeFileSync(file, `${text.replace(/\s*$/, '')}\n${missing.join('\n')}\n`);
61
62
  }
62
63
 
package/utils/engine.js CHANGED
@@ -26,9 +26,10 @@ const storageInfo = (config) => {
26
26
  module.exports = { usesMinio, storageInfo };
27
27
 
28
28
  // Projet resté sur un engine plus ancien que celui du CLI : propose de mettre
29
- // à jour `engine` dans config.toml (au sein de la même version mineure, où
30
- // seules des migrations s'appliquent). La mise à jour migre poad/data, sans
31
- // retour possible : on demande toujours, sauf avec `poad start --upgrade`.
29
+ // à jour `engine` dans config.toml. La mise à jour migre poad/data : le projet
30
+ // est d'abord sauvegardé dans poad/backups (poad upgrade --rollback y revient).
31
+ // poad start ne la propose qu'au sein de la même version mineure (seules des
32
+ // migrations s'appliquent) ; poad upgrade accepte aussi un saut de mineure.
32
33
  const parseVersion = (v) => String(v || '').split('.').map(Number);
33
34
  const isNewer = (a, b) => {
34
35
  const pa = parseVersion(a);
@@ -46,45 +47,87 @@ const ask = (question) =>
46
47
  });
47
48
  });
48
49
 
49
- /** Version d'engine à démarrer (celle du projet, ou la nouvelle si acceptée) */
50
+ /** Écrit la version d'engine dans config.toml ; false si la ligne est introuvable */
51
+ const writeEngine = (root, version) => {
52
+ const fs = require('fs');
53
+ const text = fs.readFileSync(root, 'utf-8');
54
+ const updated = text.replace(/^(\s*engine\s*=\s*)["'][^"']*["']/m, `$1"${version}"`);
55
+ if (updated === text) return false;
56
+ fs.writeFileSync(root, updated);
57
+ return true;
58
+ };
59
+
60
+ /** Sauvegarde le projet avant migration ; renvoie le fichier, ou null (message affiché) */
61
+ const backupBefore = async (root, config, target) => {
62
+ const chalk = require('chalk-v2');
63
+ const ora = require('ora');
64
+ const Docker = require('dockerode');
65
+ const docker = new Docker();
66
+ const { pullIfMissing } = require('./pull');
67
+ const backup = require('./backup');
68
+ const progress = ora('Backing up the project').start();
69
+ try {
70
+ // Image qui sert à tar : celle du projet si elle est là, sinon la nouvelle
71
+ let image = `poadio/engine:${config.engine}`;
72
+ try {
73
+ await docker.getImage(image).inspect();
74
+ } catch {
75
+ image = `poadio/engine:${target}`;
76
+ progress.stop();
77
+ if (!(await pullIfMissing(docker, image))) throw new Error(`image ${image} unavailable`);
78
+ progress.start('Backing up the project');
79
+ }
80
+ const file = await backup.create(docker, root, image, config.engine);
81
+ const size = backup.humanSize(require('fs').statSync(file).size);
82
+ progress.succeed(`${chalk.bold('Backup:')} ${require('path').relative(process.cwd(), file)} (${size})`);
83
+ return file;
84
+ } catch (err) {
85
+ progress.fail(chalk.redBright(`Backup failed (${err.message}): engine not upgraded.`));
86
+ return null;
87
+ }
88
+ };
89
+
90
+ /**
91
+ * Version d'engine à démarrer (celle du projet, ou la nouvelle si acceptée).
92
+ * args : upgrade (sans question), target (version voulue, défaut : celle du
93
+ * CLI), allowMinor (saut de version mineure permis), noOffer (ne rien proposer).
94
+ */
50
95
  const offerEngineUpgrade = async (root, config, args = {}) => {
51
96
  const chalk = require('chalk-v2');
52
- const fs = require('fs').promises;
53
- const target = global.package && global.package.engine;
97
+ const target = String(args.target || (global.package && global.package.engine) || '');
54
98
  const current = config.engine;
55
- if (!target || !isNewer(target, current)) return current;
99
+ if (args.noOffer || !target || !isNewer(target, current)) return current;
56
100
  const [cMaj, cMin] = parseVersion(current);
57
101
  const [tMaj, tMin] = parseVersion(target);
58
- if (cMaj !== tMaj || cMin !== tMin) {
102
+ if ((cMaj !== tMaj || cMin !== tMin) && !args.allowMinor) {
59
103
  console.log(chalk.yellow(` Engine ${target} is available (this project uses ${current}).`));
60
- console.log(chalk.yellow(` Upgrading across minor versions is manual: see the release notes, then edit engine in ${root}.`));
104
+ console.log(chalk.yellow(' It is a new minor version: read the release notes, then "poad upgrade" (backs up first).'));
61
105
  console.log(' ');
62
106
  return current;
63
107
  }
64
108
  let accepted = Boolean(args.upgrade || args['--upgrade']);
65
109
  if (!accepted) {
66
110
  if (!process.stdin.isTTY) {
67
- console.log(chalk.yellow(` Engine ${target} is available (this project uses ${current}). Run "poad start --upgrade" to switch.`));
111
+ console.log(chalk.yellow(` Engine ${target} is available (this project uses ${current}). Run "poad upgrade" to switch.`));
68
112
  console.log(' ');
69
113
  return current;
70
114
  }
71
115
  console.log(chalk.yellow(` Engine ${target} is available (this project uses ${current}).`));
72
- console.log(chalk.grey(' Upgrading applies database migrations to poad/data; it cannot be undone.'));
116
+ console.log(chalk.grey(' Upgrading migrates poad/data. The project is backed up first ("poad upgrade --rollback" goes back).'));
73
117
  accepted = await ask(chalk.bold(` Upgrade this project to ${target}? (y/N) `));
74
118
  console.log(' ');
75
119
  }
76
120
  if (!accepted) return current;
77
- const text = await fs.readFile(root, 'utf-8');
78
- const updated = text.replace(/^(\s*engine\s*=\s*)["'][^"']*["']/m, `$1"${target}"`);
79
- if (updated === text) {
121
+ if (!(await backupBefore(root, config, target))) return current;
122
+ if (!writeEngine(root, target)) {
80
123
  console.log(chalk.redBright(` Cannot find engine in ${root}; edit it by hand.`));
81
124
  return current;
82
125
  }
83
- await fs.writeFile(root, updated);
84
- console.log(chalk.green(` ${root}: engine ${current} → ${target}`));
126
+ console.log(chalk.green(` ${require('path').relative(process.cwd(), root)}: engine ${current} → ${target}`));
85
127
  console.log(' ');
86
128
  return target;
87
129
  };
88
130
 
89
131
  module.exports.offerEngineUpgrade = offerEngineUpgrade;
90
132
  module.exports.isNewerVersion = isNewer;
133
+ module.exports.writeEngine = writeEngine;
package/utils/seed.js ADDED
@@ -0,0 +1,53 @@
1
+ // poad/seed.sql : données de développement (utilisateurs de test, lignes
2
+ // d'exemple…), jamais en production. Appliqué après les migrations quand la
3
+ // base est neuve (premier poad start, poad db reset), ou à la main avec
4
+ // poad db seed. Il s'exécute dans une transaction : tout ou rien.
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const seedFile = (root) => path.join(path.dirname(root), 'seed.sql');
9
+
10
+ /** Applique seed.sql ; renvoie { applied, error } (applied false s'il n'existe pas) */
11
+ async function applySeed(root, config) {
12
+ const file = seedFile(root);
13
+ if (!fs.existsSync(file)) return { applied: false, error: null };
14
+ const sql = fs.readFileSync(file, 'utf-8');
15
+ if (!sql.trim()) return { applied: false, error: null };
16
+ const { connect } = require('./migrations');
17
+ const client = await connect(config);
18
+ try {
19
+ await client.query('begin');
20
+ await client.query(sql);
21
+ await client.query('commit');
22
+ return { applied: true, error: null };
23
+ } catch (err) {
24
+ await client.query('rollback').catch(() => {});
25
+ const line = err.position ? ` (line ${sql.slice(0, Number(err.position) - 1).split('\n').length})` : '';
26
+ return { applied: false, error: `${err.message}${line}` };
27
+ } finally {
28
+ await client.end().catch(() => {});
29
+ }
30
+ }
31
+
32
+ /** Application avec affichage ; renvoie true si rien n'a échoué */
33
+ async function runSeed(root, config) {
34
+ const chalk = require('chalk-v2');
35
+ const rel = path.relative(process.cwd(), seedFile(root));
36
+ let r;
37
+ try {
38
+ r = await applySeed(root, config);
39
+ } catch (err) {
40
+ console.log(chalk.redBright(`Seed not applied: ${err.message}`));
41
+ return false;
42
+ }
43
+ if (r.error) {
44
+ console.log(`${chalk.redBright('✖')} ${chalk.bold(rel)}`);
45
+ console.log(chalk.redBright(` ${r.error}`));
46
+ console.log(chalk.grey(' Rolled back: fix the file, then "poad db seed".'));
47
+ return false;
48
+ }
49
+ if (r.applied) console.log(`${chalk.greenBright('✔')} ${chalk.bold(rel)}`);
50
+ return true;
51
+ }
52
+
53
+ module.exports = { seedFile, applySeed, runSeed };