@microsoft/teamsfx-core 2.0.0 → 2.0.1-alpha.6f92bb6f7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/build/common/armInterface.d.ts +0 -5
  2. package/build/common/armInterface.d.ts.map +1 -1
  3. package/build/common/deps-checker/checkerFactory.d.ts.map +1 -1
  4. package/build/common/deps-checker/checkerFactory.js +0 -7
  5. package/build/common/deps-checker/checkerFactory.js.map +1 -1
  6. package/build/common/deps-checker/constant/helpLink.d.ts +0 -4
  7. package/build/common/deps-checker/constant/helpLink.d.ts.map +1 -1
  8. package/build/common/deps-checker/constant/helpLink.js +1 -9
  9. package/build/common/deps-checker/constant/helpLink.js.map +1 -1
  10. package/build/common/deps-checker/constant/message.d.ts +0 -5
  11. package/build/common/deps-checker/constant/message.d.ts.map +1 -1
  12. package/build/common/deps-checker/constant/message.js +0 -6
  13. package/build/common/deps-checker/constant/message.js.map +1 -1
  14. package/build/common/deps-checker/constant/telemetry.d.ts +2 -33
  15. package/build/common/deps-checker/constant/telemetry.d.ts.map +1 -1
  16. package/build/common/deps-checker/constant/telemetry.js +0 -31
  17. package/build/common/deps-checker/constant/telemetry.js.map +1 -1
  18. package/build/common/deps-checker/depsChecker.d.ts +0 -3
  19. package/build/common/deps-checker/depsChecker.d.ts.map +1 -1
  20. package/build/common/deps-checker/depsChecker.js +0 -3
  21. package/build/common/deps-checker/depsChecker.js.map +1 -1
  22. package/build/common/deps-checker/depsError.d.ts +0 -9
  23. package/build/common/deps-checker/depsError.d.ts.map +1 -1
  24. package/build/common/deps-checker/depsError.js +1 -22
  25. package/build/common/deps-checker/depsError.js.map +1 -1
  26. package/build/common/deps-checker/depsManager.d.ts.map +1 -1
  27. package/build/common/deps-checker/depsManager.js +0 -3
  28. package/build/common/deps-checker/depsManager.js.map +1 -1
  29. package/build/common/deps-checker/internal/funcToolChecker.d.ts +2 -2
  30. package/build/common/deps-checker/internal/funcToolChecker.d.ts.map +1 -1
  31. package/build/common/deps-checker/internal/funcToolChecker.js +4 -2
  32. package/build/common/deps-checker/internal/funcToolChecker.js.map +1 -1
  33. package/build/common/deps-checker/internal/nodeChecker.d.ts +0 -20
  34. package/build/common/deps-checker/internal/nodeChecker.d.ts.map +1 -1
  35. package/build/common/deps-checker/internal/nodeChecker.js +1 -51
  36. package/build/common/deps-checker/internal/nodeChecker.js.map +1 -1
  37. package/build/common/local/localEnvManager.d.ts +0 -9
  38. package/build/common/local/localEnvManager.d.ts.map +1 -1
  39. package/build/common/local/localEnvManager.js +0 -59
  40. package/build/common/local/localEnvManager.js.map +1 -1
  41. package/build/common/projectSettingsHelper.d.ts +1 -7
  42. package/build/common/projectSettingsHelper.d.ts.map +1 -1
  43. package/build/common/projectSettingsHelper.js +5 -81
  44. package/build/common/projectSettingsHelper.js.map +1 -1
  45. package/build/common/projectSettingsHelperV3.d.ts +0 -1
  46. package/build/common/projectSettingsHelperV3.d.ts.map +1 -1
  47. package/build/common/projectSettingsHelperV3.js +1 -10
  48. package/build/common/projectSettingsHelperV3.js.map +1 -1
  49. package/build/common/samples.d.ts.map +1 -1
  50. package/build/common/samples.js +18 -40
  51. package/build/common/samples.js.map +1 -1
  52. package/build/common/templates-config.json +2 -2
  53. package/build/common/tools.d.ts +1 -2
  54. package/build/common/tools.d.ts.map +1 -1
  55. package/build/common/tools.js +5 -70
  56. package/build/common/tools.js.map +1 -1
  57. package/build/component/code/utils.d.ts +1 -8
  58. package/build/component/code/utils.d.ts.map +1 -1
  59. package/build/component/code/utils.js +5 -144
  60. package/build/component/code/utils.js.map +1 -1
  61. package/build/component/constants.d.ts +3 -0
  62. package/build/component/constants.d.ts.map +1 -1
  63. package/build/component/constants.js +13 -2
  64. package/build/component/constants.js.map +1 -1
  65. package/build/component/coordinator/index.d.ts +7 -7
  66. package/build/component/coordinator/index.d.ts.map +1 -1
  67. package/build/component/coordinator/index.js +15 -179
  68. package/build/component/coordinator/index.js.map +1 -1
  69. package/build/component/debug/error.d.ts +0 -1
  70. package/build/component/debug/error.d.ts.map +1 -1
  71. package/build/component/debug/error.js +1 -11
  72. package/build/component/debug/error.js.map +1 -1
  73. package/build/component/debug/index.d.ts.map +1 -1
  74. package/build/component/debug/index.js +1 -25
  75. package/build/component/debug/index.js.map +1 -1
  76. package/build/component/driver/aad/create.d.ts.map +1 -1
  77. package/build/component/driver/aad/create.js +2 -2
  78. package/build/component/driver/aad/create.js.map +1 -1
  79. package/build/component/driver/aad/update.d.ts.map +1 -1
  80. package/build/component/driver/aad/update.js +6 -20
  81. package/build/component/driver/aad/update.js.map +1 -1
  82. package/build/component/driver/botAadApp/create.d.ts.map +1 -1
  83. package/build/component/driver/botAadApp/create.js +2 -2
  84. package/build/component/driver/botAadApp/create.js.map +1 -1
  85. package/build/component/driver/devTool/error/dotnetInstallationUserError.d.ts +1 -1
  86. package/build/component/driver/devTool/error/dotnetInstallationUserError.d.ts.map +1 -1
  87. package/build/component/driver/devTool/error/dotnetInstallationUserError.js +4 -2
  88. package/build/component/driver/devTool/error/dotnetInstallationUserError.js.map +1 -1
  89. package/build/component/driver/devTool/error/funcInstallationUserError.d.ts +1 -1
  90. package/build/component/driver/devTool/error/funcInstallationUserError.d.ts.map +1 -1
  91. package/build/component/driver/devTool/error/funcInstallationUserError.js +4 -2
  92. package/build/component/driver/devTool/error/funcInstallationUserError.js.map +1 -1
  93. package/build/component/driver/devTool/installDriver.d.ts +1 -0
  94. package/build/component/driver/devTool/installDriver.d.ts.map +1 -1
  95. package/build/component/driver/devTool/installDriver.js +17 -24
  96. package/build/component/driver/devTool/installDriver.js.map +1 -1
  97. package/build/component/driver/script/baseBuildDriver.d.ts.map +1 -1
  98. package/build/component/driver/script/baseBuildDriver.js +2 -2
  99. package/build/component/driver/script/baseBuildDriver.js.map +1 -1
  100. package/build/component/driver/script/scriptDriver.d.ts +11 -1
  101. package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
  102. package/build/component/driver/script/scriptDriver.js +121 -4
  103. package/build/component/driver/script/scriptDriver.js.map +1 -1
  104. package/build/component/driver/teamsApp/createAppPackage.d.ts +0 -1
  105. package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
  106. package/build/component/driver/teamsApp/createAppPackage.js +1 -11
  107. package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
  108. package/build/component/driver/teamsApp/validate.d.ts +0 -1
  109. package/build/component/driver/teamsApp/validate.d.ts.map +1 -1
  110. package/build/component/driver/teamsApp/validate.js +34 -18
  111. package/build/component/driver/teamsApp/validate.js.map +1 -1
  112. package/build/component/feature/bot/question.d.ts.map +1 -1
  113. package/build/component/feature/bot/question.js +7 -16
  114. package/build/component/feature/bot/question.js.map +1 -1
  115. package/build/component/feature/sso.d.ts +0 -4
  116. package/build/component/feature/sso.d.ts.map +1 -1
  117. package/build/component/feature/sso.js +10 -144
  118. package/build/component/feature/sso.js.map +1 -1
  119. package/build/component/question.d.ts +3 -64
  120. package/build/component/question.d.ts.map +1 -1
  121. package/build/component/question.js +61 -663
  122. package/build/component/question.js.map +1 -1
  123. package/build/component/registerService.d.ts +0 -14
  124. package/build/component/registerService.d.ts.map +1 -1
  125. package/build/component/registerService.js +0 -14
  126. package/build/component/registerService.js.map +1 -1
  127. package/build/component/resource/aadApp/aadApp.d.ts.map +1 -1
  128. package/build/component/resource/aadApp/aadApp.js +6 -24
  129. package/build/component/resource/aadApp/aadApp.js.map +1 -1
  130. package/build/component/resource/appManifest/appStudio.js +1 -1
  131. package/build/component/resource/appManifest/appStudio.js.map +1 -1
  132. package/build/component/resource/appManifest/utils/ManifestUtils.d.ts +1 -1
  133. package/build/component/resource/appManifest/utils/ManifestUtils.d.ts.map +1 -1
  134. package/build/component/resource/appManifest/utils/ManifestUtils.js +1 -9
  135. package/build/component/resource/appManifest/utils/ManifestUtils.js.map +1 -1
  136. package/build/component/resource/spfx/utils/questions.d.ts.map +1 -1
  137. package/build/component/resource/spfx/utils/questions.js +1 -4
  138. package/build/component/resource/spfx/utils/questions.js.map +1 -1
  139. package/build/component/utils/backupFiles.d.ts +2 -1
  140. package/build/component/utils/backupFiles.d.ts.map +1 -1
  141. package/build/component/utils/backupFiles.js +23 -3
  142. package/build/component/utils/backupFiles.js.map +1 -1
  143. package/build/component/utils/charsetUtils.d.ts +3 -0
  144. package/build/component/utils/charsetUtils.d.ts.map +1 -0
  145. package/build/component/utils/charsetUtils.js +241 -0
  146. package/build/component/utils/charsetUtils.js.map +1 -0
  147. package/build/component/utils/envUtil.d.ts.map +1 -1
  148. package/build/component/utils/envUtil.js +4 -1
  149. package/build/component/utils/envUtil.js.map +1 -1
  150. package/build/component/utils/metadataUtil.d.ts.map +1 -1
  151. package/build/component/utils/metadataUtil.js +9 -7
  152. package/build/component/utils/metadataUtil.js.map +1 -1
  153. package/build/component/utils/pathUtils.d.ts.map +1 -1
  154. package/build/component/utils/pathUtils.js +8 -7
  155. package/build/component/utils/pathUtils.js.map +1 -1
  156. package/build/component/utils/settingsUtil.js +3 -3
  157. package/build/component/utils/settingsUtil.js.map +1 -1
  158. package/build/component/utils.d.ts +1 -12
  159. package/build/component/utils.d.ts.map +1 -1
  160. package/build/component/utils.js +2 -225
  161. package/build/component/utils.js.map +1 -1
  162. package/build/component/workflow.d.ts +0 -1
  163. package/build/component/workflow.d.ts.map +1 -1
  164. package/build/component/workflow.js +1 -687
  165. package/build/component/workflow.js.map +1 -1
  166. package/build/core/FxCore.d.ts +26 -34
  167. package/build/core/FxCore.d.ts.map +1 -1
  168. package/build/core/FxCore.js +86 -654
  169. package/build/core/FxCore.js.map +1 -1
  170. package/build/core/FxCoreImplementV3.d.ts +15 -9
  171. package/build/core/FxCoreImplementV3.d.ts.map +1 -1
  172. package/build/core/FxCoreImplementV3.js +105 -105
  173. package/build/core/FxCoreImplementV3.js.map +1 -1
  174. package/build/core/middleware/envInfoLoaderV3.d.ts +1 -10
  175. package/build/core/middleware/envInfoLoaderV3.d.ts.map +1 -1
  176. package/build/core/middleware/envInfoLoaderV3.js +1 -207
  177. package/build/core/middleware/envInfoLoaderV3.js.map +1 -1
  178. package/build/core/middleware/projectMigratorV3.d.ts +1 -0
  179. package/build/core/middleware/projectMigratorV3.d.ts.map +1 -1
  180. package/build/core/middleware/projectMigratorV3.js +7 -7
  181. package/build/core/middleware/projectMigratorV3.js.map +1 -1
  182. package/build/core/middleware/projectSettingsLoader.d.ts +1 -4
  183. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  184. package/build/core/middleware/projectSettingsLoader.js +4 -58
  185. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  186. package/build/core/middleware/projectVersionChecker.d.ts.map +1 -1
  187. package/build/core/middleware/projectVersionChecker.js +4 -5
  188. package/build/core/middleware/projectVersionChecker.js.map +1 -1
  189. package/build/core/middleware/questionModel.d.ts +0 -1
  190. package/build/core/middleware/questionModel.d.ts.map +1 -1
  191. package/build/core/middleware/questionModel.js +8 -54
  192. package/build/core/middleware/questionModel.js.map +1 -1
  193. package/build/core/middleware/utils/MigrationUtils.d.ts +0 -5
  194. package/build/core/middleware/utils/MigrationUtils.d.ts.map +1 -1
  195. package/build/core/middleware/utils/MigrationUtils.js +1 -77
  196. package/build/core/middleware/utils/MigrationUtils.js.map +1 -1
  197. package/build/core/question.d.ts +2 -12
  198. package/build/core/question.d.ts.map +1 -1
  199. package/build/core/question.js +14 -236
  200. package/build/core/question.js.map +1 -1
  201. package/build/core/types.d.ts +3 -3
  202. package/build/core/types.d.ts.map +1 -1
  203. package/build/error/common.d.ts +9 -0
  204. package/build/error/common.d.ts.map +1 -1
  205. package/build/error/common.js +39 -1
  206. package/build/error/common.js.map +1 -1
  207. package/build/error/script.d.ts +1 -1
  208. package/build/error/script.d.ts.map +1 -1
  209. package/build/error/script.js +3 -3
  210. package/build/error/script.js.map +1 -1
  211. package/build/index.d.ts +0 -2
  212. package/build/index.d.ts.map +1 -1
  213. package/build/index.js +1 -4
  214. package/build/index.js.map +1 -1
  215. package/package.json +12 -28
  216. package/resource/package.nls.json +10 -97
  217. package/templates/fallback/common.zip +0 -0
  218. package/templates/fallback/csharp.zip +0 -0
  219. package/templates/fallback/js.zip +0 -0
  220. package/templates/fallback/ts.zip +0 -0
  221. package/build/common/deps-checker/internal/ngrokChecker.d.ts +0 -27
  222. package/build/common/deps-checker/internal/ngrokChecker.d.ts.map +0 -1
  223. package/build/common/deps-checker/internal/ngrokChecker.js +0 -222
  224. package/build/common/deps-checker/internal/ngrokChecker.js.map +0 -1
  225. package/build/component/connection/apimConfig.d.ts +0 -11
  226. package/build/component/connection/apimConfig.d.ts.map +0 -1
  227. package/build/component/connection/apimConfig.js +0 -44
  228. package/build/component/connection/apimConfig.js.map +0 -1
  229. package/build/component/connection/azureFunctionConfig.d.ts +0 -9
  230. package/build/component/connection/azureFunctionConfig.d.ts.map +0 -1
  231. package/build/component/connection/azureFunctionConfig.js +0 -25
  232. package/build/component/connection/azureFunctionConfig.js.map +0 -1
  233. package/build/component/connection/azureResourceConfig.d.ts +0 -11
  234. package/build/component/connection/azureResourceConfig.d.ts.map +0 -1
  235. package/build/component/connection/azureResourceConfig.js +0 -72
  236. package/build/component/connection/azureResourceConfig.js.map +0 -1
  237. package/build/component/connection/azureWebAppConfig.d.ts +0 -9
  238. package/build/component/connection/azureWebAppConfig.d.ts.map +0 -1
  239. package/build/component/connection/azureWebAppConfig.js +0 -25
  240. package/build/component/connection/azureWebAppConfig.js.map +0 -1
  241. package/build/component/coordinator/lifecycleStage.d.ts +0 -2
  242. package/build/component/coordinator/lifecycleStage.d.ts.map +0 -1
  243. package/build/component/coordinator/lifecycleStage.js +0 -23
  244. package/build/component/coordinator/lifecycleStage.js.map +0 -1
  245. package/build/component/core.d.ts +0 -65
  246. package/build/component/core.d.ts.map +0 -1
  247. package/build/component/core.js +0 -653
  248. package/build/component/core.js.map +0 -1
  249. package/build/component/debug/util/ngrok.d.ts +0 -6
  250. package/build/component/debug/util/ngrok.d.ts.map +0 -1
  251. package/build/component/debug/util/ngrok.js +0 -65
  252. package/build/component/debug/util/ngrok.js.map +0 -1
  253. package/build/component/feature/api/api.d.ts +0 -8
  254. package/build/component/feature/api/api.d.ts.map +0 -1
  255. package/build/component/feature/api/api.js +0 -188
  256. package/build/component/feature/api/api.js.map +0 -1
  257. package/build/component/feature/apiconnector/apiConnector.d.ts +0 -11
  258. package/build/component/feature/apiconnector/apiConnector.d.ts.map +0 -1
  259. package/build/component/feature/apiconnector/apiConnector.js +0 -43
  260. package/build/component/feature/apiconnector/apiConnector.js.map +0 -1
  261. package/build/component/feature/apim.d.ts +0 -8
  262. package/build/component/feature/apim.d.ts.map +0 -1
  263. package/build/component/feature/apim.js +0 -123
  264. package/build/component/feature/apim.js.map +0 -1
  265. package/build/component/feature/bot/bot.d.ts +0 -12
  266. package/build/component/feature/bot/bot.d.ts.map +0 -1
  267. package/build/component/feature/bot/bot.js +0 -309
  268. package/build/component/feature/bot/bot.js.map +0 -1
  269. package/build/component/feature/keyVault.d.ts +0 -16
  270. package/build/component/feature/keyVault.d.ts.map +0 -1
  271. package/build/component/feature/keyVault.js +0 -90
  272. package/build/component/feature/keyVault.js.map +0 -1
  273. package/build/component/feature/spfx.d.ts +0 -9
  274. package/build/component/feature/spfx.d.ts.map +0 -1
  275. package/build/component/feature/spfx.js +0 -121
  276. package/build/component/feature/spfx.js.map +0 -1
  277. package/build/component/feature/sql.d.ts +0 -10
  278. package/build/component/feature/sql.d.ts.map +0 -1
  279. package/build/component/feature/sql.js +0 -80
  280. package/build/component/feature/sql.js.map +0 -1
  281. package/build/component/feature/tab.d.ts +0 -10
  282. package/build/component/feature/tab.d.ts.map +0 -1
  283. package/build/component/feature/tab.js +0 -238
  284. package/build/component/feature/tab.js.map +0 -1
  285. package/build/component/resource/azureSql/actions/configure.d.ts +0 -15
  286. package/build/component/resource/azureSql/actions/configure.d.ts.map +0 -1
  287. package/build/component/resource/azureSql/actions/configure.js +0 -92
  288. package/build/component/resource/azureSql/actions/configure.js.map +0 -1
  289. package/build/component/resource/azureSql/actions/provision.d.ts +0 -10
  290. package/build/component/resource/azureSql/actions/provision.d.ts.map +0 -1
  291. package/build/component/resource/azureSql/actions/provision.js +0 -63
  292. package/build/component/resource/azureSql/actions/provision.js.map +0 -1
  293. package/build/component/resource/azureSql/actions/utils.d.ts +0 -12
  294. package/build/component/resource/azureSql/actions/utils.d.ts.map +0 -1
  295. package/build/component/resource/azureSql/actions/utils.js +0 -82
  296. package/build/component/resource/azureSql/actions/utils.js.map +0 -1
  297. package/build/component/resource/azureSql/azureSql.d.ts +0 -24
  298. package/build/component/resource/azureSql/azureSql.d.ts.map +0 -1
  299. package/build/component/resource/azureSql/azureSql.js +0 -75
  300. package/build/component/resource/azureSql/azureSql.js.map +0 -1
  301. package/build/component/resource/azureSql/clients/management.d.ts +0 -18
  302. package/build/component/resource/azureSql/clients/management.d.ts.map +0 -1
  303. package/build/component/resource/azureSql/clients/management.js +0 -124
  304. package/build/component/resource/azureSql/clients/management.js.map +0 -1
  305. package/build/component/resource/azureSql/clients/sql.d.ts +0 -13
  306. package/build/component/resource/azureSql/clients/sql.d.ts.map +0 -1
  307. package/build/component/resource/azureSql/clients/sql.js +0 -153
  308. package/build/component/resource/azureSql/clients/sql.js.map +0 -1
  309. package/build/component/resource/azureSql/config.d.ts +0 -7
  310. package/build/component/resource/azureSql/config.d.ts.map +0 -1
  311. package/build/component/resource/azureSql/config.js +0 -77
  312. package/build/component/resource/azureSql/config.js.map +0 -1
  313. package/build/component/resource/azureSql/constants.d.ts +0 -85
  314. package/build/component/resource/azureSql/constants.d.ts.map +0 -1
  315. package/build/component/resource/azureSql/constants.js +0 -95
  316. package/build/component/resource/azureSql/constants.js.map +0 -1
  317. package/build/component/resource/azureSql/errors.d.ts +0 -63
  318. package/build/component/resource/azureSql/errors.d.ts.map +0 -1
  319. package/build/component/resource/azureSql/errors.js +0 -107
  320. package/build/component/resource/azureSql/errors.js.map +0 -1
  321. package/build/component/resource/azureSql/index.d.ts +0 -2
  322. package/build/component/resource/azureSql/index.d.ts.map +0 -1
  323. package/build/component/resource/azureSql/index.js +0 -7
  324. package/build/component/resource/azureSql/index.js.map +0 -1
  325. package/build/component/resource/azureSql/questions.d.ts +0 -6
  326. package/build/component/resource/azureSql/questions.d.ts.map +0 -1
  327. package/build/component/resource/azureSql/questions.js +0 -59
  328. package/build/component/resource/azureSql/questions.js.map +0 -1
  329. package/build/component/resource/azureSql/results.d.ts +0 -10
  330. package/build/component/resource/azureSql/results.d.ts.map +0 -1
  331. package/build/component/resource/azureSql/results.js +0 -34
  332. package/build/component/resource/azureSql/results.js.map +0 -1
  333. package/build/component/resource/azureSql/types.d.ts +0 -12
  334. package/build/component/resource/azureSql/types.d.ts.map +0 -1
  335. package/build/component/resource/azureSql/types.js +0 -5
  336. package/build/component/resource/azureSql/types.js.map +0 -1
  337. package/build/component/resource/azureSql/utils/checkInput.d.ts +0 -10
  338. package/build/component/resource/azureSql/utils/checkInput.d.ts.map +0 -1
  339. package/build/component/resource/azureSql/utils/checkInput.js +0 -89
  340. package/build/component/resource/azureSql/utils/checkInput.js.map +0 -1
  341. package/build/component/resource/azureSql/utils/common.d.ts +0 -12
  342. package/build/component/resource/azureSql/utils/common.d.ts.map +0 -1
  343. package/build/component/resource/azureSql/utils/common.js +0 -51
  344. package/build/component/resource/azureSql/utils/common.js.map +0 -1
  345. package/build/component/resource/identity.d.ts +0 -28
  346. package/build/component/resource/identity.d.ts.map +0 -1
  347. package/build/component/resource/identity.js +0 -42
  348. package/build/component/resource/identity.js.map +0 -1
  349. package/build/component/resource/keyVault.d.ts +0 -29
  350. package/build/component/resource/keyVault.d.ts.map +0 -1
  351. package/build/component/resource/keyVault.js +0 -47
  352. package/build/component/resource/keyVault.js.map +0 -1
  353. package/build/component/resource/simpleAuth/constants.d.ts +0 -122
  354. package/build/component/resource/simpleAuth/constants.d.ts.map +0 -1
  355. package/build/component/resource/simpleAuth/constants.js +0 -163
  356. package/build/component/resource/simpleAuth/constants.js.map +0 -1
  357. package/build/component/resource/simpleAuth/errors.d.ts +0 -17
  358. package/build/component/resource/simpleAuth/errors.d.ts.map +0 -1
  359. package/build/component/resource/simpleAuth/errors.js +0 -91
  360. package/build/component/resource/simpleAuth/errors.js.map +0 -1
  361. package/build/component/resource/simpleAuth/index.d.ts +0 -12
  362. package/build/component/resource/simpleAuth/index.d.ts.map +0 -1
  363. package/build/component/resource/simpleAuth/index.js +0 -115
  364. package/build/component/resource/simpleAuth/index.js.map +0 -1
  365. package/build/component/resource/simpleAuth/result.d.ts +0 -9
  366. package/build/component/resource/simpleAuth/result.d.ts.map +0 -1
  367. package/build/component/resource/simpleAuth/result.js +0 -35
  368. package/build/component/resource/simpleAuth/result.js.map +0 -1
  369. package/build/component/resource/simpleAuth/utils/common.d.ts +0 -23
  370. package/build/component/resource/simpleAuth/utils/common.d.ts.map +0 -1
  371. package/build/component/resource/simpleAuth/utils/common.js +0 -150
  372. package/build/component/resource/simpleAuth/utils/common.js.map +0 -1
  373. package/build/component/resource/simpleAuth/utils/dialog.d.ts +0 -5
  374. package/build/component/resource/simpleAuth/utils/dialog.d.ts.map +0 -1
  375. package/build/component/resource/simpleAuth/utils/dialog.js +0 -7
  376. package/build/component/resource/simpleAuth/utils/dialog.js.map +0 -1
  377. package/build/component/resource/simpleAuth/utils/telemetry.d.ts +0 -17
  378. package/build/component/resource/simpleAuth/utils/telemetry.d.ts.map +0 -1
  379. package/build/component/resource/simpleAuth/utils/telemetry.js +0 -45
  380. package/build/component/resource/simpleAuth/utils/telemetry.js.map +0 -1
  381. package/build/core/dependencyChecker.d.ts +0 -1
  382. package/build/core/dependencyChecker.d.ts.map +0 -1
  383. package/build/core/dependencyChecker.js +0 -2
  384. package/build/core/dependencyChecker.js.map +0 -1
  385. package/build/core/middleware/CommonErrorHandlerMW.d.ts +0 -14
  386. package/build/core/middleware/CommonErrorHandlerMW.d.ts.map +0 -1
  387. package/build/core/middleware/CommonErrorHandlerMW.js +0 -63
  388. package/build/core/middleware/CommonErrorHandlerMW.js.map +0 -1
  389. package/build/core/middleware/aadManifestMigration.d.ts +0 -3
  390. package/build/core/middleware/aadManifestMigration.d.ts.map +0 -1
  391. package/build/core/middleware/aadManifestMigration.js +0 -119
  392. package/build/core/middleware/aadManifestMigration.js.map +0 -1
  393. package/build/core/middleware/consolidateLocalRemote.d.ts +0 -5
  394. package/build/core/middleware/consolidateLocalRemote.d.ts.map +0 -1
  395. package/build/core/middleware/consolidateLocalRemote.js +0 -378
  396. package/build/core/middleware/consolidateLocalRemote.js.map +0 -1
  397. package/build/core/middleware/envInfoWriter.d.ts +0 -8
  398. package/build/core/middleware/envInfoWriter.d.ts.map +0 -1
  399. package/build/core/middleware/envInfoWriter.js +0 -76
  400. package/build/core/middleware/envInfoWriter.js.map +0 -1
  401. package/build/core/middleware/envInfoWriterV3.d.ts +0 -6
  402. package/build/core/middleware/envInfoWriterV3.d.ts.map +0 -1
  403. package/build/core/middleware/envInfoWriterV3.js +0 -67
  404. package/build/core/middleware/envInfoWriterV3.js.map +0 -1
  405. package/build/core/middleware/projectMigrator.d.ts +0 -40
  406. package/build/core/middleware/projectMigrator.d.ts.map +0 -1
  407. package/build/core/middleware/projectMigrator.js +0 -1014
  408. package/build/core/middleware/projectMigrator.js.map +0 -1
  409. package/build/core/middleware/projectSettingsWriter.d.ts +0 -6
  410. package/build/core/middleware/projectSettingsWriter.d.ts.map +0 -1
  411. package/build/core/middleware/projectSettingsWriter.js +0 -52
  412. package/build/core/middleware/projectSettingsWriter.js.map +0 -1
