From 336b25a4efbf58fd9fe662d7626dc904f053dcd9 Mon Sep 17 00:00:00 2001 From: Daniel Kennedy Date: Thu, 29 Jan 2026 12:07:18 -0500 Subject: [PATCH] `@actions/cache`: convert to an ESM module --- jest.config.js | 5 +- packages/cache/RELEASES.md | 113 ++++----- packages/cache/package-lock.json | 220 +++++------------- packages/cache/package.json | 35 +-- packages/cache/src/cache.ts | 14 +- .../src/generated/results/api/v1/cache.ts | 2 +- .../results/api/v1/cache.twirp-client.ts | 2 +- .../results/entities/v1/cachemetadata.ts | 2 +- .../cache/src/internal/cacheHttpClient.ts | 16 +- packages/cache/src/internal/cacheUtils.ts | 2 +- packages/cache/src/internal/downloadUtils.ts | 10 +- packages/cache/src/internal/requestUtils.ts | 4 +- .../src/internal/shared/cacheTwirpClient.ts | 12 +- .../src/internal/shared/package-version.cjs | 7 + .../cache/src/internal/shared/user-agent.ts | 5 +- packages/cache/src/internal/tar.ts | 6 +- packages/cache/src/internal/uploadUtils.ts | 4 +- packages/cache/tsconfig.json | 2 + 18 files changed, 192 insertions(+), 269 deletions(-) create mode 100644 packages/cache/src/internal/shared/package-version.cjs diff --git a/jest.config.js b/jest.config.js index c08948fe..df456142 100644 --- a/jest.config.js +++ b/jest.config.js @@ -16,7 +16,8 @@ module.exports = { '^@actions/github$': '/packages/github/lib/github.js', '^@actions/github/lib/utils$': '/packages/github/lib/utils.js', '^@actions/glob$': '/packages/glob/lib/glob.js', - '^@actions/tool-cache$': '/packages/tool-cache/lib/tool-cache.js' + '^@actions/tool-cache$': '/packages/tool-cache/lib/tool-cache.js', + '^@actions/cache$': '/packages/cache/lib/cache.js' }, transform: { '^.+\\.(ts|js)$': ['ts-jest', { @@ -30,7 +31,7 @@ module.exports = { }] }, transformIgnorePatterns: [ - '/node_modules/(?!(@octokit|@actions/github|@actions/http-client|@actions/io|@actions/exec|@actions/core|@actions/glob|@actions/tool-cache|universal-user-agent|before-after-hook)/)' + '/node_modules/(?!(@octokit|@actions/github|@actions/http-client|@actions/io|@actions/exec|@actions/core|@actions/glob|@actions/tool-cache|@actions/cache|universal-user-agent|before-after-hook)/)' ], verbose: true } diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index 514e1efb..9754695a 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -1,23 +1,28 @@ # @actions/cache Releases -### 5.0.5 +## 6.0.0 + +- **Breaking change**: Package is now ESM-only + - CommonJS consumers must use dynamic `import()` instead of `require()` + +## 5.0.5 - Bump `@actions/glob` to `0.5.1` -### 5.0.4 +## 5.0.4 - Bump `@actions/http-client` to `3.0.2` -### 5.0.3 +## 5.0.3 Prevent retries for rate limited cache operations [2243](https://github.com/actions/toolkit/pull/2243). -### 5.0.1 +## 5.0.1 - Fix Node.js 24 punycode deprecation warning by updating `@azure/storage-blob` from `^12.13.0` to `^12.29.1` [#2213](https://github.com/actions/toolkit/pull/2213) - Newer storage-blob uses `@azure/core-rest-pipeline` instead of deprecated `@azure/core-http`, which eliminates the transitive dependency on `node-fetch@2` → `whatwg-url@5` → `tr46@0.0.3` that used the deprecated punycode module -### 5.0.0 +## 5.0.0 - Remove `@azure/ms-rest-js` dependency [#2197](https://github.com/actions/toolkit/pull/2197) - The `TransferProgressEvent` type is now imported from `@azure/core-rest-pipeline` instead of `@azure/ms-rest-js` @@ -29,15 +34,15 @@ Prevent retries for rate limited cache operations [2243](https://github.com/acti - Add support for Node.js 24 [#2110](https://github.com/actions/toolkit/pull/2110) - Add `node-fetch` override to resolve audit vulnerabilities [#2110](https://github.com/actions/toolkit/pull/2110) -### 4.1.0 +## 4.1.0 - Remove client side 10GiB cache size limit check & update twirp client [#2118](https://github.com/actions/toolkit/pull/2118) -### 4.0.5 +## 4.0.5 - Reintroduce @protobuf-ts/runtime-rpc as a runtime dependency [#2113](https://github.com/actions/toolkit/pull/2113) -### 4.0.4 +## 4.0.4 ⚠️ Faulty patch release. Upgrade to 4.0.5 instead. @@ -46,23 +51,23 @@ Prevent retries for rate limited cache operations [2243](https://github.com/acti - Enhanced server error handling: 5xx HTTP errors are now logged as errors instead of warnings [#2099](https://github.com/actions/toolkit/pull/2099) - Fixed cache hit logging to properly distinguish between exact key matches and restore key matches [#2101](https://github.com/actions/toolkit/pull/2101) -### 4.0.3 +## 4.0.3 - Added masking for Shared Access Signature (SAS) cache entry URLs [#1982](https://github.com/actions/toolkit/pull/1982) - Improved debugging by logging both the cache version alongside the keys requested when a cache restore fails [#1994](https://github.com/actions/toolkit/pull/1994) -### 4.0.2 +## 4.0.2 - Wrap create failures in ReserveCacheError [#1966](https://github.com/actions/toolkit/pull/1966) -### 4.0.1 +## 4.0.1 - Remove runtime dependency on `twirp-ts` [#1947](https://github.com/actions/toolkit/pull/1947) - Cache miss as debug, not warning annotation [#1954](https://github.com/actions/toolkit/pull/1954) -### 4.0.0 +## 4.0.0 -#### Important changes +### Important changes The cache backend service has been rewritten from the ground up for improved performance and reliability. The [@actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) package now integrates with the new cache service (v2) APIs. @@ -76,182 +81,182 @@ Upgrading to the recommended version should not break or require any changes to Read more about the change & access the migration guide: [reference to the announcement](https://github.com/actions/toolkit/discussions/1890). -#### Minor changes +### Minor changes - Update `@actions/core` to `1.11.0` - Update `semver` `6.3.1` - Add `twirp-ts` `2.5.0` to dependencies -### 3.3.0 +## 3.3.0 - Update `@actions/core` to `1.11.1` - Remove dependency on `uuid` package [#1824](https://github.com/actions/toolkit/pull/1824), [#1842](https://github.com/actions/toolkit/pull/1842) -### 3.2.4 +## 3.2.4 - Updated `isGhes` check to include `.ghe.com` and `.ghe.localhost` as accepted hosts -### 3.2.3 +## 3.2.3 - Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378) -### 3.2.2 +## 3.2.2 - Add new default cache download method to improve performance and reduce hangs [#1484](https://github.com/actions/toolkit/pull/1484) -### 3.2.1 +## 3.2.1 - Updated @azure/storage-blob to `v12.13.0` -### 3.2.0 +## 3.2.0 - Add `lookupOnly` to cache restore `DownloadOptions`. -### 3.1.4 +## 3.1.4 - Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353). -### 3.1.3 +## 3.1.3 - Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329). -### 3.1.2 +## 3.1.2 - Fix issue with symlink restoration on windows. -### 3.1.1 +## 3.1.1 - Reverted changes in 3.1.0 to fix issue with symlink restoration on windows. - Added support for verbose logging about cache version during cache miss. -### 3.1.0 +## 3.1.0 - Update actions/cache on windows to use gnu tar and zstd by default - Update actions/cache on windows to fallback to bsdtar and zstd if gnu tar is not available. - Added support for fallback to gzip to restore old caches on windows. -### 3.1.0-beta.3 +## 3.1.0-beta.3 - Bug Fixes for fallback to gzip to restore old caches on windows and bsdtar if gnutar is not available. -### 3.1.0-beta.2 +## 3.1.0-beta.2 - Added support for fallback to gzip to restore old caches on windows. -### 3.0.6 +## 3.0.6 - Added `@azure/abort-controller` to dependencies to fix compatibility issue with ESM [#1208](https://github.com/actions/toolkit/issues/1208) -### 3.0.5 +## 3.0.5 - Update `@actions/cache` to use `@actions/core@^1.10.0` -### 3.0.4 +## 3.0.4 - Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891). - Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes. -### 3.0.3 +## 3.0.3 - Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). -### 3.0.2 +## 3.0.2 - Added 1 hour timeout for the download stuck issue [#810](https://github.com/actions/cache/issues/810). -### 3.0.1 +## 3.0.1 - Fix [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory. - Fix [#809](https://github.com/actions/cache/issues/809) `zstd -d: no such file or directory` error on AWS self-hosted runners. -### 3.0.0 +## 3.0.0 - Updated actions/cache to suppress Actions cache server error and log warning for those error [#1122](https://github.com/actions/toolkit/pull/1122) -### 2.0.6 +## 2.0.6 - Fix `Tar failed with error: The process '/usr/bin/tar' failed with exit code 1` issue when temp directory where tar is getting created is actually the subdirectory of the path mentioned by the user for caching. ([issue](https://github.com/actions/cache/issues/689)) -### 2.0.5 +## 2.0.5 - Fix to avoid saving empty cache when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624)) -### 2.0.4 +## 2.0.4 - Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087) -### 2.0.3 +## 2.0.3 - Update to v2.0.0 of `@actions/http-client` -### 2.0.0 +## 2.0.0 - Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028) -### 1.0.11 +## 1.0.11 - Fix file downloads > 2GB([issue](https://github.com/actions/cache/issues/773)) -### 1.0.10 +## 1.0.10 - Update `lockfileVersion` to `v2` in `package-lock.json [#1022](https://github.com/actions/toolkit/pull/1022) -### 1.0.9 +## 1.0.9 - Use @azure/ms-rest-js v2.6.0 - Use @azure/storage-blob v12.8.0 -### 1.0.8 +## 1.0.8 - Increase the allowed artifact cache size from 5GB to 10GB ([issue](https://github.com/actions/cache/discussions/497)) -### 1.0.7 +## 1.0.7 - Fixes permissions issue extracting archives with GNU tar on macOS ([issue](https://github.com/actions/cache/issues/527)) -### 1.0.6 +## 1.0.6 - Make caching more verbose [#650](https://github.com/actions/toolkit/pull/650) - Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701) -### 1.0.5 +## 1.0.5 - Fix to ensure Windows cache paths get resolved correctly -### 1.0.4 +## 1.0.4 - Use @actions/core v1.2.6 - Fixes uploadChunk to throw an error if any unsuccessful response code is received -### 1.0.3 +## 1.0.3 - Use http-client v1.0.9 - Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example) - Adds 5 second delay between retry attempts -### 1.0.2 +## 1.0.2 - Use posix archive format to add support for some tools -### 1.0.1 +## 1.0.1 - Fix bug in downloading large files (> 2 GBs) with the Azure SDK -### 1.0.0 +## 1.0.0 - Downloads Azure-hosted caches using the Azure SDK for speed and reliability - Displays download progress - Includes changes that break compatibility with earlier versions, including: - `retry`, `retryTypedResponse`, and `retryHttpClientResponse` moved from `cacheHttpClient` to `requestUtils` -### 0.2.1 +## 0.2.1 - Fix to await async function getCompressionMethod -### 0.2.0 +## 0.2.0 - Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469) -### 0.1.0 +## 0.1.0 - Initial release diff --git a/packages/cache/package-lock.json b/packages/cache/package-lock.json index bd286961..5fca2ada 100644 --- a/packages/cache/package-lock.json +++ b/packages/cache/package-lock.json @@ -1,96 +1,86 @@ { "name": "@actions/cache", - "version": "5.0.5", + "version": "6.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@actions/cache", - "version": "5.0.5", + "version": "6.0.0", "license": "MIT", "dependencies": { - "@actions/core": "^2.0.0", - "@actions/exec": "^2.0.0", - "@actions/glob": "^0.5.1", - "@actions/http-client": "^3.0.2", - "@actions/io": "^2.0.0", - "@azure/abort-controller": "^1.1.0", + "@actions/core": "^3.0.0", + "@actions/exec": "^3.0.0", + "@actions/glob": "^0.6.0", + "@actions/http-client": "^4.0.0", + "@actions/io": "^3.0.0", "@azure/core-rest-pipeline": "^1.22.0", - "@azure/storage-blob": "^12.29.1", + "@azure/storage-blob": "^12.30.0", "@protobuf-ts/runtime-rpc": "^2.11.1", - "semver": "^6.3.1" + "semver": "^7.7.3" }, "devDependencies": { "@protobuf-ts/plugin": "^2.9.4", - "@types/node": "^24.1.0", - "@types/semver": "^6.0.0", + "@types/node": "^25.1.0", + "@types/semver": "^7.7.1", "typescript": "^5.2.2" } }, "node_modules/@actions/core": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-2.0.3.tgz", - "integrity": "sha512-Od9Thc3T1mQJYddvVPM4QGiLUewdh+3txmDYHHxoNdkqysR1MbCT+rFOtNUxYAz+7+6RIsqipVahY2GJqGPyxA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-3.0.0.tgz", + "integrity": "sha512-zYt6cz+ivnTmiT/ksRVriMBOiuoUpDCJJlZ5KPl2/FRdvwU3f7MPh9qftvbkXJThragzUZieit2nyHUyw53Seg==", "license": "MIT", "dependencies": { - "@actions/exec": "^2.0.0", - "@actions/http-client": "^3.0.2" + "@actions/exec": "^3.0.0", + "@actions/http-client": "^4.0.0" } }, "node_modules/@actions/exec": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-2.0.0.tgz", - "integrity": "sha512-k8ngrX2voJ/RIN6r9xB82NVqKpnMRtxDoiO+g3olkIUpQNqjArXrCQceduQZCQj3P3xm32pChRLqRrtXTlqhIw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-3.0.0.tgz", + "integrity": "sha512-6xH/puSoNBXb72VPlZVm7vQ+svQpFyA96qdDBvhB8eNZOE8LtPf9L4oAsfzK/crCL8YZ+19fKYVnM63Sl+Xzlw==", "license": "MIT", "dependencies": { - "@actions/io": "^2.0.0" + "@actions/io": "^3.0.2" } }, "node_modules/@actions/glob": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.1.tgz", - "integrity": "sha512-+dv/t2aKQdKp9WWSp+1yIXVJzH5Q38M0Mta26pzIbeec14EcIleMB7UU6N7sNgbEuYfyuVGpE5pOKjl6j1WXkA==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.6.0.tgz", + "integrity": "sha512-FOVXkUFauyffi3QoODDphFeNRj+zdPPit827E0sBGyBxVYqwNhOChSyxZDRTHZTbZwYvPOire+6aJvHS6HSkuQ==", "license": "MIT", "dependencies": { - "@actions/core": "^2.0.3", + "@actions/core": "^3.0.0", "minimatch": "^3.0.4" } }, "node_modules/@actions/http-client": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-3.0.2.tgz", - "integrity": "sha512-JP38FYYpyqvUsz+Igqlc/JG6YO9PaKuvqjM3iGvaLqFnJ7TFmcLyy2IDrY0bI0qCQug8E9K+elv5ZNfw62ZJzA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-4.0.0.tgz", + "integrity": "sha512-QuwPsgVMsD6qaPD57GLZi9sqzAZCtiJT8kVBCDpLtxhL5MydQ4gS+DrejtZZPdIYyB1e95uCK9Luyds7ybHI3g==", "license": "MIT", "dependencies": { "tunnel": "^0.0.6", "undici": "^6.23.0" } }, - "node_modules/@actions/http-client/node_modules/undici": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz", - "integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==", - "license": "MIT", - "engines": { - "node": ">=18.17" - } - }, "node_modules/@actions/io": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-2.0.0.tgz", - "integrity": "sha512-Jv33IN09XLO+0HS79aaODsvIRyduiF7NY/F6LYeK5oeUmrsz7aFdRphQjFoESF4jS7lMauDOttKALcpapVDIAg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz", + "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==", "license": "MIT" }, "node_modules/@azure/abort-controller": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", - "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", "license": "MIT", "dependencies": { - "tslib": "^2.2.0" + "tslib": "^2.6.2" }, "engines": { - "node": ">=12.0.0" + "node": ">=18.0.0" } }, "node_modules/@azure/core-auth": { @@ -107,18 +97,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/core-auth/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-client": { "version": "1.10.1", "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.10.1.tgz", @@ -137,18 +115,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/core-client/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-http-compat": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.3.1.tgz", @@ -163,18 +129,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/core-http-compat/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-lro": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.7.2.tgz", @@ -190,18 +144,6 @@ "node": ">=18.0.0" } }, - "node_modules/@azure/core-lro/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-paging": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.6.2.tgz", @@ -232,18 +174,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/core-rest-pipeline/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-tracing": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.3.1.tgz", @@ -270,18 +200,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/core-util/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-xml": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@azure/core-xml/-/core-xml-1.5.0.tgz", @@ -309,9 +227,9 @@ } }, "node_modules/@azure/storage-blob": { - "version": "12.29.1", - "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.29.1.tgz", - "integrity": "sha512-7ktyY0rfTM0vo7HvtK6E3UvYnI9qfd6Oz6z/+92VhGRveWng3kJwMKeUpqmW/NmwcDNbxHpSlldG+vsUnRFnBg==", + "version": "12.30.0", + "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.30.0.tgz", + "integrity": "sha512-peDCR8blSqhsAKDbpSP/o55S4sheNwSrblvCaHUZ5xUI73XA7ieUGGwrONgD/Fng0EoDe1VOa3fAQ7+WGB3Ocg==", "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -325,7 +243,7 @@ "@azure/core-util": "^1.11.0", "@azure/core-xml": "^1.4.5", "@azure/logger": "^1.1.4", - "@azure/storage-common": "^12.1.1", + "@azure/storage-common": "^12.2.0", "events": "^3.0.0", "tslib": "^2.8.1" }, @@ -333,22 +251,10 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/storage-blob/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/storage-common": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@azure/storage-common/-/storage-common-12.1.1.tgz", - "integrity": "sha512-eIOH1pqFwI6UmVNnDQvmFeSg0XppuzDLFeUNO/Xht7ODAzRLgGDh7h550pSxoA+lPDxBl1+D2m/KG3jWzCUjTg==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@azure/storage-common/-/storage-common-12.2.0.tgz", + "integrity": "sha512-YZLxiJ3vBAAnFbG3TFuAMUlxZRexjQX5JDQxOkFGb6e2TpoxH3xyHI6idsMe/QrWtj41U/KoqBxlayzhS+LlwA==", "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -365,18 +271,6 @@ "node": ">=20.0.0" } }, - "node_modules/@azure/storage-common/node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@bufbuild/protobuf": { "version": "2.10.1", "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.10.1.tgz", @@ -469,9 +363,9 @@ } }, "node_modules/@types/node": { - "version": "24.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.2.tgz", - "integrity": "sha512-WOhQTZ4G8xZ1tjJTvKOpyEVSGgOTvJAfDK3FNFgELyaTpzhdgHVHeqW8V+UJvzF5BT+/B54T/1S2K6gd9c7bbA==", + "version": "25.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.1.0.tgz", + "integrity": "sha512-t7frlewr6+cbx+9Ohpl0NOTKXZNV9xHRmNOvql47BFJKcEG1CxtxlPEEe+gR9uhVWM4DwhnvTF110mIL4yP9RA==", "dev": true, "license": "MIT", "dependencies": { @@ -479,9 +373,9 @@ } }, "node_modules/@types/semver": { - "version": "6.2.7", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-6.2.7.tgz", - "integrity": "sha512-blctEWbzUFzQx799RZjzzIdBJOXmE37YYEyDtKkx5Dg+V7o/zyyAxLPiI98A2jdTtDgxZleMdfV+7p8WbRJ1OQ==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==", "dev": true, "license": "MIT" }, @@ -632,12 +526,15 @@ "license": "MIT" }, "node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", "license": "ISC", "bin": { "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/strnum": { @@ -681,6 +578,15 @@ "node": ">=14.17" } }, + "node_modules/undici": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz", + "integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", diff --git a/packages/cache/package.json b/packages/cache/package.json index b7fdcdcc..85bfda30 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -1,7 +1,6 @@ { "name": "@actions/cache", - "version": "5.0.5", - "preview": true, + "version": "6.0.0", "description": "Actions cache lib", "keywords": [ "github", @@ -10,8 +9,15 @@ ], "homepage": "https://github.com/actions/toolkit/tree/main/packages/cache", "license": "MIT", + "type": "module", "main": "lib/cache.js", "types": "lib/cache.d.ts", + "exports": { + ".": { + "types": "./lib/cache.d.ts", + "import": "./lib/cache.js" + } + }, "directories": { "lib": "lib", "test": "__tests__" @@ -31,31 +37,30 @@ "scripts": { "audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json", "test": "echo \"Error: run tests from root\" && exit 1", - "tsc": "tsc" + "tsc": "tsc && cp src/internal/shared/package-version.cjs lib/internal/shared/" }, "bugs": { "url": "https://github.com/actions/toolkit/issues" }, "dependencies": { - "@actions/core": "^2.0.0", - "@actions/exec": "^2.0.0", - "@actions/glob": "^0.5.1", - "@protobuf-ts/runtime-rpc": "^2.11.1", - "@actions/http-client": "^3.0.2", - "@actions/io": "^2.0.0", - "@azure/abort-controller": "^1.1.0", + "@actions/core": "^3.0.0", + "@actions/exec": "^3.0.0", + "@actions/glob": "^0.6.0", + "@actions/http-client": "^4.0.0", + "@actions/io": "^3.0.0", "@azure/core-rest-pipeline": "^1.22.0", - "@azure/storage-blob": "^12.29.1", - "semver": "^6.3.1" + "@azure/storage-blob": "^12.30.0", + "@protobuf-ts/runtime-rpc": "^2.11.1", + "semver": "^7.7.3" }, "devDependencies": { - "@types/node": "^24.1.0", - "@types/semver": "^6.0.0", "@protobuf-ts/plugin": "^2.9.4", + "@types/node": "^25.1.0", + "@types/semver": "^7.7.1", "typescript": "^5.2.2" }, "overrides": { "uri-js": "npm:uri-js-replace@^1.0.1", "node-fetch": "^3.3.2" } -} \ No newline at end of file +} diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index 1cc910f0..5fb86a3d 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -1,17 +1,17 @@ import * as core from '@actions/core' import * as path from 'path' -import * as utils from './internal/cacheUtils' -import * as cacheHttpClient from './internal/cacheHttpClient' -import * as cacheTwirpClient from './internal/shared/cacheTwirpClient' -import {getCacheServiceVersion, isGhes} from './internal/config' -import {DownloadOptions, UploadOptions} from './options' -import {createTar, extractTar, listTar} from './internal/tar' +import * as utils from './internal/cacheUtils.js' +import * as cacheHttpClient from './internal/cacheHttpClient.js' +import * as cacheTwirpClient from './internal/shared/cacheTwirpClient.js' +import {getCacheServiceVersion, isGhes} from './internal/config.js' +import {DownloadOptions, UploadOptions} from './options.js' +import {createTar, extractTar, listTar} from './internal/tar.js' import { CreateCacheEntryRequest, FinalizeCacheEntryUploadRequest, FinalizeCacheEntryUploadResponse, GetCacheEntryDownloadURLRequest -} from './generated/results/api/v1/cache' +} from './generated/results/api/v1/cache.js' import {HttpClientError} from '@actions/http-client' export class ValidationError extends Error { constructor(message: string) { diff --git a/packages/cache/src/generated/results/api/v1/cache.ts b/packages/cache/src/generated/results/api/v1/cache.ts index 309f7eec..3bbecfd3 100644 --- a/packages/cache/src/generated/results/api/v1/cache.ts +++ b/packages/cache/src/generated/results/api/v1/cache.ts @@ -12,7 +12,7 @@ import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; -import { CacheMetadata } from "../../entities/v1/cachemetadata"; +import { CacheMetadata } from "../../entities/v1/cachemetadata.js"; /** * @generated from protobuf message github.actions.results.api.v1.CreateCacheEntryRequest */ diff --git a/packages/cache/src/generated/results/api/v1/cache.twirp-client.ts b/packages/cache/src/generated/results/api/v1/cache.twirp-client.ts index 96659f84..d6c15d58 100644 --- a/packages/cache/src/generated/results/api/v1/cache.twirp-client.ts +++ b/packages/cache/src/generated/results/api/v1/cache.twirp-client.ts @@ -5,7 +5,7 @@ import { FinalizeCacheEntryUploadResponse, GetCacheEntryDownloadURLRequest, GetCacheEntryDownloadURLResponse, - } from "./cache"; + } from "./cache.js"; //==================================// // Client Code // diff --git a/packages/cache/src/generated/results/entities/v1/cachemetadata.ts b/packages/cache/src/generated/results/entities/v1/cachemetadata.ts index d7af1fe2..cee269ea 100644 --- a/packages/cache/src/generated/results/entities/v1/cachemetadata.ts +++ b/packages/cache/src/generated/results/entities/v1/cachemetadata.ts @@ -11,7 +11,7 @@ import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; -import { CacheScope } from "./cachescope"; +import { CacheScope } from "./cachescope.js"; /** * @generated from protobuf message github.actions.results.entities.v1.CacheMetadata */ diff --git a/packages/cache/src/internal/cacheHttpClient.ts b/packages/cache/src/internal/cacheHttpClient.ts index 2470555b..879d73f0 100644 --- a/packages/cache/src/internal/cacheHttpClient.ts +++ b/packages/cache/src/internal/cacheHttpClient.ts @@ -7,8 +7,8 @@ import { } from '@actions/http-client/lib/interfaces' import * as fs from 'fs' import {URL} from 'url' -import * as utils from './cacheUtils' -import {uploadCacheArchiveSDK} from './uploadUtils' +import * as utils from './cacheUtils.js' +import {uploadCacheArchiveSDK} from './uploadUtils.js' import { ArtifactCacheEntry, InternalCacheOptions, @@ -17,25 +17,25 @@ import { ReserveCacheResponse, ITypedResponseWithError, ArtifactCacheList -} from './contracts' +} from './contracts.js' import { downloadCacheHttpClient, downloadCacheHttpClientConcurrent, downloadCacheStorageSDK -} from './downloadUtils' +} from './downloadUtils.js' import { DownloadOptions, UploadOptions, getDownloadOptions, getUploadOptions -} from '../options' +} from '../options.js' import { isSuccessStatusCode, retryHttpClientResponse, retryTypedResponse -} from './requestUtils' -import {getCacheServiceURL} from './config' -import {getUserAgentString} from './shared/user-agent' +} from './requestUtils.js' +import {getCacheServiceURL} from './config.js' +import {getUserAgentString} from './shared/user-agent.js' function getCacheApiUrl(resource: string): string { const baseUrl: string = getCacheServiceURL() diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts index de9053ea..e19e320f 100644 --- a/packages/cache/src/internal/cacheUtils.ts +++ b/packages/cache/src/internal/cacheUtils.ts @@ -11,7 +11,7 @@ import { CacheFilename, CompressionMethod, GnuTarPathOnWindows -} from './constants' +} from './constants.js' const versionSalt = '1.0' diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index 3eda63b5..680505a8 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -7,12 +7,10 @@ import * as fs from 'fs' import * as stream from 'stream' import * as util from 'util' -import * as utils from './cacheUtils' -import {SocketTimeout} from './constants' -import {DownloadOptions} from '../options' -import {retryHttpClientResponse} from './requestUtils' - -import {AbortController} from '@azure/abort-controller' +import * as utils from './cacheUtils.js' +import {SocketTimeout} from './constants.js' +import {DownloadOptions} from '../options.js' +import {retryHttpClientResponse} from './requestUtils.js' /** * Pipes the body of a HTTP response to a stream diff --git a/packages/cache/src/internal/requestUtils.ts b/packages/cache/src/internal/requestUtils.ts index 043c8a7c..ec4b2d8a 100644 --- a/packages/cache/src/internal/requestUtils.ts +++ b/packages/cache/src/internal/requestUtils.ts @@ -4,8 +4,8 @@ import { HttpClientError, HttpClientResponse } from '@actions/http-client' -import {DefaultRetryDelay, DefaultRetryAttempts} from './constants' -import {ITypedResponseWithError} from './contracts' +import {DefaultRetryDelay, DefaultRetryAttempts} from './constants.js' +import {ITypedResponseWithError} from './contracts.js' export function isSuccessStatusCode(statusCode?: number): boolean { if (!statusCode) { diff --git a/packages/cache/src/internal/shared/cacheTwirpClient.ts b/packages/cache/src/internal/shared/cacheTwirpClient.ts index a6e2d0ad..0a650deb 100644 --- a/packages/cache/src/internal/shared/cacheTwirpClient.ts +++ b/packages/cache/src/internal/shared/cacheTwirpClient.ts @@ -1,12 +1,12 @@ import {info, debug, warning} from '@actions/core' -import {getUserAgentString} from './user-agent' -import {NetworkError, RateLimitError, UsageError} from './errors' -import {getCacheServiceURL} from '../config' -import {getRuntimeToken} from '../cacheUtils' +import {getUserAgentString} from './user-agent.js' +import {NetworkError, RateLimitError, UsageError} from './errors.js' +import {getCacheServiceURL} from '../config.js' +import {getRuntimeToken} from '../cacheUtils.js' import {BearerCredentialHandler} from '@actions/http-client/lib/auth' import {HttpClient, HttpClientResponse, HttpCodes} from '@actions/http-client' -import {CacheServiceClientJSON} from '../../generated/results/api/v1/cache.twirp-client' -import {maskSecretUrls} from './util' +import {CacheServiceClientJSON} from '../../generated/results/api/v1/cache.twirp-client.js' +import {maskSecretUrls} from './util.js' // The twirp http client must implement this interface interface Rpc { diff --git a/packages/cache/src/internal/shared/package-version.cjs b/packages/cache/src/internal/shared/package-version.cjs new file mode 100644 index 00000000..bd43fc1b --- /dev/null +++ b/packages/cache/src/internal/shared/package-version.cjs @@ -0,0 +1,7 @@ +// This file exists as a CommonJS module to read the version from package.json. +// In an ESM package, using `require()` directly in .ts files requires disabling +// ESLint rules and doesn't work reliably across all Node.js versions. +// By keeping this as a .cjs file, we can use require() naturally and export +// the version for the ESM modules to import. +const packageJson = require('../../../package.json') +module.exports = { version: packageJson.version } diff --git a/packages/cache/src/internal/shared/user-agent.ts b/packages/cache/src/internal/shared/user-agent.ts index 9d88a659..a51962c5 100644 --- a/packages/cache/src/internal/shared/user-agent.ts +++ b/packages/cache/src/internal/shared/user-agent.ts @@ -1,9 +1,8 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -const packageJson = require('../../../package.json') +import {version} from './package-version.cjs' /** * Ensure that this User Agent String is used in all HTTP calls so that we can monitor telemetry between different versions of this package */ export function getUserAgentString(): string { - return `@actions/cache-${packageJson.version}` + return `@actions/cache-${version}` } diff --git a/packages/cache/src/internal/tar.ts b/packages/cache/src/internal/tar.ts index adf61069..73c126c7 100644 --- a/packages/cache/src/internal/tar.ts +++ b/packages/cache/src/internal/tar.ts @@ -2,15 +2,15 @@ import {exec} from '@actions/exec' import * as io from '@actions/io' import {existsSync, writeFileSync} from 'fs' import * as path from 'path' -import * as utils from './cacheUtils' -import {ArchiveTool} from './contracts' +import * as utils from './cacheUtils.js' +import {ArchiveTool} from './contracts.js' import { CompressionMethod, SystemTarPathOnWindows, ArchiveToolType, TarFilename, ManifestFilename -} from './constants' +} from './constants.js' const IS_WINDOWS = process.platform === 'win32' diff --git a/packages/cache/src/internal/uploadUtils.ts b/packages/cache/src/internal/uploadUtils.ts index a0e4961d..3ee744b5 100644 --- a/packages/cache/src/internal/uploadUtils.ts +++ b/packages/cache/src/internal/uploadUtils.ts @@ -6,8 +6,8 @@ import { BlockBlobParallelUploadOptions } from '@azure/storage-blob' import {TransferProgressEvent} from '@azure/core-rest-pipeline' -import {InvalidResponseError} from './shared/errors' -import {UploadOptions} from '../options' +import {InvalidResponseError} from './shared/errors.js' +import {UploadOptions} from '../options.js' /** * Class for tracking the upload state and displaying stats. diff --git a/packages/cache/tsconfig.json b/packages/cache/tsconfig.json index f4a0548a..9d5e16d5 100644 --- a/packages/cache/tsconfig.json +++ b/packages/cache/tsconfig.json @@ -4,6 +4,8 @@ "baseUrl": "./", "outDir": "./lib", "rootDir": "./src", + "module": "node16", + "moduleResolution": "node16", "lib": [ "es6", "dom"