cf-envsync 0.3.10 → 0.3.11

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/dist/index.js +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13581,7 +13581,7 @@ function findWranglerConfig(appPath) {
13581
13581
  }
13582
13582
  return;
13583
13583
  }
13584
- async function updateWranglerVars(appPath, vars) {
13584
+ async function updateWranglerVars(appPath, environment, vars) {
13585
13585
  const configPath = findWranglerConfig(appPath);
13586
13586
  if (!configPath) {
13587
13587
  return { success: false, updatedCount: 0 };
@@ -13589,7 +13589,15 @@ async function updateWranglerVars(appPath, vars) {
13589
13589
  const content = await readFile(configPath);
13590
13590
  const stripped = stripJsonc(content);
13591
13591
  const config = JSON.parse(stripped);
13592
- config.vars = { ...config.vars || {}, ...vars };
13592
+ if (!config.env || typeof config.env !== "object") {
13593
+ config.env = {};
13594
+ }
13595
+ const envSection = config.env;
13596
+ if (!envSection[environment] || typeof envSection[environment] !== "object") {
13597
+ envSection[environment] = {};
13598
+ }
13599
+ const existingVars = envSection[environment].vars || {};
13600
+ envSection[environment].vars = { ...existingVars, ...vars };
13593
13601
  await writeFile(configPath, JSON.stringify(config, null, 2) + `
13594
13602
  `);
13595
13603
  return { success: true, filePath: configPath, updatedCount: Object.keys(vars).length };
@@ -13775,7 +13783,7 @@ var init_push = __esm(() => {
13775
13783
  }
13776
13784
  }
13777
13785
  if (varsCount > 0) {
13778
- const varsResult = await updateWranglerVars(app.absolutePath, varsToPush);
13786
+ const varsResult = await updateWranglerVars(app.absolutePath, environment, varsToPush);
13779
13787
  if (varsResult.success) {
13780
13788
  consola.success(` Wrote ${varsCount} vars to ${varsResult.filePath}`);
13781
13789
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-envsync",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Sync .env files to Cloudflare Workers secrets, .dev.vars, and more",
5
5
  "type": "module",
6
6
  "exports": {