mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 15:48:39 +08:00 
			
		
		
		
	v0.11.0
This commit is contained in:
		
							parent
							
								
									0b4a0a4930
								
							
						
					
					
						commit
						7b3fb19462
					
				
							
								
								
									
										16
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -2349,7 +2349,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
					Object.defineProperty(exports, "__esModule", { value: true });
 | 
				
			||||||
exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
					exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.formatKey = exports.isGhes = void 0;
 | 
				
			||||||
const core = __importStar(__webpack_require__(6470));
 | 
					const core = __importStar(__webpack_require__(6470));
 | 
				
			||||||
const constants_1 = __webpack_require__(1211);
 | 
					const constants_1 = __webpack_require__(1211);
 | 
				
			||||||
function isGhes() {
 | 
					function isGhes() {
 | 
				
			||||||
| 
						 | 
					@ -2357,9 +2357,13 @@ function isGhes() {
 | 
				
			||||||
    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
					    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.isGhes = isGhes;
 | 
					exports.isGhes = isGhes;
 | 
				
			||||||
 | 
					function formatKey(key) {
 | 
				
			||||||
 | 
					    return key.replace(/[^\w\s]/gi, "-");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.formatKey = formatKey;
 | 
				
			||||||
function isExactKeyMatch(key, cacheKey) {
 | 
					function isExactKeyMatch(key, cacheKey) {
 | 
				
			||||||
    return !!(cacheKey &&
 | 
					    return !!(cacheKey &&
 | 
				
			||||||
        cacheKey.localeCompare(key, undefined, {
 | 
					        formatKey(cacheKey).localeCompare(formatKey(key), undefined, {
 | 
				
			||||||
            sensitivity: "accent"
 | 
					            sensitivity: "accent"
 | 
				
			||||||
        }) === 0);
 | 
					        }) === 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -43281,6 +43285,7 @@ const aws_sdk_1 = __webpack_require__(9350);
 | 
				
			||||||
const filesize_1 = __importDefault(__webpack_require__(7283));
 | 
					const filesize_1 = __importDefault(__webpack_require__(7283));
 | 
				
			||||||
const fs_1 = __importDefault(__webpack_require__(5747));
 | 
					const fs_1 = __importDefault(__webpack_require__(5747));
 | 
				
			||||||
const path = __importStar(__webpack_require__(5622));
 | 
					const path = __importStar(__webpack_require__(5622));
 | 
				
			||||||
 | 
					const actionUtils_1 = __webpack_require__(443);
 | 
				
			||||||
class CacheService {
 | 
					class CacheService {
 | 
				
			||||||
    constructor(accessKeyId, secretAccessKey, region, bucket) {
 | 
					    constructor(accessKeyId, secretAccessKey, region, bucket) {
 | 
				
			||||||
        this._client = new aws_sdk_1.S3({
 | 
					        this._client = new aws_sdk_1.S3({
 | 
				
			||||||
| 
						 | 
					@ -43295,7 +43300,7 @@ class CacheService {
 | 
				
			||||||
    restoreCache(paths, primaryKey, restoreKeys) {
 | 
					    restoreCache(paths, primaryKey, restoreKeys) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            restoreKeys = restoreKeys || [];
 | 
					            restoreKeys = restoreKeys || [];
 | 
				
			||||||
            const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
 | 
					            const keys = [primaryKey, ...restoreKeys].map(x => actionUtils_1.formatKey(x));
 | 
				
			||||||
            core.debug("Resolved Keys:");
 | 
					            core.debug("Resolved Keys:");
 | 
				
			||||||
            core.debug(JSON.stringify(keys));
 | 
					            core.debug(JSON.stringify(keys));
 | 
				
			||||||
            const compressionMethod = yield utils.getCompressionMethod();
 | 
					            const compressionMethod = yield utils.getCompressionMethod();
 | 
				
			||||||
| 
						 | 
					@ -43331,7 +43336,7 @@ class CacheService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    saveCache(paths, key) {
 | 
					    saveCache(paths, key) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            const formattedKey = this.formatKey(key);
 | 
					            const formattedKey = actionUtils_1.formatKey(key);
 | 
				
			||||||
            const compressionMethod = yield utils.getCompressionMethod();
 | 
					            const compressionMethod = yield utils.getCompressionMethod();
 | 
				
			||||||
            const cachePaths = yield utils.resolvePaths(paths);
 | 
					            const cachePaths = yield utils.resolvePaths(paths);
 | 
				
			||||||
            core.debug("Cache Paths:");
 | 
					            core.debug("Cache Paths:");
 | 
				
			||||||
| 
						 | 
					@ -43452,9 +43457,6 @@ class CacheService {
 | 
				
			||||||
            .replace("/", "-")
 | 
					            .replace("/", "-")
 | 
				
			||||||
            .toLowerCase();
 | 
					            .toLowerCase();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    formatKey(key) {
 | 
					 | 
				
			||||||
        return key.replace(/[^\w\s]/gi, "-");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.CacheService = CacheService;
 | 
					exports.CacheService = CacheService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -2349,7 +2349,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
					Object.defineProperty(exports, "__esModule", { value: true });
 | 
				
			||||||
exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
 | 
					exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.formatKey = exports.isGhes = void 0;
 | 
				
			||||||
const core = __importStar(__webpack_require__(6470));
 | 
					const core = __importStar(__webpack_require__(6470));
 | 
				
			||||||
const constants_1 = __webpack_require__(1211);
 | 
					const constants_1 = __webpack_require__(1211);
 | 
				
			||||||
function isGhes() {
 | 
					function isGhes() {
 | 
				
			||||||
| 
						 | 
					@ -2357,9 +2357,13 @@ function isGhes() {
 | 
				
			||||||
    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
					    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.isGhes = isGhes;
 | 
					exports.isGhes = isGhes;
 | 
				
			||||||
 | 
					function formatKey(key) {
 | 
				
			||||||
 | 
					    return key.replace(/[^\w\s]/gi, "-");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.formatKey = formatKey;
 | 
				
			||||||
function isExactKeyMatch(key, cacheKey) {
 | 
					function isExactKeyMatch(key, cacheKey) {
 | 
				
			||||||
    return !!(cacheKey &&
 | 
					    return !!(cacheKey &&
 | 
				
			||||||
        cacheKey.localeCompare(key, undefined, {
 | 
					        formatKey(cacheKey).localeCompare(formatKey(key), undefined, {
 | 
				
			||||||
            sensitivity: "accent"
 | 
					            sensitivity: "accent"
 | 
				
			||||||
        }) === 0);
 | 
					        }) === 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -43281,6 +43285,7 @@ const aws_sdk_1 = __webpack_require__(9350);
 | 
				
			||||||
const filesize_1 = __importDefault(__webpack_require__(7283));
 | 
					const filesize_1 = __importDefault(__webpack_require__(7283));
 | 
				
			||||||
const fs_1 = __importDefault(__webpack_require__(5747));
 | 
					const fs_1 = __importDefault(__webpack_require__(5747));
 | 
				
			||||||
const path = __importStar(__webpack_require__(5622));
 | 
					const path = __importStar(__webpack_require__(5622));
 | 
				
			||||||
 | 
					const actionUtils_1 = __webpack_require__(443);
 | 
				
			||||||
class CacheService {
 | 
					class CacheService {
 | 
				
			||||||
    constructor(accessKeyId, secretAccessKey, region, bucket) {
 | 
					    constructor(accessKeyId, secretAccessKey, region, bucket) {
 | 
				
			||||||
        this._client = new aws_sdk_1.S3({
 | 
					        this._client = new aws_sdk_1.S3({
 | 
				
			||||||
| 
						 | 
					@ -43295,7 +43300,7 @@ class CacheService {
 | 
				
			||||||
    restoreCache(paths, primaryKey, restoreKeys) {
 | 
					    restoreCache(paths, primaryKey, restoreKeys) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            restoreKeys = restoreKeys || [];
 | 
					            restoreKeys = restoreKeys || [];
 | 
				
			||||||
            const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
 | 
					            const keys = [primaryKey, ...restoreKeys].map(x => actionUtils_1.formatKey(x));
 | 
				
			||||||
            core.debug("Resolved Keys:");
 | 
					            core.debug("Resolved Keys:");
 | 
				
			||||||
            core.debug(JSON.stringify(keys));
 | 
					            core.debug(JSON.stringify(keys));
 | 
				
			||||||
            const compressionMethod = yield utils.getCompressionMethod();
 | 
					            const compressionMethod = yield utils.getCompressionMethod();
 | 
				
			||||||
| 
						 | 
					@ -43331,7 +43336,7 @@ class CacheService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    saveCache(paths, key) {
 | 
					    saveCache(paths, key) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            const formattedKey = this.formatKey(key);
 | 
					            const formattedKey = actionUtils_1.formatKey(key);
 | 
				
			||||||
            const compressionMethod = yield utils.getCompressionMethod();
 | 
					            const compressionMethod = yield utils.getCompressionMethod();
 | 
				
			||||||
            const cachePaths = yield utils.resolvePaths(paths);
 | 
					            const cachePaths = yield utils.resolvePaths(paths);
 | 
				
			||||||
            core.debug("Cache Paths:");
 | 
					            core.debug("Cache Paths:");
 | 
				
			||||||
| 
						 | 
					@ -43452,9 +43457,6 @@ class CacheService {
 | 
				
			||||||
            .replace("/", "-")
 | 
					            .replace("/", "-")
 | 
				
			||||||
            .toLowerCase();
 | 
					            .toLowerCase();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    formatKey(key) {
 | 
					 | 
				
			||||||
        return key.replace(/[^\w\s]/gi, "-");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.CacheService = CacheService;
 | 
					exports.CacheService = CacheService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "cache",
 | 
					  "name": "cache",
 | 
				
			||||||
  "version": "0.10.0",
 | 
					  "version": "0.11.0",
 | 
				
			||||||
  "private": true,
 | 
					  "private": true,
 | 
				
			||||||
  "description": "Cache dependencies and build outputs",
 | 
					  "description": "Cache dependencies and build outputs",
 | 
				
			||||||
  "main": "dist/restore/index.js",
 | 
					  "main": "dist/restore/index.js",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,8 @@ import filesize from "filesize";
 | 
				
			||||||
import fs from "fs";
 | 
					import fs from "fs";
 | 
				
			||||||
import * as path from "path";
 | 
					import * as path from "path";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { formatKey } from "./utils/actionUtils";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class CacheService {
 | 
					export class CacheService {
 | 
				
			||||||
    private _client: S3;
 | 
					    private _client: S3;
 | 
				
			||||||
    private _bucket: string;
 | 
					    private _bucket: string;
 | 
				
			||||||
| 
						 | 
					@ -38,7 +40,7 @@ export class CacheService {
 | 
				
			||||||
        restoreKeys: string[]
 | 
					        restoreKeys: string[]
 | 
				
			||||||
    ): Promise<string | undefined> {
 | 
					    ): Promise<string | undefined> {
 | 
				
			||||||
        restoreKeys = restoreKeys || [];
 | 
					        restoreKeys = restoreKeys || [];
 | 
				
			||||||
        const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
 | 
					        const keys = [primaryKey, ...restoreKeys].map(x => formatKey(x));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        core.debug("Resolved Keys:");
 | 
					        core.debug("Resolved Keys:");
 | 
				
			||||||
        core.debug(JSON.stringify(keys));
 | 
					        core.debug(JSON.stringify(keys));
 | 
				
			||||||
| 
						 | 
					@ -85,7 +87,7 @@ export class CacheService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async saveCache(paths: string[], key: string): Promise<string> {
 | 
					    async saveCache(paths: string[], key: string): Promise<string> {
 | 
				
			||||||
        const formattedKey: string = this.formatKey(key);
 | 
					        const formattedKey: string = formatKey(key);
 | 
				
			||||||
        const compressionMethod = await utils.getCompressionMethod();
 | 
					        const compressionMethod = await utils.getCompressionMethod();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const cachePaths = await utils.resolvePaths(paths);
 | 
					        const cachePaths = await utils.resolvePaths(paths);
 | 
				
			||||||
| 
						 | 
					@ -219,8 +221,4 @@ export class CacheService {
 | 
				
			||||||
            .replace("/", "-")
 | 
					            .replace("/", "-")
 | 
				
			||||||
            .toLowerCase();
 | 
					            .toLowerCase();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private formatKey(key: string): string {
 | 
					 | 
				
			||||||
        return key.replace(/[^\w\s]/gi, "-");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,10 +9,14 @@ export function isGhes(): boolean {
 | 
				
			||||||
    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
					    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function formatKey(key: string): string {
 | 
				
			||||||
 | 
					    return key.replace(/[^\w\s]/gi, "-");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
 | 
					export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
 | 
				
			||||||
    return !!(
 | 
					    return !!(
 | 
				
			||||||
        cacheKey &&
 | 
					        cacheKey &&
 | 
				
			||||||
        cacheKey.localeCompare(key, undefined, {
 | 
					        formatKey(cacheKey).localeCompare(formatKey(key), undefined, {
 | 
				
			||||||
            sensitivity: "accent"
 | 
					            sensitivity: "accent"
 | 
				
			||||||
        }) === 0
 | 
					        }) === 0
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user