@@ -1,1014 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT license.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.generateBicepsV3 = exports.migrateArm = exports.needMigrateToArmAndMultiEnv = exports.addPathToGitignore = exports.LocalDebugConfigKeys = exports.checkUserTasks = exports.checkMethod = exports.outputCancelMessage = exports.ProjectMigratorMW = exports.ArmParameters = exports.upgradeButton = exports.learnMoreText = void 0;
6
- const tslib_1 = require("tslib");
7
- const teamsfx_api_1 = require("@microsoft/teamsfx-api");
8
- const tools_1 = require("../../common/tools");
9
- const environment_1 = require("../environment");
10
- const folder_1 = require("../../folder");
11
- const globalState_1 = require("../../common/globalState");
12
- const error_1 = require("../error");
13
- const localSettingsProvider_1 = require("../../common/localSettingsProvider");
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
- const path_1 = tslib_1.__importDefault(require("path"));
16
- const os_1 = tslib_1.__importDefault(require("os"));
17
- require("../../component/registerService");
18
- const constants_1 = require("../../component/constants");
19
- const projectSettingsLoader_1 = require("./projectSettingsLoader");
20
- const constants_2 = require("../../common/constants");
21
- const constants_3 = require("../../component/resource/appManifest/constants");
22
- const utils_1 = require("../../component/resource/appManifest/utils/utils");
23
- const telemetry_1 = require("../../common/telemetry");
24
- const dotenv = tslib_1.__importStar(require("dotenv"));
25
- const constants_4 = require("../../component/resource/spfx/utils/constants");
26
- const utils_2 = require("../../component/resource/spfx/utils/utils");
27
- const localEnvProvider_1 = require("../../common/local/localEnvProvider");
28
- const globalVars_1 = require("../globalVars");
29
- const localizeUtils_1 = require("../../common/localizeUtils");
30
- const utils_3 = require("../../common/utils");
31
- const typedi_1 = require("typedi");
32
- const workflow_1 = require("../../component/workflow");
33
- const utils_4 = require("../../component/utils");
34
- const lodash_1 = require("lodash");
35
- const migrate_1 = require("../../component/migrate");
36
- const projectSettingsHelperV3_1 = require("../../common/projectSettingsHelperV3");
37
- const programmingLanguage = "programmingLanguage";
38
- const defaultFunctionName = "defaultFunctionName";
39
- exports.learnMoreText = localizeUtils_1.getLocalizedString("core.option.learnMore");
40
- exports.upgradeButton = localizeUtils_1.getLocalizedString("core.option.upgrade");
41
- const solutionName = "solution";
42
- const subscriptionId = "subscriptionId";
43
- const resourceGroupName = "resourceGroupName";
44
- const parameterFileNameTemplate = "azure.parameters.@envName.json";
45
- const learnMoreLink = "https://aka.ms/teamsfx-migration-guide";
46
- const manualUpgradeLink = `${learnMoreLink}#upgrade-your-project-manually`;
47
- const upgradeReportName = `upgrade-change-logs.md`;
48
- const AadSecret = "{{ $env.AAD_APP_CLIENT_SECRET }}";
49
- const ChangeLogsFlag = "openUpgradeChangelogs";
50
- const AADClientSecretFlag = "NeedToSetAADClientSecretEnv";
51
- const gitignoreFileName = ".gitignore";
52
- let fromReloadFlag = false;
53
- class EnvConfigName {
54
- }
55
- EnvConfigName.StorageName = "storageName";
56
- EnvConfigName.Identity = "identity";
57
- EnvConfigName.IdentityId = "identityId";
58
- EnvConfigName.IdentityName = "identityName";
59
- EnvConfigName.IdentityResourceId = "identityResourceId";
60
- EnvConfigName.IdentityClientId = "identityClientId";
61
- EnvConfigName.SqlEndpoint = "sqlEndpoint";
62
- EnvConfigName.SqlResourceId = "sqlResourceId";
63
- EnvConfigName.SqlDataBase = "databaseName";
64
- EnvConfigName.SqlSkipAddingUser = "skipAddingUser";
65
- EnvConfigName.SkuName = "skuName";
66
- EnvConfigName.AppServicePlanName = "appServicePlanName";
67
- EnvConfigName.StorageAccountName = "storageAccountName";
68
- EnvConfigName.StorageResourceId = "storageResourceId";
69
- EnvConfigName.FuncAppName = "functionAppName";
70
- EnvConfigName.FunctionAppResourceId = "functionAppResourceId";
71
- EnvConfigName.Endpoint = "endpoint";
72
- EnvConfigName.ServiceName = "serviceName";
73
- EnvConfigName.ProductId = "productId";
74
- EnvConfigName.OAuthServerId = "oAuthServerId";
75
- EnvConfigName.ServiceResourceId = "serviceResourceId";
76
- EnvConfigName.ProductResourceId = "productResourceId";
77
- EnvConfigName.AuthServerResourceId = "authServerResourceId";
78
- EnvConfigName.AadSkipProvision = "skipProvision";
79
- EnvConfigName.OAuthScopeId = "oauth2PermissionScopeId";
80
- EnvConfigName.ClientId = "clientId";
81
- EnvConfigName.ClientSecret = "clientSecret";
82
- EnvConfigName.ObjectId = "objectId";
83
- class ArmParameters {
84
- }
85
- exports.ArmParameters = ArmParameters;
86
- ArmParameters.FEStorageName = "frontendHostingStorageName";
87
- ArmParameters.IdentityName = "userAssignedIdentityName";
88
- ArmParameters.SQLServer = "sqlServerName";
89
- ArmParameters.SQLDatabase = "sqlDatabaseName";
90
- ArmParameters.SimpleAuthSku = "simpleAuthSku";
91
- ArmParameters.functionServerName = "functionServerfarmsName";
92
- ArmParameters.functionStorageName = "functionStorageName";
93
- ArmParameters.functionAppName = "functionWebappName";
94
- ArmParameters.botWebAppSku = "botWebAppSKU";
95
- ArmParameters.SimpleAuthWebAppName = "simpleAuthWebAppName";
96
- ArmParameters.SimpleAuthServerFarm = "simpleAuthServerFarmsName";
97
- ArmParameters.ApimServiceName = "apimServiceName";
98
- ArmParameters.ApimProductName = "apimProductName";
99
- ArmParameters.ApimOauthServerName = "apimOauthServerName";
100
- const ProjectMigratorMW = async (ctx, next) => {
101
- if ((await needMigrateToArmAndMultiEnv(ctx)) && checkMethod(ctx)) {
102
- if (!checkUserTasks(ctx)) {
103
- ctx.result = teamsfx_api_1.ok(undefined);
104
- return;
105
- }
106
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorNotificationStart);
107
- const res = await (globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.ui.showMessage("warn", localizeUtils_1.getLocalizedString("core.migrationToArmAndMultiEnv.Message"), true, exports.upgradeButton));
108
- const answer = (res === null || res === void 0 ? void 0 : res.isOk()) ? res.value : undefined;
109
- if (!answer || answer != exports.upgradeButton) {
110
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorNotification, {
111
- [telemetry_1.TelemetryProperty.Status]: telemetry_1.ProjectMigratorStatus.Cancel,
112
- });
113
- ctx.result = teamsfx_api_1.err(error_1.UpgradeCanceledError());
114
- outputCancelMessage(ctx);
115
- return;
116
- }
117
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorNotification, {
118
- [telemetry_1.TelemetryProperty.Status]: telemetry_1.ProjectMigratorStatus.OK,
119
- });
120
- try {
121
- await migrateToArmAndMultiEnv(ctx);
122
- // return ok for the lifecycle functions to prevent breaking error handling logic.
123
- ctx.result = teamsfx_api_1.ok({});
124
- }
125
- catch (error) {
126
- // Strictly speaking, this telemetry event is not required because errorHandlerMW will send error telemetry anyway.
127
- // But it makes it easier to separate projectMigratorMW errors from other provision errors.
128
- telemetry_1.sendTelemetryErrorEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorError, teamsfx_api_1.assembleError(error, error_1.CoreSource));
129
- throw error;
130
- }
131
- }
132
- else {
133
- // continue next step only when:
134
- // 1. no need to upgrade the project;
135
- // 2. no need to update Teams Toolkit version;
136
- await next();
137
- }
138
- };
139
- exports.ProjectMigratorMW = ProjectMigratorMW;
140
- function outputCancelMessage(ctx) {
141
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core] Upgrade cancelled.`);
142
- const inputs = ctx.arguments[ctx.arguments.length - 1];
143
- if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
144
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core] Notice upgrade to new configuration files is a must-have to continue to use current version Teams Toolkit. If you want to upgrade, please run command (Teams: Upgrade project) or click the “Upgrade project” button on tree view to trigger the upgrade.`);
145
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core]If you are not ready to upgrade and want to continue to use the old version Teams Toolkit, please find Teams Toolkit in Extension and install the version <= 2.10.0`);
146
- }
147
- else {
148
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core] Notice upgrade to new configuration files is a must-have to continue to use current version Teams Toolkit CLI. If you want to upgrade, please trigger this command again.`);
149
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core]If you are not ready to upgrade and want to continue to use the old version Teams Toolkit CLI, please install the version <= 2.10.0`);
150
- }
151
- }
152
- exports.outputCancelMessage = outputCancelMessage;
153
- function checkMethod(ctx) {
154
- const methods = new Set(["getProjectConfig", "checkPermission"]);
155
- if (ctx.method && methods.has(ctx.method) && fromReloadFlag)
156
- return false;
157
- fromReloadFlag = ctx.method != undefined && methods.has(ctx.method);
158
- return true;
159
- }
160
- exports.checkMethod = checkMethod;
161
- function checkUserTasks(ctx) {
162
- var _a;
163
- const userTaskArgs = new Set(["getProgrammingLanguage", "getLocalDebugEnvs"]);
164
- const userTaskMethod = (_a = ctx.arguments[0]) === null || _a === void 0 ? void 0 : _a["method"];
165
- if (ctx.method === "executeUserTask" && userTaskArgs.has(userTaskMethod)) {
166
- return false;
167
- }
168
- return true;
169
- }
170
- exports.checkUserTasks = checkUserTasks;
171
- async function getOldProjectInfoForTelemetry(projectPath) {
172
- try {
173
- const inputs = {
174
- projectPath: projectPath,
175
- // not used by `loadProjectSettings` but the type `Inputs` requires it.
176
- platform: teamsfx_api_1.Platform.VSCode,
177
- };
178
- const loadRes = await projectSettingsLoader_1.loadProjectSettings(inputs, false);
179
- if (loadRes.isErr()) {
180
- return {};
181
- }
182
- const projectSettings = loadRes.value;
183
- const solutionSettings = projectSettings.solutionSettings;
184
- const hostType = solutionSettings === null || solutionSettings === void 0 ? void 0 : solutionSettings.hostType;
185
- const result = { [telemetry_1.TelemetryProperty.HostType]: hostType };
186
- if (hostType === constants_1.HostTypeOptionAzure().id || hostType === constants_1.HostTypeOptionSPFx().id) {
187
- result[telemetry_1.TelemetryProperty.ActivePlugins] = JSON.stringify(solutionSettings.activeResourcePlugins);
188
- result[telemetry_1.TelemetryProperty.Capabilities] = JSON.stringify(solutionSettings.capabilities);
189
- }
190
- if (hostType === constants_1.HostTypeOptionAzure().id) {
191
- const azureSolutionSettings = solutionSettings;
192
- result[telemetry_1.TelemetryProperty.AzureResources] = JSON.stringify(azureSolutionSettings.azureResources);
193
- }
194
- return result;
195
- }
196
- catch (error) {
197
- // ignore telemetry errors
198
- return {};
199
- }
200
- }
201
- async function migrateToArmAndMultiEnv(ctx) {
202
- const inputs = ctx.arguments[ctx.arguments.length - 1];
203
- const projectPath = inputs.projectPath;
204
- const telemetryProperties = await getOldProjectInfoForTelemetry(projectPath);
205
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrateStart, telemetryProperties);
206
- try {
207
- await preCheckKeyFiles(projectPath, ctx);
208
- }
209
- catch (err) {
210
- telemetry_1.sendTelemetryErrorEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorPrecheckFailed, teamsfx_api_1.assembleError(err, error_1.CoreSource));
211
- return;
212
- }
213
- let backupFolder;
214
- try {
215
- backupFolder = await getBackupFolder(projectPath);
216
- await backup(projectPath, backupFolder);
217
- await updateConfig(ctx);
218
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrateMultiEnvStart);
219
- const projectSettings = await migrateMultiEnv(projectPath, globalVars_1.TOOLS.logProvider);
220
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrateMultiEnv);
221
- ctx.projectSettings = projectSettings;
222
- if (!tools_1.isSPFxProject(projectSettings)) {
223
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrateArmStart);
224
- await migrateArm(ctx);
225
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrateArm);
226
- }
227
- }
228
- catch (err) {
229
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.error(`[core] Failed to upgrade project, error: '${err}'`);
230
- await handleError(projectPath, ctx, backupFolder);
231
- throw err;
232
- }
233
- await postMigration(projectPath, ctx, inputs, backupFolder);
234
- }
235
- async function getManifestPath(fx, projectPath) {
236
- if (await fs_extra_1.default.pathExists(path_1.default.join(projectPath, teamsfx_api_1.AppPackageFolderName, constants_3.REMOTE_MANIFEST))) {
237
- return path_1.default.join(projectPath, teamsfx_api_1.AppPackageFolderName, constants_3.REMOTE_MANIFEST);
238
- }
239
- // 2.3.2<= version <= 2.4.1
240
- if (await fs_extra_1.default.pathExists(path_1.default.join(fx, teamsfx_api_1.AppPackageFolderName, constants_3.REMOTE_MANIFEST))) {
241
- return path_1.default.join(fx, teamsfx_api_1.AppPackageFolderName, constants_3.REMOTE_MANIFEST);
242
- }
243
- // 2.0.1 <= version <= 2.3.1
244
- return path_1.default.join(fx, constants_3.REMOTE_MANIFEST);
245
- }
246
- async function preCheckKeyFiles(projectPath, ctx) {
247
- const fx = path_1.default.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
248
- const manifestPath = await getManifestPath(fx, projectPath);
249
- await preReadJsonFile(path_1.default.join(fx, "env.default.json"));
250
- await preReadJsonFile(path_1.default.join(fx, "settings.json"));
251
- await preReadJsonFile(manifestPath);
252
- }
253
- async function preReadJsonFile(path) {
254
- try {
255
- await fs_extra_1.default.readJson(path);
256
- }
257
- catch (err) {
258
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.error(`'${path}' doesn't exist or is not in json format. Please fix it and try again by running command (Teams: Upgrade project).`);
259
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`Read this wiki(${learnMoreLink}) for the FAQ.`);
260
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.ui.showMessage("info", localizeUtils_1.getLocalizedString("core.migrationToArmAndMultiEnv.PreCheckErrorMessage", path), false, exports.learnMoreText).then((result) => {
261
- const userSelected = result.isOk() ? result.value : undefined;
262
- if (userSelected === exports.learnMoreText) {
263
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.ui.openUrl(manualUpgradeLink);
264
- }
265
- });
266
- throw error_1.NotJsonError(err);
267
- }
268
- }
269
- async function handleError(projectPath, ctx, backupFolder) {
270
- try {
271
- await cleanup(projectPath, backupFolder);
272
- }
273
- catch (e) {
274
- // try my best to cleanup
275
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.error(`[core] Failed to cleanup the backup, error: '${e}'`);
276
- }
277
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.ui.showMessage("info", localizeUtils_1.getLocalizedString("core.migrationToArmAndMultiEnv.ErrorMessage"), false, exports.learnMoreText).then((result) => {
278
- const userSelected = result.isOk() ? result.value : undefined;
279
- if (userSelected === exports.learnMoreText) {
280
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.ui.openUrl(manualUpgradeLink);
281
- }
282
- });
283
- }
284
- async function generateUpgradeReport(backupFolder) {
285
- try {
286
- if (backupFolder) {
287
- const target = path_1.default.join(backupFolder, upgradeReportName);
288
- const source = path_1.default.resolve(path_1.default.join(folder_1.getResourceFolder(), upgradeReportName));
289
- await fs_extra_1.default.copyFile(source, target);
290
- }
291
- }
292
- catch (error) {
293
- // do nothing
294
- }
295
- }
296
- async function postMigration(projectPath, ctx, inputs, backupFolder) {
297
- var _a, _b;
298
- await removeOldProjectFiles(projectPath);
299
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorMigrate);
300
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorGuideStart);
301
- await generateUpgradeReport(backupFolder);
302
- await updateGitIgnore(projectPath, globalVars_1.TOOLS.logProvider, backupFolder);
303
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core] Upgrade success! All old files in .fx and appPackage folder have been backed up to the .backup folder and you can delete it. Read this wiki(${learnMoreLink}) if you want to restore your configuration files or learn more about this upgrade.`);
304
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.warning(`[core] Read upgrade-change-logs.md to learn about details for this upgrade.`);
305
- if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
306
- await globalState_1.globalStateUpdate(ChangeLogsFlag, true);
307
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.ProjectMigratorGuide, {
308
- [telemetry_1.TelemetryProperty.Status]: telemetry_1.ProjectMigratorGuideStatus.Reload,
309
- });
310
- await ((_b = globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : (_a = globalVars_1.TOOLS.ui).reload) === null || _b === void 0 ? void 0 : _b.call(_a));
311
- }
312
- else {
313
- globalVars_1.TOOLS === null || globalVars_1.TOOLS === void 0 ? void 0 : globalVars_1.TOOLS.logProvider.info(localizeUtils_1.getLocalizedString("core.migrationToArmAndMultiEnv.SuccessMessage"));
314
- }
315
- }
316
- async function updateGitIgnore(projectPath, log, backupFolder) {
317
- // add .fx/configs/localSetting.json to .gitignore
318
- const localSettingsProvider = new localSettingsProvider_1.LocalSettingsProvider(projectPath);
319
- await addPathToGitignore(projectPath, localSettingsProvider.localSettingsFilePath, log);
320
- // add .fx/subscriptionInfo.json to .gitignore
321
- const subscriptionInfoPath = path_1.default.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`, "subscriptionInfo.json");
322
- await addPathToGitignore(projectPath, subscriptionInfoPath, log);
323
- // add build/ to .gitignore
324
- const buildFolder = path_1.default.join(projectPath, teamsfx_api_1.BuildFolderName);
325
- await addPathToGitignore(projectPath, buildFolder, log);
326
- // add **/.env.teamsfx.local to .gitignore
327
- const envLocal = "**/" + localEnvProvider_1.LocalEnvProvider.LocalEnvFileName;
328
- await addItemToGitignore(projectPath, envLocal, log);
329
- // add .fx/states/*.userdata to .gitignore
330
- const userdata = `.${teamsfx_api_1.ConfigFolderName}/${teamsfx_api_1.StatesFolderName}/*.userdata`;
331
- await addItemToGitignore(projectPath, userdata, log);
332
- if (backupFolder) {
333
- await addPathToGitignore(projectPath, backupFolder, log);
334
- }
335
- }
336
- async function generateRemoteTemplate(manifestString) {
337
- manifestString = manifestString.replace(new RegExp("{version}", "g"), "1.0.0");
338
- manifestString = manifestString.replace(new RegExp("{baseUrl}", "g"), "{{{state.fx-resource-frontend-hosting.endpoint}}}");
339
- manifestString = manifestString.replace(new RegExp("{appClientId}", "g"), "{{state.fx-resource-aad-app-for-teams.clientId}}");
340
- manifestString = manifestString.replace(new RegExp("{webApplicationInfoResource}", "g"), "{{{state.fx-resource-aad-app-for-teams.applicationIdUris}}}");
341
- manifestString = manifestString.replace(new RegExp("{botId}", "g"), "{{state.fx-resource-bot.botId}}");
342
- const manifest = JSON.parse(manifestString);
343
- manifest.name.short = "{{config.manifest.appName.short}}";
344
- manifest.name.full = "{{config.manifest.appName.full}}";
345
- manifest.id = "{{state.fx-resource-appstudio.teamsAppId}}";
346
- return manifest;
347
- }
348
- async function generateLocalTemplate(manifestString, isSPFx, log) {
349
- manifestString = manifestString.replace(new RegExp("{version}", "g"), "1.0.0");
350
- manifestString = manifestString.replace(new RegExp("{baseUrl}", "g"), "{{{localSettings.frontend.tabEndpoint}}}");
351
- manifestString = manifestString.replace(new RegExp("{appClientId}", "g"), "{{localSettings.auth.clientId}}");
352
- manifestString = manifestString.replace(new RegExp("{webApplicationInfoResource}", "g"), "{{{localSettings.auth.applicationIdUris}}}");
353
- manifestString = manifestString.replace(new RegExp("{botId}", "g"), "{{localSettings.bot.botId}}");
354
- const manifest = JSON.parse(manifestString);
355
- manifest.name.full =
356
- (manifest.name.full ? manifest.name.full : manifest.name.short) + "-local-debug";
357
- manifest.name.short = utils_1.getLocalAppName(manifest.name.short);
358
- manifest.id = "{{localSettings.teamsApp.teamsAppId}}";
359
- // SPFx teams workbench url needs to be updated
360
- if (isSPFx) {
361
- if (manifest.configurableTabs) {
362
- for (const [index, tab] of manifest.configurableTabs.entries()) {
363
- const reg = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/;
364
- const result = tab.configurationUrl.match(reg);
365
- if (result && result.length > 0) {
366
- const componentID = result[0];
367
- tab.configurationUrl = `https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=${componentID}%26openPropertyPane=true%26teams%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js`;
368
- }
369
- else {
370
- const message = `[core] Cannot find componentID in configurableTabs[${index}].configrationUrl, Teams workbench debug may fail.`;
371
- log.warning(message);
372
- }
373
- }
374
- }
375
- if (manifest.staticTabs) {
376
- for (const tab of manifest.staticTabs) {
377
- const componentID = tab.entityId;
378
- tab.contentUrl = `https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=${componentID}%26teams%26personal%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js`;
379
- }
380
- }
381
- }
382
- return manifest;
383
- }
384
- async function getManifest(sourceManifestFile) {
385
- return await fs_extra_1.default.readJson(sourceManifestFile);
386
- }
387
- async function copyManifest(projectPath, fx, target) {
388
- if (await fs_extra_1.default.pathExists(path_1.default.join(projectPath, teamsfx_api_1.AppPackageFolderName))) {
389
- await fs_extra_1.default.copy(path_1.default.join(projectPath, teamsfx_api_1.AppPackageFolderName), target);
390
- }
391
- else if (await fs_extra_1.default.pathExists(path_1.default.join(fx, teamsfx_api_1.AppPackageFolderName))) {
392
- // version <= 2.4.1
393
- await fs_extra_1.default.copy(path_1.default.join(fx, teamsfx_api_1.AppPackageFolderName), target);
394
- }
395
- else {
396
- // version <= 2.3.1
397
- await fs_extra_1.default.copy(path_1.default.join(fx, constants_3.REMOTE_MANIFEST), path_1.default.join(target, constants_3.REMOTE_MANIFEST));
398
- const manifest = await getManifest(path_1.default.join(target, constants_3.REMOTE_MANIFEST));
399
- const color = (await fs_extra_1.default.pathExists(path_1.default.join(fx, "color.png")))
400
- ? "color.png"
401
- : manifest.icons.color;
402
- const outline = (await fs_extra_1.default.pathExists(path_1.default.join(fx, "outline.png")))
403
- ? "outline.png"
404
- : manifest.icons.outline;
405
- if (color !== "" && (await fs_extra_1.default.pathExists(path_1.default.join(fx, color)))) {
406
- await fs_extra_1.default.copy(path_1.default.join(fx, color), path_1.default.join(target, color));
407
- }
408
- if (outline !== "" && (await fs_extra_1.default.pathExists(path_1.default.join(fx, outline)))) {
409
- await fs_extra_1.default.copy(path_1.default.join(fx, outline), path_1.default.join(target, outline));
410
- }
411
- }
412
- }
413
- async function migrateProjectSettings(projectPath) {
414
- const loadRes = await projectSettingsLoader_1.loadProjectSettingsByProjectPath(projectPath, false);
415
- if (loadRes.isErr()) {
416
- throw error_1.ProjectSettingError();
417
- }
418
- const projectSettings = loadRes.value;
419
- if (projectSettingsHelperV3_1.hasAzureResourceV3(projectSettings, true)) {
420
- if (!workflow_1.getComponent(projectSettings, constants_1.ComponentNames.Identity)) {
421
- projectSettings.components.push({ name: constants_1.ComponentNames.Identity });
422
- }
423
- }
424
- return projectSettings;
425
- }
426
- async function migrateMultiEnv(projectPath, log) {
427
- var _a, _b;
428
- const { fx, fxConfig, templateAppPackage, fxState } = await getMultiEnvFolders(projectPath);
429
- const { hasFrontend, hasBackend, hasBot, hasBotCapability, hasMessageExtensionCapability, isSPFx, hasProvision, } = await queryProjectStatus(fx);
430
- //localSettings.json
431
- const localSettingsProvider = new localSettingsProvider_1.LocalSettingsProvider(projectPath);
432
- await localSettingsProvider.save(localSettingsProvider.init(hasFrontend, hasBackend, hasBot));
433
- const projectSettings = await migrateProjectSettings(projectPath);
434
- const projectSettingsPath = projectSettingsLoader_1.getProjectSettingsPath(projectPath);
435
- const configDevJsonFilePath = path_1.default.join(fxConfig, "config.dev.json");
436
- const envDefaultFilePath = path_1.default.join(fx, "env.default.json");
437
- await ensureProjectSettings(projectSettings, envDefaultFilePath);
438
- await fs_extra_1.default.writeFile(projectSettingsPath, JSON.stringify(projectSettings, null, 4));
439
- const appName = projectSettings.appName;
440
- //config.dev.json
441
- const configDev = getConfigDevJson(appName);
442
- // migrate skipAddingSqlUser
443
- const envDefault = await fs_extra_1.default.readJson(envDefaultFilePath);
444
- if ((_a = envDefault[constants_2.ResourcePlugins.AzureSQL]) === null || _a === void 0 ? void 0 : _a[EnvConfigName.SqlSkipAddingUser]) {
445
- configDev["skipAddingSqlUser"] =
446
- envDefault[constants_2.ResourcePlugins.AzureSQL][EnvConfigName.SqlSkipAddingUser];
447
- }
448
- if (((_b = envDefault[constants_2.ResourcePlugins.Aad]) === null || _b === void 0 ? void 0 : _b[EnvConfigName.AadSkipProvision]) === "true") {
449
- configDev.auth = {};
450
- if (envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.OAuthScopeId]) {
451
- configDev.auth.accessAsUserScopeId =
452
- envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.OAuthScopeId];
453
- }
454
- if (envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ObjectId]) {
455
- configDev.auth.objectId = envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ObjectId];
456
- }
457
- if (envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ClientId]) {
458
- configDev.auth.clientId = envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ClientId];
459
- }
460
- if (envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ClientSecret]) {
461
- await globalState_1.globalStateUpdate(AADClientSecretFlag, envDefault[constants_2.ResourcePlugins.Aad][EnvConfigName.ClientSecret]);
462
- configDev.auth.clientSecret = AadSecret;
463
- }
464
- }
465
- await fs_extra_1.default.writeFile(configDevJsonFilePath, JSON.stringify(configDev, null, 4));
466
- // appPackage
467
- await copyManifest(projectPath, fx, templateAppPackage);
468
- const sourceManifestFile = path_1.default.join(templateAppPackage, constants_3.REMOTE_MANIFEST);
469
- const manifest = await getManifest(sourceManifestFile);
470
- await fs_extra_1.default.remove(sourceManifestFile);
471
- // generate manifest.remote.template.json
472
- const targetRemoteManifestFile = path_1.default.join(templateAppPackage, constants_3.MANIFEST_TEMPLATE);
473
- const remoteManifest = await generateRemoteTemplate(JSON.stringify(manifest));
474
- await fs_extra_1.default.writeFile(targetRemoteManifestFile, JSON.stringify(remoteManifest, null, 4));
475
- // generate manifest.local.template.json
476
- const localManifest = await generateLocalTemplate(JSON.stringify(manifest), isSPFx, log);
477
- const targetLocalManifestFile = path_1.default.join(templateAppPackage, constants_3.MANIFEST_LOCAL);
478
- await fs_extra_1.default.writeFile(targetLocalManifestFile, JSON.stringify(localManifest, null, 4));
479
- if (isSPFx) {
480
- const replaceMap = new Map();
481
- const packageSolutionFile = `${projectPath}/SPFx/config/package-solution.json`;
482
- if (!(await fs_extra_1.default.pathExists(packageSolutionFile))) {
483
- throw error_1.SPFxConfigError(packageSolutionFile);
484
- }
485
- const solutionConfig = await fs_extra_1.default.readJson(packageSolutionFile);
486
- replaceMap.set(constants_4.PlaceHolders.componentId, solutionConfig.solution.id);
487
- replaceMap.set(constants_4.PlaceHolders.componentNameUnescaped, localManifest.packageName);
488
- await utils_2.Utils.configure(targetLocalManifestFile, replaceMap);
489
- }
490
- // state.dev.json / dev.userdata
491
- const devState = path_1.default.join(fxState, "state.dev.json");
492
- await fs_extra_1.default.copy(path_1.default.join(fx, "new.env.default.json"), devState);
493
- const devUserData = path_1.default.join(fxState, "dev.userdata");
494
- if (await fs_extra_1.default.pathExists(path_1.default.join(fx, "default.userdata"))) {
495
- await fs_extra_1.default.copy(path_1.default.join(fx, "default.userdata"), devUserData);
496
- }
497
- await removeExpiredFields(devState, devUserData);
498
- return projectSettings;
499
- }
500
- class LocalDebugConfigKeys {
501
- }
502
- exports.LocalDebugConfigKeys = LocalDebugConfigKeys;
503
- LocalDebugConfigKeys.LocalAuthEndpoint = "localAuthEndpoint";
504
- LocalDebugConfigKeys.LocalTabEndpoint = "localTabEndpoint";
505
- LocalDebugConfigKeys.LocalTabDomain = "localTabDomain";
506
- LocalDebugConfigKeys.TrustDevelopmentCertificate = "trustDevCert";
507
- LocalDebugConfigKeys.LocalFunctionEndpoint = "localFunctionEndpoint";
508
- LocalDebugConfigKeys.LocalBotEndpoint = "localBotEndpoint";
509
- LocalDebugConfigKeys.LocalBotDomain = "localBotDomain";
510
- async function removeExpiredFields(devState, devUserData) {
511
- const stateData = await fs_extra_1.default.readJson(devState);
512
- if (stateData[constants_1.PluginNames.SOLUTION] && stateData[constants_1.PluginNames.SOLUTION]["remoteTeamsAppId"]) {
513
- stateData[constants_1.PluginNames.APPST]["teamsAppId"] =
514
- stateData[constants_1.PluginNames.SOLUTION]["remoteTeamsAppId"];
515
- }
516
- const expiredStateKeys = [
517
- [constants_1.PluginNames.LDEBUG, ""],
518
- // for version 2.0.1
519
- [constants_1.PluginNames.FUNC, defaultFunctionName],
520
- [constants_1.PluginNames.SOLUTION, programmingLanguage],
521
- [constants_1.PluginNames.SOLUTION, defaultFunctionName],
522
- [constants_1.PluginNames.SOLUTION, "localDebugTeamsAppId"],
523
- [constants_1.PluginNames.SOLUTION, "remoteTeamsAppId"],
524
- [constants_1.PluginNames.AAD, "local_clientId"],
525
- [constants_1.PluginNames.AAD, "local_objectId"],
526
- [constants_1.PluginNames.AAD, "local_tenantId"],
527
- [constants_1.PluginNames.AAD, "local_clientSecret"],
528
- [constants_1.PluginNames.AAD, "local_oauth2PermissionScopeId"],
529
- [constants_1.PluginNames.AAD, "local_applicationIdUris"],
530
- [constants_1.PluginNames.SA, "filePath"],
531
- [constants_1.PluginNames.SA, "environmentVariableParams"],
532
- ];
533
- for (const [k, v] of expiredStateKeys) {
534
- if (stateData[k]) {
535
- if (!v) {
536
- delete stateData[k];
537
- }
538
- else if (stateData[k][v]) {
539
- delete stateData[k][v];
540
- }
541
- }
542
- }
543
- await fs_extra_1.default.writeFile(devState, JSON.stringify(stateData, null, 4), { encoding: "UTF-8" });
544
- if (await fs_extra_1.default.pathExists(devUserData)) {
545
- const secrets = dotenv.parse(await fs_extra_1.default.readFile(devUserData, "UTF-8"));
546
- for (const [_, value] of Object.entries(LocalDebugConfigKeys)) {
547
- deleteUserDataKey(secrets, `${constants_1.PluginNames.LDEBUG}.${value}`);
548
- }
549
- deleteUserDataKey(secrets, `${constants_1.PluginNames.AAD}.local_clientSecret`);
550
- await fs_extra_1.default.writeFile(devUserData, tools_1.serializeDict(secrets), { encoding: "UTF-8" });
551
- }
552
- }
553
- function deleteUserDataKey(secrets, key) {
554
- if (secrets[key]) {
555
- delete secrets[key];
556
- }
557
- }
558
- function getConfigDevJson(appName) {
559
- return environment_1.environmentManager.newEnvConfigData(appName);
560
- }
561
- async function queryProjectStatus(fx) {
562
- var _a;
563
- const settings = await fs_extra_1.default.readJson(path_1.default.join(fx, "settings.json"));
564
- const settingsV3 = migrate_1.convertProjectSettingsV2ToV3(settings, "");
565
- const envDefaultJson = await fs_extra_1.default.readJson(path_1.default.join(fx, "env.default.json"));
566
- const hasFrontend = projectSettingsHelperV3_1.hasAzureTab(settingsV3);
567
- const hasBackend = projectSettingsHelperV3_1.hasApi(settingsV3);
568
- const hasBot = projectSettingsHelperV3_1.hasBot(settingsV3);
569
- const hasBotCapability = settings.solutionSettings.capabilities.includes(constants_1.BotOptionItem().id);
570
- const hasMessageExtensionCapability = settings.solutionSettings.capabilities.includes(constants_1.MessageExtensionItem().id);
571
- const isSPFx = projectSettingsHelperV3_1.hasSPFxTab(settingsV3);
572
- const hasProvision = (_a = envDefaultJson.solution) === null || _a === void 0 ? void 0 : _a.provisionSucceeded;
573
- return {
574
- hasFrontend,
575
- hasBackend,
576
- hasBot,
577
- hasBotCapability,
578
- hasMessageExtensionCapability,
579
- isSPFx,
580
- hasProvision,
581
- };
582
- }
583
- async function getMultiEnvFolders(projectPath) {
584
- const fx = path_1.default.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
585
- const fxConfig = path_1.default.join(fx, teamsfx_api_1.InputConfigsFolderName);
586
- const templateAppPackage = path_1.default.join(await utils_3.getProjectTemplatesFolderPath(projectPath), teamsfx_api_1.AppPackageFolderName);
587
- const fxState = path_1.default.join(fx, teamsfx_api_1.StatesFolderName);
588
- await fs_extra_1.default.ensureDir(fxConfig);
589
- await fs_extra_1.default.ensureDir(templateAppPackage);
590
- return { fx, fxConfig, templateAppPackage, fxState };
591
- }
592
- async function getBackupFolder(projectPath) {
593
- const backupName = ".backup";
594
- const backupPath = path_1.default.join(projectPath, backupName);
595
- if (!(await fs_extra_1.default.pathExists(backupPath))) {
596
- return backupPath;
597
- }
598
- // avoid conflict(rarely)
599
- return path_1.default.join(projectPath, `.teamsfx${backupName}`);
600
- }
601
- async function backup(projectPath, backupFolder) {
602
- const fx = path_1.default.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
603
- const backupFx = path_1.default.join(backupFolder, `.${teamsfx_api_1.ConfigFolderName}`);
604
- const backupAppPackage = path_1.default.join(backupFolder, teamsfx_api_1.AppPackageFolderName);
605
- await fs_extra_1.default.ensureDir(backupFx);
606
- await fs_extra_1.default.ensureDir(backupAppPackage);
607
- const fxFiles = [
608
- "env.default.json",
609
- "default.userdata",
610
- "settings.json",
611
- "local.env",
612
- "subscriptionInfo.json",
613
- ];
614
- for (const file of fxFiles) {
615
- if (await fs_extra_1.default.pathExists(path_1.default.join(fx, file))) {
616
- await fs_extra_1.default.copy(path_1.default.join(fx, file), path_1.default.join(backupFx, file));
617
- }
618
- }
619
- await copyManifest(projectPath, fx, backupAppPackage);
620
- }
621
- // append folder path to .gitignore under the project root.
622
- async function addPathToGitignore(projectPath, ignoredPath, log) {
623
- const relativePath = path_1.default.relative(projectPath, ignoredPath).replace(/\\/g, "/");
624
- await addItemToGitignore(projectPath, relativePath, log);
625
- }
626
- exports.addPathToGitignore = addPathToGitignore;
627
- // append item to .gitignore under the project root.
628
- async function addItemToGitignore(projectPath, item, log) {
629
- const gitignorePath = path_1.default.join(projectPath, gitignoreFileName);
630
- try {
631
- await fs_extra_1.default.ensureFile(gitignorePath);
632
- const gitignoreContent = await fs_extra_1.default.readFile(gitignorePath, "UTF-8");
633
- if (gitignoreContent.indexOf(item) === -1) {
634
- const appendedContent = os_1.default.EOL + item;
635
- await fs_extra_1.default.appendFile(gitignorePath, appendedContent);
636
- }
637
- }
638
- catch (_a) {
639
- log.warning(`[core] Failed to add '${item}' to '${gitignorePath}', please do it manually.`);
640
- }
641
- }
642
- async function removeOldProjectFiles(projectPath) {
643
- const fx = path_1.default.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
644
- await fs_extra_1.default.remove(path_1.default.join(fx, "env.default.json"));
645
- await fs_extra_1.default.remove(path_1.default.join(fx, "default.userdata"));
646
- await fs_extra_1.default.remove(path_1.default.join(fx, "settings.json"));
647
- await fs_extra_1.default.remove(path_1.default.join(fx, "local.env"));
648
- await fs_extra_1.default.remove(path_1.default.join(projectPath, teamsfx_api_1.AppPackageFolderName));
649
- await fs_extra_1.default.remove(path_1.default.join(fx, "new.env.default.json"));
650
- // version <= 2.4.1, remove .fx/appPackage.
651
- await fs_extra_1.default.remove(path_1.default.join(fx, teamsfx_api_1.AppPackageFolderName));
652
- // version <= 3.2.1
653
- await fs_extra_1.default.remove(path_1.default.join(fx, constants_3.REMOTE_MANIFEST));
654
- await fs_extra_1.default.remove(path_1.default.join(fx, "color.png"));
655
- await fs_extra_1.default.remove(path_1.default.join(fx, "outline.png"));
656
- }
657
- async function ensureProjectSettings(settings, envDefaultPath) {
658
- var _a, _b;
659
- if (!settings.programmingLanguage || !settings.defaultFunctionName) {
660
- const envDefault = await fs_extra_1.default.readJson(envDefaultPath);
661
- settings.programmingLanguage =
662
- settings.programmingLanguage || ((_a = envDefault[constants_1.PluginNames.SOLUTION]) === null || _a === void 0 ? void 0 : _a[programmingLanguage]);
663
- settings.defaultFunctionName =
664
- settings.defaultFunctionName || ((_b = envDefault[constants_1.PluginNames.FUNC]) === null || _b === void 0 ? void 0 : _b[defaultFunctionName]);
665
- }
666
- settings.version = "2.0.0";
667
- }
668
- async function cleanup(projectPath, backupFolder) {
669
- const { _, fxConfig, templateAppPackage, fxState } = await getMultiEnvFolders(projectPath);
670
- await fs_extra_1.default.remove(fxConfig);
671
- await fs_extra_1.default.remove(templateAppPackage);
672
- await fs_extra_1.default.remove(fxState);
673
- await fs_extra_1.default.remove(path_1.default.join(templateAppPackage, ".."));
674
- if (await fs_extra_1.default.pathExists(path_1.default.join(fxConfig, "..", "new.env.default.json"))) {
675
- await fs_extra_1.default.remove(path_1.default.join(fxConfig, "..", "new.env.default.json"));
676
- }
677
- if (backupFolder) {
678
- await fs_extra_1.default.remove(backupFolder);
679
- }
680
- }
681
- async function needMigrateToArmAndMultiEnv(ctx) {
682
- const inputs = ctx.arguments[ctx.arguments.length - 1];
683
- if (!inputs.projectPath) {
684
- return false;
685
- }
686
- const fxExist = await fs_extra_1.default.pathExists(path_1.default.join(inputs.projectPath, ".fx"));
687
- if (!fxExist) {
688
- return false;
689
- }
690
- const parameterEnvFileName = parameterFileNameTemplate.replace("@envName", environment_1.environmentManager.getDefaultEnvName());
691
- const envFileExist = await fs_extra_1.default.pathExists(path_1.default.join(inputs.projectPath, ".fx", "env.default.json"));
692
- const configDirExist = await fs_extra_1.default.pathExists(path_1.default.join(inputs.projectPath, ".fx", "configs"));
693
- const armParameterExist = await fs_extra_1.default.pathExists(path_1.default.join(inputs.projectPath, ".fx", "configs", parameterEnvFileName));
694
- if (envFileExist && (!armParameterExist || !configDirExist)) {
695
- return true;
696
- }
697
- return false;
698
- }
699
- exports.needMigrateToArmAndMultiEnv = needMigrateToArmAndMultiEnv;
700
- async function migrateArm(ctx) {
701
- await generateArmTemplatesFiles(ctx);
702
- await generateArmParameterJson(ctx);
703
- }
704
- exports.migrateArm = migrateArm;
705
- async function updateConfig(ctx) {
706
- var _a, _b, _c, _d, _e, _f, _g, _h;
707
- const inputs = ctx.arguments[ctx.arguments.length - 1];
708
- const fx = path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
709
- const envConfig = await fs_extra_1.default.readJson(path_1.default.join(fx, "env.default.json"));
710
- if (envConfig[constants_2.ResourcePlugins.Bot]) {
711
- delete envConfig[constants_2.ResourcePlugins.Bot];
712
- envConfig[constants_2.ResourcePlugins.Bot] = { wayToRegisterBot: "create-new" };
713
- envConfig.solution.provisionSucceeded = false;
714
- }
715
- let needUpdate = false;
716
- let configPrefix = "";
717
- if (envConfig[solutionName][subscriptionId] && envConfig[solutionName][resourceGroupName]) {
718
- configPrefix = `/subscriptions/${envConfig[solutionName][subscriptionId]}/resourcegroups/${envConfig[solutionName][resourceGroupName]}`;
719
- needUpdate = true;
720
- }
721
- if (needUpdate && ((_a = envConfig[constants_2.ResourcePlugins.FrontendHosting]) === null || _a === void 0 ? void 0 : _a[EnvConfigName.StorageName])) {
722
- envConfig[constants_2.ResourcePlugins.FrontendHosting][EnvConfigName.StorageResourceId] = `${configPrefix}/providers/Microsoft.Storage/storageAccounts/${envConfig[constants_2.ResourcePlugins.FrontendHosting][EnvConfigName.StorageName]}`;
723
- }
724
- if (needUpdate && ((_b = envConfig[constants_2.ResourcePlugins.AzureSQL]) === null || _b === void 0 ? void 0 : _b[EnvConfigName.SqlEndpoint])) {
725
- envConfig[constants_2.ResourcePlugins.AzureSQL][EnvConfigName.SqlResourceId] = `${configPrefix}/providers/Microsoft.Sql/servers/${envConfig[constants_2.ResourcePlugins.AzureSQL][EnvConfigName.SqlEndpoint].split(".database.windows.net")[0]}`;
726
- }
727
- if (needUpdate && ((_c = envConfig[constants_2.ResourcePlugins.Function]) === null || _c === void 0 ? void 0 : _c[EnvConfigName.FuncAppName])) {
728
- envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.FunctionAppResourceId] = `${configPrefix}/providers/Microsoft.Web/sites/${envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.FuncAppName]}`;
729
- delete envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.FuncAppName];
730
- if (envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.StorageAccountName]) {
731
- delete envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.StorageAccountName];
732
- }
733
- if (envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.AppServicePlanName]) {
734
- delete envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.AppServicePlanName];
735
- }
736
- }
737
- if (needUpdate && ((_d = envConfig[constants_2.ResourcePlugins.Identity]) === null || _d === void 0 ? void 0 : _d[EnvConfigName.Identity])) {
738
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityResourceId] = `${configPrefix}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/${envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.Identity]}`;
739
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityName] =
740
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.Identity];
741
- delete envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.Identity];
742
- }
743
- if (needUpdate && ((_e = envConfig[constants_2.ResourcePlugins.Identity]) === null || _e === void 0 ? void 0 : _e[EnvConfigName.IdentityId])) {
744
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityClientId] =
745
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityId];
746
- delete envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityId];
747
- }
748
- if (needUpdate && ((_f = envConfig[constants_2.ResourcePlugins.Apim]) === null || _f === void 0 ? void 0 : _f[EnvConfigName.ServiceName])) {
749
- envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ServiceResourceId] = `${configPrefix}/providers/Microsoft.ApiManagement/service/${envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ServiceName]}`;
750
- delete envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ServiceName];
751
- if ((_g = envConfig[constants_2.ResourcePlugins.Apim]) === null || _g === void 0 ? void 0 : _g[EnvConfigName.ProductId]) {
752
- envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ProductResourceId] = `${envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ServiceResourceId]}/products/${envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ProductId]}`;
753
- delete envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ProductId];
754
- }
755
- if ((_h = envConfig[constants_2.ResourcePlugins.Apim]) === null || _h === void 0 ? void 0 : _h[EnvConfigName.OAuthServerId]) {
756
- envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.AuthServerResourceId] = `${envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.ServiceResourceId]}/authorizationServers/${envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.OAuthServerId]}`;
757
- delete envConfig[constants_2.ResourcePlugins.Apim][EnvConfigName.OAuthServerId];
758
- }
759
- }
760
- await fs_extra_1.default.writeFile(path_1.default.join(fx, "new.env.default.json"), JSON.stringify(envConfig, null, 4));
761
- }
762
- async function generateBicepsV3(projectSettings, inputs) {
763
- //init bicep folder
764
- {
765
- const bicepComponent = typedi_1.Container.get("bicep");
766
- const res = await bicepComponent.init(inputs.projectPath);
767
- if (res.isErr())
768
- return teamsfx_api_1.err(res.error);
769
- }
770
- const biceps = [];
771
- const context = utils_4.createContextV3(projectSettings);
772
- // teams-tab
773
- {
774
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.TeamsTab);
775
- if (config) {
776
- const hosting = config.hosting || constants_1.ComponentNames.AzureStorage;
777
- const hostingComponent = typedi_1.Container.get(hosting);
778
- const clonedInputs = lodash_1.cloneDeep(inputs);
779
- lodash_1.assign(clonedInputs, {
780
- componentId: constants_1.ComponentNames.TeamsTab,
781
- scenario: constants_1.Scenarios.Tab,
782
- });
783
- const res = await hostingComponent.generateBicep(context, clonedInputs);
784
- if (res.isErr())
785
- return teamsfx_api_1.err(res.error);
786
- res.value.forEach((b) => biceps.push(b));
787
- }
788
- }
789
- // teams-bot
790
- {
791
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.TeamsBot);
792
- if (config) {
793
- // bot hosting
794
- const hosting = config.hosting || constants_1.ComponentNames.AzureWebApp;
795
- {
796
- const hostingComponent = typedi_1.Container.get(hosting);
797
- const clonedInputs = lodash_1.cloneDeep(inputs);
798
- lodash_1.assign(clonedInputs, {
799
- componentId: constants_1.ComponentNames.TeamsBot,
800
- scenario: constants_1.Scenarios.Bot,
801
- });
802
- const res = await hostingComponent.generateBicep(context, clonedInputs);
803
- if (res.isErr())
804
- return teamsfx_api_1.err(res.error);
805
- res.value.forEach((b) => biceps.push(b));
806
- }
807
- // bot service
808
- {
809
- const clonedInputs = lodash_1.cloneDeep(inputs);
810
- lodash_1.assign(clonedInputs, {
811
- hosting: hosting,
812
- scenario: constants_1.Scenarios.Bot,
813
- });
814
- const botService = typedi_1.Container.get(constants_1.ComponentNames.BotService);
815
- const res = await botService.generateBicep(context, clonedInputs);
816
- if (res.isErr())
817
- return teamsfx_api_1.err(res.error);
818
- res.value.forEach((b) => biceps.push(b));
819
- }
820
- }
821
- }
822
- // teams-api
823
- {
824
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.TeamsApi);
825
- if (config) {
826
- const clonedInputs = lodash_1.cloneDeep(inputs);
827
- lodash_1.assign(clonedInputs, {
828
- componentId: constants_1.ComponentNames.TeamsApi,
829
- hosting: constants_1.ComponentNames.Function,
830
- scenario: constants_1.Scenarios.Api,
831
- });
832
- const functionComponent = typedi_1.Container.get(constants_1.ComponentNames.Function);
833
- const res = await functionComponent.generateBicep(context, clonedInputs);
834
- if (res.isErr())
835
- return teamsfx_api_1.err(res.error);
836
- res.value.forEach((b) => biceps.push(b));
837
- }
838
- }
839
- // identity
840
- {
841
- const identity = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.Identity);
842
- if (identity) {
843
- const clonedInputs = lodash_1.cloneDeep(inputs);
844
- lodash_1.assign(clonedInputs, {
845
- componentId: "",
846
- scenario: "",
847
- });
848
- const identityComponent = typedi_1.Container.get(constants_1.ComponentNames.Identity);
849
- const res = await identityComponent.generateBicep(context, clonedInputs);
850
- if (res.isErr())
851
- return teamsfx_api_1.err(res.error);
852
- res.value.forEach((b) => biceps.push(b));
853
- }
854
- }
855
- // apim
856
- {
857
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.APIM);
858
- if (config) {
859
- const resource = typedi_1.Container.get(constants_1.ComponentNames.APIM);
860
- const res = await resource.generateBicep(context, inputs);
861
- if (res.isErr())
862
- return teamsfx_api_1.err(res.error);
863
- res.value.forEach((b) => biceps.push(b));
864
- }
865
- }
866
- // keyvault
867
- {
868
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.KeyVault);
869
- if (config) {
870
- const resource = typedi_1.Container.get(constants_1.ComponentNames.KeyVault);
871
- const res = await resource.generateBicep(context, inputs);
872
- if (res.isErr())
873
- return teamsfx_api_1.err(res.error);
874
- res.value.forEach((b) => biceps.push(b));
875
- }
876
- }
877
- // sql
878
- {
879
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.AzureSQL);
880
- if (config) {
881
- const provisionType = "server";
882
- const clonedInputs = lodash_1.cloneDeep(inputs);
883
- clonedInputs.provisionType = provisionType;
884
- const sqlResource = typedi_1.Container.get(constants_1.ComponentNames.AzureSQL);
885
- const res = await sqlResource.generateBicep(context, clonedInputs);
886
- if (res.isErr())
887
- return teamsfx_api_1.err(res.error);
888
- res.value.forEach((b) => biceps.push(b));
889
- }
890
- }
891
- // aad
892
- {
893
- const config = workflow_1.getComponent(projectSettings, constants_1.ComponentNames.AadApp);
894
- if (config) {
895
- const aadApp = typedi_1.Container.get(constants_1.ComponentNames.AadApp);
896
- const res = await aadApp.generateBicep(context, inputs);
897
- if (res.isErr())
898
- return teamsfx_api_1.err(res.error);
899
- res.value.forEach((b) => biceps.push(b));
900
- }
901
- }
902
- // persist bicep
903
- {
904
- const bicepRes = await utils_4.bicepUtils.persistBiceps(inputs.projectPath, utils_3.convertToAlphanumericOnly(context.projectSetting.appName), biceps);
905
- if (bicepRes.isErr())
906
- return bicepRes;
907
- }
908
- // generate config bicep
909
- {
910
- const res = await utils_4.generateConfigBiceps(context, inputs);
911
- if (res.isErr())
912
- return teamsfx_api_1.err(res.error);
913
- }
914
- return teamsfx_api_1.ok(undefined);
915
- }
916
- exports.generateBicepsV3 = generateBicepsV3;
917
- async function generateArmTemplatesFiles(ctx) {
918
- const inputs = ctx.arguments[ctx.arguments.length - 1];
919
- const fx = path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
920
- const fxConfig = path_1.default.join(fx, teamsfx_api_1.InputConfigsFolderName);
921
- const templateAzure = path_1.default.join(inputs.projectPath, "templates", "azure");
922
- await fs_extra_1.default.ensureDir(fxConfig);
923
- await fs_extra_1.default.ensureDir(templateAzure);
924
- let projectSettings = ctx.projectSettings;
925
- if (!projectSettings) {
926
- projectSettings = await migrateProjectSettings(inputs.projectPath);
927
- }
928
- const genRes = await generateBicepsV3(projectSettings, inputs);
929
- if (genRes.isErr())
930
- throw genRes.error;
931
- const parameterEnvFileName = parameterFileNameTemplate.replace("@envName", environment_1.environmentManager.getDefaultEnvName());
932
- if (!(await fs_extra_1.default.pathExists(path_1.default.join(fxConfig, parameterEnvFileName)))) {
933
- throw new teamsfx_api_1.SystemError(error_1.CoreSource, "GenerateArmTemplateFailed", `Failed to generate ${parameterEnvFileName} on migration`);
934
- }
935
- }
936
- async function generateArmParameterJson(ctx) {
937
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
938
- const inputs = ctx.arguments[ctx.arguments.length - 1];
939
- const fx = path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`);
940
- const fxConfig = path_1.default.join(fx, teamsfx_api_1.InputConfigsFolderName);
941
- const envConfig = await fs_extra_1.default.readJson(path_1.default.join(fx, "env.default.json"));
942
- const parameterEnvFileName = parameterFileNameTemplate.replace("@envName", environment_1.environmentManager.getDefaultEnvName());
943
- const targetJson = await fs_extra_1.default.readJson(path_1.default.join(fxConfig, parameterEnvFileName));
944
- const parameterObj = targetJson["parameters"]["provisionParameters"]["value"];
945
- // frontend hosting
946
- if ((_a = envConfig[constants_2.ResourcePlugins.FrontendHosting]) === null || _a === void 0 ? void 0 : _a[EnvConfigName.StorageName]) {
947
- parameterObj[ArmParameters.FEStorageName] =
948
- envConfig[constants_2.ResourcePlugins.FrontendHosting][EnvConfigName.StorageName];
949
- }
950
- // manage identity
951
- if ((_b = envConfig[constants_2.ResourcePlugins.Identity]) === null || _b === void 0 ? void 0 : _b[EnvConfigName.Identity]) {
952
- // Teams Toolkit <= 2.7
953
- parameterObj[ArmParameters.IdentityName] =
954
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.Identity];
955
- }
956
- else if ((_c = envConfig[constants_2.ResourcePlugins.Identity]) === null || _c === void 0 ? void 0 : _c[EnvConfigName.IdentityName]) {
957
- // Teams Toolkit >= 2.8
958
- parameterObj[ArmParameters.IdentityName] =
959
- envConfig[constants_2.ResourcePlugins.Identity][EnvConfigName.IdentityName];
960
- }
961
- // azure SQL
962
- if ((_d = envConfig[constants_2.ResourcePlugins.AzureSQL]) === null || _d === void 0 ? void 0 : _d[EnvConfigName.SqlEndpoint]) {
963
- parameterObj[ArmParameters.SQLServer] =
964
- envConfig[constants_2.ResourcePlugins.AzureSQL][EnvConfigName.SqlEndpoint].split(".database.windows.net")[0];
965
- }
966
- if ((_e = envConfig[constants_2.ResourcePlugins.AzureSQL]) === null || _e === void 0 ? void 0 : _e[EnvConfigName.SqlDataBase]) {
967
- parameterObj[ArmParameters.SQLDatabase] =
968
- envConfig[constants_2.ResourcePlugins.AzureSQL][EnvConfigName.SqlDataBase];
969
- }
970
- // SimpleAuth
971
- if ((_f = envConfig[constants_2.ResourcePlugins.SimpleAuth]) === null || _f === void 0 ? void 0 : _f[EnvConfigName.SkuName]) {
972
- parameterObj[ArmParameters.SimpleAuthSku] =
973
- envConfig[constants_2.ResourcePlugins.SimpleAuth][EnvConfigName.SkuName];
974
- }
975
- if ((_g = envConfig[constants_2.ResourcePlugins.SimpleAuth]) === null || _g === void 0 ? void 0 : _g[EnvConfigName.Endpoint]) {
976
- const simpleAuthHost = new URL((_h = envConfig[constants_2.ResourcePlugins.SimpleAuth]) === null || _h === void 0 ? void 0 : _h[EnvConfigName.Endpoint])
977
- .hostname;
978
- const simpleAuthName = simpleAuthHost.split(".")[0];
979
- parameterObj[ArmParameters.SimpleAuthWebAppName] = parameterObj[ArmParameters.SimpleAuthServerFarm] = simpleAuthName;
980
- }
981
- // Function
982
- if ((_j = envConfig[constants_2.ResourcePlugins.Function]) === null || _j === void 0 ? void 0 : _j[EnvConfigName.AppServicePlanName]) {
983
- parameterObj[ArmParameters.functionServerName] =
984
- envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.AppServicePlanName];
985
- }
986
- if ((_k = envConfig[constants_2.ResourcePlugins.Function]) === null || _k === void 0 ? void 0 : _k[EnvConfigName.StorageAccountName]) {
987
- parameterObj[ArmParameters.functionStorageName] =
988
- envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.StorageAccountName];
989
- }
990
- if ((_l = envConfig[constants_2.ResourcePlugins.Function]) === null || _l === void 0 ? void 0 : _l[EnvConfigName.FuncAppName]) {
991
- parameterObj[ArmParameters.functionAppName] =
992
- envConfig[constants_2.ResourcePlugins.Function][EnvConfigName.FuncAppName];
993
- }
994
- // Bot
995
- if ((_m = envConfig[constants_2.ResourcePlugins.Bot]) === null || _m === void 0 ? void 0 : _m[EnvConfigName.SkuName]) {
996
- parameterObj[ArmParameters.botWebAppSku] =
997
- (_o = envConfig[constants_2.ResourcePlugins.Bot]) === null || _o === void 0 ? void 0 : _o[EnvConfigName.SkuName];
998
- }
999
- // Apim
1000
- if ((_p = envConfig[constants_2.ResourcePlugins.Apim]) === null || _p === void 0 ? void 0 : _p[EnvConfigName.ServiceName]) {
1001
- parameterObj[ArmParameters.ApimServiceName] =
1002
- (_q = envConfig[constants_2.ResourcePlugins.Apim]) === null || _q === void 0 ? void 0 : _q[EnvConfigName.ServiceName];
1003
- }
1004
- if ((_r = envConfig[constants_2.ResourcePlugins.Apim]) === null || _r === void 0 ? void 0 : _r[EnvConfigName.ProductId]) {
1005
- parameterObj[ArmParameters.ApimProductName] =
1006
- (_s = envConfig[constants_2.ResourcePlugins.Apim]) === null || _s === void 0 ? void 0 : _s[EnvConfigName.ProductId];
1007
- }
1008
- if ((_t = envConfig[constants_2.ResourcePlugins.Apim]) === null || _t === void 0 ? void 0 : _t[EnvConfigName.OAuthServerId]) {
1009
- parameterObj[ArmParameters.ApimOauthServerName] =
1010
- (_u = envConfig[constants_2.ResourcePlugins.Apim]) === null || _u === void 0 ? void 0 : _u[EnvConfigName.OAuthServerId];
1011
- }
1012
- await fs_extra_1.default.writeFile(path_1.default.join(fxConfig, parameterEnvFileName), JSON.stringify(targetJson, null, 4));
1013
- }
1014
- //# sourceMappingURL=projectMigrator.js.map