{"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/utils/update-shell-references.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CA+CzF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAiBxD","file":"update-shell-references.d.ts","sourcesContent":["import fse from 'fs-extra';\r\nimport { Logger } from \"./logger\";\r\n\r\nexport function updateShellReferences(primaryDisplayName: string, internal: boolean): void {\r\n    Logger.log('Updating shell references...');\r\n    Logger.log('Detected internal: ' + internal);\r\n    const internalShellReference = '@msft-sme';\r\n    const externalShellReference = '@microsoft/windows-admin-center-sdk';\r\n    const find = internal ? externalShellReference : internalShellReference;\r\n    const replace = internal ? internalShellReference : externalShellReference;\r\n\r\n    // For performance reasons, all applicable files are listed here, rather than scanning all files\r\n    const extensionDirectory = ('./' + primaryDisplayName + '/').replace('//', '/');\r\n    const extensionSrcDirectory = extensionDirectory + 'src/';\r\n    const extensionAppDirectory = extensionSrcDirectory + 'app/';\r\n    const gulpFileDirectory = extensionDirectory + 'gulpfile.ts/';\r\n    const gulpFileCommonDirectory = gulpFileDirectory + 'common/';\r\n\r\n    const filesWithShellReferences = [\r\n        extensionDirectory + 'angular.json',\r\n        gulpFileDirectory + 'config-data.ts',\r\n        gulpFileDirectory + 'index.ts',\r\n        gulpFileCommonDirectory + 'pack.ts',\r\n        gulpFileCommonDirectory + 'powershell.ts',\r\n        gulpFileCommonDirectory + 'resjson.ts',\r\n        gulpFileCommonDirectory + 'test.ts',\r\n        gulpFileCommonDirectory + 'validate.ts',\r\n        extensionSrcDirectory + 'main.ts',\r\n        extensionSrcDirectory + 'manifest.json',\r\n        extensionSrcDirectory + 'polyfills.ts',\r\n        extensionSrcDirectory + 'test.ts',\r\n        extensionAppDirectory + 'app-routing.module.ts',\r\n        extensionAppDirectory + 'app.component.ts',\r\n        extensionAppDirectory + 'app.module.ts',\r\n        extensionDirectory + '.eslintrc.json'\r\n    ];\r\n\r\n    const cleanFiles = {};\r\n\r\n    filesWithShellReferences.forEach((file) => {\r\n        cleanFiles[file] = {\r\n            [find]: replace\r\n        };\r\n    });\r\n\r\n    for (const key in cleanFiles) {\r\n        if (Object.prototype.hasOwnProperty.call(cleanFiles, key)) {\r\n            cleanFile(key, cleanFiles[key]);\r\n        }\r\n    }\r\n}\r\n\r\nexport function cleanFile(key: string, values: any): void {\r\n    Logger.log('Updating: ' + key + ' ' + JSON.stringify(values));\r\n    for (const valuesKey in values) {\r\n        let a = 0;\r\n        if (Object.prototype.hasOwnProperty.call(values, valuesKey)) {\r\n            let fileData = fse.readFileSync(key, 'utf8');\r\n            let displayNameIndex = fileData.indexOf(valuesKey);\r\n\r\n            while (displayNameIndex > 0) {\r\n                Logger.log('Found key: ' + valuesKey + ' at index: ' + displayNameIndex);\r\n                fileData = fileData.replace(valuesKey, values[valuesKey]);\r\n                displayNameIndex = fileData.indexOf(valuesKey);\r\n            }\r\n\r\n            fse.outputFileSync(key, fileData);\r\n        }\r\n    }\r\n}"]}