@microsoft/teamsfx-core 1.5.0 → 1.5.1-alpha.142fe332a.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 (308) hide show
  1. package/build/common/constants.d.ts +2 -0
  2. package/build/common/constants.d.ts.map +1 -1
  3. package/build/common/constants.js +2 -0
  4. package/build/common/constants.js.map +1 -1
  5. package/build/common/index.d.ts +1 -0
  6. package/build/common/index.d.ts.map +1 -1
  7. package/build/common/index.js +1 -0
  8. package/build/common/index.js.map +1 -1
  9. package/build/common/projectSettingsHelper.d.ts +11 -0
  10. package/build/common/projectSettingsHelper.d.ts.map +1 -0
  11. package/build/common/projectSettingsHelper.js +134 -0
  12. package/build/common/projectSettingsHelper.js.map +1 -0
  13. package/build/common/template-utils/templatesActions.d.ts.map +1 -1
  14. package/build/common/template-utils/templatesActions.js +3 -2
  15. package/build/common/template-utils/templatesActions.js.map +1 -1
  16. package/build/common/templates-config.json +2 -2
  17. package/build/common/tools.d.ts +5 -1
  18. package/build/common/tools.d.ts.map +1 -1
  19. package/build/common/tools.js +40 -1
  20. package/build/common/tools.js.map +1 -1
  21. package/build/core/FxCore.d.ts +78 -0
  22. package/build/core/FxCore.d.ts.map +1 -0
  23. package/build/core/FxCore.js +1334 -0
  24. package/build/core/FxCore.js.map +1 -0
  25. package/build/core/SolutionPluginContainer.d.ts.map +1 -1
  26. package/build/core/SolutionPluginContainer.js.map +1 -1
  27. package/build/core/collaborator.d.ts +1 -4
  28. package/build/core/collaborator.d.ts.map +1 -1
  29. package/build/core/collaborator.js +9 -45
  30. package/build/core/collaborator.js.map +1 -1
  31. package/build/core/downloadSample.d.ts +2 -2
  32. package/build/core/downloadSample.d.ts.map +1 -1
  33. package/build/core/downloadSample.js +4 -3
  34. package/build/core/downloadSample.js.map +1 -1
  35. package/build/core/environment.d.ts +2 -0
  36. package/build/core/environment.d.ts.map +1 -1
  37. package/build/core/environment.js +49 -21
  38. package/build/core/environment.js.map +1 -1
  39. package/build/core/globalVars.d.ts +9 -0
  40. package/build/core/globalVars.d.ts.map +1 -0
  41. package/build/core/globalVars.js +33 -0
  42. package/build/core/globalVars.js.map +1 -0
  43. package/build/core/index.d.ts +4 -101
  44. package/build/core/index.d.ts.map +1 -1
  45. package/build/core/index.js +5 -1377
  46. package/build/core/index.js.map +1 -1
  47. package/build/core/middleware/concurrentLocker.d.ts +1 -0
  48. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  49. package/build/core/middleware/concurrentLocker.js +14 -9
  50. package/build/core/middleware/concurrentLocker.js.map +1 -1
  51. package/build/core/middleware/envInfoLoader.d.ts +1 -1
  52. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  53. package/build/core/middleware/envInfoLoader.js +24 -17
  54. package/build/core/middleware/envInfoLoader.js.map +1 -1
  55. package/build/core/middleware/envInfoLoaderV3.d.ts.map +1 -1
  56. package/build/core/middleware/envInfoLoaderV3.js +1 -2
  57. package/build/core/middleware/envInfoLoaderV3.js.map +1 -1
  58. package/build/core/middleware/envInfoWriter.d.ts.map +1 -1
  59. package/build/core/middleware/envInfoWriter.js +2 -2
  60. package/build/core/middleware/envInfoWriter.js.map +1 -1
  61. package/build/core/middleware/envInfoWriterV3.d.ts.map +1 -1
  62. package/build/core/middleware/envInfoWriterV3.js +2 -2
  63. package/build/core/middleware/envInfoWriterV3.js.map +1 -1
  64. package/build/core/middleware/errorHandler.d.ts.map +1 -1
  65. package/build/core/middleware/errorHandler.js +3 -5
  66. package/build/core/middleware/errorHandler.js.map +1 -1
  67. package/build/core/middleware/localSettingsLoader.js +2 -3
  68. package/build/core/middleware/localSettingsLoader.js.map +1 -1
  69. package/build/core/middleware/localSettingsWriter.d.ts.map +1 -1
  70. package/build/core/middleware/localSettingsWriter.js +4 -4
  71. package/build/core/middleware/localSettingsWriter.js.map +1 -1
  72. package/build/core/middleware/projectMigrator.d.ts +1 -1
  73. package/build/core/middleware/projectMigrator.d.ts.map +1 -1
  74. package/build/core/middleware/projectMigrator.js +51 -56
  75. package/build/core/middleware/projectMigrator.js.map +1 -1
  76. package/build/core/middleware/projectSettingsLoader.d.ts +1 -1
  77. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  78. package/build/core/middleware/projectSettingsLoader.js +8 -6
  79. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  80. package/build/core/middleware/projectSettingsWriter.js +2 -2
  81. package/build/core/middleware/projectSettingsWriter.js.map +1 -1
  82. package/build/core/middleware/questionModel.d.ts.map +1 -1
  83. package/build/core/middleware/questionModel.js +33 -35
  84. package/build/core/middleware/questionModel.js.map +1 -1
  85. package/build/core/middleware/solutionLoader.d.ts +1 -1
  86. package/build/core/middleware/solutionLoader.d.ts.map +1 -1
  87. package/build/core/middleware/solutionLoader.js.map +1 -1
  88. package/build/core/middleware/solutionLoaderV3.d.ts +1 -1
  89. package/build/core/middleware/solutionLoaderV3.d.ts.map +1 -1
  90. package/build/core/middleware/solutionLoaderV3.js.map +1 -1
  91. package/build/core/question.d.ts.map +1 -1
  92. package/build/core/question.js +8 -8
  93. package/build/core/question.js.map +1 -1
  94. package/build/core/types.d.ts +14 -0
  95. package/build/core/types.d.ts.map +1 -0
  96. package/build/core/types.js +5 -0
  97. package/build/core/types.js.map +1 -0
  98. package/build/plugins/resource/aad/aadAppClient.d.ts.map +1 -1
  99. package/build/plugins/resource/aad/aadAppClient.js +8 -9
  100. package/build/plugins/resource/aad/aadAppClient.js.map +1 -1
  101. package/build/plugins/resource/aad/appStudio.js +2 -2
  102. package/build/plugins/resource/aad/appStudio.js.map +1 -1
  103. package/build/plugins/resource/aad/permissions/index.d.ts +5 -0
  104. package/build/plugins/resource/aad/permissions/index.d.ts.map +1 -0
  105. package/build/plugins/resource/aad/permissions/index.js +38 -0
  106. package/build/plugins/resource/aad/permissions/index.js.map +1 -0
  107. package/build/plugins/resource/aad/plugin.d.ts.map +1 -1
  108. package/build/plugins/resource/aad/plugin.js +21 -22
  109. package/build/plugins/resource/aad/plugin.js.map +1 -1
  110. package/build/plugins/resource/aad/utils/configs.d.ts +18 -1
  111. package/build/plugins/resource/aad/utils/configs.d.ts.map +1 -1
  112. package/build/plugins/resource/aad/utils/configs.js +128 -7
  113. package/build/plugins/resource/aad/utils/configs.js.map +1 -1
  114. package/build/plugins/resource/aad/utils/telemetry.js +3 -3
  115. package/build/plugins/resource/aad/utils/telemetry.js.map +1 -1
  116. package/build/plugins/resource/aad/v3/index.d.ts +1 -5
  117. package/build/plugins/resource/aad/v3/index.d.ts.map +1 -1
  118. package/build/plugins/resource/aad/v3/index.js +8 -42
  119. package/build/plugins/resource/aad/v3/index.js.map +1 -1
  120. package/build/plugins/resource/appstudio/appStudio.js +2 -2
  121. package/build/plugins/resource/appstudio/appStudio.js.map +1 -1
  122. package/build/plugins/resource/appstudio/constants.d.ts +9 -0
  123. package/build/plugins/resource/appstudio/constants.d.ts.map +1 -1
  124. package/build/plugins/resource/appstudio/constants.js +10 -1
  125. package/build/plugins/resource/appstudio/constants.js.map +1 -1
  126. package/build/plugins/resource/appstudio/manifestTemplate.d.ts +10 -4
  127. package/build/plugins/resource/appstudio/manifestTemplate.d.ts.map +1 -1
  128. package/build/plugins/resource/appstudio/manifestTemplate.js +84 -63
  129. package/build/plugins/resource/appstudio/manifestTemplate.js.map +1 -1
  130. package/build/plugins/resource/appstudio/plugin.d.ts +2 -2
  131. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  132. package/build/plugins/resource/appstudio/plugin.js +55 -24
  133. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  134. package/build/plugins/resource/appstudio/v2/index.d.ts +2 -3
  135. package/build/plugins/resource/appstudio/v2/index.d.ts.map +1 -1
  136. package/build/plugins/resource/appstudio/v2/index.js +1 -2
  137. package/build/plugins/resource/appstudio/v2/index.js.map +1 -1
  138. package/build/plugins/resource/appstudio/v3/index.d.ts +2 -2
  139. package/build/plugins/resource/appstudio/v3/index.d.ts.map +1 -1
  140. package/build/plugins/resource/appstudio/v3/index.js +2 -2
  141. package/build/plugins/resource/appstudio/v3/index.js.map +1 -1
  142. package/build/plugins/resource/appstudio/v3/plugin.d.ts +2 -2
  143. package/build/plugins/resource/appstudio/v3/plugin.d.ts.map +1 -1
  144. package/build/plugins/resource/appstudio/v3/plugin.js +3 -3
  145. package/build/plugins/resource/appstudio/v3/plugin.js.map +1 -1
  146. package/build/plugins/resource/bot/errors.d.ts +1 -0
  147. package/build/plugins/resource/bot/errors.d.ts.map +1 -1
  148. package/build/plugins/resource/bot/errors.js +8 -1
  149. package/build/plugins/resource/bot/errors.js.map +1 -1
  150. package/build/plugins/resource/bot/index.d.ts.map +1 -1
  151. package/build/plugins/resource/bot/index.js +2 -2
  152. package/build/plugins/resource/bot/index.js.map +1 -1
  153. package/build/plugins/resource/bot/plugin.d.ts +2 -2
  154. package/build/plugins/resource/bot/plugin.d.ts.map +1 -1
  155. package/build/plugins/resource/bot/plugin.js +31 -43
  156. package/build/plugins/resource/bot/plugin.js.map +1 -1
  157. package/build/plugins/resource/bot/utils/retryHandler.d.ts +1 -1
  158. package/build/plugins/resource/bot/utils/retryHandler.d.ts.map +1 -1
  159. package/build/plugins/resource/bot/utils/retryHandler.js.map +1 -1
  160. package/build/plugins/resource/bot/v3/index.d.ts +2 -1
  161. package/build/plugins/resource/bot/v3/index.d.ts.map +1 -1
  162. package/build/plugins/resource/bot/v3/index.js +14 -0
  163. package/build/plugins/resource/bot/v3/index.js.map +1 -1
  164. package/build/plugins/resource/frontend/dotnet/plugin.d.ts +2 -2
  165. package/build/plugins/resource/frontend/dotnet/plugin.d.ts.map +1 -1
  166. package/build/plugins/resource/frontend/dotnet/plugin.js.map +1 -1
  167. package/build/plugins/resource/frontend/index.d.ts.map +1 -1
  168. package/build/plugins/resource/frontend/index.js +3 -3
  169. package/build/plugins/resource/frontend/index.js.map +1 -1
  170. package/build/plugins/resource/spfx/index.d.ts.map +1 -1
  171. package/build/plugins/resource/spfx/index.js +3 -29
  172. package/build/plugins/resource/spfx/index.js.map +1 -1
  173. package/build/plugins/resource/spfx/plugin.d.ts.map +1 -1
  174. package/build/plugins/resource/spfx/plugin.js +139 -73
  175. package/build/plugins/resource/spfx/plugin.js.map +1 -1
  176. package/build/plugins/resource/spfx/utils/constants.d.ts +7 -2
  177. package/build/plugins/resource/spfx/utils/constants.d.ts.map +1 -1
  178. package/build/plugins/resource/spfx/utils/constants.js +9 -3
  179. package/build/plugins/resource/spfx/utils/constants.js.map +1 -1
  180. package/build/plugins/resource/spfx/utils/progress-helper.d.ts +3 -0
  181. package/build/plugins/resource/spfx/utils/progress-helper.d.ts.map +1 -1
  182. package/build/plugins/resource/spfx/utils/progress-helper.js +11 -0
  183. package/build/plugins/resource/spfx/utils/progress-helper.js.map +1 -1
  184. package/build/plugins/resource/spfx/utils/questions.d.ts.map +1 -1
  185. package/build/plugins/resource/spfx/utils/questions.js +11 -4
  186. package/build/plugins/resource/spfx/utils/questions.js.map +1 -1
  187. package/build/plugins/resource/spfx/utils/utils.d.ts +1 -0
  188. package/build/plugins/resource/spfx/utils/utils.d.ts.map +1 -1
  189. package/build/plugins/resource/spfx/utils/utils.js +7 -3
  190. package/build/plugins/resource/spfx/utils/utils.js.map +1 -1
  191. package/build/plugins/resource/spfx/v3/index.d.ts.map +1 -1
  192. package/build/plugins/resource/spfx/v3/index.js +2 -14
  193. package/build/plugins/resource/spfx/v3/index.js.map +1 -1
  194. package/build/plugins/resource/spfx/v3/plugin.d.ts.map +1 -1
  195. package/build/plugins/resource/spfx/v3/plugin.js +8 -7
  196. package/build/plugins/resource/spfx/v3/plugin.js.map +1 -1
  197. package/build/plugins/resource/utils4v2.d.ts +4 -0
  198. package/build/plugins/resource/utils4v2.d.ts.map +1 -1
  199. package/build/plugins/resource/utils4v2.js +28 -4
  200. package/build/plugins/resource/utils4v2.js.map +1 -1
  201. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  202. package/build/plugins/solution/fx-solution/arm.js +5 -1
  203. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  204. package/build/plugins/solution/fx-solution/debug/provisionLocal.d.ts.map +1 -1
  205. package/build/plugins/solution/fx-solution/debug/provisionLocal.js +18 -12
  206. package/build/plugins/solution/fx-solution/debug/provisionLocal.js.map +1 -1
  207. package/build/plugins/solution/fx-solution/debug/scaffolding.d.ts.map +1 -1
  208. package/build/plugins/solution/fx-solution/debug/scaffolding.js +1 -30
  209. package/build/plugins/solution/fx-solution/debug/scaffolding.js.map +1 -1
  210. package/build/plugins/solution/fx-solution/solution.d.ts +4 -11
  211. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  212. package/build/plugins/solution/fx-solution/solution.js +20 -28
  213. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  214. package/build/plugins/solution/fx-solution/types.d.ts +10 -0
  215. package/build/plugins/solution/fx-solution/types.d.ts.map +1 -0
  216. package/build/plugins/solution/fx-solution/types.js +12 -0
  217. package/build/plugins/solution/fx-solution/types.js.map +1 -0
  218. package/build/plugins/solution/fx-solution/v2/adaptor.js +6 -6
  219. package/build/plugins/solution/fx-solution/v2/adaptor.js.map +1 -1
  220. package/build/plugins/solution/fx-solution/v2/checkPermission.d.ts.map +1 -1
  221. package/build/plugins/solution/fx-solution/v2/checkPermission.js.map +1 -1
  222. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -1
  223. package/build/plugins/solution/fx-solution/v2/createEnv.js +2 -1
  224. package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -1
  225. package/build/plugins/solution/fx-solution/v2/deploy.d.ts.map +1 -1
  226. package/build/plugins/solution/fx-solution/v2/deploy.js +2 -2
  227. package/build/plugins/solution/fx-solution/v2/deploy.js.map +1 -1
  228. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  229. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +3 -2
  230. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  231. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -1
  232. package/build/plugins/solution/fx-solution/v2/getQuestions.js +2 -1
  233. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -1
  234. package/build/plugins/solution/fx-solution/v2/grantPermission.d.ts.map +1 -1
  235. package/build/plugins/solution/fx-solution/v2/grantPermission.js.map +1 -1
  236. package/build/plugins/solution/fx-solution/v2/listCollaborator.js +1 -2
  237. package/build/plugins/solution/fx-solution/v2/listCollaborator.js.map +1 -1
  238. package/build/plugins/solution/fx-solution/v2/provision.js +2 -2
  239. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -1
  240. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
  241. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +10 -3
  242. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
  243. package/build/plugins/solution/fx-solution/v2/publish.d.ts.map +1 -1
  244. package/build/plugins/solution/fx-solution/v2/publish.js +8 -1
  245. package/build/plugins/solution/fx-solution/v2/publish.js.map +1 -1
  246. package/build/plugins/solution/fx-solution/v2/scaffolding.js +18 -17
  247. package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
  248. package/build/plugins/solution/fx-solution/v2/utils.d.ts +1 -1
  249. package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
  250. package/build/plugins/solution/fx-solution/v2/utils.js +8 -8
  251. package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
  252. package/build/plugins/solution/fx-solution/v3/addFeature.d.ts.map +1 -1
  253. package/build/plugins/solution/fx-solution/v3/addFeature.js +8 -15
  254. package/build/plugins/solution/fx-solution/v3/addFeature.js.map +1 -1
  255. package/build/plugins/solution/fx-solution/v3/provision.d.ts.map +1 -1
  256. package/build/plugins/solution/fx-solution/v3/provision.js +2 -2
  257. package/build/plugins/solution/fx-solution/v3/provision.js.map +1 -1
  258. package/build/plugins/solution/fx-solution/v3/publish.d.ts.map +1 -1
  259. package/build/plugins/solution/fx-solution/v3/publish.js +4 -1
  260. package/build/plugins/solution/fx-solution/v3/publish.js.map +1 -1
  261. package/build/plugins/solution/fx-solution/v3/userTask.d.ts.map +1 -1
  262. package/build/plugins/solution/fx-solution/v3/userTask.js +2 -1
  263. package/build/plugins/solution/fx-solution/v3/userTask.js.map +1 -1
  264. package/build/plugins/solution/spfx-solution/addFeature.d.ts.map +1 -1
  265. package/build/plugins/solution/spfx-solution/addFeature.js +2 -2
  266. package/build/plugins/solution/spfx-solution/addFeature.js.map +1 -1
  267. package/package.json +8 -7
  268. package/templates/plugins/resource/bot/bicep/botConfiguration.template.bicep +14 -8
  269. package/templates/plugins/resource/bot/bot.csharp.default.zip +0 -0
  270. package/templates/plugins/resource/bot/bot.js.default.zip +0 -0
  271. package/templates/plugins/resource/bot/bot.ts.default.zip +0 -0
  272. package/templates/plugins/resource/dotnet/blazor-base.csharp.default.zip +0 -0
  273. package/templates/plugins/resource/frontend/tab.csharp.default.zip +0 -0
  274. package/templates/plugins/resource/frontend/tab.js.default.zip +0 -0
  275. package/templates/plugins/resource/frontend/tab.ts.default.zip +0 -0
  276. package/templates/plugins/resource/function/function-base.js.default.zip +0 -0
  277. package/templates/plugins/resource/function/function-base.ts.default.zip +0 -0
  278. package/templates/plugins/resource/function/function-triggers.js.HTTPTrigger.zip +0 -0
  279. package/templates/plugins/resource/function/function-triggers.ts.HTTPTrigger.zip +0 -0
  280. package/build/common/fileUtils.d.ts +0 -2
  281. package/build/common/fileUtils.d.ts.map +0 -1
  282. package/build/common/fileUtils.js +0 -46
  283. package/build/common/fileUtils.js.map +0 -1
  284. package/build/common/projectSettingsValidator.d.ts +0 -3
  285. package/build/common/projectSettingsValidator.d.ts.map +0 -1
  286. package/build/common/projectSettingsValidator.js +0 -54
  287. package/build/common/projectSettingsValidator.js.map +0 -1
  288. package/build/core/tools.d.ts +0 -8
  289. package/build/core/tools.d.ts.map +0 -1
  290. package/build/core/tools.js +0 -72
  291. package/build/core/tools.js.map +0 -1
  292. package/build/core/utils.d.ts +0 -3
  293. package/build/core/utils.d.ts.map +0 -1
  294. package/build/core/utils.js +0 -10
  295. package/build/core/utils.js.map +0 -1
  296. package/build/plugins/resource/aad/utils/common.d.ts +0 -19
  297. package/build/plugins/resource/aad/utils/common.d.ts.map +0 -1
  298. package/build/plugins/resource/aad/utils/common.js +0 -132
  299. package/build/plugins/resource/aad/utils/common.js.map +0 -1
  300. package/build/plugins/resource/frontend/dotnet/error-factory.d.ts +0 -10
  301. package/build/plugins/resource/frontend/dotnet/error-factory.d.ts.map +0 -1
  302. package/build/plugins/resource/frontend/dotnet/error-factory.js +0 -20
  303. package/build/plugins/resource/frontend/dotnet/error-factory.js.map +0 -1
  304. package/templates/plugins/resource/bot/bot-msgext.csharp.default.zip +0 -0
  305. package/templates/plugins/resource/bot/bot-msgext.js.default.zip +0 -0
  306. package/templates/plugins/resource/bot/bot-msgext.ts.default.zip +0 -0
  307. package/templates/plugins/resource/bot/msgext.js.default.zip +0 -0
  308. package/templates/plugins/resource/bot/msgext.ts.default.zip +0 -0
