@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 3.12 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/upgrader/audit/subjuct-next-updater-util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,qBAAa,sBAAsB;IAC/B;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM;IAW3D;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAwCrB","file":"subjuct-next-updater-util.d.ts","sourcesContent":["import { ResolveState } from '../../../common';\r\nimport { ErrorResult } from '../../../upgrade/models/error-result';\r\nimport { Logger } from '../../utils/logger';\r\n\r\nexport class SubjectNextUpdaterUtil {\r\n /**\r\n * the update function.\r\n * @param fileData the file data.\r\n * @param error the error object.\r\n * @returns the updated file data.\r\n */\r\n public update(fileData: string, error: ErrorResult): string {\r\n if (!fileData) {\r\n Logger.error(`Cannot find file data`);\r\n }\r\n\r\n const result = this.regexFixer(fileData);\r\n\r\n error.resolved = ResolveState.Resolved;\r\n return result;\r\n }\r\n\r\n /**\r\n * the regexFixer function.\r\n * @param inputString the input file data string.\r\n * @returns the updated file data string.\r\n */\r\n private regexFixer(inputString: string) {\r\n // Define the regular expression pattern\r\n const regexPattern = /this\\.(\\w+)\\.next\\(\\);/;\r\n const match = inputString.match(regexPattern);\r\n\r\n if (match) {\r\n var extractedString = match[1];\r\n console.log(extractedString);\r\n\r\n /**\r\n * public myString: Subject();\r\n * protected myString: Subject();\r\n * private myString: Subject();\r\n * To:\r\n * public myString: Subject<void>();\r\n * protected myString: Subject<void>();\r\n * private myString: Subject<void>();\r\n */\r\n const regex = new RegExp(`(${extractedString}:\\\\s+Subject\\\\(\\\\);)`, 'g');\r\n inputString = inputString.replace(regex, `${extractedString}: Subject<void>();`);\r\n\r\n /**\r\n * public myString = new Subject();\r\n * protected myString = new Subject();\r\n * private myString = new Subject();\r\n * TO:\r\n * public myString = new Subject<void>();\r\n * protected myString = new Subject<void>();\r\n * private myString = new Subject<void>();\r\n *\r\n * 'private myString = new Subject();'.replace(new RegExp(`(public|protected|private)\\\\s+(\\\\w+)\\\\s*=\\\\s*new\\\\s+Subject\\\\(\\\\);`, 'g'), '$1 $2 = new Subject<void>();')\r\n */\r\n const regex2 = new RegExp(`(public|protected|private)\\\\s+(\\\\w+)\\\\s*=\\\\s*new\\\\s+Subject\\\\(\\\\);`, 'g');\r\n inputString = inputString.replace(regex2, `$1 $2 = new Subject<void>();`);\r\n } else {\r\n console.log(\"No match found\");\r\n }\r\n\r\n return inputString;\r\n }\r\n}\r\n"]}