wattetheria 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/lib/cli.js +18 -0
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -419,6 +419,8 @@ function ensureDeploymentAssets(options) {
419
419
 
420
420
  if (options.force || !fs.existsSync(targetEnvPath)) {
421
421
  fs.copyFileSync(templateEnvPath, targetEnvPath);
422
+ } else {
423
+ mergeNewTemplateKeys(templateEnvPath, targetEnvPath);
422
424
  }
423
425
  if (options.force || !fs.existsSync(targetComposePath)) {
424
426
  fs.copyFileSync(templateComposePath, targetComposePath);
@@ -469,6 +471,22 @@ function writeEnvFile(filePath, envMap) {
469
471
  fs.writeFileSync(filePath, `${lines.join("\n")}\n`);
470
472
  }
471
473
 
474
+ function mergeNewTemplateKeys(templatePath, targetPath) {
475
+ const templateMap = readEnvFile(templatePath);
476
+ const targetMap = readEnvFile(targetPath);
477
+ let added = 0;
478
+ for (const [key, value] of templateMap.entries()) {
479
+ if (!targetMap.has(key)) {
480
+ targetMap.set(key, value);
481
+ added += 1;
482
+ }
483
+ }
484
+ if (added > 0) {
485
+ writeEnvFile(targetPath, targetMap);
486
+ console.log(`Merged ${added} new config key(s) from updated template.`);
487
+ }
488
+ }
489
+
472
490
  function ensureDatabasePassword(envMap) {
473
491
  const placeholder = "replace-with-strong-password";
474
492
  const current = envMap.get("WATTSWARM_PG_PASSWORD");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattetheria",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Wattetheria deployment CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",