nx-remotecache-custom
Version:
Build custom caching for @nrwl/nx in a few lines of code
26 lines (25 loc) • 2.24 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.cacheCreated = exports.checkFailure = exports.storeFailure = exports.storeSuccess = exports.setupFailure = exports.retrieveFailure = exports.retrieveSuccess = void 0;
const chalk_1 = require("chalk");
const DELIMITER_LENGTH = 78;
const DELIMITER = Array.from({ length: DELIMITER_LENGTH }, () => "-").join("");
const log = console.log;
const formatSection = (...content) => (0, chalk_1.grey)([DELIMITER, ...content, DELIMITER].join("\n"));
const retrieveSuccess = ({ name }, file) => log(formatSection(`Remote cache hit: ${(0, chalk_1.green)(name)}`, `File: ${file}`));
exports.retrieveSuccess = retrieveSuccess;
const retrieveFailure = ({ name }, file, error) => log(formatSection(`${(0, chalk_1.yellow)(`Warning`)}: Failed to retrieve cache from ${(0, chalk_1.red)(name)}`, `File: ${file}`, `Error: ${error === null || error === void 0 ? void 0 : error.message}`));
exports.retrieveFailure = retrieveFailure;
const setupFailure = (error) => {
var _a;
return log(formatSection(`${(0, chalk_1.yellow)(`Warning`)}: Failed to setup remote cache. Check your nx.json.`, `Error: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`));
};
exports.setupFailure = setupFailure;
const storeSuccess = ({ name }, file) => log(formatSection(`Stored output to remote cache: ${(0, chalk_1.green)(name)}`, `File: ${file}`));
exports.storeSuccess = storeSuccess;
const storeFailure = ({ name }, file, error) => log(formatSection(`${(0, chalk_1.yellow)(`Warning`)}: Failed to store cache to ${(0, chalk_1.red)(name)}`, `File: ${file}`, `Error: ${error === null || error === void 0 ? void 0 : error.message}`));
exports.storeFailure = storeFailure;
const checkFailure = ({ name }, file, error) => log(formatSection(`${(0, chalk_1.yellow)(`Warning`)}: Failed to check if cache file exists in ${(0, chalk_1.red)(name)}`, `File: ${file}`, `Error: ${error === null || error === void 0 ? void 0 : error.message}`));
exports.checkFailure = checkFailure;
const cacheCreated = ({ read, write, }) => log((0, chalk_1.grey)(`Remote cache created. Read: ${read}. Write: ${write}.`));
exports.cacheCreated = cacheCreated;
;