@microsoft/teamsfx-core 1.13.0 → 1.13.1-alpha.ae549cb45.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 (280) hide show
  1. package/build/common/deps-checker/depsChecker.d.ts +15 -5
  2. package/build/common/deps-checker/depsChecker.d.ts.map +1 -1
  3. package/build/common/deps-checker/depsChecker.js.map +1 -1
  4. package/build/common/deps-checker/depsManager.d.ts +1 -15
  5. package/build/common/deps-checker/depsManager.d.ts.map +1 -1
  6. package/build/common/deps-checker/depsManager.js +4 -17
  7. package/build/common/deps-checker/depsManager.js.map +1 -1
  8. package/build/common/deps-checker/internal/dotnetChecker.d.ts +4 -5
  9. package/build/common/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
  10. package/build/common/deps-checker/internal/dotnetChecker.js +22 -19
  11. package/build/common/deps-checker/internal/dotnetChecker.js.map +1 -1
  12. package/build/common/deps-checker/internal/funcToolChecker.d.ts +11 -7
  13. package/build/common/deps-checker/internal/funcToolChecker.d.ts.map +1 -1
  14. package/build/common/deps-checker/internal/funcToolChecker.js +40 -28
  15. package/build/common/deps-checker/internal/funcToolChecker.js.map +1 -1
  16. package/build/common/deps-checker/internal/ngrokChecker.d.ts +4 -6
  17. package/build/common/deps-checker/internal/ngrokChecker.d.ts.map +1 -1
  18. package/build/common/deps-checker/internal/ngrokChecker.js +21 -13
  19. package/build/common/deps-checker/internal/ngrokChecker.js.map +1 -1
  20. package/build/common/deps-checker/internal/nodeChecker.d.ts +8 -6
  21. package/build/common/deps-checker/internal/nodeChecker.d.ts.map +1 -1
  22. package/build/common/deps-checker/internal/nodeChecker.js +44 -48
  23. package/build/common/deps-checker/internal/nodeChecker.js.map +1 -1
  24. package/build/common/templates-config.json +2 -2
  25. package/build/component/bicep.d.ts +4 -4
  26. package/build/component/bicep.d.ts.map +1 -1
  27. package/build/component/bicep.js +29 -79
  28. package/build/component/bicep.js.map +1 -1
  29. package/build/component/code/apiCode.d.ts +4 -4
  30. package/build/component/code/apiCode.d.ts.map +1 -1
  31. package/build/component/code/apiCode.js +56 -70
  32. package/build/component/code/apiCode.js.map +1 -1
  33. package/build/component/code/botCode.d.ts +4 -4
  34. package/build/component/code/botCode.d.ts.map +1 -1
  35. package/build/component/code/botCode.js +127 -136
  36. package/build/component/code/botCode.js.map +1 -1
  37. package/build/component/code/spfxTabCode.d.ts +3 -3
  38. package/build/component/code/spfxTabCode.d.ts.map +1 -1
  39. package/build/component/code/spfxTabCode.js +25 -28
  40. package/build/component/code/spfxTabCode.js.map +1 -1
  41. package/build/component/code/tabCode.d.ts +5 -5
  42. package/build/component/code/tabCode.d.ts.map +1 -1
  43. package/build/component/code/tabCode.js +139 -160
  44. package/build/component/code/tabCode.js.map +1 -1
  45. package/build/component/connection/apimConfig.d.ts +0 -2
  46. package/build/component/connection/apimConfig.d.ts.map +1 -1
  47. package/build/component/connection/apimConfig.js +2 -16
  48. package/build/component/connection/apimConfig.js.map +1 -1
  49. package/build/component/connection/azureFunctionConfig.d.ts +0 -2
  50. package/build/component/connection/azureFunctionConfig.d.ts.map +1 -1
  51. package/build/component/connection/azureFunctionConfig.js +2 -15
  52. package/build/component/connection/azureFunctionConfig.js.map +1 -1
  53. package/build/component/connection/azureResourceConfig.d.ts +2 -2
  54. package/build/component/connection/azureResourceConfig.d.ts.map +1 -1
  55. package/build/component/connection/azureResourceConfig.js +43 -60
  56. package/build/component/connection/azureResourceConfig.js.map +1 -1
  57. package/build/component/connection/azureWebAppConfig.d.ts +0 -2
  58. package/build/component/connection/azureWebAppConfig.d.ts.map +1 -1
  59. package/build/component/connection/azureWebAppConfig.js +2 -14
  60. package/build/component/connection/azureWebAppConfig.js.map +1 -1
  61. package/build/component/constants.d.ts +1 -0
  62. package/build/component/constants.d.ts.map +1 -1
  63. package/build/component/constants.js +6 -1
  64. package/build/component/constants.js.map +1 -1
  65. package/build/component/core.d.ts +22 -25
  66. package/build/component/core.d.ts.map +1 -1
  67. package/build/component/core.js +442 -449
  68. package/build/component/core.js.map +1 -1
  69. package/build/component/debug.d.ts +1 -7
  70. package/build/component/debug.d.ts.map +1 -1
  71. package/build/component/debug.js +1 -70
  72. package/build/component/debug.js.map +1 -1
  73. package/build/component/envManager.d.ts +2 -5
  74. package/build/component/envManager.d.ts.map +1 -1
  75. package/build/component/envManager.js +10 -129
  76. package/build/component/envManager.js.map +1 -1
  77. package/build/component/feature/api.d.ts +1 -7
  78. package/build/component/feature/api.d.ts.map +1 -1
  79. package/build/component/feature/api.js +112 -145
  80. package/build/component/feature/api.js.map +1 -1
  81. package/build/component/feature/apim.d.ts.map +1 -1
  82. package/build/component/feature/apim.js +64 -86
  83. package/build/component/feature/apim.js.map +1 -1
  84. package/build/component/feature/bot.d.ts +3 -12
  85. package/build/component/feature/bot.d.ts.map +1 -1
  86. package/build/component/feature/bot.js +221 -210
  87. package/build/component/feature/bot.js.map +1 -1
  88. package/build/component/feature/keyVault.d.ts.map +1 -1
  89. package/build/component/feature/keyVault.js +48 -101
  90. package/build/component/feature/keyVault.js.map +1 -1
  91. package/build/component/feature/spfx.d.ts.map +1 -1
  92. package/build/component/feature/spfx.js +52 -55
  93. package/build/component/feature/spfx.js.map +1 -1
  94. package/build/component/feature/sql.d.ts +0 -6
  95. package/build/component/feature/sql.d.ts.map +1 -1
  96. package/build/component/feature/sql.js +57 -113
  97. package/build/component/feature/sql.js.map +1 -1
  98. package/build/component/feature/sso.d.ts +5 -7
  99. package/build/component/feature/sso.d.ts.map +1 -1
  100. package/build/component/feature/sso.js +101 -175
  101. package/build/component/feature/sso.js.map +1 -1
  102. package/build/component/feature/tab.d.ts +1 -6
  103. package/build/component/feature/tab.d.ts.map +1 -1
  104. package/build/component/feature/tab.js +165 -197
  105. package/build/component/feature/tab.js.map +1 -1
  106. package/build/component/messages.d.ts +3 -0
  107. package/build/component/messages.d.ts.map +1 -1
  108. package/build/component/messages.js +3 -0
  109. package/build/component/messages.js.map +1 -1
  110. package/build/component/middleware/actionExecutionMW.d.ts +20 -0
  111. package/build/component/middleware/actionExecutionMW.d.ts.map +1 -0
  112. package/build/component/middleware/actionExecutionMW.js +100 -0
  113. package/build/component/middleware/actionExecutionMW.js.map +1 -0
  114. package/build/component/migrate.d.ts.map +1 -1
  115. package/build/component/migrate.js +2 -26
  116. package/build/component/migrate.js.map +1 -1
  117. package/build/component/questionV3.d.ts +1 -0
  118. package/build/component/questionV3.d.ts.map +1 -1
  119. package/build/component/questionV3.js +42 -10
  120. package/build/component/questionV3.js.map +1 -1
  121. package/build/component/resource/aadApp/aadApp.d.ts +7 -7
  122. package/build/component/resource/aadApp/aadApp.d.ts.map +1 -1
  123. package/build/component/resource/aadApp/aadApp.js +56 -18
  124. package/build/component/resource/aadApp/aadApp.js.map +1 -1
  125. package/build/component/resource/aadApp/actions/configure.js +2 -2
  126. package/build/component/resource/aadApp/actions/configure.js.map +1 -1
  127. package/build/component/resource/aadApp/actions/deploy.d.ts +3 -0
  128. package/build/component/resource/aadApp/actions/deploy.d.ts.map +1 -0
  129. package/build/component/resource/aadApp/actions/deploy.js +70 -0
  130. package/build/component/resource/aadApp/actions/deploy.js.map +1 -0
  131. package/build/component/resource/aadApp/actions/generateManifest.d.ts.map +1 -1
  132. package/build/component/resource/aadApp/actions/generateManifest.js +3 -1
  133. package/build/component/resource/aadApp/actions/generateManifest.js.map +1 -1
  134. package/build/component/resource/aadApp/actions/provision.d.ts +1 -2
  135. package/build/component/resource/aadApp/actions/provision.d.ts.map +1 -1
  136. package/build/component/resource/aadApp/actions/provision.js +3 -33
  137. package/build/component/resource/aadApp/actions/provision.js.map +1 -1
  138. package/build/component/resource/aadApp/actions/setApplication.js +2 -2
  139. package/build/component/resource/aadApp/actions/setApplication.js.map +1 -1
  140. package/build/component/resource/aadApp/actions/utils.d.ts +3 -0
  141. package/build/component/resource/aadApp/actions/utils.d.ts.map +1 -0
  142. package/build/component/resource/aadApp/actions/utils.js +38 -0
  143. package/build/component/resource/aadApp/actions/utils.js.map +1 -0
  144. package/build/component/resource/apim.d.ts +4 -5
  145. package/build/component/resource/apim.d.ts.map +1 -1
  146. package/build/component/resource/apim.js +21 -63
  147. package/build/component/resource/apim.js.map +1 -1
  148. package/build/component/resource/appManifest/appManifest.d.ts +5 -5
  149. package/build/component/resource/appManifest/appManifest.d.ts.map +1 -1
  150. package/build/component/resource/appManifest/appManifest.js +82 -117
  151. package/build/component/resource/appManifest/appManifest.js.map +1 -1
  152. package/build/component/resource/azureAppService/azureAppService.d.ts +3 -3
  153. package/build/component/resource/azureAppService/azureAppService.d.ts.map +1 -1
  154. package/build/component/resource/azureAppService/azureAppService.js +24 -36
  155. package/build/component/resource/azureAppService/azureAppService.js.map +1 -1
  156. package/build/component/resource/azureAppService/azureFunction.d.ts +2 -2
  157. package/build/component/resource/azureAppService/azureFunction.d.ts.map +1 -1
  158. package/build/component/resource/azureAppService/azureFunction.js +2 -25
  159. package/build/component/resource/azureAppService/azureFunction.js.map +1 -1
  160. package/build/component/resource/azureResource.d.ts +2 -2
  161. package/build/component/resource/azureResource.d.ts.map +1 -1
  162. package/build/component/resource/azureResource.js +29 -47
  163. package/build/component/resource/azureResource.js.map +1 -1
  164. package/build/component/resource/azureSql/actions/configure.d.ts.map +1 -1
  165. package/build/component/resource/azureSql/azureSql.d.ts +4 -4
  166. package/build/component/resource/azureSql/azureSql.d.ts.map +1 -1
  167. package/build/component/resource/azureSql/azureSql.js +41 -7
  168. package/build/component/resource/azureSql/azureSql.js.map +1 -1
  169. package/build/component/resource/azureStorage.d.ts +3 -3
  170. package/build/component/resource/azureStorage.d.ts.map +1 -1
  171. package/build/component/resource/azureStorage.js +45 -56
  172. package/build/component/resource/azureStorage.js.map +1 -1
  173. package/build/component/resource/botService.d.ts +4 -4
  174. package/build/component/resource/botService.d.ts.map +1 -1
  175. package/build/component/resource/botService.js +66 -74
  176. package/build/component/resource/botService.js.map +1 -1
  177. package/build/component/resource/identity.d.ts.map +1 -1
  178. package/build/component/resource/identity.js +9 -4
  179. package/build/component/resource/identity.js.map +1 -1
  180. package/build/component/resource/spfx.d.ts +2 -2
  181. package/build/component/resource/spfx.d.ts.map +1 -1
  182. package/build/component/resource/spfx.js +23 -34
  183. package/build/component/resource/spfx.js.map +1 -1
  184. package/build/component/utils.d.ts +12 -1
  185. package/build/component/utils.d.ts.map +1 -1
  186. package/build/component/utils.js +108 -45
  187. package/build/component/utils.js.map +1 -1
  188. package/build/component/workflow.d.ts +2 -1
  189. package/build/component/workflow.d.ts.map +1 -1
  190. package/build/component/workflow.js +41 -29
  191. package/build/component/workflow.js.map +1 -1
  192. package/build/core/FxCore.d.ts.map +1 -1
  193. package/build/core/FxCore.js +9 -65
  194. package/build/core/FxCore.js.map +1 -1
  195. package/build/core/middleware/questionModel.d.ts.map +1 -1
  196. package/build/core/middleware/questionModel.js +19 -5
  197. package/build/core/middleware/questionModel.js.map +1 -1
  198. package/build/plugins/resource/frontend/dotnet/plugin.d.ts.map +1 -1
  199. package/build/plugins/resource/frontend/dotnet/plugin.js +6 -3
  200. package/build/plugins/resource/frontend/dotnet/plugin.js.map +1 -1
  201. package/build/plugins/resource/frontend/dotnet/resources/templateInfo.d.ts +2 -1
  202. package/build/plugins/resource/frontend/dotnet/resources/templateInfo.d.ts.map +1 -1
  203. package/build/plugins/resource/frontend/dotnet/resources/templateInfo.js +3 -2
  204. package/build/plugins/resource/frontend/dotnet/resources/templateInfo.js.map +1 -1
  205. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  206. package/build/plugins/solution/fx-solution/solution.js +1 -1
  207. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  208. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
  209. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +1 -1
  210. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
  211. package/build/plugins/solution/fx-solution/v2/utils.d.ts +2 -2
  212. package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
  213. package/build/plugins/solution/fx-solution/v2/utils.js +19 -6
  214. package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
  215. package/build/plugins/solution/fx-solution/v3/provision.d.ts.map +1 -1
  216. package/build/plugins/solution/fx-solution/v3/provision.js +41 -30
  217. package/build/plugins/solution/fx-solution/v3/provision.js.map +1 -1
  218. package/package.json +4 -4
  219. package/resource/package.nls.cs.json +20 -16
  220. package/resource/package.nls.de.json +20 -16
  221. package/resource/package.nls.es.json +21 -17
  222. package/resource/package.nls.fr.json +20 -16
  223. package/resource/package.nls.it.json +20 -16
  224. package/resource/package.nls.ja.json +21 -17
  225. package/resource/package.nls.json +3 -1
  226. package/resource/package.nls.ko.json +21 -17
  227. package/resource/package.nls.pl.json +21 -17
  228. package/resource/package.nls.pt-BR.json +21 -17
  229. package/resource/package.nls.ru.json +21 -17
  230. package/resource/package.nls.tr.json +21 -17
  231. package/resource/package.nls.zh-Hans.json +21 -17
  232. package/resource/package.nls.zh-Hant.json +21 -17
  233. package/templates/bicep/apim.config.module.bicep +2 -2
  234. package/templates/bicep/azureFunction.config.module.bicep +7 -4
  235. package/templates/bicep/azureFunction.config.orchestration.bicep +2 -2
  236. package/templates/bicep/azureFunction.provision.orchestration.bicep +5 -0
  237. package/templates/bicep/azureStorage.provision.orchestration.bicep +6 -0
  238. package/templates/bicep/azureWebApp.config.module.bicep +5 -5
  239. package/templates/bicep/azureWebApp.config.orchestration.bicep +1 -1
  240. package/templates/bicep/azureWebApp.provision.orchestration.bicep +5 -0
  241. package/templates/fallback/bot.csharp.command-and-response.zip +0 -0
  242. package/templates/fallback/bot.csharp.default.zip +0 -0
  243. package/templates/fallback/bot.csharp.notification-function-base.zip +0 -0
  244. package/templates/fallback/bot.csharp.notification-trigger-http.zip +0 -0
  245. package/templates/fallback/bot.csharp.notification-trigger-timer.zip +0 -0
  246. package/templates/fallback/bot.csharp.notification-webapi.zip +0 -0
  247. package/templates/fallback/bot.js.command-and-response.zip +0 -0
  248. package/templates/fallback/bot.js.default.zip +0 -0
  249. package/templates/fallback/bot.js.m365.zip +0 -0
  250. package/templates/fallback/bot.js.notification-function-base.zip +0 -0
  251. package/templates/fallback/bot.js.notification-restify.zip +0 -0
  252. package/templates/fallback/bot.js.notification-trigger-http.zip +0 -0
  253. package/templates/fallback/bot.js.notification-trigger-timer.zip +0 -0
  254. package/templates/fallback/bot.ts.command-and-response.zip +0 -0
  255. package/templates/fallback/bot.ts.default.zip +0 -0
  256. package/templates/fallback/bot.ts.m365.zip +0 -0
  257. package/templates/fallback/bot.ts.notification-function-base.zip +0 -0
  258. package/templates/fallback/bot.ts.notification-restify.zip +0 -0
  259. package/templates/fallback/bot.ts.notification-trigger-http.zip +0 -0
  260. package/templates/fallback/bot.ts.notification-trigger-timer.zip +0 -0
  261. package/templates/fallback/function-base.js.default.zip +0 -0
  262. package/templates/fallback/function-base.ts.default.zip +0 -0
  263. package/templates/fallback/function-triggers.js.HTTPTrigger.zip +0 -0
  264. package/templates/fallback/function-triggers.ts.HTTPTrigger.zip +0 -0
  265. package/templates/fallback/tab.csharp.default.zip +0 -0
  266. package/templates/fallback/tab.csharp.non-sso.zip +0 -0
  267. package/templates/fallback/tab.js.default.zip +0 -0
  268. package/templates/fallback/tab.js.m365.zip +0 -0
  269. package/templates/fallback/tab.js.non-sso.zip +0 -0
  270. package/templates/fallback/tab.ts.default.zip +0 -0
  271. package/templates/fallback/tab.ts.m365.zip +0 -0
  272. package/templates/fallback/tab.ts.non-sso.zip +0 -0
  273. package/build/component/fx/preDeployAction.d.ts +0 -7
  274. package/build/component/fx/preDeployAction.d.ts.map +0 -1
  275. package/build/component/fx/preDeployAction.js +0 -28
  276. package/build/component/fx/preDeployAction.js.map +0 -1
  277. package/build/component/fx/preProvisionAction.d.ts +0 -7
  278. package/build/component/fx/preProvisionAction.d.ts.map +0 -1
  279. package/build/component/fx/preProvisionAction.js +0 -71
  280. package/build/component/fx/preProvisionAction.js.map +0 -1
