create-asaje-go-vue 0.3.1 → 0.3.2
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.
- package/README.md +23 -11
- package/bin/create-asaje-go-vue.js +55 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,15 @@ npx -p create-asaje-go-vue@latest asaje setup-railway ./my-app --dry-run
|
|
|
82
82
|
npx -p create-asaje-go-vue@latest asaje update-railway ./my-app --yes
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
By default this manages four Railway app services:
|
|
86
|
+
|
|
87
|
+
- `api`
|
|
88
|
+
- `worker`
|
|
89
|
+
- `realtime-gateway`
|
|
90
|
+
- `admin`
|
|
91
|
+
|
|
92
|
+
The default `worker` service reuses `api/Dockerfile` and starts with `API_COMMAND=worker`.
|
|
93
|
+
|
|
85
94
|
### Sync Railway app variables
|
|
86
95
|
|
|
87
96
|
```bash
|
|
@@ -127,6 +136,7 @@ npx -p create-asaje-go-vue@latest asaje diff-railway-config ./my-app --file ./sn
|
|
|
127
136
|
|
|
128
137
|
```bash
|
|
129
138
|
npx -p create-asaje-go-vue@latest asaje deploy-railway ./my-app
|
|
139
|
+
npx -p create-asaje-go-vue@latest asaje deploy-railway ./my-app --service worker
|
|
130
140
|
npx -p create-asaje-go-vue@latest asaje deploy-railway ./my-app --service api
|
|
131
141
|
npx -p create-asaje-go-vue@latest asaje deploy-railway ./my-app --services api,admin --dry-run
|
|
132
142
|
```
|
|
@@ -195,9 +205,9 @@ npx -p create-asaje-go-vue@latest asaje destroy-railway ./my-app --scope project
|
|
|
195
205
|
- reads the linked Railway project context
|
|
196
206
|
- provisions PostgreSQL, RabbitMQ, and S3-compatible object storage on Railway
|
|
197
207
|
- creates missing Railway app services for the configured app service list
|
|
198
|
-
- defaults to `api`, `realtime-gateway`, and `admin` when no custom Railway service config is present
|
|
208
|
+
- defaults to `api`, `worker`, `realtime-gateway`, and `admin` when no custom Railway service config is present
|
|
199
209
|
- applies Railway variables from `asaje.config.json` when configured
|
|
200
|
-
- keeps the legacy automatic variable wiring for `api`, `realtime-gateway`, and `admin` unless `railway.variablesMode` is set to `replace`
|
|
210
|
+
- keeps the legacy automatic variable wiring for `api`, `worker`, `realtime-gateway`, and `admin` unless `railway.variablesMode` is set to `replace`
|
|
201
211
|
- triggers the first Railway deployment for each app service using the service-local `Dockerfile` and `railway.json`
|
|
202
212
|
- generates missing app secrets such as `JWT_SECRET` and `SWAGGER_PASSWORD`, while reusing existing Railway values when present
|
|
203
213
|
- supports `--dry-run` to preview provisioning and variable changes without applying them
|
|
@@ -218,7 +228,7 @@ npx -p create-asaje-go-vue@latest asaje destroy-railway ./my-app --scope project
|
|
|
218
228
|
- reads the linked Railway project context
|
|
219
229
|
- discovers existing Railway app and infra services
|
|
220
230
|
- syncs configured Railway variables without provisioning infra resources
|
|
221
|
-
- keeps the legacy automatic variable wiring for `api`, `realtime-gateway`, and `admin` unless `railway.variablesMode` is set to `replace`
|
|
231
|
+
- keeps the legacy automatic variable wiring for `api`, `worker`, `realtime-gateway`, and `admin` unless `railway.variablesMode` is set to `replace`
|
|
222
232
|
- supports `--diff` to show what would be added or changed compared with the current Railway variables
|
|
223
233
|
- supports `--dry-run` to preview variable changes without applying them
|
|
224
234
|
|
|
@@ -263,7 +273,7 @@ npx -p create-asaje-go-vue@latest asaje destroy-railway ./my-app --scope project
|
|
|
263
273
|
- reads the linked Railway project context
|
|
264
274
|
- discovers the existing Railway app services from the linked project or `asaje.railway.json`
|
|
265
275
|
- triggers fresh Railway builds/deployments for the configured app service list from the current local source tree
|
|
266
|
-
- defaults to `api`, `realtime-gateway`, and `admin` when no custom Railway service config is present
|
|
276
|
+
- defaults to `api`, `worker`, `realtime-gateway`, and `admin` when no custom Railway service config is present
|
|
267
277
|
- supports `--service` and `--services` to redeploy only selected app services
|
|
268
278
|
- supports `--dry-run` to preview which services would be redeployed
|
|
269
279
|
|
|
@@ -285,6 +295,13 @@ If the `railway` block is omitted, the CLI keeps the default built-in services a
|
|
|
285
295
|
"directory": "api",
|
|
286
296
|
"dockerfile": "api/Dockerfile"
|
|
287
297
|
},
|
|
298
|
+
{
|
|
299
|
+
"key": "worker",
|
|
300
|
+
"directory": "api",
|
|
301
|
+
"baseName": "worker",
|
|
302
|
+
"aliases": ["worker", "api-worker"],
|
|
303
|
+
"dockerfile": "api/Dockerfile"
|
|
304
|
+
},
|
|
288
305
|
{
|
|
289
306
|
"key": "admin",
|
|
290
307
|
"directory": "admin",
|
|
@@ -297,12 +314,6 @@ If the `railway` block is omitted, the CLI keeps the default built-in services a
|
|
|
297
314
|
"aliases": ["realtime-gateway"],
|
|
298
315
|
"dockerfile": "realtime-gateway/Dockerfile"
|
|
299
316
|
},
|
|
300
|
-
{
|
|
301
|
-
"key": "worker",
|
|
302
|
-
"directory": "worker-api",
|
|
303
|
-
"baseName": "worker",
|
|
304
|
-
"dockerfile": "worker-api/Dockerfile"
|
|
305
|
-
},
|
|
306
317
|
{
|
|
307
318
|
"key": "marketing",
|
|
308
319
|
"directory": "marketing",
|
|
@@ -403,7 +414,8 @@ Notes:
|
|
|
403
414
|
- the service directory should contain the `Dockerfile` Railway will build from
|
|
404
415
|
- custom services are provisioned and deployed by `setup-railway` and `deploy-railway`
|
|
405
416
|
- `sync-railway-env` can now apply declarative variables to any managed service key, including custom services
|
|
406
|
-
- with `variablesMode: "merge"`, the core services `api`, `realtime-gateway`, and `admin` still receive the legacy generated defaults unless you override them
|
|
417
|
+
- with `variablesMode: "merge"`, the core services `api`, `worker`, `realtime-gateway`, and `admin` still receive the legacy generated defaults unless you override them
|
|
418
|
+
- the default `worker` service reuses the `api` image and starts with `API_COMMAND=worker`
|
|
407
419
|
- with `variablesMode: "replace"`, only the variables declared in `asaje.config.json` are applied
|
|
408
420
|
- after changing the Railway config, run `asaje update-railway ./my-app --yes` to reconcile the linked Railway project with the new configuration
|
|
409
421
|
- you can target a custom service with `asaje deploy-railway ./my-app --service worker`
|
|
@@ -34,6 +34,12 @@ const DEFAULT_RAILWAY_APP_SERVICE_SPECS = [
|
|
|
34
34
|
directory: "api",
|
|
35
35
|
key: "api",
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
aliases: ["worker", "api-worker"],
|
|
39
|
+
baseName: "worker",
|
|
40
|
+
directory: "api",
|
|
41
|
+
key: "worker",
|
|
42
|
+
},
|
|
37
43
|
{
|
|
38
44
|
aliases: ["admin", "frontend", "web"],
|
|
39
45
|
baseName: "admin",
|
|
@@ -3070,6 +3076,7 @@ async function resolveRailwayVariablePlan(config) {
|
|
|
3070
3076
|
admin: findRailwayServiceByKey(config.services, config.appServiceSpecs, config.manifest, "admin"),
|
|
3071
3077
|
api: findRailwayServiceByKey(config.services, config.appServiceSpecs, config.manifest, "api"),
|
|
3072
3078
|
realtime: findRailwayServiceByKey(config.services, config.appServiceSpecs, config.manifest, "realtime"),
|
|
3079
|
+
worker: findRailwayServiceByKey(config.services, config.appServiceSpecs, config.manifest, "worker"),
|
|
3073
3080
|
};
|
|
3074
3081
|
|
|
3075
3082
|
const serviceRegistry = {
|
|
@@ -3079,6 +3086,7 @@ async function resolveRailwayVariablePlan(config) {
|
|
|
3079
3086
|
postgres: infra.postgres ? { name: infra.postgres.name, variables: {} } : null,
|
|
3080
3087
|
rabbitmq: infra.rabbitmq ? { name: infra.rabbitmq.name, variables: {} } : null,
|
|
3081
3088
|
realtime: appServices.realtime ? { name: appServices.realtime.name, variables: {} } : null,
|
|
3089
|
+
worker: appServices.worker ? { name: appServices.worker.name, variables: {} } : null,
|
|
3082
3090
|
};
|
|
3083
3091
|
|
|
3084
3092
|
for (const spec of config.appServiceSpecs) {
|
|
@@ -3109,6 +3117,9 @@ async function resolveRailwayVariablePlan(config) {
|
|
|
3109
3117
|
if (!appServices.admin) {
|
|
3110
3118
|
notices.push("admin service not found, skipping admin variable wiring");
|
|
3111
3119
|
}
|
|
3120
|
+
if (!appServices.worker) {
|
|
3121
|
+
notices.push("worker service not found, skipping worker variable wiring");
|
|
3122
|
+
}
|
|
3112
3123
|
if (!infra.postgres) {
|
|
3113
3124
|
notices.push("postgres resource not found, DATABASE_URL wiring will be skipped");
|
|
3114
3125
|
}
|
|
@@ -3170,6 +3181,26 @@ async function resolveRailwayVariablePlan(config) {
|
|
|
3170
3181
|
mergeRailwayServiceVariables(serviceRegistry.admin, variables);
|
|
3171
3182
|
}
|
|
3172
3183
|
|
|
3184
|
+
if (variablesMode !== "replace" && appServices.worker) {
|
|
3185
|
+
const existingApiVariables = appServices.api?.name
|
|
3186
|
+
? await loadRailwayServiceVariables(config.projectDir, config.railwayContext.environmentRef, appServices.api.name)
|
|
3187
|
+
: {};
|
|
3188
|
+
const variables = {};
|
|
3189
|
+
const sharedSecrets = buildRailwaySharedSecrets(localEnv, existingApiVariables);
|
|
3190
|
+
Object.assign(variables, sharedSecrets.api);
|
|
3191
|
+
variables.API_COMMAND = "worker";
|
|
3192
|
+
if (infra.postgres?.name) {
|
|
3193
|
+
variables.DATABASE_URL = railwayReference(infra.postgres.name, "DATABASE_URL");
|
|
3194
|
+
}
|
|
3195
|
+
if (infra.rabbitmq?.name) {
|
|
3196
|
+
variables.RABBITMQ_URL = buildRabbitMqUrlReference(infra.rabbitmq.name);
|
|
3197
|
+
}
|
|
3198
|
+
if (infra.objectStorage?.name) {
|
|
3199
|
+
Object.assign(variables, buildObjectStorageVariables(infra.objectStorage.name));
|
|
3200
|
+
}
|
|
3201
|
+
mergeRailwayServiceVariables(serviceRegistry.worker, variables);
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3173
3204
|
if (declaredVariables.hasDeclaredVariables) {
|
|
3174
3205
|
if (Object.keys(declaredVariables.sharedVariables).length > 0) {
|
|
3175
3206
|
for (const entry of Object.values(serviceRegistry)) {
|
|
@@ -3909,6 +3940,7 @@ function printRailwaySetupSummary(config) {
|
|
|
3909
3940
|
if (config.railwayContext.environmentName || config.railwayContext.environmentId) {
|
|
3910
3941
|
console.log(`- Environment: ${pc.bold(config.railwayContext.environmentName || config.railwayContext.environmentId)}`);
|
|
3911
3942
|
}
|
|
3943
|
+
console.log(`- Managed services: ${pc.bold("api, worker, realtime-gateway, admin")}`);
|
|
3912
3944
|
console.log(`- Bucket: ${pc.bold(config.bucket)}`);
|
|
3913
3945
|
|
|
3914
3946
|
console.log(pc.bold("\nResources"));
|
|
@@ -3969,6 +4001,7 @@ function printRailwayDeploySummary(config) {
|
|
|
3969
4001
|
if (config.railwayContext.environmentName || config.railwayContext.environmentId) {
|
|
3970
4002
|
console.log(`- Environment: ${pc.bold(config.railwayContext.environmentName || config.railwayContext.environmentId)}`);
|
|
3971
4003
|
}
|
|
4004
|
+
console.log(`- Default managed services: ${pc.bold("api, worker, realtime-gateway, admin")}`);
|
|
3972
4005
|
console.log(`- Services: ${pc.bold(config.selectedServices.join(", "))}`);
|
|
3973
4006
|
|
|
3974
4007
|
console.log(pc.bold("\nDeployments"));
|
|
@@ -4244,17 +4277,38 @@ async function scanProjectForManagedRailwayServices(projectDir) {
|
|
|
4244
4277
|
const dockerfiles = [];
|
|
4245
4278
|
await collectDockerfiles(projectDir, "", dockerfiles);
|
|
4246
4279
|
|
|
4247
|
-
const
|
|
4280
|
+
const scannedSpecs = dockerfiles
|
|
4248
4281
|
.map((dockerfilePath) => buildScannedRailwayServiceSpec(projectDir, dockerfilePath))
|
|
4249
4282
|
.filter(Boolean)
|
|
4250
4283
|
.sort((left, right) => left.directory.localeCompare(right.directory));
|
|
4251
4284
|
|
|
4285
|
+
const serviceSpecs = synthesizeDerivedRailwayServices(scannedSpecs);
|
|
4286
|
+
|
|
4252
4287
|
return {
|
|
4253
4288
|
dockerfiles,
|
|
4254
4289
|
serviceSpecs,
|
|
4255
4290
|
};
|
|
4256
4291
|
}
|
|
4257
4292
|
|
|
4293
|
+
function synthesizeDerivedRailwayServices(serviceSpecs) {
|
|
4294
|
+
const nextSpecs = [...serviceSpecs];
|
|
4295
|
+
const hasAPI = serviceSpecs.some((spec) => spec.key === "api" && spec.directory === "api");
|
|
4296
|
+
const hasWorker = serviceSpecs.some((spec) => spec.key === "worker");
|
|
4297
|
+
if (hasAPI && !hasWorker) {
|
|
4298
|
+
nextSpecs.push({
|
|
4299
|
+
aliases: ["worker", "api-worker"],
|
|
4300
|
+
baseName: "worker",
|
|
4301
|
+
directory: "api",
|
|
4302
|
+
dockerfile: "api/Dockerfile",
|
|
4303
|
+
key: "worker",
|
|
4304
|
+
seedImage: "alpine:3.22",
|
|
4305
|
+
serviceName: null,
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
return nextSpecs.sort((left, right) => `${left.directory}:${left.key}`.localeCompare(`${right.directory}:${right.key}`));
|
|
4310
|
+
}
|
|
4311
|
+
|
|
4258
4312
|
async function collectDockerfiles(projectDir, relativeDir, results) {
|
|
4259
4313
|
const absoluteDir = path.join(projectDir, relativeDir);
|
|
4260
4314
|
const entries = await fs.readdir(absoluteDir, { withFileTypes: true });
|