{"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/upgrader/package-json-upgrader.ts"],"names":[],"mappings":"AAKA,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,QAAQ,CAEd;IAEF;;;OAGG;gBACS,QAAQ,EAAE,MAAM;IAK5B;;OAEG;IACU,GAAG,CAAC,QAAQ,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBpD","file":"package-json-upgrader.d.ts","sourcesContent":["import { pathExists } from 'fs-extra';\r\nimport { Logger } from '../utils/logger';\r\nimport { FileWriter } from '../utils/file-writer';\r\nimport { adds, removes, replaces, replacesPipeline } from '../configs/package-json-config';\r\n\r\nexport class PackageJsonUpgrader {\r\n    private readonly fileName = 'package.json';\r\n    private filePath: string;\r\n    private fileWriter: FileWriter;\r\n\r\n    private messages = {\r\n        notFound: ''\r\n    };\r\n\r\n    /**\r\n     * the constructor.\r\n     * @param filePath the file path.\r\n     */\r\n    constructor(filePath: string) {\r\n        this.filePath = filePath;\r\n        this.messages.notFound = `${this.fileName} not found at ${this.filePath}.`\r\n    }\r\n\r\n    /**\r\n     * the run function to resolve the errors.\r\n     */\r\n    public async run(pipeline = false): Promise<void> {\r\n        try {\r\n            const exists = await pathExists(this.filePath);\r\n\r\n            if (exists) {\r\n                this.fileWriter = new FileWriter(this.filePath);\r\n\r\n                this.fileWriter\r\n                .tabToTwoSpaces()\r\n                .replaceDependencyVersion(replaces, pipeline)\r\n                .replaceDependencyVersion(replacesPipeline)\r\n                .removeContent(removes)\r\n                .addContent(adds)\r\n                .writeFile();\r\n            } else {\r\n                Logger.log(this.messages.notFound);\r\n            }\r\n        } catch (error) {\r\n            Logger.error(error);\r\n        }\r\n    }\r\n}\r\n"]}