@@ -9,57 +9,59 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
9
  const path_1 = tslib_1.__importDefault(require("path"));
10
10
  require("reflect-metadata");
11
11
  const typedi_1 = require("typedi");
12
- const projectSettingsLoader_1 = require("../core/middleware/projectSettingsLoader");
13
12
  const question_1 = require("../core/question");
14
13
  const projectSettingsHelper_1 = require("./../common/projectSettingsHelper");
15
14
  require("./bicep");
16
- require("./debug");
17
- require("./envManager");
18
- require("./resource/appManifest/appManifest");
19
- require("./resource/azureSql");
15
+ require("./code/apiCode");
16
+ require("./code/botCode");
17
+ require("./code/spfxTabCode");
18
+ require("./code/tabCode");
19
+ require("./connection/apimConfig");
20
+ require("./connection/azureFunctionConfig");
21
+ require("./connection/azureWebAppConfig");
22
+ const debug_1 = require("./debug");
23
+ const envManager_1 = require("./envManager");
24
+ require("./feature/api");
25
+ require("./feature/apiConnector");
26
+ require("./feature/apim");
27
+ require("./feature/bot");
28
+ require("./feature/cicd");
29
+ require("./feature/keyVault");
30
+ require("./feature/spfx");
31
+ require("./feature/sql");
32
+ require("./feature/sso");
33
+ require("./feature/tab");
20
34
  require("./resource/aadApp/aadApp");
