* Remove mongo coll dataset * JSEXe spec flaky trial fix * AbortActions to ts * js func exe fix * Abort spec fix * Appsmith down flaky fix * SelectWidget bug 12531 comment * JSfun exec spec flaky fix * Scrolling spec fix * mysql crud fix * mySql crud fix * CRUD generate page fix * jsonload flaky fix * Automcomplete spec update * jsOnload-1 spec flaky fix * http patch * patch install * patch path correction * cypress instal force * removed * yarn * adding dev * applypatch path corrected * patch fix * patch update * patches * patch file name update * Adding blureprint patch back * Cypress install removed * Removed .only * Autocomplete + Abort spec fix * CI run key press fix * https proxy update path fix * JS editor parsing delay handle * Autocmplete js fix * Abort Query added * Removed "dev": "cypress open" * js func exec spec fix * js editor type flaky fix * GetNClick revert * Saving JS editor aft removal * JS specs flaky fixes * JSfun flaky fix * Auto complete spec fi * jSonkoad1 spec fix * JSOnload spec * Auto complete JS spec fix * Removing waiting for toasts * jsfun fix * EditJSObj Preetify update * contains index or colection * SetQueryTimeout update * DS toasts handle * POstgresCRUD toast change * POstgres CRUD toasts fix * Bug 15372 spec toast fix + Api timeout update * Added DeleteDSDirectly() * Arango spec fix * JSEditor indent spec - 6 fix * JSeditor indent spec update 7, 1,2 * removed only * JSEDitor Indent spec fixes * removed only * MySQK CRUD fixes * BUg 14006 spec fix * Mongo spec toast fix * Mongo update * text wrapping spec flaky fix
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
const { getVersionDir } = require("cypress/lib/tasks/state");
|
|
const chalk = require("chalk");
|
|
const Diff = require("diff");
|
|
const fs = require("fs/promises");
|
|
const path = require("path");
|
|
|
|
async function applyPatches() {
|
|
const patchesDir = path.join("cypress", "patches");
|
|
const patchesAbsDir = path.join(process.cwd(), patchesDir);
|
|
const patches = await fs.readdir(patchesAbsDir);
|
|
const installDir = getVersionDir();
|
|
|
|
console.log(`\n> Applying patches on to ${chalk.cyan(installDir)}\n`);
|
|
|
|
for (const filename of patches) {
|
|
if (!filename.endsWith(".patch")) {
|
|
continue;
|
|
}
|
|
const fullpath = path.join(patchesAbsDir, filename);
|
|
const enc = "utf8";
|
|
const patch = await fs.readFile(fullpath, enc);
|
|
const relativeFilename = path.join(patchesDir, filename);
|
|
console.log(`>> Applying patch ${chalk.cyan(relativeFilename)}`);
|
|
await Diff.applyPatches(patch, {
|
|
loadFile: (index, callback) => {
|
|
console.debug(`>>> Loading old file: ${chalk.red(index.oldFileName)}`);
|
|
fs.readFile(path.join(installDir, index.oldFileName), enc)
|
|
.then((contents) => {
|
|
callback(null, contents);
|
|
})
|
|
.catch(callback);
|
|
},
|
|
patched: (index, content, callback) => {
|
|
console.debug(
|
|
`>>> Patched new file: ${chalk.green(index.newFileName)}`,
|
|
);
|
|
fs.writeFile(path.join(installDir, index.newFileName), content, enc)
|
|
.then(callback)
|
|
.catch(callback);
|
|
},
|
|
complete: () => {
|
|
console.log(
|
|
`>> Successfully applied patch ${chalk.cyan(relativeFilename)}`,
|
|
);
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
applyPatches().catch((e) => {
|
|
console.error(e);
|
|
process.exit(42);
|
|
});
|