@devramps/cli 0.1.30 → 0.1.31

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 +35 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1378,15 +1378,30 @@ async function parsePipeline(basePath, slug) {
1378
1378
  throw new PipelineParseError(slug, `Stage "${stage.name}" is missing region`);
1379
1379
  }
1380
1380
  }
1381
+ if (definition.pipeline.ephemeral_environments) {
1382
+ for (const [name, env] of Object.entries(definition.pipeline.ephemeral_environments)) {
1383
+ if (!env.account_id) {
1384
+ throw new PipelineParseError(slug, `Ephemeral environment "${name}" is missing account_id`);
1385
+ }
1386
+ if (!env.region) {
1387
+ throw new PipelineParseError(slug, `Ephemeral environment "${name}" is missing region`);
1388
+ }
1389
+ }
1390
+ }
1381
1391
  const targetAccountIds = extractTargetAccountIds(definition);
1382
1392
  const steps = extractSteps(definition);
1383
1393
  const additionalPolicies = await parseAdditionalPoliciesForPipeline(basePath, slug);
1384
- verbose(`Pipeline ${slug}: ${targetAccountIds.length} accounts, ${steps.length} steps`);
1394
+ const ephemeralStages = ephemeralEnvironmentsAsStages(definition);
1395
+ const allStages = [...definition.pipeline.stages, ...ephemeralStages];
1396
+ if (ephemeralStages.length > 0) {
1397
+ verbose(`Pipeline ${slug}: ${ephemeralStages.length} ephemeral environment(s) will be bootstrapped as stages`);
1398
+ }
1399
+ verbose(`Pipeline ${slug}: ${targetAccountIds.length} accounts, ${allStages.length} stages, ${steps.length} steps`);
1385
1400
  return {
1386
1401
  slug,
1387
1402
  definition,
1388
1403
  targetAccountIds,
1389
- stages: definition.pipeline.stages,
1404
+ stages: allStages,
1390
1405
  steps,
1391
1406
  additionalPolicies
1392
1407
  };
@@ -1398,8 +1413,26 @@ function extractTargetAccountIds(definition) {
1398
1413
  accountIds.add(stage.account_id);
1399
1414
  }
1400
1415
  }
1416
+ if (definition.pipeline.ephemeral_environments) {
1417
+ for (const env of Object.values(definition.pipeline.ephemeral_environments)) {
1418
+ if (env.account_id) {
1419
+ accountIds.add(env.account_id);
1420
+ }
1421
+ }
1422
+ }
1401
1423
  return Array.from(accountIds);
1402
1424
  }
1425
+ function ephemeralEnvironmentsAsStages(definition) {
1426
+ const envs = definition.pipeline.ephemeral_environments;
1427
+ if (!envs) return [];
1428
+ return Object.entries(envs).map(([name, env]) => ({
1429
+ name: `ephemeral-${name}`,
1430
+ account_id: env.account_id,
1431
+ region: env.region,
1432
+ skip: env.skip,
1433
+ vars: env.vars
1434
+ }));
1435
+ }
1403
1436
  function extractSteps(definition) {
1404
1437
  return definition.pipeline.steps || [];
1405
1438
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devramps/cli",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "DevRamps CLI - Bootstrap AWS infrastructure for CI/CD pipelines",
5
5
  "main": "dist/index.js",
6
6
  "bin": {