35
+ require("./resource/apim");
21
36
  require("./resource/azureAppService/azureFunction");
22
- require("./resource/azureStorage");
23
37
  require("./resource/azureAppService/azureWebApp");
38
+ require("./resource/azureSql");
39
+ require("./resource/azureStorage");
24
40
  require("./resource/botService");
25
41
  require("./resource/keyVault");
26
- require("./feature/apim");
27
- require("./resource/apim");
28
- require("./feature/spfx");
29
42
  require("./resource/spfx");
30
- require("./feature/api");
31
- require("./feature/bot");
32
- require("./feature/sql");
33
- require("./feature/tab");
34
- require("./feature/cicd");
35
- require("./feature/keyVault");
36
- require("./feature/sso");
37
- require("./feature/apiConnector");
38
- require("./code/botCode");
39
- require("./code/tabCode");
40
- require("./code/apiCode");
41
- require("./code/spfxTabCode");
42
- require("./connection/azureWebAppConfig");
43
- require("./connection/azureFunctionConfig");
44
- require("./connection/apimConfig");
45
- const constants_1 = require("./constants");
43
+ const jsonschema = tslib_1.__importStar(require("jsonschema"));
44
+ const lodash_1 = require("lodash");
45
+ const constants_1 = require("../common/constants");
46
+ const globalState_1 = require("../common/globalState");
46
47
  const localizeUtils_1 = require("../common/localizeUtils");
47
- const tools_1 = require("../common/tools");
48
- const workflow_1 = require("./workflow");
49
- const preDeployAction_1 = require("./fx/preDeployAction");
50
- const preProvisionAction_1 = require("./fx/preProvisionAction");
51
- const migrate_1 = require("./migrate");
52
- const constants_2 = require("../common/constants");
53
48
  const projectSettingsHelperV3_1 = require("../common/projectSettingsHelperV3");
54
- const utils_1 = require("../plugins/solution/fx-solution/v2/utils");
55
- const questionModel_1 = require("../core/middleware/questionModel");
56
- const error_1 = require("../core/error");
57
- const globalState_1 = require("../common/globalState");
49
+ const tools_1 = require("../common/tools");
58
50
  const downloadSample_1 = require("../core/downloadSample");
59
- const jsonschema = tslib_1.__importStar(require("jsonschema"));
51
+ const error_1 = require("../core/error");
60
52
  const globalVars_1 = require("../core/globalVars");
53
+ const questionModel_1 = require("../core/middleware/questionModel");
54
+ const arm_1 = tslib_1.__importStar(require("../plugins/solution/fx-solution/arm"));
61
55
  const question_2 = require("../plugins/solution/fx-solution/question");
56
+ const ResourceGroupHelper_1 = require("../plugins/solution/fx-solution/utils/ResourceGroupHelper");
57
+ const executor_1 = require("../plugins/solution/fx-solution/v2/executor");
58
+ const utils_1 = require("../plugins/solution/fx-solution/v2/utils");
59
+ const deploy_1 = require("../plugins/solution/fx-solution/v3/deploy");
60
+ const provision_1 = require("../plugins/solution/fx-solution/v3/provision");
61
+ const constants_2 = require("./constants");
62
+ const migrate_1 = require("./migrate");
62
63
  const questionV3_1 = require("./questionV3");
