@rharkor/caching-for-turbo 2.3.3 → 2.3.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.
- package/dist/cli/index.js +36 -36
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -203815,10 +203815,24 @@ function parse(str = '', format = 'ms') {
|
|
|
203815
203815
|
return result && ((result / (parse.unit[format] || 1)) * (str[0] === '-' ? -1 : 1))
|
|
203816
203816
|
}
|
|
203817
203817
|
|
|
203818
|
-
;// CONCATENATED MODULE: external "node:stream/promises"
|
|
203819
|
-
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
|
203820
203818
|
// EXTERNAL MODULE: external "node:fs"
|
|
203821
203819
|
var external_node_fs_ = __nccwpck_require__(73024);
|
|
203820
|
+
;// CONCATENATED MODULE: external "node:stream/promises"
|
|
203821
|
+
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
|
|
203822
|
+
;// CONCATENATED MODULE: ./src/lib/utils.ts
|
|
203823
|
+
const timingProvider = (name, tracker, fn) => {
|
|
203824
|
+
return async (...args) => {
|
|
203825
|
+
const start = performance.now();
|
|
203826
|
+
const result = await fn(...args);
|
|
203827
|
+
const end = performance.now();
|
|
203828
|
+
if (process.env.LOG_LEVEL === 'debug') {
|
|
203829
|
+
console.log(`${name} took ${end - start}ms`);
|
|
203830
|
+
}
|
|
203831
|
+
tracker[name] += end - start;
|
|
203832
|
+
return result;
|
|
203833
|
+
};
|
|
203834
|
+
};
|
|
203835
|
+
|
|
203822
203836
|
// EXTERNAL MODULE: ./node_modules/stream-to-promise/index.js
|
|
203823
203837
|
var stream_to_promise = __nccwpck_require__(42050);
|
|
203824
203838
|
var stream_to_promise_default = /*#__PURE__*/__nccwpck_require__.n(stream_to_promise);
|
|
@@ -203887,20 +203901,6 @@ function getCacheClient() {
|
|
|
203887
203901
|
};
|
|
203888
203902
|
}
|
|
203889
203903
|
|
|
203890
|
-
;// CONCATENATED MODULE: ./src/lib/utils.ts
|
|
203891
|
-
const timingProvider = (name, tracker, fn) => {
|
|
203892
|
-
return async (...args) => {
|
|
203893
|
-
const start = performance.now();
|
|
203894
|
-
const result = await fn(...args);
|
|
203895
|
-
const end = performance.now();
|
|
203896
|
-
if (process.env.LOG_LEVEL === 'debug') {
|
|
203897
|
-
console.log(`${name} took ${end - start}ms`);
|
|
203898
|
-
}
|
|
203899
|
-
tracker[name] += end - start;
|
|
203900
|
-
return result;
|
|
203901
|
-
};
|
|
203902
|
-
};
|
|
203903
|
-
|
|
203904
203904
|
;// CONCATENATED MODULE: ./src/lib/providers/cache/index.ts
|
|
203905
203905
|
|
|
203906
203906
|
|
|
@@ -204287,29 +204287,29 @@ const parseFileSize = (size) => {
|
|
|
204287
204287
|
|
|
204288
204288
|
|
|
204289
204289
|
async function cleanup(ctx, tracker) {
|
|
204290
|
-
const maxAge = core_core.getInput(
|
|
204291
|
-
const maxFiles = core_core.getInput(
|
|
204292
|
-
const maxSize = core_core.getInput(
|
|
204290
|
+
const maxAge = core_core.getInput('max-age') || process.env.MAX_AGE;
|
|
204291
|
+
const maxFiles = core_core.getInput('max-files') || process.env.MAX_FILES;
|
|
204292
|
+
const maxSize = core_core.getInput('max-size') || process.env.MAX_SIZE;
|
|
204293
204293
|
if (!maxAge && !maxFiles && !maxSize) {
|
|
204294
|
-
ctx.log.info(
|
|
204294
|
+
ctx.log.info('No cleanup options provided, skipping cleanup');
|
|
204295
204295
|
return;
|
|
204296
204296
|
}
|
|
204297
204297
|
const { maxAgeParsed, maxFilesParsed, maxSizeParsed } = {
|
|
204298
204298
|
maxAgeParsed: maxAge ? parse(maxAge) : undefined,
|
|
204299
204299
|
maxFilesParsed: maxFiles ? parseInt(maxFiles) : undefined,
|
|
204300
|
-
maxSizeParsed: maxSize ? parseFileSize(maxSize) : undefined
|
|
204300
|
+
maxSizeParsed: maxSize ? parseFileSize(maxSize) : undefined
|
|
204301
204301
|
};
|
|
204302
204302
|
if (maxAge && !maxAgeParsed) {
|
|
204303
|
-
core_core.error(
|
|
204304
|
-
throw new Error(
|
|
204303
|
+
core_core.error('Invalid max-age provided');
|
|
204304
|
+
throw new Error('Invalid max-age provided');
|
|
204305
204305
|
}
|
|
204306
204306
|
if (maxFiles && !maxFilesParsed) {
|
|
204307
|
-
core_core.error(
|
|
204308
|
-
throw new Error(
|
|
204307
|
+
core_core.error('Invalid max-files provided');
|
|
204308
|
+
throw new Error('Invalid max-files provided');
|
|
204309
204309
|
}
|
|
204310
204310
|
if (maxSize && !maxSizeParsed) {
|
|
204311
|
-
core_core.error(
|
|
204312
|
-
throw new Error(
|
|
204311
|
+
core_core.error('Invalid max-size provided');
|
|
204312
|
+
throw new Error('Invalid max-size provided');
|
|
204313
204313
|
}
|
|
204314
204314
|
const provider = getProvider(tracker);
|
|
204315
204315
|
let files = [];
|
|
@@ -204327,15 +204327,15 @@ Exiting early, no files were cleaned up.`;
|
|
|
204327
204327
|
const now = new Date();
|
|
204328
204328
|
const age = new Date(now.getTime() - maxAgeParsed);
|
|
204329
204329
|
fileToDelete.push(...files
|
|
204330
|
-
.filter(
|
|
204331
|
-
.map(
|
|
204330
|
+
.filter(file => new Date(file.createdAt) < age)
|
|
204331
|
+
.map(file => ({ ...file, reason: 'max-age' })));
|
|
204332
204332
|
}
|
|
204333
204333
|
if (maxFilesParsed && files.length > maxFilesParsed) {
|
|
204334
204334
|
const sortedByDate = [...files].sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
204335
204335
|
const excessFiles = sortedByDate.slice(0, files.length - maxFilesParsed);
|
|
204336
|
-
excessFiles.forEach(
|
|
204337
|
-
if (!fileToDelete.some(
|
|
204338
|
-
fileToDelete.push({ ...file, reason:
|
|
204336
|
+
excessFiles.forEach(file => {
|
|
204337
|
+
if (!fileToDelete.some(f => f.path === file.path)) {
|
|
204338
|
+
fileToDelete.push({ ...file, reason: 'max-files' });
|
|
204339
204339
|
}
|
|
204340
204340
|
});
|
|
204341
204341
|
}
|
|
@@ -204346,15 +204346,15 @@ Exiting early, no files were cleaned up.`;
|
|
|
204346
204346
|
for (const file of sortedByDate) {
|
|
204347
204347
|
if (totalSize <= maxSizeParsed)
|
|
204348
204348
|
break;
|
|
204349
|
-
if (!fileToDelete.some(
|
|
204350
|
-
fileToDelete.push({ ...file, reason:
|
|
204349
|
+
if (!fileToDelete.some(f => f.path === file.path)) {
|
|
204350
|
+
fileToDelete.push({ ...file, reason: 'max-size' });
|
|
204351
204351
|
totalSize -= file.size;
|
|
204352
204352
|
}
|
|
204353
204353
|
}
|
|
204354
204354
|
}
|
|
204355
204355
|
}
|
|
204356
204356
|
if (fileToDelete.length > 0) {
|
|
204357
|
-
ctx.log.info(`Cleaning up ${fileToDelete.length} files (${fileToDelete.map(
|
|
204357
|
+
ctx.log.info(`Cleaning up ${fileToDelete.length} files (${fileToDelete.map(f => `${f.path} (${f.reason})`)})`);
|
|
204358
204358
|
for (const file of fileToDelete) {
|
|
204359
204359
|
try {
|
|
204360
204360
|
await provider.delete(file.path);
|
|
@@ -204366,7 +204366,7 @@ Exiting early, no files were cleaned up.`;
|
|
|
204366
204366
|
}
|
|
204367
204367
|
}
|
|
204368
204368
|
else {
|
|
204369
|
-
ctx.log.info(
|
|
204369
|
+
ctx.log.info('No files to clean up');
|
|
204370
204370
|
}
|
|
204371
204371
|
}
|
|
204372
204372
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rharkor/caching-for-turbo",
|
|
3
3
|
"description": "Sets up Turborepo Remote Caching to work with GitHub Actions built-in cache",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/rharkor/caching-for-turbo",
|
|
7
7
|
"repository": {
|