@tachyon-gg/railway-deploy 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +60 -14
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -23745,6 +23745,48 @@ var require_graphql2 = __commonJS((exports) => {
23745
23745
  var _index6 = require_utilities();
23746
23746
  });
23747
23747
 
23748
+ // node_modules/fast-deep-equal/index.js
23749
+ var require_fast_deep_equal = __commonJS((exports, module) => {
23750
+ module.exports = function equal(a, b) {
23751
+ if (a === b)
23752
+ return true;
23753
+ if (a && b && typeof a == "object" && typeof b == "object") {
23754
+ if (a.constructor !== b.constructor)
23755
+ return false;
23756
+ var length, i, keys;
23757
+ if (Array.isArray(a)) {
23758
+ length = a.length;
23759
+ if (length != b.length)
23760
+ return false;
23761
+ for (i = length;i-- !== 0; )
23762
+ if (!equal(a[i], b[i]))
23763
+ return false;
23764
+ return true;
23765
+ }
23766
+ if (a.constructor === RegExp)
23767
+ return a.source === b.source && a.flags === b.flags;
23768
+ if (a.valueOf !== Object.prototype.valueOf)
23769
+ return a.valueOf() === b.valueOf();
23770
+ if (a.toString !== Object.prototype.toString)
23771
+ return a.toString() === b.toString();
23772
+ keys = Object.keys(a);
23773
+ length = keys.length;
23774
+ if (length !== Object.keys(b).length)
23775
+ return false;
23776
+ for (i = length;i-- !== 0; )
23777
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
23778
+ return false;
23779
+ for (i = length;i-- !== 0; ) {
23780
+ var key = keys[i];
23781
+ if (!equal(a[key], b[key]))
23782
+ return false;
23783
+ }
23784
+ return true;
23785
+ }
23786
+ return a !== a && b !== b;
23787
+ };
23788
+ });
23789
+
23748
23790
  // node_modules/commander/esm.mjs
23749
23791
  var import__ = __toESM(require_commander(), 1);