64
+ const workflow_1 = require("./workflow");
63
65
  let TeamsfxCore = class TeamsfxCore {
64
66
  constructor() {
65
67
  this.name = "fx";
@@ -68,378 +70,288 @@ let TeamsfxCore = class TeamsfxCore {
68
70
  * create project
69
71
  */
70
72
  create(context, inputs) {
71
- const createFromSample = {
72
- type: "function",
73
- name: "fx.createFromSample",
74
- condition: (context, inputs) => {
75
- const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
76
- return teamsfx_api_1.ok(scratch === question_1.ScratchOptionNo.id);
77
- },
78
- execute: async (context, inputs) => {
79
- const downloadRes = await downloadSample_1.downloadSample(inputs);
80
- if (downloadRes.isErr()) {
81
- return teamsfx_api_1.err(downloadRes.error);
82
- }
83
- context.projectPath = downloadRes.value; // used as output for the action
84
- inputs.projectPath = downloadRes.value; // used as inputs for sub-actions
85
- return teamsfx_api_1.ok(["create app from sample"]);
86
- },
87
- };
88
- const createFromNew = {
89
- type: "group",
90
- name: "fx.createFromNew",
91
- condition: (context, inputs) => {
92
- const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
93
- return teamsfx_api_1.ok(scratch === question_1.ScratchOptionYes.id);
94
- },
95
- pre: async (context, inputs) => {
96
- const appName = inputs[question_1.CoreQuestionNames.AppName];
97
- if (undefined === appName)
98
- return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
99
- const validateResult = jsonschema.validate(appName, {
100
- pattern: question_1.ProjectNamePattern,
101
- });
102
- if (validateResult.errors && validateResult.errors.length > 0) {
103
- return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
104
- }
105
- const folder = inputs[question_1.CoreQuestionNames.Folder];
106
- inputs.projectPath = path_1.default.join(folder, appName);
107
- context.projectPath = path_1.default.join(folder, appName);
108
- delete inputs.folder;
109
- globalVars_1.globalVars.isVS = projectSettingsHelper_1.isVSProject(context.projectSetting);
110
- const features = inputs.capabilities;
111
- if (features === question_2.M365SsoLaunchPageOptionItem.id ||
112
- features === question_2.M365SearchAppOptionItem.id) {
113
- context.projectSetting.isM365 = true;
114
- inputs.isM365 = true;
115
- }
116
- inputs[question_2.AzureSolutionQuestionNames.Features] = features;
117
- return teamsfx_api_1.ok(undefined);
118
- },
119
- actions: [
120
- {
121
- type: "call",
122
- targetAction: "fx.init",
123
- required: true,
124
- },
125
- {
126
- type: "call",
127
- targetAction: "teams-bot.add",
128
- required: true,
129
- condition: (context, inputs) => {
130
- return teamsfx_api_1.ok(question_2.BotFeatureIds.includes(inputs[question_2.AzureSolutionQuestionNames.Features]));
131
- },
132
- },
133
- {
134
- type: "call",
135
- targetAction: "teams-tab.add",
136
- required: true,
137
- condition: (context, inputs) => {
138
- return teamsfx_api_1.ok(question_2.TabFeatureIds.includes(inputs[question_2.AzureSolutionQuestionNames.Features]));
139
- },
140
- },
141
- {
142
- type: "call",
143
- targetAction: "spfx-tab.add",
144
- required: true,
145
- condition: (context, inputs) => {
146
- return teamsfx_api_1.ok(question_2.TabSPFxItem.id === inputs[question_2.AzureSolutionQuestionNames.Features]);
147
- },
148
- },
149
- ],
150
- };
151
- const action = {
152
- type: "group",
73
+ const createAction = {
153
74
  name: "fx.create",
75
+ type: "function",
154
76
  question: async (context, inputs) => {
155
77
  return await questionModel_1.getQuestionsForCreateProjectV2(inputs);
156
78
  },
157
- pre: async (context, inputs) => {
158
- const folder = inputs[question_1.CoreQuestionNames.Folder];
79
+ execute: async (context, inputs) => {
80
+ const folder = inputs[question_1.QuestionRootFolder.name];
159
81
  if (!folder) {
160
82
  return teamsfx_api_1.err(error_1.InvalidInputError("folder is undefined"));
161
83
  }
162
- return teamsfx_api_1.ok(undefined);
163
- },
164
- post: async (context, inputs) => {
84
+ inputs.folder = folder;
85
+ const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
86
+ let projectPath;
87
+ const automaticNpmInstall = "automaticNpmInstall";
88
+ if (scratch === question_1.ScratchOptionNo.id) {
89
+ // create from sample
90
+ const downloadRes = await downloadSample_1.downloadSample(inputs);
91
+ if (downloadRes.isErr()) {
92
+ return teamsfx_api_1.err(downloadRes.error);
93
+ }
94
+ projectPath = downloadRes.value;
95
+ }
96
+ else {
97
+ // create from new
98
+ const appName = inputs[question_1.CoreQuestionNames.AppName];
99
+ if (undefined === appName)
100
+ return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
101
+ const validateResult = jsonschema.validate(appName, {
102
+ pattern: question_1.ProjectNamePattern,
103
+ });
104
+ if (validateResult.errors && validateResult.errors.length > 0) {
105
+ return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
106
+ }
107
+ projectPath = path_1.default.join(folder, appName);
108
+ inputs.projectPath = projectPath;
109
+ const initRes = await this.init(context, inputs);
110
+ if (initRes.isErr())
111
+ return teamsfx_api_1.err(initRes.error);
112
+ const features = inputs.capabilities;
113
+ delete inputs.folder;
114
+ if (features === question_2.M365SsoLaunchPageOptionItem.id ||
115
+ features === question_2.M365SearchAppOptionItem.id) {
116
+ context.projectSetting.isM365 = true;
117
+ inputs.isM365 = true;
118
+ }
119
+ if (question_2.BotFeatureIds.includes(features)) {
120
+ inputs[question_2.AzureSolutionQuestionNames.Features] = features;
121
+ const res = await workflow_1.runActionByName("teams-bot.add", context, inputs);
122
+ if (res.isErr())
123
+ return teamsfx_api_1.err(res.error);
124
+ }
125
+ if (question_2.TabFeatureIds.includes(features)) {
126
+ inputs[question_2.AzureSolutionQuestionNames.Features] = features;
127
+ const res = await workflow_1.runActionByName("teams-tab.add", context, inputs);
128
+ if (res.isErr())
129
+ return teamsfx_api_1.err(res.error);
130
+ }
131
+ if (features === question_2.TabSPFxItem.id) {
132
+ inputs[question_2.AzureSolutionQuestionNames.Features] = features;
133
+ const res = await workflow_1.runActionByName("spfx-tab.add", context, inputs);
134
+ if (res.isErr())
135
+ return teamsfx_api_1.err(res.error);
136
+ }
137
+ }
165
138
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
166
- await globalState_1.globalStateUpdate("automaticNpmInstall", true);
139
+ await globalState_1.globalStateUpdate(automaticNpmInstall, true);
167
140
  }
168
- return teamsfx_api_1.ok(undefined);
141
+ context.projectPath = projectPath;
142
+ return teamsfx_api_1.ok(["create a new project with capability:" + inputs.capabilities]);
169
143
  },
170
- actions: [createFromSample, createFromNew],
171
144
  };
172
- return teamsfx_api_1.ok(action);
145
+ return teamsfx_api_1.ok(createAction);
173
146
  }
174
147
  /**
175
148
  * add feature
176
149
  */
177
150
  addFeature(context, inputs) {
178
151
  const action = {
179
- type: "group",
152
+ type: "function",
180
153
  name: "fx.addFeature",
181
154
  question: async (context, inputs) => {
182
155
  return await questionV3_1.getQuestionsForAddFeatureV3(context, inputs);
183
156
  },
184
- actions: [
185
- {
186
- type: "call",
187
- targetAction: "sql.add",
188
- required: true,
189
- condition: (context, inputs) => {
190
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.AzureResourceSQLNewUI.id);
191
- },
192
- },
193
- {
194
- type: "call",
195
- targetAction: "teams-bot.add",
196
- required: true,
197
- condition: (context, inputs) => {
198
- return teamsfx_api_1.ok(question_2.BotFeatureIds.includes(inputs[question_2.AzureSolutionQuestionNames.Features]));
199
- },
200
- },
201
- {
202
- type: "call",
203
- targetAction: "teams-tab.add",
204
- required: true,
205
- condition: (context, inputs) => {
206
- return teamsfx_api_1.ok(question_2.TabFeatureIds.includes(inputs[question_2.AzureSolutionQuestionNames.Features]));
207
- },
208
- },
209
- {
210
- type: "call",
211
- targetAction: "teams-api.add",
212
- required: true,
213
- condition: (context, inputs) => {
214
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.AzureResourceFunctionNewUI.id);
215
- },
216
- },
217
- {
218
- type: "call",
219
- targetAction: "cicd.add",
220
- required: true,
221
- condition: (context, inputs) => {
222
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.CicdOptionItem.id);
223
- },
224
- },
225
- {
226
- type: "call",
227
- targetAction: "api-connector.add",
228
- required: true,
229
- condition: (context, inputs) => {
230
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.ApiConnectionOptionItem.id);
231
- },
232
- },
233
- {
234
- type: "call",
235
- targetAction: "sso.add",
236
- required: true,
237
- condition: (context, inputs) => {
238
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.SingleSignOnOptionItem.id);
239
- },
240
- },
241
- {
242
- type: "call",
243
- targetAction: "apim-feature.add",
244
- required: true,
245
- condition: (context, inputs) => {
246
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.AzureResourceApim.id);
247
- },
248
- },
249
- {
250
- type: "call",
251
- targetAction: "key-vault-feature.add",
252
- required: true,
253
- condition: (context, inputs) => {
254
- return teamsfx_api_1.ok(inputs[question_2.AzureSolutionQuestionNames.Features] === question_2.AzureResourceKeyVaultNewUI.id);
255
- },
256
- },
257
- ],
258
- };
259
- return teamsfx_api_1.ok(action);
260
- }
261
- init(context, inputs) {
262
- const initProjectSettings = {
263
- type: "function",
264
- name: "fx.initConfig",
265
- plan: (context, inputs) => {
266
- return teamsfx_api_1.ok([
267
- {
268
- type: "file",
269
- operate: "create",
270
- filePath: projectSettingsLoader_1.getProjectSettingsPath(inputs.projectPath),
271
- },
272
- ]);
273
- },
274
- question: (context, inputs) => {
275
- const root = new teamsfx_api_1.QTreeNode({ type: "group" });
276
- root.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
277
- root.addChild(new teamsfx_api_1.QTreeNode(question_1.createAppNameQuestion()));
278
- return teamsfx_api_1.ok(root);
279
- },
280
157
  execute: async (context, inputs) => {
281
- const projectSettings = projectSettingsHelper_1.newProjectSettings();
282
- projectSettings.appName = inputs["app-name"];
283
- projectSettings.components = [];
284
- context.projectSetting = projectSettings;
285
- await fs_extra_1.default.ensureDir(inputs.projectPath);
286
- await fs_extra_1.default.ensureDir(path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
287
- await fs_extra_1.default.ensureDir(path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`, "configs"));
288
- return teamsfx_api_1.ok([
289
- {
290
- type: "file",
291
- operate: "create",
292
- filePath: projectSettingsLoader_1.getProjectSettingsPath(inputs.projectPath),
293
- },
294
- ]);
158
+ const features = inputs[question_2.AzureSolutionQuestionNames.Features];
159
+ let actionName;
160
+ if (question_2.BotFeatureIds.includes(features)) {
161
+ actionName = "teams-bot.add";
162
+ }
163
+ else if (question_2.TabFeatureIds.includes(features)) {
164
+ actionName = "teams-tab.add";
165
+ }
166
+ else if (features === question_2.AzureResourceSQLNewUI.id) {
167
+ actionName = "sql.add";
168
+ }
169
+ else if (features === question_2.AzureResourceFunctionNewUI.id) {
170
+ actionName = "teams-api.add";
171
+ }
172
+ else if (features === question_2.AzureResourceApim.id) {
173
+ actionName = "apim-feature.add";
174
+ }
175
+ else if (features === question_2.AzureResourceKeyVaultNewUI.id) {
176
+ actionName = "key-vault-feature.add";
177
+ }
178
+ else if (features === question_2.CicdOptionItem.id) {
179
+ actionName = "cicd.add";
180
+ }
181
+ else if (features === question_2.ApiConnectionOptionItem.id) {
182
+ actionName = "api-connector.add";
183
+ }
184
+ else if (features === question_2.SingleSignOnOptionItem.id) {
185
+ actionName = "sso.add";
186
+ }
187
+ if (actionName) {
188
+ const res = await workflow_1.runActionByName(actionName, context, inputs);
189
+ if (res.isErr())
190
+ return teamsfx_api_1.err(res.error);
191
+ }
192
+ return teamsfx_api_1.ok([]);
295
193
  },
296
194
  };
297
- const action = {
298
- type: "group",
299
- name: "fx.init",
300
- actions: [
301
- initProjectSettings,
302
- {
303
- type: "call",
304
- name: "call:app-manifest.init",
305
- targetAction: "app-manifest.init",
306
- required: true,
307
- },
308
- {
309
- type: "call",
310
- name: "call:env-manager.create",
311
- targetAction: "env-manager.create",
312
- required: true,
313
- },
314
- ],
315
- };
316
195
  return teamsfx_api_1.ok(action);
317
196
  }
318
- async provision(context, inputs) {
319
- const ctx = context;
320
- const resourcesToProvision = ctx.projectSetting.components.filter((r) => r.provision);
321
- const provisionActions = resourcesToProvision.map((r) => {
322
- return {
323
- type: "call",
324
- name: `call:${r.name}.provision`,
325
- required: false,
326
- targetAction: `${r.name}.provision`,
327
- };
328
- });
329
- const configureActions = resourcesToProvision.map((r) => {
330
- return {
331
- type: "call",
332
- name: `call:${r.name}.configure`,
333
- required: false,
334
- targetAction: `${r.name}.configure`,
335
- };
336
- });
337
- const setupLocalEnvironmentStep = {
338
- type: "call",
339
- name: "call debug.setupLocalEnvInfo",
340
- targetAction: "debug.setupLocalEnvInfo",
341
- required: true,
342
- condition: (context, inputs) => {
343
- return teamsfx_api_1.ok(ctx.envInfo && ctx.envInfo.envName === "local");
344
- },
345
- };
346
- const configLocalEnvironmentStep = {
347
- type: "call",
348
- name: "call debug.configLocalEnvInfo",
349
- targetAction: "debug.configLocalEnvInfo",
350
- required: true,
351
- condition: (context, inputs) => {
352
- return teamsfx_api_1.ok(ctx.envInfo && ctx.envInfo.envName === "local");
353
- },
354
- };
355
- const preProvisionStep = new preProvisionAction_1.FxPreProvisionAction();
356
- const createTeamsAppStep = {
357
- type: "call",
358
- name: "call app-manifest.provision",
359
- targetAction: "app-manifest.provision",
360
- required: true,
361
- };
362
- const updateTeamsAppStep = {
363
- type: "call",
364
- name: "call app-manifest.configure",
365
- targetAction: "app-manifest.configure",
366
- required: true,
367
- };
368
- const provisionResourcesStep = {
369
- type: "group",
370
- name: "resources.provision",
371
- mode: "parallel",
372
- actions: provisionActions,
373
- };
374
- const configureResourcesStep = {
375
- type: "group",
376
- name: "resources.configure",
377
- mode: "parallel",
378
- actions: configureActions,
379
- };
380
- const deployBicepStep = {
381
- type: "call",
382
- name: "call:bicep.deploy",
383
- required: true,
384
- targetAction: "bicep.deploy",
385
- condition: (context, inputs) => {
386
- return teamsfx_api_1.ok(ctx.envInfo && ctx.envInfo.envName !== "local");
387
- },
388
- };
389
- const postProvisionStep = {
197
+ async init(context, inputs) {
198
+ const projectSettings = projectSettingsHelper_1.newProjectSettings();
199
+ projectSettings.appName = inputs["app-name"];
200
+ projectSettings.components = [];
201
+ context.projectSetting = projectSettings;
202
+ await fs_extra_1.default.ensureDir(inputs.projectPath);
203
+ await fs_extra_1.default.ensureDir(path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
204
+ await fs_extra_1.default.ensureDir(path_1.default.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`, "configs"));
205
+ {
206
+ const appManifest = typedi_1.Container.get(constants_2.ComponentNames.AppManifest);
207
+ const res = await appManifest.init(context, inputs);
208
+ if (res.isErr())
209
+ return res;
210
+ }
211
+ {
212
+ const res = await envManager_1.createNewEnv(context, inputs);
213
+ if (res.isErr())
214
+ return res;
215
+ }
216
+ return teamsfx_api_1.ok(undefined);
217
+ }
218
+ provision(ctx, inputs) {
219
+ const action = {
220
+ name: "fx.provision",
390
221
  type: "function",
391
- name: "fx.postProvision",
392
- condition: (context, inputs) => {
393
- return teamsfx_api_1.ok(ctx.envInfo && ctx.envInfo.envName !== "local");
394
- },
395
- plan: (context, inputs) => {
396
- return teamsfx_api_1.ok([]);
222
+ question: async (context, inputs) => {
223
+ return await questionV3_1.getQuestionsForDeployV3(context, context.envInfo, inputs);
397
224
  },
398
- execute: (context, inputs) => {
225
+ execute: async (context, inputs) => {
399
226
  const ctx = context;
400
- ctx.envInfo.state.solution.provisionSucceeded = true;
401
- const url = tools_1.getResourceGroupInPortal(ctx.envInfo.state.solution.subscriptionId, ctx.envInfo.state.solution.tenantId, ctx.envInfo.state.solution.resourceGroupName);
402
- const msg = localizeUtils_1.getLocalizedString("core.provision.successAzure");
403
- if (url) {
404
- const title = "View Provisioned Resources";
405
- ctx.userInteraction.showMessage("info", msg, false, title).then((result) => {
406
- const userSelected = result.isOk() ? result.value : undefined;
407
- if (userSelected === title) {
408
- ctx.userInteraction.openUrl(url);
227
+ ctx.envInfo.state.solution = ctx.envInfo.state.solution || {};
228
+ ctx.envInfo.state.solution.provisionSucceeded = false;
229
+ // 1. pre provision
230
+ {
231
+ const res = await preProvision(ctx, inputs);
232
+ if (res.isErr())
233
+ return teamsfx_api_1.err(res.error);
234
+ }
235
+ // 2. create a teams app
236
+ const appManifest = typedi_1.Container.get(constants_2.ComponentNames.AppManifest);
237
+ {
238
+ const res = await appManifest.provision(ctx, inputs);
239
+ if (res.isErr())
240
+ return teamsfx_api_1.err(res.error);
241
+ }
242
+ // 3. call resources provision api
243
+ const componentsToProvision = ctx.projectSetting.components.filter((r) => r.provision);
244
+ {
245
+ const thunks = [];
246
+ for (const componentConfig of componentsToProvision) {
247
+ const componentInstance = typedi_1.Container.get(componentConfig.name);
248
+ if (componentInstance.provision) {
249
+ thunks.push({
250
+ pluginName: `${componentConfig.name}`,
251
+ taskName: "provision",
252
+ thunk: () => {
253
+ ctx.envInfo.state[componentConfig.name] =
254
+ ctx.envInfo.state[componentConfig.name] || [];
255
+ return componentInstance.provision(ctx, inputs);
256
+ },
257
+ });
409
258
  }
410
- });
259
+ }
260
+ const provisionResult = await executor_1.executeConcurrently(thunks, ctx.logProvider);
261
+ if (provisionResult.kind !== "success") {
262
+ return teamsfx_api_1.err(provisionResult.error);
263
+ }
264
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.provision.ProvisionFinishNotice", constants_1.PluginDisplayName.Solution));
265
+ }
266
+ // 4
267
+ if (ctx.envInfo.envName === "local") {
268
+ //4.1 setup local env
269
+ const localEnvSetupResult = await debug_1.setupLocalEnvironment(ctx, inputs, ctx.envInfo);
270
+ if (localEnvSetupResult.isErr()) {
271
+ return teamsfx_api_1.err(localEnvSetupResult.error);
272
+ }
411
273
  }
412
274
  else {
275
+ //4.2 deploy arm templates for remote
276
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.deployArmTemplates.StartNotice", constants_1.PluginDisplayName.Solution));
277
+ const armRes = await arm_1.default.deployArmTemplates(ctx, inputs, ctx.envInfo, ctx.tokenProvider.azureAccountProvider);
278
+ if (armRes.isErr()) {
279
+ return teamsfx_api_1.err(armRes.error);
280
+ }
281
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.deployArmTemplates.SuccessNotice", constants_1.PluginDisplayName.Solution));
282
+ }
283
+ // 5.0 "aad-app.setApplicationInContext"
284
+ const aadApp = typedi_1.Container.get(constants_2.ComponentNames.AadApp);
285
+ if (projectSettingsHelperV3_1.hasAAD(ctx.projectSetting)) {
286
+ const res = await aadApp.setApplicationInContext(ctx, inputs);
287
+ if (res.isErr())
288
+ return teamsfx_api_1.err(res.error);
289
+ }
290
+ // 5. call resources configure api
291
+ {
292
+ const thunks = [];
293
+ for (const componentConfig of componentsToProvision) {
294
+ const componentInstance = typedi_1.Container.get(componentConfig.name);
295
+ if (componentInstance.configure) {
296
+ thunks.push({
297
+ pluginName: `${componentConfig.name}`,
298
+ taskName: "configure",
299
+ thunk: () => {
300
+ ctx.envInfo.state[componentConfig.name] =
301
+ ctx.envInfo.state[componentConfig.name] || [];
302
+ return componentInstance.configure(ctx, inputs);
303
+ },
304
+ });
305
+ }
306
+ }
307
+ const configResult = await executor_1.executeConcurrently(thunks, ctx.logProvider);
308
+ if (configResult.kind !== "success") {
309
+ return teamsfx_api_1.err(configResult.error);
310
+ }
311
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.provision.configurationFinishNotice", constants_1.PluginDisplayName.Solution));
312
+ }
313
+ // 6.
314
+ if (ctx.envInfo.envName === "local") {
315
+ // 6.1 config local env
316
+ const localConfigResult = await debug_1.configLocalEnvironment(ctx, inputs, ctx.envInfo);
317
+ if (localConfigResult.isErr()) {
318
+ return teamsfx_api_1.err(localConfigResult.error);
319
+ }
320
+ }
321
+ else {
322
+ // 6.2 show message for remote azure provision
323
+ const url = tools_1.getResourceGroupInPortal(ctx.envInfo.state.solution.subscriptionId, ctx.envInfo.state.solution.tenantId, ctx.envInfo.state.solution.resourceGroupName);
324
+ const msg = localizeUtils_1.getLocalizedString("core.provision.successAzure");
325
+ if (url) {
326
+ const title = "View Provisioned Resources";
327
+ ctx.userInteraction.showMessage("info", msg, false, title).then((result) => {
328
+ const userSelected = result.isOk() ? result.value : undefined;
329
+ if (userSelected === title) {
330
+ ctx.userInteraction.openUrl(url);
331
+ }
332
+ });
333
+ }
334
+ else {
335
+ ctx.userInteraction.showMessage("info", msg, false);
336
+ }
337
+ }
338
+ // 7. update teams app
339
+ {
340
+ const res = await appManifest.configure(ctx, inputs);
341
+ if (res.isErr())
342
+ return teamsfx_api_1.err(res.error);
343
+ }
344
+ // 8. show and set state
345
+ if (ctx.envInfo.envName !== "local") {
346
+ const msg = localizeUtils_1.getLocalizedString("core.provision.successNotice", ctx.projectSetting.appName);
413
347
  ctx.userInteraction.showMessage("info", msg, false);
348
+ ctx.logProvider.info(msg);
414
349
  }
350
+ ctx.envInfo.state.solution.provisionSucceeded = true;
415
351
  return teamsfx_api_1.ok([]);
416
352
  },
417
353
  };
418
- const aadComponent = workflow_1.getComponent(context.projectSetting, constants_1.ComponentNames.AadApp);
419
- const preConfigureStep = {
420
- type: "call",
421
- name: "call:aad-app.setApplicationInContext",
422
- required: true,
423
- targetAction: "aad-app.setApplicationInContext",
424
- };
425
- const provisionSequences = [
426
- preProvisionStep,
427
- createTeamsAppStep,
428
- provisionResourcesStep,
429
- deployBicepStep,
430
- setupLocalEnvironmentStep,
431
- ...(aadComponent ? [preConfigureStep] : []),
432
- configureResourcesStep,
433
- postProvisionStep,
434
- configLocalEnvironmentStep,
435
- updateTeamsAppStep,
436
- ];
437
- const result = {
438
- name: "fx.provision",
439
- type: "group",
440
- actions: provisionSequences,
441
- };
442
- return teamsfx_api_1.ok(result);
354
+ return teamsfx_api_1.ok(action);
443
355
  }
444
356
  build(context, inputs) {
445
357
  const projectSettings = context.projectSetting;
@@ -463,95 +375,176 @@ let TeamsfxCore = class TeamsfxCore {
463
375
  return teamsfx_api_1.ok(group);
464
376
  }
465
377
  deploy(context, inputs) {
466
- const projectSettings = context.projectSetting;
467
- const buildAction = {
468
- name: "call:fx.build",
469
- type: "call",
470
- targetAction: "fx.build",
471
- required: true,
472
- };
473
- const actions = [];
474
- // if is vs project, no selection question, deploy all deployable components
475
- // if is none vs project, only deploy selected components
476
- const inputPlugins = inputs[question_2.AzureSolutionQuestionNames.PluginSelectionDeploy] || [];
477
- const components = projectSettingsHelper_1.isVSProject(projectSettings)
478
- ? projectSettings.components.filter((component) => component.deploy).map((c) => c.name)
479
- : inputPlugins.map((plugin) => migrate_1.pluginName2ComponentName(plugin));
480
- let hasAzureResource = false;
481
- const callDeployActions = [];
482
- components.forEach((componentName) => {
483
- const componentConfig = workflow_1.getComponent(projectSettings, componentName);
484
- if (componentConfig) {
485
- if (componentConfig.hosting && constants_1.AzureResources.includes(componentConfig.hosting)) {
486
- hasAzureResource = true;
487
- }
488
- callDeployActions.push({
489
- type: "call",
490
- targetAction: componentName === constants_1.ComponentNames.AppManifest
491
- ? `${constants_1.ComponentNames.AppManifest}.configure`
492
- : `${componentConfig.hosting}.deploy`,
493
- required: false,
494
- inputs: {
495
- scenario: constants_1.componentToScenario.get(componentName),
496
- },
497
- });
498
- }
499
- });
500
- if (inputs.platform !== teamsfx_api_1.Platform.CLI_HELP && callDeployActions.length === 0) {
501
- return teamsfx_api_1.err(new teamsfx_api_1.UserError("fx", "NoResourcePluginSelected", localizeUtils_1.getDefaultString("core.NoPluginSelected"), localizeUtils_1.getLocalizedString("core.NoPluginSelected")));
502
- }
503
- if (hasAzureResource) {
504
- actions.push(new preDeployAction_1.FxPreDeployForAzureAction());
505
- }
506
- actions.push(buildAction);
507
- context.logProvider.info(localizeUtils_1.getLocalizedString("core.deploy.selectedPluginsToDeployNotice", constants_2.PluginDisplayName.Solution, JSON.stringify(components)));
508
- const callDeployGroup = {
509
- type: "group",
510
- name: "fx.callComponentDeploy",
511
- mode: "parallel",
512
- pre: (context, inputs) => {
513
- context.logProvider.info(localizeUtils_1.getLocalizedString("core.deploy.startNotice", constants_2.PluginDisplayName.Solution));
514
- return teamsfx_api_1.ok(undefined);
378
+ const action = {
379
+ name: "fx.deploy",
380
+ type: "function",
381
+ question: async (context, inputs) => {
382
+ return await questionV3_1.getQuestionsForDeployV3(context, context.envInfo, inputs);
515
383
  },
516
- post: (context, inputs) => {
517
- if (hasAzureResource) {
518
- const botTroubleShootMsg = utils_1.getBotTroubleShootMessage(projectSettingsHelperV3_1.hasBot(context.projectSetting));
519
- const msg = localizeUtils_1.getLocalizedString("core.deploy.successNotice", context.projectSetting.appName) +
520
- botTroubleShootMsg.textForLogging;
521
- context.logProvider.info(msg);
522
- if (botTroubleShootMsg.textForLogging) {
523
- // Show a `Learn more` action button for bot trouble shooting.
524
- context.userInteraction
525
- .showMessage("info", `${localizeUtils_1.getLocalizedString("core.deploy.successNotice", context.projectSetting.appName)} ${botTroubleShootMsg.textForMsgBox}`, false, botTroubleShootMsg.textForActionButton)
526
- .then((result) => {
527
- const userSelected = result.isOk() ? result.value : undefined;
528
- if (userSelected === botTroubleShootMsg.textForActionButton) {
529
- context.userInteraction.openUrl(botTroubleShootMsg.troubleShootLink);
530
- }
384
+ execute: async (context, inputs) => {
385
+ const ctx = context;
386
+ const projectSettings = ctx.projectSetting;
387
+ const inputPlugins = inputs[question_2.AzureSolutionQuestionNames.PluginSelectionDeploy] || [];
388
+ const inputComponentNames = inputPlugins.map(migrate_1.pluginName2ComponentName);
389
+ const thunks = [];
390
+ let hasAzureResource = false;
391
+ // 1. collect resources to deploy
392
+ const isVS = projectSettingsHelper_1.isVSProject(projectSettings);
393
+ for (const component of projectSettings.components) {
394
+ if (component.deploy &&
395
+ component.hosting !== undefined &&
396
+ (isVS || inputComponentNames.includes(component.name))) {
397
+ const componentInstance = typedi_1.Container.get(component.hosting);
398
+ // const actionName = `${component.hosting}.deploy`;
399
+ // const action = await getAction(actionName, ctx, inputs, true);
400
+ thunks.push({
401
+ pluginName: `${component.name}`,
402
+ taskName: "deploy",
403
+ thunk: () => {
404
+ const clonedInputs = lodash_1.cloneDeep(inputs);
405
+ clonedInputs.folder = component.folder;
406
+ clonedInputs.artifactFolder = component.artifactFolder;
407
+ clonedInputs.componentId = component.name;
408
+ return componentInstance.deploy(ctx, clonedInputs);
409
+ },
531
410
  });
411
+ if (constants_2.AzureResources.includes(component.hosting)) {
412
+ hasAzureResource = true;
413
+ }
532
414
  }
533
- else {
534
- context.userInteraction.showMessage("info", msg, false);
415
+ }
416
+ if (inputComponentNames.includes(constants_2.ComponentNames.AppManifest)) {
417
+ const appManifest = typedi_1.Container.get(constants_2.ComponentNames.AppManifest);
418
+ thunks.push({
419
+ pluginName: constants_2.ComponentNames.AppManifest,
420
+ taskName: "deploy",
421
+ thunk: () => {
422
+ return appManifest.configure(ctx, inputs);
423
+ },
424
+ });
425
+ }
426
+ if (thunks.length === 0) {
427
+ return teamsfx_api_1.err(new teamsfx_api_1.UserError("fx", "NoResourcePluginSelected", localizeUtils_1.getDefaultString("core.NoPluginSelected"), localizeUtils_1.getLocalizedString("core.NoPluginSelected")));
428
+ }
429
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.deploy.selectedPluginsToDeployNotice", constants_1.PluginDisplayName.Solution, JSON.stringify(thunks.map((p) => p.pluginName))));
430
+ // 2. check azure account
431
+ if (hasAzureResource) {
432
+ const subscriptionResult = await deploy_1.checkDeployAzureSubscription(ctx, ctx.envInfo, ctx.tokenProvider.azureAccountProvider);
433
+ if (subscriptionResult.isErr()) {
434
+ return teamsfx_api_1.err(subscriptionResult.error);
435
+ }
436
+ const consent = await provision_1.askForDeployConsent(ctx, ctx.tokenProvider.azureAccountProvider, ctx.envInfo);
437
+ if (consent.isErr()) {
438
+ return teamsfx_api_1.err(consent.error);
535
439
  }
536
440
  }
537
- return teamsfx_api_1.ok(undefined);
538
- },
539
- actions: callDeployActions,
540
- };
541
- actions.push(callDeployGroup);
542
- const finalAction = {
543
- type: "group",
544
- name: "fx.deploy",
545
- question: async (context, inputs) => {
546
- return await questionV3_1.getQuestionsForDeployV3(context, context.envInfo, inputs);
441
+ // 3. build
442
+ {
443
+ const res = await workflow_1.runActionByName("fx.build", context, inputs);
444
+ if (res.isErr())
445
+ return teamsfx_api_1.err(res.error);
446
+ }
447
+ // 4. start deploy
448
+ ctx.logProvider.info(localizeUtils_1.getLocalizedString("core.deploy.startNotice", constants_1.PluginDisplayName.Solution));
449
+ const result = await executor_1.executeConcurrently(thunks, ctx.logProvider);
450
+ if (result.kind === "success") {
451
+ if (hasAzureResource) {
452
+ const botTroubleShootMsg = utils_1.getBotTroubleShootMessage(projectSettingsHelperV3_1.hasBot(context.projectSetting));
453
+ const msg = localizeUtils_1.getLocalizedString("core.deploy.successNotice", context.projectSetting.appName) +
454
+ botTroubleShootMsg.textForLogging;
455
+ context.logProvider.info(msg);
456
+ if (botTroubleShootMsg.textForLogging) {
457
+ // Show a `Learn more` action button for bot trouble shooting.
458
+ context.userInteraction
459
+ .showMessage("info", `${localizeUtils_1.getLocalizedString("core.deploy.successNotice", context.projectSetting.appName)} ${botTroubleShootMsg.textForMsgBox}`, false, botTroubleShootMsg.textForActionButton)
460
+ .then((result) => {
461
+ const userSelected = result.isOk() ? result.value : undefined;
462
+ if (userSelected === botTroubleShootMsg.textForActionButton) {
463
+ context.userInteraction.openUrl(botTroubleShootMsg.troubleShootLink);
464
+ }
465
+ });
466
+ }
467
+ else {
468
+ context.userInteraction.showMessage("info", msg, false);
469
+ }
470
+ }
471
+ return teamsfx_api_1.ok([]);
472
+ }
473
+ else {
474
+ const msg = localizeUtils_1.getLocalizedString("core.deploy.failNotice", ctx.projectSetting.appName);
475
+ ctx.logProvider.info(msg);
476
+ return teamsfx_api_1.err(result.error);
477
+ }
547
478
  },
548
- actions: actions,
549
479
  };
550
- return teamsfx_api_1.ok(finalAction);
480
+ return teamsfx_api_1.ok(action);
551
481
  }
552
482
  };
553
483
  TeamsfxCore = tslib_1.__decorate([
554
484
  typedi_1.Service("fx")
555
485
  ], TeamsfxCore);
556
486
  exports.TeamsfxCore = TeamsfxCore;
487
+ async function preProvision(context, inputs) {
488
+ const ctx = context;
489
+ const envInfo = ctx.envInfo;
490
+ // 1. check M365 tenant
491
+ envInfo.state[constants_2.ComponentNames.AppManifest] = envInfo.state[constants_2.ComponentNames.AppManifest] || {};
492
+ envInfo.state.solution = envInfo.state.solution || {};
493
+ const appManifest = envInfo.state[constants_2.ComponentNames.AppManifest];
494
+ const solutionConfig = envInfo.state.solution;
495
+ solutionConfig.provisionSucceeded = false;
496
+ const tenantIdInConfig = appManifest.tenantId;
497
+ const isLocalDebug = envInfo.envName === "local";
498
+ const tenantIdInTokenRes = await provision_1.getM365TenantId(ctx.tokenProvider.m365TokenProvider);
499
+ if (tenantIdInTokenRes.isErr()) {
500
+ return teamsfx_api_1.err(tenantIdInTokenRes.error);
501
+ }
502
+ const tenantIdInToken = tenantIdInTokenRes.value;
503
+ if (!isLocalDebug) {
504
+ if (tenantIdInConfig && tenantIdInToken && tenantIdInToken !== tenantIdInConfig) {
505
+ return teamsfx_api_1.err(new teamsfx_api_1.UserError("Solution", "TeamsAppTenantIdNotRight", localizeUtils_1.getLocalizedString("error.M365AccountNotMatch", envInfo.envName)));
506
+ }
507
+ if (!tenantIdInConfig) {
508
+ appManifest.tenantId = tenantIdInToken;
509
+ solutionConfig.teamsAppTenantId = tenantIdInToken;
510
+ globalVars_1.globalVars.m365TenantId = tenantIdInToken;
511
+ }
512
+ }
513
+ else {
514
+ const res = await utils_1.checkWhetherLocalDebugM365TenantMatches(envInfo, tenantIdInConfig, ctx.tokenProvider.m365TokenProvider, inputs.projectPath);
515
+ if (res.isErr()) {
516
+ return teamsfx_api_1.err(res.error);
517
+ }
518
+ envInfo.state[constants_2.ComponentNames.AppManifest] = envInfo.state[constants_2.ComponentNames.AppManifest] || {};
519
+ envInfo.state[constants_2.ComponentNames.AppManifest].tenantId = tenantIdInToken;
520
+ envInfo.state.solution.teamsAppTenantId = tenantIdInToken;
521
+ globalVars_1.globalVars.m365TenantId = tenantIdInToken;
522
+ }
523
+ // 3. check Azure configs
524
+ if (projectSettingsHelperV3_1.hasAzureResourceV3(ctx.projectSetting) && envInfo.envName !== "local") {
525
+ // ask common question and fill in solution config
526
+ const solutionConfigRes = await provision_1.fillInAzureConfigs(ctx, inputs, envInfo, ctx.tokenProvider);
527
+ if (solutionConfigRes.isErr()) {
528
+ return teamsfx_api_1.err(solutionConfigRes.error);
529
+ }
530
+ if (!solutionConfigRes.value.hasSwitchedSubscription) {
531
+ // ask for provision consent
532
+ const consentResult = await provision_1.askForProvisionConsent(ctx, ctx.tokenProvider.azureAccountProvider, envInfo);
533
+ if (consentResult.isErr()) {
534
+ return teamsfx_api_1.err(consentResult.error);
535
+ }
536
+ }
537
+ // create resource group if needed
538
+ if (solutionConfig.needCreateResourceGroup) {
539
+ const createRgRes = await ResourceGroupHelper_1.resourceGroupHelper.createNewResourceGroup(solutionConfig.resourceGroupName, ctx.tokenProvider.azureAccountProvider, solutionConfig.subscriptionId, solutionConfig.location);
540
+ if (createRgRes.isErr()) {
541
+ return teamsfx_api_1.err(createRgRes.error);
542
+ }
543
+ }
544
+ if (solutionConfigRes.value.hasSwitchedSubscription) {
545
+ arm_1.updateResourceBaseName(inputs.projectPath, ctx.projectSetting.appName, envInfo.envName);
546
+ }
547
+ }
548
+ return teamsfx_api_1.ok(undefined);
549
+ }
557
550
  //# sourceMappingURL=core.js.map