@fishawack/lab-env 5.9.0-beta.3 → 5.9.0-beta.5

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.
@@ -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.all) return listGitBranches();
117
- if (argv.branch) return [argv.branch];
128
+ if (argv.branch) return [{ branch: argv.branch, awsEb: null }];
118
129
 
119
- const { check } = await inquirer.prompt([
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 (check) return [_.branch];
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: listGitBranches(),
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(caches, clientName, branch, isPrimaryRegion) {
172
- const s3Slug = aws.slug(_.repoSafe, clientName, branch, "s3");
173
- const ebSlug = aws.slug(_.repoSafe, clientName, branch, "eb");
174
- const rdsSlug = aws.slug(_.repoSafe, clientName, branch, "rds");
175
- const osSlug = aws.slug(_.repoSafe, clientName, branch, "os");
176
- const cacheSlug = aws.slug(_.repoSafe, clientName, branch, "cache");
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
- branch,
308
+ effectiveBranch,
181
309
  );
182
310
 
183
- const result = { slug: s3Slug };
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 = `${ebSlug}-role`;
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 = `${ebSlug}-ses`;
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")}\n`);
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 branch of branches) {
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
  });
@@ -18,6 +18,12 @@ const {
18
18
  ListAvailableSolutionStacksCommand,
19
19
  ListTagsForResourceCommand,
20
20
  RestartAppServerCommand,
21
+ DescribeEnvironmentManagedActionsCommand,
22
+ DescribeEnvironmentManagedActionHistoryCommand,
23
+ ApplyEnvironmentManagedActionCommand,
24
+ DescribePlatformVersionCommand,
25
+ ListPlatformVersionsCommand,
26
+ DescribeEventsCommand,
21
27
  } = require("@aws-sdk/client-elastic-beanstalk");
22
28
  const { Spinner, poll } = require("../../libs/utilities");
23
29
  const { eb, secretGroups, awsClientConfig } = require("../../libs/vars");
@@ -25,6 +31,131 @@ const { template } = require("lodash");
25
31
 
26
32
  const getClient = () => new ElasticBeanstalkClient(awsClientConfig);
27
33
 