23750
23792
  var {
@@ -37549,19 +37591,21 @@ ${issues}`);
37549
37591
  // src/config/variables.ts
37550
37592
  var import_dotenv = __toESM(require_main(), 1);
37551
37593
  import { readFileSync } from "fs";
37552
- function resolveEnvVars(variables, env = process.env) {
37594
+ function resolveEnvVars(variables, env = process.env, lenient = false) {
37553
37595
  const resolved = {};
37554
37596
  for (const [key, value] of Object.entries(variables)) {
37555
37597
  if (value === null)
37556
37598
  continue;
37557
- resolved[key] = resolveEnvVarString(value, env);
37599
+ resolved[key] = resolveEnvVarString(value, env, lenient);
37558
37600
  }
37559
37601
  return resolved;
37560
37602
  }
37561
- function resolveEnvVarString(input, env = process.env) {
37562
- return input.replace(/\$\{(?!\{)([^}]+)\}/g, (_match, name) => {
37603
+ function resolveEnvVarString(input, env = process.env, lenient = false) {
37604
+ return input.replace(/\$\{(?!\{)([^}]+)\}/g, (match, name) => {
37563
37605
  const value = env[name];
37564
37606
  if (value === undefined) {
37607
+ if (lenient)
37608
+ return match;
37565
37609
  throw new Error(`Environment variable "${name}" is not set (referenced as \${${name}})`);
37566
37610
  }
37567
37611
  return value;
@@ -37590,7 +37634,7 @@ function normalizeDomains(domains) {
37590
37634
  return [];
37591
37635
  return domains.map(normalizeDomainEntry);
37592
37636
  }
37593
- function loadEnvironmentConfig(envFilePath) {
37637
+ function loadEnvironmentConfig(envFilePath, options) {
37594
37638
  const absPath = resolve(envFilePath);
37595
37639
  if (!existsSync(absPath)) {
37596
37640
  throw new Error(`Config file not found: ${absPath}`);
@@ -37612,14 +37656,15 @@ function loadEnvironmentConfig(envFilePath) {
37612
37656
  const config2 = parsed;
37613
37657
  const services = {};
37614
37658
  const deletedVars = {};
37659
+ const lenient = options?.lenient ?? false;
37615
37660
  for (const [name, entry] of Object.entries(config2.services)) {
37616
- const { service, deleted } = resolveService(name, entry, envDir);
37661
+ const { service, deleted } = resolveService(name, entry, envDir, lenient);
37617
37662
  services[name] = service;
37618
37663
  if (deleted.length > 0) {
37619
37664
  deletedVars[name] = deleted;
37620
37665
  }
37621
37666
  }
37622
- const resolvedSharedVars = config2.shared_variables ? resolveEnvVars(config2.shared_variables) : {};
37667
+ const resolvedSharedVars = config2.shared_variables ? resolveEnvVars(config2.shared_variables, process.env, lenient) : {};
37623
37668
  const deletedSharedVars = config2.shared_variables ? getDeletedVariables(config2.shared_variables) : [];
37624
37669
  const buckets = {};
37625
37670
  if (config2.buckets) {
@@ -37641,7 +37686,7 @@ function loadEnvironmentConfig(envFilePath) {
37641
37686
  environmentName: config2.environment
37642
37687
  };
37643
37688
  }
37644
- function resolveService(name, entry, envDir) {
37689
+ function resolveService(name, entry, envDir, lenient = false) {
37645
37690
  let template;
37646
37691
  if (entry.template) {
37647
37692
  const templatePath = resolve(envDir, entry.template);
@@ -37708,9 +37753,9 @@ function resolveService(name, entry, envDir) {
37708
37753
  ...entry.variables || {}
37709
37754
  };
37710
37755
  const deleted = getDeletedVariables(mergedVars);
37711
- const resolvedVars = resolveEnvVars(mergedVars);
37756
+ const resolvedVars = resolveEnvVars(mergedVars, process.env, lenient);
37712
37757
  const resolvedDomainsRaw = domains.map((d) => ({
37713
- domain: resolveEnvVarString(d.domain),
37758
+ domain: resolveEnvVarString(d.domain, process.env, lenient),
37714
37759
  ...d.targetPort !== undefined ? { targetPort: d.targetPort } : {}
37715
37760
  }));
37716
37761
  const seenDomains = new Set;
@@ -37776,8 +37821,8 @@ function resolveService(name, entry, envDir) {
37776
37821
  service.checkSuites = checkSuites;
37777
37822
  if (registryCredentials) {
37778
37823
  service.registryCredentials = {
37779
- username: resolveEnvVarString(registryCredentials.username),
37780
- password: resolveEnvVarString(registryCredentials.password)
37824
+ username: resolveEnvVarString(registryCredentials.username, process.env, lenient),
37825
+ password: resolveEnvVarString(registryCredentials.password, process.env, lenient)
37781
37826
  };
37782
37827
  }
37783
37828
  if (railwayDomain !== undefined) {
@@ -39381,8 +39426,9 @@ async function applyChange(client, change, projectId, environmentId, createdServ
39381
39426
  }
39382
39427
 
39383
39428
  // src/util.ts
39429
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
39384
39430
  function deepEqual(a, b) {
39385
- return Bun.deepEquals(a, b);
39431
+ return import_fast_deep_equal.default(a, b);
39386
39432
  }
39387
39433
 
39388
39434
  // src/reconcile/diff.ts
@@ -39868,7 +39914,7 @@ async function run(configPath, opts) {
39868
39914
  const raw = readFileSync3(absPath, "utf-8");
39869
39915
  const parsed = $parse(raw);
39870
39916
  validateEnvironmentConfig(parsed);
39871
- loadEnvironmentConfig(configPath);
39917
+ loadEnvironmentConfig(configPath, { lenient: true });
39872
39918
  console.log("Config is valid.");
39873
39919
  process.exit(0);
39874
39920
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachyon-gg/railway-deploy",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,6 +35,7 @@
35
35
  "@graphql-typed-document-node/core": "^3.2.0",
36
36
  "commander": "^14.0.3",
37
37
  "dotenv": "^17.3.1",
38
+ "fast-deep-equal": "^3.1.3",
38
39
  "graphql": "^16.10.0",
39
40
  "graphql-request": "^7.1.2",
40
41
  "yaml": "^2.7.0",