@tachyon-gg/railway-deploy 0.2.5 → 0.2.7

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 (3) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +27 -11
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -60,7 +60,7 @@ environment: production # Railway environment name
60
60
 
61
61
  shared_variables: # Variables shared across all services
62
62
  APP_ENV: production
63
- DATABASE_URL: ${{Postgres.DATABASE_URL}}
63
+ API_PORT: "8080"
64
64
 
65
65
  services: # Map of service name -> config
66
66
  web: { ... }
@@ -212,6 +212,8 @@ variables:
212
212
  | `%{service_name}` | At config load time | Built-in: the service's config key |
213
213
  | `null` | N/A | Marks a variable for deletion |
214
214
 
215
+ **Important:** Shared variables (`shared_variables`) cannot contain `${{service.VAR}}` references — Railway resolves shared variables without a service context, so cross-service references will resolve to empty strings. Use `${{service.VAR}}` references directly in service variables instead, and use shared variables only for plain values or `${{shared.OTHER_VAR}}` self-references.
216
+
215
217
  `%{param}` is expanded first, so it can be used inside `${{}}` Railway references. This is useful for templates that need to reference their own or other services' variables:
216
218
 
217
219
  ```yaml
package/dist/index.js CHANGED
@@ -39225,11 +39225,19 @@ async function applyChangeset(client, changeset, projectId, environmentId, optio
39225
39225
  const failed = [];
39226
39226
  const noColor = options?.noColor ?? false;
39227
39227
  const createdServiceIds = new Map;
39228
- const varChangeIndices = changeset.changes.map((c, i) => c.type === "upsert-variables" || c.type === "upsert-shared-variables" ? i : -1).filter((i) => i >= 0);
39229
- const lastVarChangeIdx = varChangeIndices.length > 0 ? varChangeIndices[varChangeIndices.length - 1] : -1;
39228
+ const lastVarChangeByService = new Map;
39229
+ for (let i = 0;i < changeset.changes.length; i++) {
39230
+ const c = changeset.changes[i];
39231
+ if (c.type === "upsert-variables") {
39232
+ lastVarChangeByService.set(c.serviceName, i);
39233
+ }
39234
+ }
39230
39235
  for (let i = 0;i < changeset.changes.length; i++) {
39231
39236
  const change = changeset.changes[i];
39232
- const skipDeploys = (change.type === "upsert-variables" || change.type === "upsert-shared-variables") && i < lastVarChangeIdx;
39237
+ let skipDeploys = false;
39238
+ if (change.type === "upsert-variables") {
39239
+ skipDeploys = i < (lastVarChangeByService.get(change.serviceName) ?? -1);
39240
+ }
39233
39241
  try {
39234
39242
  await applyChange(client, change, projectId, environmentId, createdServiceIds, skipDeploys);
39235
39243
  applied.push(change);
@@ -39645,8 +39653,10 @@ function diffServiceSettings(desired, current, changes) {
39645
39653
  if (!deepEqual(desired.source, current.source)) {
39646
39654
  settings.source = desired.source ?? null;
39647
39655
  }
39648
- if (desired.restartPolicy !== current.restartPolicy) {
39649
- settings.restartPolicy = desired.restartPolicy ?? null;
39656
+ if (desired.restartPolicy !== undefined && desired.restartPolicy !== current.restartPolicy) {
39657
+ settings.restartPolicy = desired.restartPolicy;
39658
+ } else if (desired.restartPolicy === undefined && current.restartPolicy !== undefined) {
39659
+ console.warn(` Warning: "${desired.name}" has no restart_policy in config — Railway will keep "${current.restartPolicy}"`);
39650
39660
  }
39651
39661
  if (!deepEqual(desired.healthcheck, current.healthcheck)) {
39652
39662
  settings.healthcheck = desired.healthcheck ?? null;
@@ -39672,17 +39682,23 @@ function diffServiceSettings(desired, current, changes) {
39672
39682
  if (!deepEqual(desired.preDeployCommand, current.preDeployCommand)) {
39673
39683
  settings.preDeployCommand = desired.preDeployCommand ?? null;
39674
39684
  }
39675
- if (desired.restartPolicyMaxRetries !== current.restartPolicyMaxRetries) {
39676
- settings.restartPolicyMaxRetries = desired.restartPolicyMaxRetries ?? null;
39685
+ if (desired.restartPolicyMaxRetries !== undefined && desired.restartPolicyMaxRetries !== current.restartPolicyMaxRetries) {
39686
+ settings.restartPolicyMaxRetries = desired.restartPolicyMaxRetries;
39687
+ } else if (desired.restartPolicyMaxRetries === undefined && current.restartPolicyMaxRetries !== undefined) {
39688
+ console.warn(` Warning: "${desired.name}" has no restart_policy_max_retries in config — Railway will keep ${current.restartPolicyMaxRetries}`);
39677
39689
  }
39678
39690
  if (desired.sleepApplication !== current.sleepApplication) {
39679
39691
  settings.sleepApplication = desired.sleepApplication ?? null;
39680
39692
  }
39681
- if (desired.builder !== current.builder) {
39682
- settings.builder = desired.builder ?? null;
39693
+ if (desired.builder !== undefined && desired.builder !== current.builder) {
39694
+ settings.builder = desired.builder;
39695
+ } else if (desired.builder === undefined && current.builder !== undefined) {
39696
+ console.warn(` Warning: "${desired.name}" has no builder in config — Railway will keep "${current.builder}"`);
39683
39697
  }
39684
- if (!deepEqual(desired.watchPatterns, current.watchPatterns)) {
39685
- settings.watchPatterns = desired.watchPatterns ?? null;
39698
+ if (desired.watchPatterns !== undefined && !deepEqual(desired.watchPatterns, current.watchPatterns)) {
39699
+ settings.watchPatterns = desired.watchPatterns;
39700
+ } else if (desired.watchPatterns === undefined && current.watchPatterns !== undefined) {
39701
+ console.warn(` Warning: "${desired.name}" has no watch_patterns in config — Railway will keep current patterns`);
39686
39702
  }
39687
39703
  if (desired.drainingSeconds !== current.drainingSeconds) {
39688
39704
  settings.drainingSeconds = desired.drainingSeconds ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachyon-gg/railway-deploy",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,8 @@
29
29
  "test:all": "bun test --bail --timeout 30000 --env-file .env.test test/",
30
30
  "lint": "biome check .",
31
31
  "lint:fix": "biome check --write .",
32
- "format": "biome format --write ."
32
+ "format": "biome format --write .",
33
+ "prepare": "husky"
33
34
  },
34
35
  "dependencies": {
35
36
  "@graphql-typed-document-node/core": "^3.2.0",
@@ -48,6 +49,7 @@
48
49
  "@graphql-codegen/typescript": "^4.1.2",
49
50
  "@graphql-codegen/typescript-operations": "^4.4.0",
50
51
  "@types/bun": "latest",
52
+ "husky": "^9.1.7",
51
53
  "typescript": "^5.7.0"
52
54
  }
53
55
  }