import * as fs from "fs-extra-plus"; import { homedir } from "os"; import { join } from "path"; /** 可以将wallaby.js升级到最新的版本 然后在运行一次这个 ctrl+shift+= force update */ //1.先激活 后运行这个脚本 async function main() { let delFiles = [ join(homedir(), ".quokka/.qid"), join(homedir(), ".quokka/state.json"), join(homedir(), ".quokka/notifications.json"), join(homedir(), ".wallaby/key.lic"), join(homedir(), ".wallaby/notifications.json"), ]; for (let file of delFiles) try { await fs.remove(file);//必须删除 更新试用的key } catch { } let wallabys = await fs.glob(["wallabyjs.wallaby-vscode*"], { cwd: join(homedir(), ".vscode\\extensions\\"), onlyDirectories: true }); for (let wallaby of wallabys) { try { let index = join(wallaby, "dist/index.js"); await fs.copy(index, join(wallaby, "dist/index_bak.js")); let str = await fs.readFile(index, "utf-8"); if (str.includes("wallaby已经破解")) return; str = str.replace(`this.on("notification",a=>{`, ` this.on("notification",a=>{ this._continueTrial(); console.log("wallaby已经破解!"); if (a.text.indexOf("continue-trial-link") || a.text.indexOf("If you would like to try Wallaby")) { return; } `); await fs.writeFile(index, str); } catch (error) { } } let quokkas = await fs.glob(["wallabyjs.quokka-vscode*"], { cwd: join(homedir(), ".vscode\\extensions\\"), onlyDirectories: true }); for (let quokka of quokkas) { try { let index = join(quokka, "dist/index.js"); let str = await fs.readFile(index, "utf-8"); if (str.includes("quokka已经破解")) return; await fs.copy(index, join(quokka, "dist/index_bak.js")); str = str.replace(`_showNotification(e,t){`, ` _showNotification(e,t){ t.continueTrial() console.log("quokka已经破解!"); if ("expiredLicense" === e.id || e.expiringSoon || e.suggestProEdition) { console.log("wallaby 没有许可或者即将到期 自动续期"); //return;//便于调试是不是试用期过了 } `); await fs.writeFile(index, str); } catch (error) { } } } main();