@adobe/helix-deploy 9.5.0 → 9.6.0

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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [9.6.0](https://github.com/adobe/helix-deploy/compare/v9.5.1...v9.6.0) (2024-01-08)
2
+
3
+
4
+ ### Features
5
+
6
+ * clean up unused versions ([#636](https://github.com/adobe/helix-deploy/issues/636)) ([e516d1e](https://github.com/adobe/helix-deploy/commit/e516d1e3312e1fadbdfe57121c6f6099ec289af1))
7
+
8
+ ## [9.5.1](https://github.com/adobe/helix-deploy/compare/v9.5.0...v9.5.1) (2024-01-06)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([bbdc3d1](https://github.com/adobe/helix-deploy/commit/bbdc3d166ea14c26e386de7cac686aad0596ad01))
14
+
1
15
  # [9.5.0](https://github.com/adobe/helix-deploy/compare/v9.4.5...v9.5.0) (2024-01-05)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -39,12 +39,12 @@
39
39
  "@adobe/fastly-native-promises": "3.0.6",
40
40
  "@adobe/fetch": "4.1.1",
41
41
  "@adobe/helix-shared-process-queue": "3.0.0",
42
- "@aws-sdk/client-apigatewayv2": "3.484.0",
43
- "@aws-sdk/client-lambda": "3.484.0",
44
- "@aws-sdk/client-s3": "3.484.0",
45
- "@aws-sdk/client-secrets-manager": "3.484.0",
46
- "@aws-sdk/client-ssm": "3.484.0",
47
- "@aws-sdk/client-sts": "3.484.0",
42
+ "@aws-sdk/client-apigatewayv2": "3.485.0",
43
+ "@aws-sdk/client-lambda": "3.485.0",
44
+ "@aws-sdk/client-s3": "3.485.0",
45
+ "@aws-sdk/client-secrets-manager": "3.485.0",
46
+ "@aws-sdk/client-ssm": "3.485.0",
47
+ "@aws-sdk/client-sts": "3.485.0",
48
48
  "@fastly/js-compute": "3.7.3",
49
49
  "@google-cloud/functions": "3.0.1",
50
50
  "@google-cloud/secret-manager": "5.0.1",
@@ -63,7 +63,7 @@
63
63
  "fs-extra": "11.2.0",
64
64
  "isomorphic-git": "1.25.2",
65
65
  "openwhisk": "3.21.8",
66
- "rollup": "4.9.2",
66
+ "rollup": "4.9.4",
67
67
  "semver": "7.5.4",
68
68
  "tar": "6.2.0",
69
69
  "webpack": "5.89.0",
@@ -20,6 +20,7 @@ export default class AWSConfig {
20
20
  role: '',
21
21
  apiId: '',
22
22
  cleanUpIntegrations: false,
23
+ cleanUpVersions: false,
23
24
  createRoutes: false,
24
25
  lambdaFormat: DEFAULT_LAMBDA_FORMAT,
25
26
  parameterMgr: ['secret'],
@@ -47,6 +48,7 @@ export default class AWSConfig {
47
48
  .withAWSAttachAuthorizer(argv.awsAttachAuthorizer)
48
49
  .withAWSIdentitySources(argv.awsIdentitySource)
49
50
  .withAWSCleanUpIntegrations(argv.awsCleanupIntegrations)
51
+ .withAWSCleanUpVersions(argv.awsCleanupVersions)
50
52
  .withAWSCreateRoutes(argv.awsCreateRoutes)
51
53
  .withAWSParamsManager(argv.awsParameterManager)
52
54
  .withAWSDeployBucket(argv.awsDeployBucket)
@@ -90,6 +92,11 @@ export default class AWSConfig {
90
92
  return this;
91
93
  }
92
94
 
95
+ withAWSCleanUpVersions(value) {
96
+ this.cleanUpVersions = value;
97
+ return this;
98
+ }
99
+
93
100
  withAWSCreateRoutes(value) {
94
101
  this.createRoutes = value;
95
102
  return this;
@@ -148,8 +155,8 @@ export default class AWSConfig {
148
155
  static yarg(yargs) {
149
156
  return yargs
150
157
  .group(['aws-region', 'aws-api', 'aws-role', 'aws-cleanup-buckets', 'aws-cleanup-integrations',
151
- 'aws-create-routes', 'aws-create-authorizer', 'aws-attach-authorizer', 'aws-lambda-format',
152
- 'aws-parameter-manager', 'aws-deploy-template', 'aws-arch', 'aws-update-secrets',
158
+ 'aws-cleanup-versions', 'aws-create-routes', 'aws-create-authorizer', 'aws-attach-authorizer',
159
+ 'aws-lambda-format', 'aws-parameter-manager', 'aws-deploy-template', 'aws-arch', 'aws-update-secrets',
153
160
  'aws-deploy-bucket', 'aws-identity-source', 'aws-log-format', 'aws-layers',
154
161
  'aws-tracing-mode', 'aws-extra-permissions'], 'AWS Deployment Options')
155
162
  .option('aws-region', {
@@ -214,6 +221,11 @@ export default class AWSConfig {
214
221
  type: 'boolean',
215
222
  default: false,
216
223
  })
224
+ .option('aws-cleanup-versions', {
225
+ description: 'Cleans up unused versions',
226
+ type: 'boolean',
227
+ default: false,
228
+ })
217
229
  .option('aws-deploy-bucket', {
218
230
  description: 'Name of the deploy S3 bucket to use (default is helix-deploy-bucket-{accountId})',
219
231
  type: 'string',
@@ -634,6 +634,39 @@ export default class AWSDeployer extends BaseDeployer {
634
634
  }
635
635
  }
636
636
 
637
+ async cleanUpVersions() {
638
+ const { functionName } = this;
639
+
640
+ this.log.info('Clean up unused versions');
641
+ this.log.info(chalk`--: fetching aliases...`);
642
+ const aliases = await this.listAliases(functionName);
643
+ this.log.info(chalk`--: fetching versions...`);
644
+ const versions = (await this.listVersions(functionName))
645
+ .map((version) => ({
646
+ ...version,
647
+ Aliases: aliases
648
+ .filter(({ FunctionVersion }) => version.Version === FunctionVersion)
649
+ .map(({ Name }) => Name),
650
+ }));
651
+
652
+ const unusedVersions = versions
653
+ .filter(({ Version }) => Version !== '$LATEST')
654
+ .filter(({ Aliases }) => Aliases.length === 0);
655
+ this.log.info(`Found ${unusedVersions.length} unused versions`);
656
+
657
+ if (unusedVersions.length) {
658
+ this.log.info(chalk`--: deleting unused versions...`);
659
+ const deleted = await processQueue(unusedVersions, async ({ Version }) => {
660
+ await this._lambda.send(new DeleteFunctionCommand({
661
+ FunctionName: functionName,
662
+ Qualifier: Version,
663
+ }));
664
+ return Version;
665
+ }, 2);
666
+ this.log.info(chalk`{green ok}: deleted ${deleted.length} unused versions.`);
667
+ }
668
+ }
669
+
637
670
  async cleanUpIntegrations(filter) {
638
671
  this.log.info('Clean up Integrations');
639
672
  const { ApiId } = await this.initApiId();
@@ -959,6 +992,9 @@ export default class AWSDeployer extends BaseDeployer {
959
992
  if (this._cfg.cleanUpIntegrations) {
960
993
  await this.cleanUpIntegrations();
961
994
  }
995
+ if (this._cfg.cleanUpVersions) {
996
+ await this.cleanUpVersions();
997
+ }
962
998
  if (this._cfg.updateSecrets !== undefined) {
963
999
  await this.updateSecrets();
964
1000
  }