34
+ module.exports.describePlatformVersion = async (PlatformArn) => {
35
+ const response = await getClient().send(
36
+ new DescribePlatformVersionCommand({ PlatformArn }),
37
+ );
38
+ return response.PlatformDescription || null;
39
+ };
40
+
41
+ module.exports.listBranchPlatformVersions = async (PlatformBranchName) => {
42
+ const versions = [];
43
+ let NextToken;
44
+ do {
45
+ const response = await getClient().send(
46
+ new ListPlatformVersionsCommand({
47
+ Filters: [
48
+ {
49
+ Type: "PlatformBranchName",
50
+ Operator: "=",
51
+ Values: [PlatformBranchName],
52
+ },
53
+ {
54
+ Type: "PlatformStatus",
55
+ Operator: "=",
56
+ Values: ["Ready"],
57
+ },
58
+ ],
59
+ MaxRecords: 100,
60
+ NextToken,
61
+ }),
62
+ );
63
+ versions.push(...(response.PlatformSummaryList || []));
64
+ NextToken = response.NextToken;
65
+ } while (NextToken);
66
+ return versions;
67
+ };
68
+
69
+ module.exports.updateEnvironmentPlatform = async (
70
+ EnvironmentId,
71
+ PlatformArn,
72
+ ) => {
73
+ return new ElasticBeanstalkClient({
74
+ ...awsClientConfig,
75
+ maxAttempts: 1,
76
+ }).send(new UpdateEnvironmentCommand({ EnvironmentId, PlatformArn }));
77
+ };
78
+
79
+ module.exports.getEnvironmentUpdateEvents = async (
80
+ EnvironmentId,
81
+ StartTime,
82
+ ) => {
83
+ const events = [];
84
+ let NextToken;
85
+ do {
86
+ const response = await getClient().send(
87
+ new DescribeEventsCommand({
88
+ EnvironmentId,
89
+ StartTime,
90
+ NextToken,
91
+ MaxRecords: 100,
92
+ }),
93
+ );
94
+ events.push(...(response.Events || []));
95
+ NextToken = response.NextToken;
96
+ } while (NextToken);
97
+ return events;
98
+ };
99
+
100
+ module.exports.listAccountEnvironments = async () => {
101
+ const environments = [];
102
+ let NextToken;
103
+
104
+ do {
105
+ const response = await getClient().send(
106
+ new DescribeEnvironmentsCommand({
107
+ IncludeDeleted: false,
108
+ MaxRecords: 100,
109
+ NextToken,
110
+ }),
111
+ );
112
+ environments.push(...(response.Environments || []));
113
+ NextToken = response.NextToken;
114
+ } while (NextToken);
115
+
116
+ return environments.filter(
117
+ (environment) =>
118
+ !["Terminated", "Terminating"].includes(environment.Status),
119
+ );
120
+ };
121
+
122
+ module.exports.getManagedActions = async (EnvironmentId) => {
123
+ const response = await getClient().send(
124
+ new DescribeEnvironmentManagedActionsCommand({ EnvironmentId }),
125
+ );
126
+ return response.ManagedActions || [];
127
+ };
128
+
129
+ module.exports.getManagedActionHistory = async (EnvironmentId, ActionId) => {
130
+ let NextToken;
131
+
132
+ do {
133
+ const response = await getClient().send(
134
+ new DescribeEnvironmentManagedActionHistoryCommand({
135
+ EnvironmentId,
136
+ MaxItems: 100,
137
+ NextToken,
138
+ }),
139
+ );
140
+ const action = (response.ManagedActionHistoryItems || []).find(
141
+ (item) => item.ActionId === ActionId,
142
+ );
143
+ if (action) return action;
144
+ NextToken = response.NextToken;
145
+ } while (NextToken);
146
+
147
+ return null;
148
+ };
149
+
150
+ module.exports.applyManagedAction = async (EnvironmentId, ActionId) => {
151
+ return new ElasticBeanstalkClient({
152
+ ...awsClientConfig,
153
+ maxAttempts: 1,
154
+ }).send(
155
+ new ApplyEnvironmentManagedActionCommand({ EnvironmentId, ActionId }),
156
+ );
157
+ };
158
+
28
159
  module.exports.createElasticBeanstalkApplication = async (name, tags = []) => {
29
160
  let res = await Spinner.prototype.simple(
30
161
  `Creating elasticbeanstalk application ${name}`,
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.6.2 (2026-10-23)
4
+ * [Bug] force rebuild to bump to 8.2.25 to fix php2shell issue
5
+
3
6
  ### 0.6.1 (2023-08-14)
4
7
  * [Bug] move composer home directory so cache folder is writeable
5
8
 
@@ -1,4 +1,4 @@
1
- FROM chialab/php:8.1-fpm AS development
1
+ FROM chialab/php:8.2-fpm AS development
2
2
 
3
3
  LABEL org.opencontainers.image.authors="Mike Mellor <mike.mellor@avalerehealth.com>"
4
4
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "php",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "lab-env docker config for the php module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",
package/globals.js CHANGED
@@ -236,7 +236,9 @@ if (composer && composer.require && composer.require["laravel/framework"]) {
236
236
  args[0] !== "rekey" &&
237
237
  args[0] !== "lint" &&
238
238
  args[0] !== "workspace" &&
239
- args[0] !== "prune"
239
+ args[0] !== "prune" &&
240
+ args[0] !== "force-managed-updates" &&
241
+ args[0] !== "fmu"
240
242
  ) {
241
243
  unknownLabEnvConfig(platform, version);
242
244
  }
@@ -283,7 +285,9 @@ if (composer && composer.require && composer.require["laravel/framework"]) {
283
285
  args[0] !== "rekey" &&
284
286
  args[0] !== "lint" &&
285
287
  args[0] !== "workspace" &&
286
- args[0] !== "prune"
288
+ args[0] !== "prune" &&
289
+ args[0] !== "force-managed-updates" &&
290
+ args[0] !== "fmu"
287
291
  ) {
288
292
  unknownLabEnvConfig(platform, version);
289
293
  }
@@ -359,7 +363,9 @@ if (process.env.FW_NEXT || forced) {
359
363
  args[0] !== "rekey" &&
360
364
  args[0] !== "lint" &&
361
365
  args[0] !== "workspace" &&
362
- args[0] !== "prune"
366
+ args[0] !== "prune" &&
367
+ args[0] !== "force-managed-updates" &&
368
+ args[0] !== "fmu"
363
369
  ) {
364
370
  if (version) {
365
371
  unknownLabEnvConfig("core", version);
@@ -720,7 +726,9 @@ if (
720
726
  args[0] !== "rekey" &&
721
727
  args[0] !== "lint" &&
722
728
  args[0] !== "workspace" &&
723
- args[0] !== "prune"
729
+ args[0] !== "prune" &&
730
+ args[0] !== "force-managed-updates" &&
731
+ args[0] !== "fmu"
724
732
  ) {
725
733
  if (!forced) {
726
734
  // Stop here if diagnosis either unset or outdated
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.0.2 (2026-10-23)
4
+ * [Bug] force rebuild to bump to 8.2.25 to fix php2shell issue
5
+
3
6
  ### 1.0.1 (2025-11-07)
4
7
  * [Bug] installed mariadb for db dumps and schema imports
5
8
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "php",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "lab-env docker config for the php module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.0.4 (2026-10-23)
4
+ * [Bug] force rebuild to bump to 8.2.25 to fix php2shell issue
5
+
3
6
  ### 1.0.3 (2025-11-07)
4
7
  * [Bug] installed mariadb for db dumps and schema imports
5
8
 
@@ -1,4 +1,4 @@
1
- FROM chialab/php:8.1-fpm AS development
1
+ FROM chialab/php:8.2-fpm AS development
2
2
 
3
3
  LABEL org.opencontainers.image.authors="Mike Mellor <mike.mellor@avalerehealth.com>"
4
4
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "php",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "lab-env docker config for the php module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "5.9.0-beta.3",
3
+ "version": "5.9.0-beta.5",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
@@ -1,4 +1,7 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.0.1 (2026-10-23)
4
+ * [Bug] force rebuild to bump to 8.2.25 to fix php2shell issue
5
+
3
6
  ### 1.0.0 (2025-07-21)
4
7
  * [Misc] initial commit
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "php",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "lab-env docker config for the php module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",
@@ -1,5 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.2 (2026-10-23)
4
+ * [Bug] force rebuild to bump to 8.2.25 to fix php2shell issue
5
+
3
6
  ### 1.1.1 (2023-08-14)
4
7
  * [Bug] move composer home directory so cache folder is writeable
5
8
 
@@ -1,4 +1,4 @@
1
- FROM chialab/php:8.1-fpm AS development
1
+ FROM chialab/php:8.2-fpm AS development
2
2
 
3
3
  LABEL org.opencontainers.image.authors="Mike Mellor <mike.mellor@avalerehealth.com>"
4
4
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "php",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "lab-env docker config for the php module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",