@fishawack/lab-env 5.9.0-beta.3 → 5.9.0-beta.4
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/CHANGELOG.md +6 -0
- package/commands/create/cmds/server-status.js +172 -47
- package/package.json +1 -1
- package/php/8.2/Dockerfile +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 5.9.0-beta.4 (2026-10-08)
|
|
4
|
+
|
|
5
|
+
#### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* server-status now resolves from config with branch as fallback ([c3a7c75](https://bitbucket.org/fishawackdigital/lab-env/commits/c3a7c75841f36a7a6c0b3eccce202618c40fa599))
|
|
8
|
+
|
|
3
9
|
### 5.9.0-beta.3 (2026-09-25)
|
|
4
10
|
|
|
5
11
|
#### Features
|
|
@@ -54,6 +54,18 @@ function listGitBranches() {
|
|
|
54
54
|
return [...branches].sort();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Deploy targets explicitly configured in config can point at an EB environment that
|
|
58
|
+
// was provisioned under a different (possibly now-deleted) branch name, e.g. after a
|
|
59
|
+
// blue/green swap — these won't be found by recomputing the slug from the branch name alone
|
|
60
|
+
function getDynamicTargets() {
|
|
61
|
+
const targets = _.coreConfig?.attributes?.targets || {};
|
|
62
|
+
|
|
63
|
+
return Object.entries(targets).map(([name, cfg]) => ({
|
|
64
|
+
branch: name,
|
|
65
|
+
awsEb: cfg?.deploy?.["aws-eb"] || null,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
async function resolveClients(argv) {
|
|
58
70
|
if (argv.all) return client.choices;
|
|
59
71
|
if (argv.client) return [argv.client];
|
|
@@ -113,32 +125,61 @@ async function resolveRegions(argv) {
|
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
async function resolveBranches(argv) {
|
|
116
|
-
if (argv.
|
|
117
|
-
if (argv.branch) return [argv.branch];
|
|
128
|
+
if (argv.branch) return [{ branch: argv.branch, awsEb: null }];
|
|
118
129
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
type: "confirm",
|
|
122
|
-
name: "check",
|
|
123
|
-
message: `Check status for the current branch (${colorize(_.branch, "success")})?`,
|
|
124
|
-
default: true,
|
|
125
|
-
},
|
|
126
|
-
]);
|
|
130
|
+
const dynamicTargets = getDynamicTargets();
|
|
131
|
+
const dynamicByBranch = new Map(dynamicTargets.map((t) => [t.branch, t]));
|
|
127
132
|
|
|
128
|
-
if (
|
|
133
|
+
if (argv.all) {
|
|
134
|
+
const merged = listGitBranches().map(
|
|
135
|
+
(b) => dynamicByBranch.get(b) || { branch: b, awsEb: null },
|
|
136
|
+
);
|
|
137
|
+
const missing = dynamicTargets.filter(
|
|
138
|
+
(t) => !merged.some((m) => m.branch === t.branch),
|
|
139
|
+
);
|
|
140
|
+
return [...merged, ...missing];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (dynamicTargets.length) {
|
|
144
|
+
const { useTargets } = await inquirer.prompt([
|
|
145
|
+
{
|
|
146
|
+
type: "confirm",
|
|
147
|
+
name: "useTargets",
|
|
148
|
+
message: `Found deploy targets in config (${dynamicTargets.map((t) => t.branch).join(", ")}) — check just these?`,
|
|
149
|
+
default: true,
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
if (useTargets) return dynamicTargets;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const gitBranches = listGitBranches().filter(
|
|
157
|
+
(b) => !dynamicByBranch.has(b),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const choices = [
|
|
161
|
+
...dynamicTargets.map((t) => ({
|
|
162
|
+
name: `${t.branch} (config target)`,
|
|
163
|
+
value: t.branch,
|
|
164
|
+
checked: true,
|
|
165
|
+
})),
|
|
166
|
+
...gitBranches.map((b) => ({ name: b, value: b })),
|
|
167
|
+
];
|
|
129
168
|
|
|
130
169
|
const { selected } = await inquirer.prompt([
|
|
131
170
|
{
|
|
132
171
|
type: "checkbox",
|
|
133
172
|
name: "selected",
|
|
134
173
|
message: "Which branches would you like to check?",
|
|
135
|
-
choices
|
|
174
|
+
choices,
|
|
136
175
|
validate: (input) =>
|
|
137
176
|
input.length > 0 || "Select at least one branch",
|
|
138
177
|
},
|
|
139
178
|
]);
|
|
140
179
|
|
|
141
|
-
return selected
|
|
180
|
+
return selected.map(
|
|
181
|
+
(b) => dynamicByBranch.get(b) || { branch: b, awsEb: null },
|
|
182
|
+
);
|
|
142
183
|
}
|
|
143
184
|
|
|
144
185
|
// S3/CloudFront are account-wide, not per-region, so fetch once per client and reuse
|
|
@@ -168,38 +209,106 @@ function findDistribution(distributions, s3Slug) {
|
|
|
168
209
|
|
|
169
210
|
// EB/RDS/OpenSearch/ElastiCache are the only truly regional checks; S3/CloudFront/IAM/SES
|
|
170
211
|
// are account-wide, so they're only worth fetching once per branch (on the primary region)
|
|
171
|
-
async function checkBranch(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
212
|
+
async function checkBranch(
|
|
213
|
+
caches,
|
|
214
|
+
clientName,
|
|
215
|
+
branch,
|
|
216
|
+
isPrimaryRegion,
|
|
217
|
+
awsEbOverride,
|
|
218
|
+
) {
|
|
219
|
+
const guessedEbSlug = aws.slug(_.repoSafe, clientName, branch, "eb");
|
|
220
|
+
|
|
221
|
+
const result = {};
|
|
222
|
+
|
|
223
|
+
let environment = null;
|
|
224
|
+
let environmentName = guessedEbSlug;
|
|
225
|
+
let resolution = null; // "fw-json" | "branch-fallback" | null
|
|
226
|
+
|
|
227
|
+
// Config state is authoritative when available, so check it before guessing
|
|
228
|
+
if (awsEbOverride) {
|
|
229
|
+
try {
|
|
230
|
+
const { Environments } =
|
|
231
|
+
await aws.elasticbeanstalk.describeEnvironment(awsEbOverride);
|
|
232
|
+
environment =
|
|
233
|
+
(Environments || []).find((e) => e.Status !== "Terminated") ||
|
|
234
|
+
null;
|
|
235
|
+
if (environment) {
|
|
236
|
+
environmentName = awsEbOverride;
|
|
237
|
+
resolution = "fw-json";
|
|
238
|
+
}
|
|
239
|
+
} catch {
|
|
240
|
+
/* config-registered env not found, fall back to computing from the branch name */
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!environment) {
|
|
245
|
+
try {
|
|
246
|
+
const { Environments } =
|
|
247
|
+
await aws.elasticbeanstalk.describeEnvironment(guessedEbSlug);
|
|
248
|
+
environment =
|
|
249
|
+
(Environments || []).find((e) => e.Status !== "Terminated") ||
|
|
250
|
+
null;
|
|
251
|
+
if (environment) {
|
|
252
|
+
environmentName = guessedEbSlug;
|
|
253
|
+
resolution = awsEbOverride ? "branch-fallback" : null;
|
|
254
|
+
}
|
|
255
|
+
} catch {
|
|
256
|
+
/* not found via the computed slug either */
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
result.elasticbeanstalk = environment
|
|
261
|
+
? {
|
|
262
|
+
found: true,
|
|
263
|
+
name: environmentName,
|
|
264
|
+
status: environment.Status,
|
|
265
|
+
health: environment.Health,
|
|
266
|
+
domain: environment.CNAME,
|
|
267
|
+
}
|
|
268
|
+
: { found: false };
|
|
269
|
+
|
|
270
|
+
// Recover the true provisioning-time branch name from tags so the rest of this
|
|
271
|
+
// family's resources can be located — only meaningful when we trusted config's
|
|
272
|
+
// config state over our own guess. The "branch" tag is relatively new; older
|
|
273
|
+
// environments only carry an "environment" tag whose value was the branch name.
|
|
274
|
+
let effectiveBranch = branch;
|
|
275
|
+
|
|
276
|
+
if (resolution === "fw-json") {
|
|
277
|
+
try {
|
|
278
|
+
const tags = await aws.elasticbeanstalk.getEnvironmentTags(
|
|
279
|
+
environment.EnvironmentArn,
|
|
280
|
+
);
|
|
281
|
+
const branchTag = tags.find((t) => t.Key === "branch");
|
|
282
|
+
const environmentTag = tags.find((t) => t.Key === "environment");
|
|
283
|
+
const recovered = branchTag?.Value || environmentTag?.Value;
|
|
284
|
+
if (recovered) effectiveBranch = recovered;
|
|
285
|
+
} catch {
|
|
286
|
+
/* keep the target name as the branch to derive sibling slugs from */
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
result.resolution = resolution;
|
|
291
|
+
result.resolvedBranch =
|
|
292
|
+
resolution === "fw-json" && effectiveBranch !== branch
|
|
293
|
+
? effectiveBranch
|
|
294
|
+
: null;
|
|
295
|
+
|
|
296
|
+
const s3Slug = aws.slug(_.repoSafe, clientName, effectiveBranch, "s3");
|
|
297
|
+
const rdsSlug = aws.slug(_.repoSafe, clientName, effectiveBranch, "rds");
|
|
298
|
+
const osSlug = aws.slug(_.repoSafe, clientName, effectiveBranch, "os");
|
|
299
|
+
const cacheSlug = aws.slug(
|
|
300
|
+
_.repoSafe,
|
|
301
|
+
clientName,
|
|
302
|
+
effectiveBranch,
|
|
303
|
+
"cache",
|
|
304
|
+
);
|
|
177
305
|
const responseFnSlug = aws.slug(
|
|
178
306
|
`${_.repoSafe}-response`,
|
|
179
307
|
clientName,
|
|
180
|
-
|
|
308
|
+
effectiveBranch,
|
|
181
309
|
);
|
|
182
310
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
const { Environments } =
|
|
187
|
-
await aws.elasticbeanstalk.describeEnvironment(ebSlug);
|
|
188
|
-
const active = (Environments || []).find(
|
|
189
|
-
(e) => e.Status !== "Terminated",
|
|
190
|
-
);
|
|
191
|
-
result.elasticbeanstalk = active
|
|
192
|
-
? {
|
|
193
|
-
found: true,
|
|
194
|
-
name: ebSlug,
|
|
195
|
-
status: active.Status,
|
|
196
|
-
health: active.Health,
|
|
197
|
-
domain: active.CNAME,
|
|
198
|
-
}
|
|
199
|
-
: { found: false };
|
|
200
|
-
} catch {
|
|
201
|
-
result.elasticbeanstalk = { found: false };
|
|
202
|
-
}
|
|
311
|
+
result.slug = s3Slug;
|
|
203
312
|
|
|
204
313
|
if (isPrimaryRegion) {
|
|
205
314
|
const buckets = await getS3Buckets(caches.s3, clientName);
|
|
@@ -320,13 +429,13 @@ async function checkBranch(caches, clientName, branch, isPrimaryRegion) {
|
|
|
320
429
|
: { found: false };
|
|
321
430
|
|
|
322
431
|
// Laravel fullstack apps instead grant service access via a per-environment IAM role/instance profile
|
|
323
|
-
const roleName = `${
|
|
432
|
+
const roleName = `${environmentName}-role`;
|
|
324
433
|
const instanceRole = await aws.iam.getIAMRole(roleName);
|
|
325
434
|
result.iamInstanceRole = instanceRole
|
|
326
435
|
? { found: true, name: roleName }
|
|
327
436
|
: { found: false };
|
|
328
437
|
|
|
329
|
-
const sesUserName = `${
|
|
438
|
+
const sesUserName = `${environmentName}-ses`;
|
|
330
439
|
const mailUser = await aws.iam.getIAMUser(sesUserName, mailIamClient);
|
|
331
440
|
result.sesMail = mailUser
|
|
332
441
|
? { found: true, name: sesUserName }
|
|
@@ -455,7 +564,22 @@ function printStatusReport(results) {
|
|
|
455
564
|
console.log(
|
|
456
565
|
` ${colorize(`${clientName} / ${regionName} / ${branch}`, "divider")}`,
|
|
457
566
|
);
|
|
458
|
-
console.log(` ${colorize(result.slug, "info")}
|
|
567
|
+
console.log(` ${colorize(result.slug, "info")}`);
|
|
568
|
+
|
|
569
|
+
if (result.resolution === "fw-json") {
|
|
570
|
+
const detail = result.resolvedBranch
|
|
571
|
+
? ` (originally provisioned as "${result.resolvedBranch}")`
|
|
572
|
+
: "";
|
|
573
|
+
console.log(
|
|
574
|
+
` ${colorize(`resolved via config${detail}`, "warning")}`,
|
|
575
|
+
);
|
|
576
|
+
} else if (result.resolution === "branch-fallback") {
|
|
577
|
+
console.log(
|
|
578
|
+
` ${colorize("config target not found on AWS — resolved from branch name instead", "warning")}`,
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
console.log("");
|
|
459
583
|
|
|
460
584
|
if (fullstackFound) {
|
|
461
585
|
fullstackEntries.forEach(([label, entry]) =>
|
|
@@ -530,18 +654,19 @@ module.exports = [
|
|
|
530
654
|
const isPrimaryRegion = r === primaryRegion;
|
|
531
655
|
const spinner = new Spinner(`Checking ${c} / ${r}`, true);
|
|
532
656
|
|
|
533
|
-
for (const
|
|
534
|
-
spinner.ora.text = `Checking ${c} / ${r} - ${branch}`;
|
|
657
|
+
for (const target of branches) {
|
|
658
|
+
spinner.ora.text = `Checking ${c} / ${r} - ${target.branch}`;
|
|
535
659
|
const result = await checkBranch(
|
|
536
660
|
caches,
|
|
537
661
|
c,
|
|
538
|
-
branch,
|
|
662
|
+
target.branch,
|
|
539
663
|
isPrimaryRegion,
|
|
664
|
+
target.awsEb,
|
|
540
665
|
);
|
|
541
666
|
results.push({
|
|
542
667
|
client: c,
|
|
543
668
|
region: r,
|
|
544
|
-
branch,
|
|
669
|
+
branch: target.branch,
|
|
545
670
|
result,
|
|
546
671
|
isPrimaryRegion,
|
|
547
672
|
});
|
package/package.json
CHANGED
package/php/8.2/Dockerfile
CHANGED
|
@@ -15,6 +15,9 @@ COPY ./policy.xml /etc/ImageMagick-6/policy.xml
|
|
|
15
15
|
# Add php user
|
|
16
16
|
RUN useradd -m -G www-data -s /bin/bash php
|
|
17
17
|
|
|
18
|
+
# Set safe directory to remove intel errors when running git rev-parse
|
|
19
|
+
RUN su php -c "git config --global --add safe.directory /app"
|
|
20
|
+
|
|
18
21
|
# Change composer home dir
|
|
19
22
|
ENV COMPOSER_HOME=/home/php/.composer
|
|
20
23
|
|