@@ -0,0 +1,1334 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ensureBasicFolderStructure = exports.FxCore = void 0;
6
+ const tslib_1 = require("tslib");
7
+ const hooks_1 = require("@feathersjs/hooks");
8
+ const teamsfx_api_1 = require("@microsoft/teamsfx-api");
9
+ const fs = tslib_1.__importStar(require("fs-extra"));
10
+ const jsonschema = tslib_1.__importStar(require("jsonschema"));
11
+ const path = tslib_1.__importStar(require("path"));
12
+ const typedi_1 = require("typedi");
13
+ const uuid = tslib_1.__importStar(require("uuid"));
14
+ const globalVars_1 = require("./globalVars");
15
+ const globalState_1 = require("../common/globalState");
16
+ const localSettingsProvider_1 = require("../common/localSettingsProvider");
17
+ const projectSettingsHelper_1 = require("../common/projectSettingsHelper");
18
+ const telemetry_1 = require("../common/telemetry");
19
+ const tools_1 = require("../common/tools");
20
+ const utils_1 = require("../plugins/resource/appstudio/utils/utils");
21
+ const question_1 = require("../plugins/solution/fx-solution/question");
22
+ const constants_1 = require("../plugins/solution/fx-solution/v3/constants");
23
+ const callback_1 = require("./callback");
24
+ const collaborator_1 = require("./collaborator");
25
+ const crypto_1 = require("./crypto");
26
+ const downloadSample_1 = require("./downloadSample");
27
+ const environment_1 = require("./environment");
28
+ const error_1 = require("./error");
29
+ const concurrentLocker_1 = require("./middleware/concurrentLocker");
30
+ const contextInjector_1 = require("./middleware/contextInjector");
31
+ const envInfoLoader_1 = require("./middleware/envInfoLoader");
32
+ const envInfoLoaderV3_1 = require("./middleware/envInfoLoaderV3");
33
+ const envInfoWriter_1 = require("./middleware/envInfoWriter");
34
+ const envInfoWriterV3_1 = require("./middleware/envInfoWriterV3");
35
+ const errorHandler_1 = require("./middleware/errorHandler");
36
+ const localSettingsLoader_1 = require("./middleware/localSettingsLoader");
37
+ const localSettingsWriter_1 = require("./middleware/localSettingsWriter");
38
+ const projectMigrator_1 = require("./middleware/projectMigrator");
39
+ const projectSettingsLoader_1 = require("./middleware/projectSettingsLoader");
40
+ const projectSettingsWriter_1 = require("./middleware/projectSettingsWriter");
41
+ const questionModel_1 = require("./middleware/questionModel");
42
+ const solutionLoader_1 = require("./middleware/solutionLoader");
43
+ const solutionLoaderV3_1 = require("./middleware/solutionLoaderV3");
44
+ const question_2 = require("./question");
45
+ const SolutionPluginContainer_1 = require("./SolutionPluginContainer");
46
+ class FxCore {
47
+ constructor(tools) {
48
+ //V1,V2 questions
49
+ this._getQuestionsForCreateProjectV2 = questionModel_1.getQuestionsForCreateProjectV2;
50
+ this._getQuestionsForCreateProjectV3 = questionModel_1.getQuestionsForCreateProjectV3;
51
+ this._getQuestionsForUserTask = questionModel_1.getQuestionsForUserTaskV2;
52
+ this._getQuestions = questionModel_1.getQuestionsV2;
53
+ //v3 questions
54
+ this._getQuestionsForAddFeature = questionModel_1.getQuestionsForAddFeature;
55
+ this._getQuestionsForProvision = questionModel_1.getQuestionsForProvision;
56
+ this._getQuestionsForDeploy = questionModel_1.getQuestionsForDeploy;
57
+ this._getQuestionsForPublish = questionModel_1.getQuestionsForPublish;
58
+ this._getQuestionsForInit = questionModel_1.getQuestionsForInit;
59
+ this._getQuestionsForUserTaskV3 = questionModel_1.getQuestionsForUserTaskV3;
60
+ this.tools = tools;
61
+ globalVars_1.setTools(tools);
62
+ telemetry_1.TelemetryReporterInstance.telemetryReporter = tools.telemetryReporter;
63
+ }
64
+ /**
65
+ * @todo this's a really primitive implement. Maybe could use Subscription Model to
66
+ * refactor later.
67
+ */
68
+ on(event, callback) {
69
+ return callback_1.CallbackRegistry.set(event, callback);
70
+ }
71
+ async createProject(inputs) {
72
+ if (globalVars_1.isV3()) {
73
+ return this.createProjectV3(inputs);
74
+ }
75
+ else {
76
+ return this.createProjectV2(inputs);
77
+ }
78
+ }
79
+ async createProjectV2(inputs, ctx) {
80
+ var _a;
81
+ if (!ctx) {
82
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
83
+ }
84
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.create);
85
+ inputs.stage = teamsfx_api_1.Stage.create;
86
+ let folder = inputs[question_2.QuestionRootFolder.name];
87
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
88
+ folder = tools_1.getRootDirectory();
89
+ try {
90
+ await fs.ensureDir(folder);
91
+ }
92
+ catch (e) {
93
+ throw error_1.ProjectFolderInvalidError(folder);
94
+ }
95
+ }
96
+ const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
97
+ let projectPath;
98
+ const automaticNpmInstall = "automaticNpmInstall";
99
+ if (scratch === question_2.ScratchOptionNo.id) {
100
+ // create from sample
101
+ const downloadRes = await downloadSample_1.downloadSample(inputs, ctx);
102
+ if (downloadRes.isErr()) {
103
+ return teamsfx_api_1.err(downloadRes.error);
104
+ }
105
+ projectPath = downloadRes.value;
106
+ }
107
+ else {
108
+ // create from new
109
+ const appName = inputs[question_2.QuestionAppName.name];
110
+ if (undefined === appName)
111
+ return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
112
+ const validateResult = jsonschema.validate(appName, {
113
+ pattern: question_2.ProjectNamePattern,
114
+ });
115
+ if (validateResult.errors && validateResult.errors.length > 0) {
116
+ return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
117
+ }
118
+ projectPath = path.join(folder, appName);
119
+ inputs.projectPath = projectPath;
120
+ const folderExist = await fs.pathExists(projectPath);
121
+ if (folderExist) {
122
+ return teamsfx_api_1.err(error_1.ProjectFolderExistError(projectPath));
123
+ }
124
+ await fs.ensureDir(projectPath);
125
+ await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
126
+ await fs.ensureDir(path.join(projectPath, path.join("templates", `${teamsfx_api_1.AppPackageFolderName}`)));
127
+ const basicFolderRes = await ensureBasicFolderStructure(inputs);
128
+ if (basicFolderRes.isErr()) {
129
+ return teamsfx_api_1.err(basicFolderRes.error);
130
+ }
131
+ const projectSettings = {
132
+ appName: appName,
133
+ projectId: inputs.projectId ? inputs.projectId : uuid.v4(),
134
+ version: projectSettingsHelper_1.getProjectSettingsVersion(),
135
+ isFromSample: false,
136
+ };
137
+ if ((_a = inputs.existingAppConfig) === null || _a === void 0 ? void 0 : _a.isCreatedFromExistingApp) {
138
+ // there is no solution settings if created from existing app
139
+ // create default env
140
+ ctx.projectSettings = projectSettings;
141
+ const newEnvConfig = environment_1.environmentManager.newEnvConfigData(appName, inputs.existingAppConfig);
142
+ const writeEnvResult = await environment_1.environmentManager.writeEnvConfig(projectPath, newEnvConfig, environment_1.environmentManager.getDefaultEnvName());
143
+ if (writeEnvResult.isErr()) {
144
+ return teamsfx_api_1.err(writeEnvResult.error);
145
+ }
146
+ // call App Studio V3 API to create manifest with placeholder
147
+ const appStudio = typedi_1.Container.get(constants_1.BuiltInFeaturePluginNames.appStudio);
148
+ const contextV2 = tools_1.createV2Context(projectSettings);
149
+ const initRes = await appStudio.init(contextV2, inputs);
150
+ if (initRes.isErr())
151
+ return teamsfx_api_1.err(initRes.error);
152
+ const manifestCaps = [];
153
+ inputs.existingAppConfig.newAppTypes.forEach((t) => {
154
+ if (t === teamsfx_api_1.ExistingTeamsAppType.Bot)
155
+ manifestCaps.push({ name: "Bot", existingApp: true });
156
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.StaticTab)
157
+ manifestCaps.push({ name: "staticTab", existingApp: true });
158
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.ConfigurableTab)
159
+ manifestCaps.push({ name: "configurableTab", existingApp: true });
160
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.MessageExtension)
161
+ manifestCaps.push({ name: "MessageExtension", existingApp: true });
162
+ });
163
+ const addCapabilitiesRes = await appStudio.addCapabilities(contextV2, inputs, manifestCaps);
164
+ if (addCapabilitiesRes.isErr())
165
+ return teamsfx_api_1.err(addCapabilitiesRes.error);
166
+ if (tools_1.isConfigUnifyEnabled()) {
167
+ const createLocalEnvResult = await this.createEnvWithName(environment_1.environmentManager.getLocalEnvName(), projectSettings, inputs);
168
+ if (createLocalEnvResult.isErr()) {
169
+ return teamsfx_api_1.err(createLocalEnvResult.error);
170
+ }
171
+ }
172
+ }
173
+ else {
174
+ projectSettings.solutionSettings = {
175
+ name: "",
176
+ version: "1.0.0",
177
+ };
178
+ projectSettings.programmingLanguage = inputs[question_2.CoreQuestionNames.ProgrammingLanguage];
179
+ ctx.projectSettings = projectSettings;
180
+ const createEnvResult = await this.createEnvWithName(environment_1.environmentManager.getDefaultEnvName(), projectSettings, inputs);
181
+ if (createEnvResult.isErr()) {
182
+ return teamsfx_api_1.err(createEnvResult.error);
183
+ }
184
+ if (tools_1.isConfigUnifyEnabled()) {
185
+ const createLocalEnvResult = await this.createEnvWithName(environment_1.environmentManager.getLocalEnvName(), projectSettings, inputs);
186
+ if (createLocalEnvResult.isErr()) {
187
+ return teamsfx_api_1.err(createLocalEnvResult.error);
188
+ }
189
+ }
190
+ const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_2.CoreQuestionNames.Solution]);
191
+ if (!solution) {
192
+ return teamsfx_api_1.err(new error_1.LoadSolutionError());
193
+ }
194
+ ctx.solutionV2 = solution;
195
+ projectSettings.solutionSettings.name = solution.name;
196
+ const contextV2 = tools_1.createV2Context(projectSettings);
197
+ ctx.contextV2 = contextV2;
198
+ const scaffoldSourceCodeRes = await solution.scaffoldSourceCode(contextV2, inputs);
199
+ if (scaffoldSourceCodeRes.isErr()) {
200
+ return teamsfx_api_1.err(scaffoldSourceCodeRes.error);
201
+ }
202
+ const generateResourceTemplateRes = await solution.generateResourceTemplate(contextV2, inputs);
203
+ if (generateResourceTemplateRes.isErr()) {
204
+ return teamsfx_api_1.err(generateResourceTemplateRes.error);
205
+ }
206
+ // ctx.provisionInputConfig = generateResourceTemplateRes.value;
207
+ if (solution.createEnv) {
208
+ inputs.copy = false;
209
+ const createEnvRes = await solution.createEnv(contextV2, inputs);
210
+ if (createEnvRes.isErr()) {
211
+ return teamsfx_api_1.err(createEnvRes.error);
212
+ }
213
+ }
214
+ }
215
+ }
216
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
217
+ await globalState_1.globalStateUpdate(automaticNpmInstall, true);
218
+ }
219
+ return teamsfx_api_1.ok(projectPath);
220
+ }
221
+ async createProjectV3(inputs, ctx) {
222
+ var _a;
223
+ if (!ctx) {
224
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
225
+ }
226
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.create);
227
+ inputs.stage = teamsfx_api_1.Stage.create;
228
+ let folder = inputs[question_2.QuestionRootFolder.name];
229
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode || inputs.platform === teamsfx_api_1.Platform.VS) {
230
+ folder = tools_1.getRootDirectory();
231
+ try {
232
+ await fs.ensureDir(folder);
233
+ }
234
+ catch (e) {
235
+ throw error_1.ProjectFolderInvalidError(folder);
236
+ }
237
+ }
238
+ if (!folder) {
239
+ return teamsfx_api_1.err(error_1.InvalidInputError("folder is undefined"));
240
+ }
241
+ inputs.folder = folder;
242
+ const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
243
+ let projectPath;
244
+ const automaticNpmInstall = "automaticNpmInstall";
245
+ if (scratch === question_2.ScratchOptionNo.id) {
246
+ // create from sample
247
+ const downloadRes = await downloadSample_1.downloadSample(inputs, ctx);
248
+ if (downloadRes.isErr()) {
249
+ return teamsfx_api_1.err(downloadRes.error);
250
+ }
251
+ projectPath = downloadRes.value;
252
+ }
253
+ else {
254
+ // create from new
255
+ const appName = inputs[question_2.QuestionAppName.name];
256
+ if (undefined === appName)
257
+ return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
258
+ const validateResult = jsonschema.validate(appName, {
259
+ pattern: question_2.ProjectNamePattern,
260
+ });
261
+ if (validateResult.errors && validateResult.errors.length > 0) {
262
+ return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
263
+ }
264
+ projectPath = path.join(folder, appName);
265
+ inputs.projectPath = projectPath;
266
+ const folderExist = await fs.pathExists(projectPath);
267
+ if (folderExist) {
268
+ return teamsfx_api_1.err(error_1.ProjectFolderExistError(projectPath));
269
+ }
270
+ await fs.ensureDir(projectPath);
271
+ await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
272
+ const capabilities = inputs[question_2.CoreQuestionNames.Capabilities];
273
+ // init
274
+ const initInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath });
275
+ const initRes = await this._init(initInputs, ctx);
276
+ if (initRes.isErr()) {
277
+ return teamsfx_api_1.err(initRes.error);
278
+ }
279
+ // persist projectSettings.json
280
+ ctx.projectSettings.programmingLanguage = inputs[question_2.CoreQuestionNames.ProgrammingLanguage];
281
+ ctx.projectSettings.isFromSample = false;
282
+ const projectSettingsPath = projectSettingsLoader_1.getProjectSettingsPath(projectPath);
283
+ await fs.writeFile(projectSettingsPath, JSON.stringify(ctx.projectSettings, null, 4));
284
+ if (!((_a = inputs.existingAppConfig) === null || _a === void 0 ? void 0 : _a.isCreatedFromExistingApp)) {
285
+ // addFeature
286
+ const features = [];
287
+ if (!capabilities.includes(question_2.TabSPFxItem.id)) {
288
+ features.push(constants_1.BuiltInFeaturePluginNames.aad);
289
+ }
290
+ if (inputs.platform === teamsfx_api_1.Platform.VS) {
291
+ features.push(constants_1.BuiltInFeaturePluginNames.dotnet);
292
+ }
293
+ else {
294
+ if (capabilities.includes(question_2.TabOptionItem.id)) {
295
+ features.push(constants_1.BuiltInFeaturePluginNames.frontend);
296
+ }
297
+ else if (capabilities.includes(question_2.TabSPFxItem.id)) {
298
+ features.push(constants_1.BuiltInFeaturePluginNames.spfx);
299
+ }
300
+ if (capabilities.includes(question_2.BotOptionItem.id) ||
301
+ capabilities.includes(question_1.MessageExtensionItem.id)) {
302
+ features.push(constants_1.BuiltInFeaturePluginNames.bot);
303
+ }
304
+ }
305
+ const addFeatureInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, features: features });
306
+ const addFeatureRes = await this.addFeature(addFeatureInputs);
307
+ if (addFeatureRes.isErr()) {
308
+ return teamsfx_api_1.err(addFeatureRes.error);
309
+ }
310
+ }
311
+ }
312
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
313
+ await globalState_1.globalStateUpdate(automaticNpmInstall, true);
314
+ }
315
+ return teamsfx_api_1.ok(projectPath);
316
+ }
317
+ /**
318
+ * switch to different versions of provisionResources
319
+ */
320
+ async provisionResources(inputs) {
321
+ if (globalVars_1.isV3()) {
322
+ return this.provisionResourcesV3(inputs);
323
+ }
324
+ else {
325
+ return this.provisionResourcesV2(inputs);
326
+ }
327
+ }
328
+ async provisionResourcesV2(inputs, ctx) {
329
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.provision);
330
+ inputs.stage = teamsfx_api_1.Stage.provision;
331
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
332
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Provision input stuff"));
333
+ }
334
+ const envInfo = ctx.envInfoV2;
335
+ const result = await ctx.solutionV2.provisionResources(ctx.contextV2, inputs, envInfo, this.tools.tokenProvider);
336
+ return result;
337
+ }
338
+ async provisionResourcesV3(inputs, ctx) {
339
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.provision);
340
+ inputs.stage = teamsfx_api_1.Stage.provision;
341
+ if (ctx &&
342
+ ctx.solutionV3 &&
343
+ ctx.contextV2 &&
344
+ ctx.envInfoV3 &&
345
+ ctx.solutionV3.provisionResources) {
346
+ const res = await ctx.solutionV3.provisionResources(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider);
347
+ return res;
348
+ }
349
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
350
+ }
351
+ /**
352
+ * Only used to provision Teams app with user provided app package
353
+ * @param inputs
354
+ * @returns teamsAppId on provision success
355
+ */
356
+ async provisionTeamsAppForCLI(inputs) {
357
+ if (!inputs.appPackagePath) {
358
+ return teamsfx_api_1.err(error_1.InvalidInputError("appPackagePath is not defined", inputs));
359
+ }
360
+ const projectSettings = {
361
+ appName: "fake",
362
+ projectId: uuid.v4(),
363
+ };
364
+ const context = {
365
+ userInteraction: globalVars_1.TOOLS.ui,
366
+ logProvider: globalVars_1.TOOLS.logProvider,
367
+ telemetryReporter: globalVars_1.TOOLS.telemetryReporter,
368
+ cryptoProvider: new crypto_1.LocalCrypto(projectSettings.projectId),
369
+ permissionRequestProvider: globalVars_1.TOOLS.permissionRequest,
370
+ projectSetting: projectSettings,
371
+ };
372
+ const appStudioV3 = typedi_1.Container.get(constants_1.BuiltInFeaturePluginNames.appStudio);
373
+ return appStudioV3.registerTeamsApp(context, inputs, environment_1.newEnvInfoV3(), globalVars_1.TOOLS.tokenProvider);
374
+ }
375
+ async deployArtifacts(inputs) {
376
+ if (globalVars_1.isV3())
377
+ return this.deployArtifactsV3(inputs);
378
+ else
379
+ return this.deployArtifactsV2(inputs);
380
+ }
381
+ async deployArtifactsV2(inputs, ctx) {
382
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.deploy);
383
+ inputs.stage = teamsfx_api_1.Stage.deploy;
384
+ if (!(ctx === null || ctx === void 0 ? void 0 : ctx.projectSettings)) {
385
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("deploy input stuff"));
386
+ }
387
+ if (projectSettingsHelper_1.isPureExistingApp(ctx.projectSettings)) {
388
+ // existing app scenario, deploy has no effect
389
+ return teamsfx_api_1.err(new error_1.OperationNotSupportedForExistingAppError("deploy"));
390
+ }
391
+ if (!ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
392
+ const name = tools_1.undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solutionV2, ctx === null || ctx === void 0 ? void 0 : ctx.contextV2, ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2], ["ctx", "ctx.solutionV2", "ctx.contextV2", "ctx.envInfoV2"]);
393
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`Deploy input stuff: ${name}`));
394
+ }
395
+ if (ctx.solutionV2.deploy)
396
+ return await ctx.solutionV2.deploy(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider);
397
+ else
398
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
399
+ }
400
+ async deployArtifactsV3(inputs, ctx) {
401
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.deploy);
402
+ inputs.stage = teamsfx_api_1.Stage.deploy;
403
+ if (ctx && ctx.solutionV3 && ctx.contextV2 && ctx.envInfoV3 && ctx.solutionV3.deploy) {
404
+ const res = await ctx.solutionV3.deploy(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider);
405
+ return res;
406
+ }
407
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
408
+ }
409
+ async localDebug(inputs) {
410
+ inputs.env = environment_1.environmentManager.getLocalEnvName();
411
+ if (globalVars_1.isV3())
412
+ return this.provisionResourcesV3(inputs);
413
+ else
414
+ return this.localDebugV2(inputs);
415
+ }
416
+ async localDebugV2(inputs, ctx) {
417
+ var _a;
418
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.debug);
419
+ inputs.stage = teamsfx_api_1.Stage.debug;
420
+ if (!(ctx === null || ctx === void 0 ? void 0 : ctx.projectSettings)) {
421
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("local debug input stuff"));
422
+ }
423
+ if (!ctx.solutionV2 || !ctx.contextV2) {
424
+ const name = tools_1.undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solutionV2, ctx === null || ctx === void 0 ? void 0 : ctx.contextV2], ["ctx", "ctx.solutionV2", "ctx.contextV2"]);
425
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`localDebug input stuff (${name})`));
426
+ }
427
+ if (!ctx.localSettings)
428
+ ctx.localSettings = {};
429
+ if (ctx.solutionV2.provisionLocalResource) {
430
+ if (tools_1.isConfigUnifyEnabled() && ((_a = ctx.envInfoV2) === null || _a === void 0 ? void 0 : _a.config)) {
431
+ ctx.envInfoV2.config.isLocalDebug = true;
432
+ }
433
+ const res = await ctx.solutionV2.provisionLocalResource(ctx.contextV2, inputs, ctx.localSettings, this.tools.tokenProvider, ctx.envInfoV2);
434
+ if (res.kind === "success") {
435
+ ctx.localSettings = res.output;
436
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
437
+ }
438
+ else if (res.kind === "partialSuccess") {
439
+ ctx.localSettings = res.output;
440
+ return teamsfx_api_1.err(res.error);
441
+ }
442
+ else {
443
+ return teamsfx_api_1.err(res.error);
444
+ }
445
+ }
446
+ else {
447
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
448
+ }
449
+ }
450
+ _setEnvInfoV2(ctx) {
451
+ if (ctx && ctx.solutionContext) {
452
+ //workaround, compatible to api v2
453
+ ctx.envInfoV2 = {
454
+ envName: ctx.solutionContext.envInfo.envName,
455
+ config: ctx.solutionContext.envInfo.config,
456
+ state: {},
457
+ };
458
+ ctx.envInfoV2.state = tools_1.mapToJson(ctx.solutionContext.envInfo.state);
459
+ }
460
+ }
461
+ async publishApplication(inputs) {
462
+ if (globalVars_1.isV3())
463
+ return this.publishApplicationV3(inputs);
464
+ else
465
+ return this.publishApplicationV2(inputs);
466
+ }
467
+ async publishApplicationV2(inputs, ctx) {
468
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.publish);
469
+ inputs.stage = teamsfx_api_1.Stage.publish;
470
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
471
+ const name = tools_1.undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solutionV2, ctx === null || ctx === void 0 ? void 0 : ctx.contextV2, ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2], ["ctx", "ctx.solutionV2", "ctx.contextV2", "ctx.envInfoV2"]);
472
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`publish input stuff: ${name}`));
473
+ }
474
+ return await ctx.solutionV2.publishApplication(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider.appStudioToken);
475
+ }
476
+ async publishApplicationV3(inputs, ctx) {
477
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.publish);
478
+ inputs.stage = teamsfx_api_1.Stage.publish;
479
+ if (ctx &&
480
+ ctx.solutionV3 &&
481
+ ctx.contextV2 &&
482
+ ctx.envInfoV3 &&
483
+ ctx.solutionV3.publishApplication) {
484
+ const res = await ctx.solutionV3.publishApplication(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider.appStudioToken);
485
+ return res;
486
+ }
487
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
488
+ }
489
+ async executeUserTask(func, inputs) {
490
+ if (globalVars_1.isV3())
491
+ return this.executeUserTaskV3(func, inputs);
492
+ else
493
+ return this.executeUserTaskV2(func, inputs);
494
+ }
495
+ async executeUserTaskV2(func, inputs, ctx) {
496
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.userTask);
497
+ inputs.stage = teamsfx_api_1.Stage.userTask;
498
+ const namespace = func.namespace;
499
+ const array = namespace ? namespace.split("/") : [];
500
+ if ("" !== namespace && array.length > 0) {
501
+ if (!ctx || !ctx.solutionV2 || !ctx.envInfoV2) {
502
+ const name = tools_1.undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solutionV2, ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2], ["ctx", "ctx.solutionV2", "ctx.envInfoV2"]);
503
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`executeUserTask input stuff: ${name}`));
504
+ }
505
+ if (!ctx.contextV2)
506
+ ctx.contextV2 = tools_1.createV2Context(projectSettingsHelper_1.newProjectSettings());
507
+ if (ctx.solutionV2.executeUserTask) {
508
+ if (!ctx.localSettings)
509
+ ctx.localSettings = {};
510
+ const res = await ctx.solutionV2.executeUserTask(ctx.contextV2, inputs, func, ctx.localSettings, ctx.envInfoV2, this.tools.tokenProvider);
511
+ //for existing app
512
+ if (res.isOk() &&
513
+ func.method === "addCapability" &&
514
+ inputs.capabilities &&
515
+ inputs.capabilities.length > 0) {
516
+ await ensureBasicFolderStructure(inputs);
517
+ }
518
+ return res;
519
+ }
520
+ else
521
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
522
+ }
523
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
524
+ }
525
+ async executeUserTaskV3(func, inputs, ctx) {
526
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.userTask);
527
+ inputs.stage = teamsfx_api_1.Stage.userTask;
528
+ const namespace = func.namespace;
529
+ const array = namespace ? namespace.split("/") : [];
530
+ if ("" !== namespace && array.length > 0) {
531
+ if (!ctx || !ctx.solutionV3 || !ctx.envInfoV3) {
532
+ const name = tools_1.undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solutionV3, ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV3], ["ctx", "ctx.solutionV3", "ctx.envInfoV3"]);
533
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`executeUserTask input stuff: ${name}`));
534
+ }
535
+ if (!ctx.contextV2)
536
+ ctx.contextV2 = tools_1.createV2Context(projectSettingsHelper_1.newProjectSettings());
537
+ if (ctx.solutionV3.executeUserTask) {
538
+ const res = await ctx.solutionV3.executeUserTask(ctx.contextV2, inputs, func, ctx.envInfoV3, this.tools.tokenProvider);
539
+ return res;
540
+ }
541
+ else
542
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
543
+ }
544
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
545
+ }
546
+ async getQuestions(stage, inputs, ctx) {
547
+ if (!ctx)
548
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getQuestions input stuff"));
549
+ inputs.stage = teamsfx_api_1.Stage.getQuestions;
550
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.getQuestions);
551
+ if (stage === teamsfx_api_1.Stage.create) {
552
+ delete inputs.projectPath;
553
+ return await this._getQuestionsForCreateProjectV2(inputs);
554
+ }
555
+ else {
556
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : tools_1.createV2Context(projectSettingsHelper_1.newProjectSettings());
557
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
558
+ const envInfoV2 = ctx.envInfoV2
559
+ ? ctx.envInfoV2
560
+ : { envName: environment_1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
561
+ inputs.stage = stage;
562
+ return await this._getQuestions(contextV2, solutionV2, stage, inputs, envInfoV2);
563
+ }
564
+ }
565
+ async getQuestionsForUserTask(func, inputs, ctx) {
566
+ if (!ctx)
567
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getQuestionsForUserTask input stuff"));
568
+ inputs.stage = teamsfx_api_1.Stage.getQuestions;
569
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.getQuestions);
570
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : tools_1.createV2Context(projectSettingsHelper_1.newProjectSettings());
571
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
572
+ const envInfoV2 = ctx.envInfoV2
573
+ ? ctx.envInfoV2
574
+ : { envName: environment_1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
575
+ return await this._getQuestionsForUserTask(contextV2, solutionV2, func, inputs, envInfoV2);
576
+ }
577
+ async getProjectConfig(inputs, ctx) {
578
+ var _a, _b;
579
+ if (!ctx)
580
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getProjectConfig input stuff"));
581
+ inputs.stage = teamsfx_api_1.Stage.getProjectConfig;
582
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.getProjectConfig);
583
+ return teamsfx_api_1.ok({
584
+ settings: ctx.projectSettings,
585
+ config: (_a = ctx.solutionContext) === null || _a === void 0 ? void 0 : _a.envInfo.state,
586
+ localSettings: (_b = ctx.solutionContext) === null || _b === void 0 ? void 0 : _b.localSettings,
587
+ });
588
+ }
589
+ async getProjectConfigV3(inputs, ctx) {
590
+ if (!ctx || !ctx.projectSettings)
591
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getProjectConfigV3 input stuff"));
592
+ if (!inputs.projectPath)
593
+ return teamsfx_api_1.ok(undefined);
594
+ inputs.stage = teamsfx_api_1.Stage.getProjectConfig;
595
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.getProjectConfig);
596
+ const config = {
597
+ projectSettings: ctx.projectSettings,
598
+ envInfos: {},
599
+ };
600
+ const envNamesRes = await environment_1.environmentManager.listAllEnvConfigs(inputs.projectPath);
601
+ if (envNamesRes.isErr()) {
602
+ return teamsfx_api_1.err(envNamesRes.error);
603
+ }
604
+ for (const env of envNamesRes.value) {
605
+ const result = await envInfoLoaderV3_1.loadEnvInfoV3(inputs, ctx.projectSettings, env, false);
606
+ if (result.isErr()) {
607
+ return teamsfx_api_1.err(result.error);
608
+ }
609
+ config.envInfos[env] = result.value;
610
+ }
611
+ return teamsfx_api_1.ok(config);
612
+ }
613
+ async grantPermission(inputs) {
614
+ if (globalVars_1.isV3())
615
+ return this.grantPermissionV3(inputs);
616
+ else
617
+ return this.grantPermissionV2(inputs);
618
+ }
619
+ async grantPermissionV2(inputs, ctx) {
620
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.grantPermission);
621
+ inputs.stage = teamsfx_api_1.Stage.grantPermission;
622
+ const projectPath = inputs.projectPath;
623
+ if (!projectPath) {
624
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
625
+ }
626
+ return ctx.solutionV2.grantPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
627
+ }
628
+ async grantPermissionV3(inputs, ctx) {
629
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.grantPermission);
630
+ inputs.stage = teamsfx_api_1.Stage.grantPermission;
631
+ const projectPath = inputs.projectPath;
632
+ if (!projectPath) {
633
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
634
+ }
635
+ if (ctx && ctx.contextV2 && ctx.envInfoV3) {
636
+ const res = await collaborator_1.grantPermission(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider);
637
+ return res;
638
+ }
639
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx, contextV2, envInfoV3"));
640
+ }
641
+ async checkPermission(inputs) {
642
+ if (globalVars_1.isV3())
643
+ return this.checkPermissionV3(inputs);
644
+ else
645
+ return this.checkPermissionV2(inputs);
646
+ }
647
+ async checkPermissionV2(inputs, ctx) {
648
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.checkPermission);
649
+ inputs.stage = teamsfx_api_1.Stage.checkPermission;
650
+ const projectPath = inputs.projectPath;
651
+ if (!projectPath) {
652
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
653
+ }
654
+ return ctx.solutionV2.checkPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
655
+ }
656
+ async checkPermissionV3(inputs, ctx) {
657
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.checkPermission);
658
+ inputs.stage = teamsfx_api_1.Stage.checkPermission;
659
+ const projectPath = inputs.projectPath;
660
+ if (!projectPath) {
661
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
662
+ }
663
+ if (ctx && ctx.contextV2 && ctx.envInfoV3) {
664
+ const res = await collaborator_1.checkPermission(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider);
665
+ return res;
666
+ }
667
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx, contextV2, envInfoV3"));
668
+ }
669
+ async listCollaborator(inputs) {
670
+ if (globalVars_1.isV3())
671
+ return this.listCollaboratorV3(inputs);
672
+ else
673
+ return this.listCollaboratorV2(inputs);
674
+ }
675
+ async listCollaboratorV2(inputs, ctx) {
676
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.listCollaborator);
677
+ inputs.stage = teamsfx_api_1.Stage.listCollaborator;
678
+ const projectPath = inputs.projectPath;
679
+ if (!projectPath) {
680
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
681
+ }
682
+ return ctx.solutionV2.listCollaborator(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
683
+ }
684
+ async listCollaboratorV3(inputs, ctx) {
685
+ globalVars_1.setCurrentStage(teamsfx_api_1.Stage.listCollaborator);
686
+ inputs.stage = teamsfx_api_1.Stage.listCollaborator;
687
+ const projectPath = inputs.projectPath;
688
+ if (!projectPath) {
689
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
690
+ }
691
+ if (ctx && ctx.contextV2 && ctx.envInfoV3) {
692
+ const res = await collaborator_1.listCollaborator(ctx.contextV2, inputs, ctx.envInfoV3, globalVars_1.TOOLS.tokenProvider);
693
+ return res;
694
+ }
695
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx, contextV2, envInfoV3"));
696
+ }
697
+ async getSelectedEnv(inputs, ctx) {
698
+ var _a;
699
+ return teamsfx_api_1.ok((_a = ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2) === null || _a === void 0 ? void 0 : _a.envName);
700
+ }
701
+ async encrypt(plaintext, inputs, ctx) {
702
+ if (!ctx)
703
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx"));
704
+ if (!ctx.contextV2)
705
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
706
+ return ctx.contextV2.cryptoProvider.encrypt(plaintext);
707
+ }
708
+ async decrypt(ciphertext, inputs, ctx) {
709
+ if (!ctx)
710
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx"));
711
+ if (!ctx.contextV2)
712
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
713
+ return ctx.contextV2.cryptoProvider.decrypt(ciphertext);
714
+ }
715
+ async buildArtifacts(inputs) {
716
+ throw new error_1.TaskNotSupportError(teamsfx_api_1.Stage.build);
717
+ }
718
+ async createEnv(inputs, ctx) {
719
+ if (!ctx)
720
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("createEnv input stuff"));
721
+ const projectSettings = ctx.projectSettings;
722
+ if (!projectSettings) {
723
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
724
+ }
725
+ const core = ctx.self;
726
+ const createEnvCopyInput = await envInfoLoader_1.askNewEnvironment(ctx, inputs);
727
+ if (!createEnvCopyInput ||
728
+ !createEnvCopyInput.targetEnvName ||
729
+ !createEnvCopyInput.sourceEnvName) {
730
+ return teamsfx_api_1.err(teamsfx_api_1.UserCancelError);
731
+ }
732
+ const createEnvResult = await this.createEnvCopy(createEnvCopyInput.targetEnvName, createEnvCopyInput.sourceEnvName, inputs, core);
733
+ if (createEnvResult.isErr()) {
734
+ return createEnvResult;
735
+ }
736
+ inputs.sourceEnvName = createEnvCopyInput.sourceEnvName;
737
+ inputs.targetEnvName = createEnvCopyInput.targetEnvName;
738
+ if (!ctx.solutionV2 || !ctx.contextV2)
739
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionV2, ctx.contextV2"));
740
+ if (ctx.solutionV2.createEnv) {
741
+ inputs.copy = true;
742
+ return await ctx.solutionV2.createEnv(ctx.contextV2, inputs);
743
+ }
744
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
745
+ }
746
+ async createEnvWithName(targetEnvName, projectSettings, inputs) {
747
+ let appName = projectSettings.appName;
748
+ if (targetEnvName === environment_1.environmentManager.getLocalEnvName()) {
749
+ appName = utils_1.getLocalAppName(appName);
750
+ }
751
+ const newEnvConfig = environment_1.environmentManager.newEnvConfigData(appName);
752
+ const writeEnvResult = await environment_1.environmentManager.writeEnvConfig(inputs.projectPath, newEnvConfig, targetEnvName);
753
+ if (writeEnvResult.isErr()) {
754
+ return teamsfx_api_1.err(writeEnvResult.error);
755
+ }
756
+ this.tools.logProvider.debug(`[core] persist ${targetEnvName} env state to path ${writeEnvResult.value}: ${JSON.stringify(newEnvConfig)}`);
757
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
758
+ }
759
+ async createEnvCopy(targetEnvName, sourceEnvName, inputs, core) {
760
+ // copy env config file
761
+ const targetEnvConfigFilePath = environment_1.environmentManager.getEnvConfigPath(targetEnvName, inputs.projectPath);
762
+ const sourceEnvConfigFilePath = environment_1.environmentManager.getEnvConfigPath(sourceEnvName, inputs.projectPath);
763
+ try {
764
+ await fs.copy(sourceEnvConfigFilePath, targetEnvConfigFilePath);
765
+ }
766
+ catch (e) {
767
+ return teamsfx_api_1.err(error_1.CopyFileError(e));
768
+ }
769
+ globalVars_1.TOOLS.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
770
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
771
+ }
772
+ // deprecated
773
+ async activateEnv(inputs, ctx) {
774
+ const env = inputs.env;
775
+ if (!env) {
776
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("env"));
777
+ }
778
+ if (!ctx.projectSettings) {
779
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
780
+ }
781
+ const envConfigs = await environment_1.environmentManager.listRemoteEnvConfigs(inputs.projectPath);
782
+ if (envConfigs.isErr()) {
783
+ return envConfigs;
784
+ }
785
+ if (envConfigs.isErr() || envConfigs.value.indexOf(env) < 0) {
786
+ return teamsfx_api_1.err(error_1.NonExistEnvNameError(env));
787
+ }
788
+ const core = ctx.self;
789
+ const solutionContext = await envInfoLoader_1.loadSolutionContext(inputs, ctx.projectSettings, env);
790
+ if (!solutionContext.isErr()) {
791
+ ctx.provisionInputConfig = solutionContext.value.envInfo.config;
792
+ ctx.provisionOutputs = solutionContext.value.envInfo.state;
793
+ ctx.envName = solutionContext.value.envInfo.envName;
794
+ }
795
+ this.tools.ui.showMessage("info", `[${env}] is activated.`, false);
796
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
797
+ }
798
+ async _init(inputs, ctx) {
799
+ var _a;
800
+ if (!ctx) {
801
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
802
+ }
803
+ // validate app name
804
+ const appName = inputs[question_2.QuestionAppName.name];
805
+ const validateResult = jsonschema.validate(appName, {
806
+ pattern: question_2.ProjectNamePattern,
807
+ });
808
+ if (validateResult.errors && validateResult.errors.length > 0) {
809
+ return teamsfx_api_1.err(error_1.InvalidInputError("invalid app-name", inputs));
810
+ }
811
+ const folder = inputs[question_2.QuestionRootFolder.name];
812
+ inputs.projectPath = path.join(folder, appName);
813
+ // create ProjectSettings
814
+ const projectSettings = projectSettingsHelper_1.newProjectSettings();
815
+ projectSettings.appName = appName;
816
+ ctx.projectSettings = projectSettings;
817
+ // create folder structure
818
+ await fs.ensureDir(path.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
819
+ await fs.ensureDir(path.join(inputs.projectPath, "templates", `${teamsfx_api_1.AppPackageFolderName}`));
820
+ const basicFolderRes = await ensureBasicFolderStructure(inputs);
821
+ if (basicFolderRes.isErr()) {
822
+ return teamsfx_api_1.err(basicFolderRes.error);
823
+ }
824
+ // create contextV2
825
+ const context = tools_1.createV2Context(projectSettings);
826
+ ctx.contextV2 = context;
827
+ const appStudioV3 = typedi_1.Container.get(constants_1.BuiltInFeaturePluginNames.appStudio);
828
+ // init manifest
829
+ const manifestInitRes = await appStudioV3.init(context, inputs);
830
+ if (manifestInitRes.isErr())
831
+ return teamsfx_api_1.err(manifestInitRes.error);
832
+ if ((_a = inputs.existingAppConfig) === null || _a === void 0 ? void 0 : _a.isCreatedFromExistingApp) {
833
+ const newEnvConfig = environment_1.environmentManager.newEnvConfigData(appName, inputs.existingAppConfig);
834
+ const writeEnvResult = await environment_1.environmentManager.writeEnvConfig(inputs.projectPath, newEnvConfig, environment_1.environmentManager.getDefaultEnvName());
835
+ if (writeEnvResult.isErr()) {
836
+ return teamsfx_api_1.err(writeEnvResult.error);
837
+ }
838
+ // call App Studio V3 API to create manifest with placeholder
839
+ const appStudio = typedi_1.Container.get(constants_1.BuiltInFeaturePluginNames.appStudio);
840
+ const contextV2 = tools_1.createV2Context(projectSettings);
841
+ const initRes = await appStudio.init(contextV2, inputs);
842
+ if (initRes.isErr())
843
+ return teamsfx_api_1.err(initRes.error);
844
+ const manifestCaps = [];
845
+ inputs.existingAppConfig.newAppTypes.forEach((t) => {
846
+ if (t === teamsfx_api_1.ExistingTeamsAppType.Bot)
847
+ manifestCaps.push({ name: "Bot", existingApp: true });
848
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.StaticTab)
849
+ manifestCaps.push({ name: "staticTab", existingApp: true });
850
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.ConfigurableTab)
851
+ manifestCaps.push({ name: "configurableTab", existingApp: true });
852
+ else if (t === teamsfx_api_1.ExistingTeamsAppType.MessageExtension)
853
+ manifestCaps.push({ name: "MessageExtension", existingApp: true });
854
+ });
855
+ const addCapabilitiesRes = await appStudio.addCapabilities(contextV2, inputs, manifestCaps);
856
+ if (addCapabilitiesRes.isErr())
857
+ return teamsfx_api_1.err(addCapabilitiesRes.error);
858
+ }
859
+ else {
860
+ const createEnvResult = await this.createEnvWithName(environment_1.environmentManager.getDefaultEnvName(), projectSettings, inputs);
861
+ if (createEnvResult.isErr()) {
862
+ return teamsfx_api_1.err(createEnvResult.error);
863
+ }
864
+ }
865
+ const createLocalEnvResult = await this.createEnvWithName(environment_1.environmentManager.getLocalEnvName(), projectSettings, inputs);
866
+ if (createLocalEnvResult.isErr()) {
867
+ return teamsfx_api_1.err(createLocalEnvResult.error);
868
+ }
869
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
870
+ }
871
+ async init(inputs, ctx) {
872
+ return this._init(inputs, ctx);
873
+ }
874
+ async addFeature(inputs, ctx) {
875
+ return this._addFeature(inputs, ctx);
876
+ }
877
+ async _addFeature(inputs, ctx) {
878
+ if (ctx && ctx.solutionV3 && ctx.contextV2 && ctx.solutionV3.addFeature) {
879
+ const res = await ensureBasicFolderStructure(inputs);
880
+ if (res.isErr()) {
881
+ return teamsfx_api_1.err(res.error);
882
+ }
883
+ return await ctx.solutionV3.addFeature(ctx.contextV2, inputs);
884
+ }
885
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
886
+ }
887
+ }
888
+ tslib_1.__decorate([
889
+ hooks_1.hooks([
890
+ errorHandler_1.ErrorHandlerMW,
891
+ questionModel_1.QuestionModelMW,
892
+ contextInjector_1.ContextInjectorMW,
893
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
894
+ envInfoWriter_1.EnvInfoWriterMW(true),
895
+ ]),
896
+ tslib_1.__metadata("design:type", Function),
897
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
898
+ tslib_1.__metadata("design:returntype", Promise)
899
+ ], FxCore.prototype, "createProjectV2", null);
900
+ tslib_1.__decorate([
901
+ hooks_1.hooks([errorHandler_1.ErrorHandlerMW, questionModel_1.QuestionModelMW, contextInjector_1.ContextInjectorMW]),
902
+ tslib_1.__metadata("design:type", Function),
903
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
904
+ tslib_1.__metadata("design:returntype", Promise)
905
+ ], FxCore.prototype, "createProjectV3", null);
906
+ tslib_1.__decorate([
907
+ hooks_1.hooks([
908
+ errorHandler_1.ErrorHandlerMW,
909
+ concurrentLocker_1.ConcurrentLockerMW,
910
+ projectMigrator_1.ProjectMigratorMW,
911
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
912
+ envInfoLoader_1.EnvInfoLoaderMW(false),
913
+ solutionLoader_1.SolutionLoaderMW,
914
+ questionModel_1.QuestionModelMW,
915
+ contextInjector_1.ContextInjectorMW,
916
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
917
+ envInfoWriter_1.EnvInfoWriterMW(),
918
+ ]),
919
+ tslib_1.__metadata("design:type", Function),
920
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
921
+ tslib_1.__metadata("design:returntype", Promise)
922
+ ], FxCore.prototype, "provisionResourcesV2", null);
923
+ tslib_1.__decorate([
924
+ hooks_1.hooks([
925
+ errorHandler_1.ErrorHandlerMW,
926
+ concurrentLocker_1.ConcurrentLockerMW,
927
+ projectMigrator_1.ProjectMigratorMW,
928
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
929
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
930
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
931
+ questionModel_1.QuestionModelMW,
932
+ contextInjector_1.ContextInjectorMW,
933
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
934
+ envInfoWriterV3_1.EnvInfoWriterMW_V3(),
935
+ ]),
936
+ tslib_1.__metadata("design:type", Function),
937
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
938
+ tslib_1.__metadata("design:returntype", Promise)
939
+ ], FxCore.prototype, "provisionResourcesV3", null);
940
+ tslib_1.__decorate([
941
+ hooks_1.hooks([
942
+ errorHandler_1.ErrorHandlerMW,
943
+ concurrentLocker_1.ConcurrentLockerMW,
944
+ projectMigrator_1.ProjectMigratorMW,
945
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
946
+ envInfoLoader_1.EnvInfoLoaderMW(false),
947
+ solutionLoader_1.SolutionLoaderMW,
948
+ questionModel_1.QuestionModelMW,
949
+ contextInjector_1.ContextInjectorMW,
950
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
951
+ envInfoWriter_1.EnvInfoWriterMW(),
952
+ ]),
953
+ tslib_1.__metadata("design:type", Function),
954
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
955
+ tslib_1.__metadata("design:returntype", Promise)
956
+ ], FxCore.prototype, "deployArtifactsV2", null);
957
+ tslib_1.__decorate([
958
+ hooks_1.hooks([
959
+ errorHandler_1.ErrorHandlerMW,
960
+ concurrentLocker_1.ConcurrentLockerMW,
961
+ projectMigrator_1.ProjectMigratorMW,
962
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
963
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
964
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
965
+ questionModel_1.QuestionModelMW,
966
+ contextInjector_1.ContextInjectorMW,
967
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
968
+ envInfoWriterV3_1.EnvInfoWriterMW_V3(),
969
+ ]),
970
+ tslib_1.__metadata("design:type", Function),
971
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
972
+ tslib_1.__metadata("design:returntype", Promise)
973
+ ], FxCore.prototype, "deployArtifactsV3", null);
974
+ tslib_1.__decorate([
975
+ hooks_1.hooks([
976
+ errorHandler_1.ErrorHandlerMW,
977
+ concurrentLocker_1.ConcurrentLockerMW,
978
+ projectMigrator_1.ProjectMigratorMW,
979
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
980
+ envInfoLoader_1.EnvInfoLoaderMW(!tools_1.isConfigUnifyEnabled()),
981
+ localSettingsLoader_1.LocalSettingsLoaderMW,
982
+ solutionLoader_1.SolutionLoaderMW,
983
+ questionModel_1.QuestionModelMW,
984
+ contextInjector_1.ContextInjectorMW,
985
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
986
+ envInfoWriter_1.EnvInfoWriterMW(!tools_1.isConfigUnifyEnabled()),
987
+ localSettingsWriter_1.LocalSettingsWriterMW,
988
+ ]),
989
+ tslib_1.__metadata("design:type", Function),
990
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
991
+ tslib_1.__metadata("design:returntype", Promise)
992
+ ], FxCore.prototype, "localDebugV2", null);
993
+ tslib_1.__decorate([
994
+ hooks_1.hooks([
995
+ errorHandler_1.ErrorHandlerMW,
996
+ concurrentLocker_1.ConcurrentLockerMW,
997
+ projectMigrator_1.ProjectMigratorMW,
998
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
999
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1000
+ solutionLoader_1.SolutionLoaderMW,
1001
+ questionModel_1.QuestionModelMW,
1002
+ contextInjector_1.ContextInjectorMW,
1003
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1004
+ envInfoWriter_1.EnvInfoWriterMW(),
1005
+ ]),
1006
+ tslib_1.__metadata("design:type", Function),
1007
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1008
+ tslib_1.__metadata("design:returntype", Promise)
1009
+ ], FxCore.prototype, "publishApplicationV2", null);
1010
+ tslib_1.__decorate([
1011
+ hooks_1.hooks([
1012
+ errorHandler_1.ErrorHandlerMW,
1013
+ concurrentLocker_1.ConcurrentLockerMW,
1014
+ projectMigrator_1.ProjectMigratorMW,
1015
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1016
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1017
+ solutionLoader_1.SolutionLoaderMW,
1018
+ questionModel_1.QuestionModelMW,
1019
+ contextInjector_1.ContextInjectorMW,
1020
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1021
+ envInfoWriter_1.EnvInfoWriterMW(),
1022
+ ]),
1023
+ tslib_1.__metadata("design:type", Function),
1024
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1025
+ tslib_1.__metadata("design:returntype", Promise)
1026
+ ], FxCore.prototype, "publishApplicationV3", null);
1027
+ tslib_1.__decorate([
1028
+ hooks_1.hooks([
1029
+ errorHandler_1.ErrorHandlerMW,
1030
+ concurrentLocker_1.ConcurrentLockerMW,
1031
+ projectMigrator_1.ProjectMigratorMW,
1032
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1033
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1034
+ localSettingsLoader_1.LocalSettingsLoaderMW,
1035
+ solutionLoader_1.SolutionLoaderMW,
1036
+ questionModel_1.QuestionModelMW,
1037
+ contextInjector_1.ContextInjectorMW,
1038
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1039
+ envInfoWriter_1.EnvInfoWriterMW(),
1040
+ ]),
1041
+ tslib_1.__metadata("design:type", Function),
1042
+ tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
1043
+ tslib_1.__metadata("design:returntype", Promise)
1044
+ ], FxCore.prototype, "executeUserTaskV2", null);
1045
+ tslib_1.__decorate([
1046
+ hooks_1.hooks([
1047
+ errorHandler_1.ErrorHandlerMW,
1048
+ concurrentLocker_1.ConcurrentLockerMW,
1049
+ projectMigrator_1.ProjectMigratorMW,
1050
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1051
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1052
+ localSettingsLoader_1.LocalSettingsLoaderMW,
1053
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1054
+ questionModel_1.QuestionModelMW,
1055
+ contextInjector_1.ContextInjectorMW,
1056
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1057
+ envInfoWriter_1.EnvInfoWriterMW(),
1058
+ ]),
1059
+ tslib_1.__metadata("design:type", Function),
1060
+ tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
1061
+ tslib_1.__metadata("design:returntype", Promise)
1062
+ ], FxCore.prototype, "executeUserTaskV3", null);
1063
+ tslib_1.__decorate([
1064
+ hooks_1.hooks([
1065
+ errorHandler_1.ErrorHandlerMW,
1066
+ concurrentLocker_1.ConcurrentLockerMW,
1067
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1068
+ envInfoLoader_1.EnvInfoLoaderMW(true),
1069
+ solutionLoader_1.SolutionLoaderMW,
1070
+ contextInjector_1.ContextInjectorMW,
1071
+ envInfoWriter_1.EnvInfoWriterMW(),
1072
+ ]),
1073
+ tslib_1.__metadata("design:type", Function),
1074
+ tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
1075
+ tslib_1.__metadata("design:returntype", Promise)
1076
+ ], FxCore.prototype, "getQuestions", null);
1077
+ tslib_1.__decorate([
1078
+ hooks_1.hooks([
1079
+ errorHandler_1.ErrorHandlerMW,
1080
+ concurrentLocker_1.ConcurrentLockerMW,
1081
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1082
+ envInfoLoader_1.EnvInfoLoaderMW(true),
1083
+ solutionLoader_1.SolutionLoaderMW,
1084
+ contextInjector_1.ContextInjectorMW,
1085
+ envInfoWriter_1.EnvInfoWriterMW(),
1086
+ ]),
1087
+ tslib_1.__metadata("design:type", Function),
1088
+ tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
1089
+ tslib_1.__metadata("design:returntype", Promise)
1090
+ ], FxCore.prototype, "getQuestionsForUserTask", null);
1091
+ tslib_1.__decorate([
1092
+ hooks_1.hooks([
1093
+ errorHandler_1.ErrorHandlerMW,
1094
+ concurrentLocker_1.ConcurrentLockerMW,
1095
+ projectMigrator_1.ProjectMigratorMW,
1096
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1097
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1098
+ localSettingsLoader_1.LocalSettingsLoaderMW,
1099
+ contextInjector_1.ContextInjectorMW,
1100
+ ]),
1101
+ tslib_1.__metadata("design:type", Function),
1102
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1103
+ tslib_1.__metadata("design:returntype", Promise)
1104
+ ], FxCore.prototype, "getProjectConfig", null);
1105
+ tslib_1.__decorate([
1106
+ hooks_1.hooks([errorHandler_1.ErrorHandlerMW, concurrentLocker_1.ConcurrentLockerMW, projectSettingsLoader_1.ProjectSettingsLoaderMW, contextInjector_1.ContextInjectorMW]),
1107
+ tslib_1.__metadata("design:type", Function),
1108
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1109
+ tslib_1.__metadata("design:returntype", Promise)
1110
+ ], FxCore.prototype, "getProjectConfigV3", null);
1111
+ tslib_1.__decorate([
1112
+ hooks_1.hooks([
1113
+ errorHandler_1.ErrorHandlerMW,
1114
+ concurrentLocker_1.ConcurrentLockerMW,
1115
+ projectMigrator_1.ProjectMigratorMW,
1116
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1117
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1118
+ solutionLoader_1.SolutionLoaderMW,
1119
+ questionModel_1.QuestionModelMW,
1120
+ contextInjector_1.ContextInjectorMW,
1121
+ ]),
1122
+ tslib_1.__metadata("design:type", Function),
1123
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1124
+ tslib_1.__metadata("design:returntype", Promise)
1125
+ ], FxCore.prototype, "grantPermissionV2", null);
1126
+ tslib_1.__decorate([
1127
+ hooks_1.hooks([
1128
+ errorHandler_1.ErrorHandlerMW,
1129
+ concurrentLocker_1.ConcurrentLockerMW,
1130
+ projectMigrator_1.ProjectMigratorMW,
1131
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1132
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1133
+ questionModel_1.QuestionModelMW,
1134
+ contextInjector_1.ContextInjectorMW,
1135
+ ]),
1136
+ tslib_1.__metadata("design:type", Function),
1137
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1138
+ tslib_1.__metadata("design:returntype", Promise)
1139
+ ], FxCore.prototype, "grantPermissionV3", null);
1140
+ tslib_1.__decorate([
1141
+ hooks_1.hooks([
1142
+ errorHandler_1.ErrorHandlerMW,
1143
+ concurrentLocker_1.ConcurrentLockerMW,
1144
+ projectMigrator_1.ProjectMigratorMW,
1145
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1146
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1147
+ solutionLoader_1.SolutionLoaderMW,
1148
+ questionModel_1.QuestionModelMW,
1149
+ contextInjector_1.ContextInjectorMW,
1150
+ ]),
1151
+ tslib_1.__metadata("design:type", Function),
1152
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1153
+ tslib_1.__metadata("design:returntype", Promise)
1154
+ ], FxCore.prototype, "checkPermissionV2", null);
1155
+ tslib_1.__decorate([
1156
+ hooks_1.hooks([
1157
+ errorHandler_1.ErrorHandlerMW,
1158
+ concurrentLocker_1.ConcurrentLockerMW,
1159
+ projectMigrator_1.ProjectMigratorMW,
1160
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1161
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1162
+ contextInjector_1.ContextInjectorMW,
1163
+ ]),
1164
+ tslib_1.__metadata("design:type", Function),
1165
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1166
+ tslib_1.__metadata("design:returntype", Promise)
1167
+ ], FxCore.prototype, "checkPermissionV3", null);
1168
+ tslib_1.__decorate([
1169
+ hooks_1.hooks([
1170
+ errorHandler_1.ErrorHandlerMW,
1171
+ concurrentLocker_1.ConcurrentLockerMW,
1172
+ projectMigrator_1.ProjectMigratorMW,
1173
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1174
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1175
+ solutionLoader_1.SolutionLoaderMW,
1176
+ questionModel_1.QuestionModelMW,
1177
+ contextInjector_1.ContextInjectorMW,
1178
+ ]),
1179
+ tslib_1.__metadata("design:type", Function),
1180
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1181
+ tslib_1.__metadata("design:returntype", Promise)
1182
+ ], FxCore.prototype, "listCollaboratorV2", null);
1183
+ tslib_1.__decorate([
1184
+ hooks_1.hooks([
1185
+ errorHandler_1.ErrorHandlerMW,
1186
+ concurrentLocker_1.ConcurrentLockerMW,
1187
+ projectMigrator_1.ProjectMigratorMW,
1188
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1189
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1190
+ contextInjector_1.ContextInjectorMW,
1191
+ ]),
1192
+ tslib_1.__metadata("design:type", Function),
1193
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1194
+ tslib_1.__metadata("design:returntype", Promise)
1195
+ ], FxCore.prototype, "listCollaboratorV3", null);
1196
+ tslib_1.__decorate([
1197
+ hooks_1.hooks([
1198
+ errorHandler_1.ErrorHandlerMW,
1199
+ concurrentLocker_1.ConcurrentLockerMW,
1200
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1201
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1202
+ contextInjector_1.ContextInjectorMW,
1203
+ ]),
1204
+ tslib_1.__metadata("design:type", Function),
1205
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1206
+ tslib_1.__metadata("design:returntype", Promise)
1207
+ ], FxCore.prototype, "getSelectedEnv", null);
1208
+ tslib_1.__decorate([
1209
+ hooks_1.hooks([
1210
+ errorHandler_1.ErrorHandlerMW,
1211
+ concurrentLocker_1.ConcurrentLockerMW,
1212
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1213
+ envInfoLoader_1.EnvInfoLoaderMW(true),
1214
+ contextInjector_1.ContextInjectorMW,
1215
+ ]),
1216
+ tslib_1.__metadata("design:type", Function),
1217
+ tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
1218
+ tslib_1.__metadata("design:returntype", Promise)
1219
+ ], FxCore.prototype, "encrypt", null);
1220
+ tslib_1.__decorate([
1221
+ hooks_1.hooks([
1222
+ errorHandler_1.ErrorHandlerMW,
1223
+ concurrentLocker_1.ConcurrentLockerMW,
1224
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1225
+ envInfoLoader_1.EnvInfoLoaderMW(true),
1226
+ contextInjector_1.ContextInjectorMW,
1227
+ ]),
1228
+ tslib_1.__metadata("design:type", Function),
1229
+ tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
1230
+ tslib_1.__metadata("design:returntype", Promise)
1231
+ ], FxCore.prototype, "decrypt", null);
1232
+ tslib_1.__decorate([
1233
+ hooks_1.hooks([
1234
+ errorHandler_1.ErrorHandlerMW,
1235
+ concurrentLocker_1.ConcurrentLockerMW,
1236
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1237
+ solutionLoader_1.SolutionLoaderMW,
1238
+ envInfoLoader_1.EnvInfoLoaderMW(true),
1239
+ contextInjector_1.ContextInjectorMW,
1240
+ ]),
1241
+ tslib_1.__metadata("design:type", Function),
1242
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1243
+ tslib_1.__metadata("design:returntype", Promise)
1244
+ ], FxCore.prototype, "createEnv", null);
1245
+ tslib_1.__decorate([
1246
+ hooks_1.hooks([
1247
+ errorHandler_1.ErrorHandlerMW,
1248
+ concurrentLocker_1.ConcurrentLockerMW,
1249
+ projectMigrator_1.ProjectMigratorMW,
1250
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1251
+ solutionLoader_1.SolutionLoaderMW,
1252
+ contextInjector_1.ContextInjectorMW,
1253
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1254
+ ]),
1255
+ tslib_1.__metadata("design:type", Function),
1256
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1257
+ tslib_1.__metadata("design:returntype", Promise)
1258
+ ], FxCore.prototype, "activateEnv", null);
1259
+ tslib_1.__decorate([
1260
+ hooks_1.hooks([errorHandler_1.ErrorHandlerMW, questionModel_1.QuestionModelMW, contextInjector_1.ContextInjectorMW, projectSettingsWriter_1.ProjectSettingsWriterMW]),
1261
+ tslib_1.__metadata("design:type", Function),
1262
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1263
+ tslib_1.__metadata("design:returntype", Promise)
1264
+ ], FxCore.prototype, "init", null);
1265
+ tslib_1.__decorate([
1266
+ hooks_1.hooks([
1267
+ errorHandler_1.ErrorHandlerMW,
1268
+ concurrentLocker_1.ConcurrentLockerMW,
1269
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1270
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1271
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1272
+ questionModel_1.QuestionModelMW,
1273
+ contextInjector_1.ContextInjectorMW,
1274
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1275
+ ]),
1276
+ tslib_1.__metadata("design:type", Function),
1277
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1278
+ tslib_1.__metadata("design:returntype", Promise)
1279
+ ], FxCore.prototype, "addFeature", null);
1280
+ exports.FxCore = FxCore;
1281
+ async function ensureBasicFolderStructure(inputs) {
1282
+ if (!inputs.projectPath) {
1283
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
1284
+ }
1285
+ try {
1286
+ {
1287
+ const appName = inputs[question_2.QuestionAppName.name];
1288
+ if (inputs.platform !== teamsfx_api_1.Platform.VS) {
1289
+ const packageJsonFilePath = path.join(inputs.projectPath, `package.json`);
1290
+ const exists = await fs.pathExists(packageJsonFilePath);
1291
+ if (!exists) {
1292
+ await fs.writeFile(packageJsonFilePath, JSON.stringify({
1293
+ name: appName,
1294
+ version: "0.0.1",
1295
+ description: "",
1296
+ author: "",
1297
+ scripts: {
1298
+ test: 'echo "Error: no test specified" && exit 1',
1299
+ },
1300
+ devDependencies: {
1301
+ "@microsoft/teamsfx-cli": "0.*",
1302
+ },
1303
+ license: "MIT",
1304
+ }, null, 4));
1305
+ }
1306
+ }
1307
+ }
1308
+ {
1309
+ const gitIgnoreFilePath = path.join(inputs.projectPath, `.gitignore`);
1310
+ const exists = await fs.pathExists(gitIgnoreFilePath);
1311
+ if (!exists) {
1312
+ const gitIgnoreContent = [
1313
+ "node_modules",
1314
+ `.${teamsfx_api_1.ConfigFolderName}/${teamsfx_api_1.InputConfigsFolderName}/${localSettingsProvider_1.localSettingsFileName}`,
1315
+ `.${teamsfx_api_1.ConfigFolderName}/${teamsfx_api_1.StatesFolderName}/*.userdata`,
1316
+ ".DS_Store",
1317
+ ".env.teamsfx.local",
1318
+ "subscriptionInfo.json",
1319
+ teamsfx_api_1.BuildFolderName,
1320
+ ];
1321
+ if (inputs.platform === teamsfx_api_1.Platform.VS) {
1322
+ gitIgnoreContent.push("appsettings.Development.json");
1323
+ }
1324
+ await fs.writeFile(gitIgnoreFilePath, gitIgnoreContent.join("\n"));
1325
+ }
1326
+ }
1327
+ }
1328
+ catch (e) {
1329
+ return teamsfx_api_1.err(error_1.WriteFileError(e));
1330
+ }
1331
+ return teamsfx_api_1.ok(null);
1332
+ }
1333
+ exports.ensureBasicFolderStructure = ensureBasicFolderStructure;
1334
+ //# sourceMappingURL=FxCore.js.map