cf-envsync 0.3.7 → 0.3.9

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 +19 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13268,7 +13268,7 @@ var init_env_file = __esm(() => {
13268
13268
  });
13269
13269
 
13270
13270
  // src/core/resolver.ts
13271
- import { normalize, relative } from "node:path";
13271
+ import { join as join4, normalize, relative } from "node:path";
13272
13272
  async function resolveAppEnv(config, app, environment) {
13273
13273
  const layers = [];
13274
13274
  const encryption = config.raw.encryption;
@@ -13282,7 +13282,7 @@ async function resolveAppEnv(config, app, environment) {
13282
13282
  layers.push({ source: rootEnvPath, map: rootEnv });
13283
13283
  }
13284
13284
  if (config.raw.envFiles.perApp) {
13285
- const appEnvPath = getAppEnvPath(config, app, environment);
13285
+ const appEnvPath = environment === "local" ? join4(app.absolutePath, config.raw.envFiles.local) : getAppEnvPath(config, app, environment);
13286
13286
  if (normalize(appEnvPath) !== normalize(rootEnvPath)) {
13287
13287
  const appEnv = await loadEnvFile(appEnvPath, environment, config.projectRoot, encryption);
13288
13288
  if (Object.keys(appEnv).length > 0) {
@@ -13332,7 +13332,7 @@ var exports_dev = {};
13332
13332
  __export(exports_dev, {
13333
13333
  default: () => dev_default
13334
13334
  });
13335
- import { join as join4, relative as relative2 } from "node:path";
13335
+ import { join as join5, relative as relative2 } from "node:path";
13336
13336
  function parseAppNames(args) {
13337
13337
  const rest = args._;
13338
13338
  return rest?.length ? rest : undefined;
@@ -13399,7 +13399,7 @@ var init_dev = __esm(() => {
13399
13399
  continue;
13400
13400
  }
13401
13401
  for (const devFileName of app.devFiles) {
13402
- const devFilePath = join4(app.absolutePath, devFileName);
13402
+ const devFilePath = join5(app.absolutePath, devFileName);
13403
13403
  const relDevFile = relative2(config.projectRoot, devFilePath);
13404
13404
  if (args["dry-run"]) {
13405
13405
  consola.log(`
@@ -13785,7 +13785,7 @@ var exports_validate = {};
13785
13785
  __export(exports_validate, {
13786
13786
  default: () => validate_default
13787
13787
  });
13788
- import { join as join5 } from "node:path";
13788
+ import { join as join6 } from "node:path";
13789
13789
  function parseAppNames4(args, skip = 1) {
13790
13790
  const rest = args._?.slice(skip);
13791
13791
  return rest?.length ? rest : undefined;
@@ -13840,7 +13840,7 @@ var init_validate = __esm(() => {
13840
13840
  appNames = undefined;
13841
13841
  }
13842
13842
  const apps = resolveApps(config, appNames);
13843
- const examplePath = join5(config.projectRoot, ".env.example");
13843
+ const examplePath = join6(config.projectRoot, ".env.example");
13844
13844
  if (!fileExists(examplePath)) {
13845
13845
  consola.error("No .env.example found at project root.");
13846
13846
  process.exit(1);
@@ -14128,7 +14128,7 @@ var exports_init = {};
14128
14128
  __export(exports_init, {
14129
14129
  default: () => init_default
14130
14130
  });
14131
- import { join as join6, relative as relative3, basename } from "node:path";
14131
+ import { join as join7, relative as relative3, basename } from "node:path";
14132
14132
  function generateConfigTS(config) {
14133
14133
  const lines = [
14134
14134
  `import { defineConfig } from "cf-envsync";`,
@@ -14209,10 +14209,10 @@ var init_init = __esm(() => {
14209
14209
  },
14210
14210
  async run({ args }) {
14211
14211
  const cwd = process.cwd();
14212
- const existingConfig = CONFIG_FILES.find((f3) => fileExists(join6(cwd, f3)));
14212
+ const existingConfig = CONFIG_FILES.find((f3) => fileExists(join7(cwd, f3)));
14213
14213
  if (existingConfig) {
14214
14214
  consola.warn(`${existingConfig} already exists.`);
14215
- const existingContent = await readFile(join6(cwd, existingConfig));
14215
+ const existingContent = await readFile(join7(cwd, existingConfig));
14216
14216
  const lines = existingContent.split(`
14217
14217
  `);
14218
14218
  const preview = lines.length > 20 ? [...lines.slice(0, 20), ` ... (${lines.length - 20} more lines)`].join(`
@@ -14252,8 +14252,8 @@ ${preview}
14252
14252
  ` + " Falling back to manual configuration.");
14253
14253
  }
14254
14254
  for (const wranglerFile of wranglerFiles.sort()) {
14255
- const fullPath = join6(cwd, wranglerFile);
14256
- const appDir = join6(cwd, wranglerFile, "..");
14255
+ const fullPath = join7(cwd, wranglerFile);
14256
+ const appDir = join7(cwd, wranglerFile, "..");
14257
14257
  const appPath = relative3(cwd, appDir);
14258
14258
  const appName = basename(appDir);
14259
14259
  consola.info(` Found ${wranglerFile}`);
@@ -14354,10 +14354,10 @@ ${preview}
14354
14354
  apps,
14355
14355
  ...shared.length > 0 ? { shared } : {}
14356
14356
  };
14357
- const configPath = join6(cwd, "envsync.config.ts");
14357
+ const configPath = join7(cwd, "envsync.config.ts");
14358
14358
  const tsContent = generateConfigTS(config);
14359
14359
  if (existingConfig && existingConfig !== "envsync.config.ts") {
14360
- const oldPath = join6(cwd, existingConfig);
14360
+ const oldPath = join7(cwd, existingConfig);
14361
14361
  if (fileExists(oldPath)) {
14362
14362
  const { unlink } = await import("node:fs/promises");
14363
14363
  await unlink(oldPath);
@@ -14365,7 +14365,7 @@ ${preview}
14365
14365
  }
14366
14366
  await writeFile(configPath, tsContent);
14367
14367
  consola.success("Created envsync.config.ts");
14368
- const examplePath = join6(cwd, ".env.example");
14368
+ const examplePath = join7(cwd, ".env.example");
14369
14369
  if (!fileExists(examplePath)) {
14370
14370
  const allKeys = new Set;
14371
14371
  for (const app of Object.values(apps)) {
@@ -14388,20 +14388,20 @@ ${preview}
14388
14388
  for (const env2 of environments) {
14389
14389
  if (env2 === "local")
14390
14390
  continue;
14391
- const envFile = join6(cwd, `.env.${env2}`);
14391
+ const envFile = join7(cwd, `.env.${env2}`);
14392
14392
  if (!fileExists(envFile)) {
14393
14393
  await writeFile(envFile, `# ${env2} environment variables
14394
14394
  `);
14395
14395
  consola.success(`Created .env.${env2}`);
14396
14396
  }
14397
14397
  }
14398
- const rootEnv = join6(cwd, ".env");
14398
+ const rootEnv = join7(cwd, ".env");
14399
14399
  if (!fileExists(rootEnv)) {
14400
14400
  await writeFile(rootEnv, `# Local environment variables
14401
14401
  `);
14402
14402
  consola.success("Created .env");
14403
14403
  }
14404
- const gitignorePath = join6(cwd, ".gitignore");
14404
+ const gitignorePath = join7(cwd, ".gitignore");
14405
14405
  const gitignoreEntries = [".env.local", ".env.keys", ".env.password", "**/.dev.vars"];
14406
14406
  if (fileExists(gitignorePath)) {
14407
14407
  const existing = await readFile(gitignorePath);
@@ -14422,7 +14422,7 @@ ${preview}
14422
14422
  `);
14423
14423
  consola.success(`Created .gitignore`);
14424
14424
  }
14425
- const gitattrsPath = join6(cwd, ".gitattributes");
14425
+ const gitattrsPath = join7(cwd, ".gitattributes");
14426
14426
  const mergeDriverLines = `.env merge=envsync
14427
14427
  .env.* merge=envsync
14428
14428
  `;
@@ -14438,7 +14438,7 @@ ${preview}
14438
14438
  await writeFile(gitattrsPath, mergeDriverLines);
14439
14439
  consola.success("Created .gitattributes with merge driver");
14440
14440
  }
14441
- const gitConfigPath = join6(cwd, ".git", "config");
14441
+ const gitConfigPath = join7(cwd, ".git", "config");
14442
14442
  if (fileExists(gitConfigPath)) {
14443
14443
  const gitConfig = await readFile(gitConfigPath);
14444
14444
  if (!gitConfig.includes('[merge "envsync"]')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-envsync",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Sync .env files to Cloudflare Workers secrets, .dev.vars, and more",
5
5
  "type": "module",
6
6
  "exports": {