@microsoft/teamsfx-core 1.1.1 → 1.1.2-alpha.30d0724a.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 (447) hide show
  1. package/build/common/armInterface.d.ts +1 -1
  2. package/build/common/armInterface.d.ts.map +1 -1
  3. package/build/common/constants.d.ts +3 -2
  4. package/build/common/constants.d.ts.map +1 -1
  5. package/build/common/constants.js +3 -2
  6. package/build/common/constants.js.map +1 -1
  7. package/build/common/local/localEnvManager.d.ts +17 -0
  8. package/build/common/local/localEnvManager.d.ts.map +1 -0
  9. package/build/common/local/localEnvManager.js +72 -0
  10. package/build/common/local/localEnvManager.js.map +1 -0
  11. package/build/common/localSettingsProvider.d.ts +3 -3
  12. package/build/common/localSettingsProvider.d.ts.map +1 -1
  13. package/build/common/localSettingsProvider.js +11 -6
  14. package/build/common/localSettingsProvider.js.map +1 -1
  15. package/build/common/samples-config.json +14 -0
  16. package/build/common/tools.d.ts +11 -1
  17. package/build/common/tools.d.ts.map +1 -1
  18. package/build/common/tools.js +23 -10
  19. package/build/common/tools.js.map +1 -1
  20. package/build/core/SolutionPluginContainer.d.ts +2 -1
  21. package/build/core/SolutionPluginContainer.d.ts.map +1 -1
  22. package/build/core/SolutionPluginContainer.js +9 -1
  23. package/build/core/SolutionPluginContainer.js.map +1 -1
  24. package/build/core/environment.d.ts +4 -3
  25. package/build/core/environment.d.ts.map +1 -1
  26. package/build/core/environment.js +37 -7
  27. package/build/core/environment.js.map +1 -1
  28. package/build/core/error.d.ts +2 -1
  29. package/build/core/error.d.ts.map +1 -1
  30. package/build/core/error.js +7 -3
  31. package/build/core/error.js.map +1 -1
  32. package/build/core/index.d.ts +52 -14
  33. package/build/core/index.d.ts.map +1 -1
  34. package/build/core/index.js +699 -485
  35. package/build/core/index.js.map +1 -1
  36. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  37. package/build/core/middleware/concurrentLocker.js +23 -12
  38. package/build/core/middleware/concurrentLocker.js.map +1 -1
  39. package/build/core/middleware/envInfoLoader.d.ts +5 -1
  40. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  41. package/build/core/middleware/envInfoLoader.js +51 -44
  42. package/build/core/middleware/envInfoLoader.js.map +1 -1
  43. package/build/core/middleware/envInfoLoaderV3.d.ts +3 -0
  44. package/build/core/middleware/envInfoLoaderV3.d.ts.map +1 -0
  45. package/build/core/middleware/envInfoLoaderV3.js +64 -0
  46. package/build/core/middleware/envInfoLoaderV3.js.map +1 -0
  47. package/build/core/middleware/envInfoWriter.js +13 -30
  48. package/build/core/middleware/envInfoWriter.js.map +1 -1
  49. package/build/core/middleware/envInfoWriterV3.d.ts +6 -0
  50. package/build/core/middleware/envInfoWriterV3.d.ts.map +1 -0
  51. package/build/core/middleware/envInfoWriterV3.js +63 -0
  52. package/build/core/middleware/envInfoWriterV3.js.map +1 -0
  53. package/build/core/middleware/errorHandler.d.ts.map +1 -1
  54. package/build/core/middleware/errorHandler.js +3 -5
  55. package/build/core/middleware/errorHandler.js.map +1 -1
  56. package/build/core/middleware/localSettingsLoader.js.map +1 -1
  57. package/build/core/middleware/localSettingsWriter.d.ts.map +1 -1
  58. package/build/core/middleware/localSettingsWriter.js +6 -16
  59. package/build/core/middleware/localSettingsWriter.js.map +1 -1
  60. package/build/core/middleware/projectMigrator.d.ts.map +1 -1
  61. package/build/core/middleware/projectMigrator.js +22 -54
  62. package/build/core/middleware/projectMigrator.js.map +1 -1
  63. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  64. package/build/core/middleware/projectSettingsLoader.js +2 -4
  65. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  66. package/build/core/middleware/projectSettingsLoaderV3.d.ts +4 -0
  67. package/build/core/middleware/projectSettingsLoaderV3.d.ts.map +1 -0
  68. package/build/core/middleware/projectSettingsLoaderV3.js +49 -0
  69. package/build/core/middleware/projectSettingsLoaderV3.js.map +1 -0
  70. package/build/core/middleware/projectSettingsWriter.d.ts.map +1 -1
  71. package/build/core/middleware/projectSettingsWriter.js +2 -2
  72. package/build/core/middleware/projectSettingsWriter.js.map +1 -1
  73. package/build/core/middleware/questionModel.d.ts +14 -1
  74. package/build/core/middleware/questionModel.d.ts.map +1 -1
  75. package/build/core/middleware/questionModel.js +319 -23
  76. package/build/core/middleware/questionModel.js.map +1 -1
  77. package/build/core/middleware/solutionLoader.d.ts +3 -2
  78. package/build/core/middleware/solutionLoader.d.ts.map +1 -1
  79. package/build/core/middleware/solutionLoader.js +21 -23
  80. package/build/core/middleware/solutionLoader.js.map +1 -1
  81. package/build/core/middleware/solutionLoaderV3.d.ts +4 -0
  82. package/build/core/middleware/solutionLoaderV3.d.ts.map +1 -0
  83. package/build/core/middleware/solutionLoaderV3.js +19 -0
  84. package/build/core/middleware/solutionLoaderV3.js.map +1 -0
  85. package/build/core/question.d.ts +9 -1
  86. package/build/core/question.d.ts.map +1 -1
  87. package/build/core/question.js +113 -3
  88. package/build/core/question.js.map +1 -1
  89. package/build/core/tools.d.ts +2 -1
  90. package/build/core/tools.d.ts.map +1 -1
  91. package/build/core/tools.js +15 -1
  92. package/build/core/tools.js.map +1 -1
  93. package/build/plugins/resource/aad/plugin.d.ts.map +1 -1
  94. package/build/plugins/resource/aad/plugin.js +1 -10
  95. package/build/plugins/resource/aad/plugin.js.map +1 -1
  96. package/build/plugins/resource/apim/managers/apimManager.d.ts.map +1 -1
  97. package/build/plugins/resource/apim/managers/apimManager.js +5 -7
  98. package/build/plugins/resource/apim/managers/apimManager.js.map +1 -1
  99. package/build/plugins/resource/appstudio/appStudio.d.ts +1 -1
  100. package/build/plugins/resource/appstudio/appStudio.d.ts.map +1 -1
  101. package/build/plugins/resource/appstudio/appStudio.js +106 -85
  102. package/build/plugins/resource/appstudio/appStudio.js.map +1 -1
  103. package/build/plugins/resource/appstudio/constants.d.ts +6 -1
  104. package/build/plugins/resource/appstudio/constants.d.ts.map +1 -1
  105. package/build/plugins/resource/appstudio/constants.js +6 -1
  106. package/build/plugins/resource/appstudio/constants.js.map +1 -1
  107. package/build/plugins/resource/appstudio/errors.d.ts +1 -1
  108. package/build/plugins/resource/appstudio/errors.d.ts.map +1 -1
  109. package/build/plugins/resource/appstudio/errors.js +2 -1
  110. package/build/plugins/resource/appstudio/errors.js.map +1 -1
  111. package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
  112. package/build/plugins/resource/appstudio/index.js +10 -2
  113. package/build/plugins/resource/appstudio/index.js.map +1 -1
  114. package/build/plugins/resource/appstudio/plugin.d.ts +2 -3
  115. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  116. package/build/plugins/resource/appstudio/plugin.js +93 -119
  117. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  118. package/build/plugins/resource/bot/index.d.ts.map +1 -1
  119. package/build/plugins/resource/bot/index.js +5 -1
  120. package/build/plugins/resource/bot/index.js.map +1 -1
  121. package/build/plugins/resource/bot/plugin.d.ts.map +1 -1
  122. package/build/plugins/resource/bot/plugin.js +9 -11
  123. package/build/plugins/resource/bot/plugin.js.map +1 -1
  124. package/build/plugins/resource/frontend/constants.d.ts +1 -7
  125. package/build/plugins/resource/frontend/constants.d.ts.map +1 -1
  126. package/build/plugins/resource/frontend/constants.js +2 -9
  127. package/build/plugins/resource/frontend/constants.js.map +1 -1
  128. package/build/plugins/resource/frontend/env.d.ts +21 -0
  129. package/build/plugins/resource/frontend/env.d.ts.map +1 -0
  130. package/build/plugins/resource/frontend/env.js +82 -0
  131. package/build/plugins/resource/frontend/env.js.map +1 -0
  132. package/build/plugins/resource/frontend/ops/deploy.d.ts +2 -1
  133. package/build/plugins/resource/frontend/ops/deploy.d.ts.map +1 -1
  134. package/build/plugins/resource/frontend/ops/deploy.js +2 -2
  135. package/build/plugins/resource/frontend/ops/deploy.js.map +1 -1
  136. package/build/plugins/resource/frontend/plugin.d.ts +2 -0
  137. package/build/plugins/resource/frontend/plugin.d.ts.map +1 -1
  138. package/build/plugins/resource/frontend/plugin.js +28 -16
  139. package/build/plugins/resource/frontend/plugin.js.map +1 -1
  140. package/build/plugins/resource/frontend/utils/environment-utils.d.ts.map +1 -1
  141. package/build/plugins/resource/frontend/utils/environment-utils.js +4 -2
  142. package/build/plugins/resource/frontend/utils/environment-utils.js.map +1 -1
  143. package/build/plugins/resource/frontend/utils.d.ts +6 -1
  144. package/build/plugins/resource/frontend/utils.d.ts.map +1 -1
  145. package/build/plugins/resource/frontend/utils.js +17 -6
  146. package/build/plugins/resource/frontend/utils.js.map +1 -1
  147. package/build/plugins/resource/function/plugin.d.ts.map +1 -1
  148. package/build/plugins/resource/function/plugin.js +7 -9
  149. package/build/plugins/resource/function/plugin.js.map +1 -1
  150. package/build/plugins/resource/function/utils/depsChecker/checker.d.ts +0 -1
  151. package/build/plugins/resource/function/utils/depsChecker/checker.d.ts.map +1 -1
  152. package/build/plugins/resource/function/utils/depsChecker/checker.js +2 -2
  153. package/build/plugins/resource/function/utils/depsChecker/checker.js.map +1 -1
  154. package/build/plugins/resource/function/utils/depsChecker/common.d.ts +2 -2
  155. package/build/plugins/resource/function/utils/depsChecker/common.d.ts.map +1 -1
  156. package/build/plugins/resource/function/utils/depsChecker/common.js +6 -6
  157. package/build/plugins/resource/function/utils/depsChecker/common.js.map +1 -1
  158. package/build/plugins/resource/function/utils/depsChecker/dotnetChecker.d.ts +3 -2
  159. package/build/plugins/resource/function/utils/depsChecker/dotnetChecker.d.ts.map +1 -1
  160. package/build/plugins/resource/function/utils/depsChecker/dotnetChecker.js +3 -2
  161. package/build/plugins/resource/function/utils/depsChecker/dotnetChecker.js.map +1 -1
  162. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.d.ts +0 -1
  163. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.d.ts.map +1 -1
  164. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.js +1 -23
  165. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.js.map +1 -1
  166. package/build/plugins/resource/identity/index.d.ts.map +1 -1
  167. package/build/plugins/resource/identity/index.js +11 -13
  168. package/build/plugins/resource/identity/index.js.map +1 -1
  169. package/build/plugins/resource/keyvault/plugin.d.ts.map +1 -1
  170. package/build/plugins/resource/keyvault/plugin.js +7 -9
  171. package/build/plugins/resource/keyvault/plugin.js.map +1 -1
  172. package/build/plugins/resource/localdebug/certificate.js +3 -3
  173. package/build/plugins/resource/localdebug/certificate.js.map +1 -1
  174. package/build/plugins/resource/localdebug/index.d.ts +0 -1
  175. package/build/plugins/resource/localdebug/index.d.ts.map +1 -1
  176. package/build/plugins/resource/localdebug/index.js +3 -280
  177. package/build/plugins/resource/localdebug/index.js.map +1 -1
  178. package/build/plugins/resource/localdebug/util/error.d.ts.map +1 -1
  179. package/build/plugins/resource/localdebug/util/error.js +1 -1
  180. package/build/plugins/resource/localdebug/util/error.js.map +1 -1
  181. package/build/plugins/resource/localdebug/v2/index.d.ts.map +1 -1
  182. package/build/plugins/resource/localdebug/v2/index.js +34 -1
  183. package/build/plugins/resource/localdebug/v2/index.js.map +1 -1
  184. package/build/plugins/resource/simpleauth/plugin.d.ts.map +1 -1
  185. package/build/plugins/resource/simpleauth/plugin.js +7 -9
  186. package/build/plugins/resource/simpleauth/plugin.js.map +1 -1
  187. package/build/plugins/resource/simpleauth/utils/common.d.ts.map +1 -1
  188. package/build/plugins/resource/simpleauth/utils/common.js +3 -1
  189. package/build/plugins/resource/simpleauth/utils/common.js.map +1 -1
  190. package/build/plugins/resource/sql/config.d.ts +0 -1
  191. package/build/plugins/resource/sql/config.d.ts.map +1 -1
  192. package/build/plugins/resource/sql/config.js +0 -1
  193. package/build/plugins/resource/sql/config.js.map +1 -1
  194. package/build/plugins/resource/sql/constants.d.ts +1 -0
  195. package/build/plugins/resource/sql/constants.d.ts.map +1 -1
  196. package/build/plugins/resource/sql/constants.js +1 -0
  197. package/build/plugins/resource/sql/constants.js.map +1 -1
  198. package/build/plugins/resource/sql/errors.d.ts +1 -0
  199. package/build/plugins/resource/sql/errors.d.ts.map +1 -1
  200. package/build/plugins/resource/sql/errors.js +1 -0
  201. package/build/plugins/resource/sql/errors.js.map +1 -1
  202. package/build/plugins/resource/sql/managementClient.d.ts +3 -1
  203. package/build/plugins/resource/sql/managementClient.d.ts.map +1 -1
  204. package/build/plugins/resource/sql/managementClient.js +11 -2
  205. package/build/plugins/resource/sql/managementClient.js.map +1 -1
  206. package/build/plugins/resource/sql/plugin.d.ts +3 -0
  207. package/build/plugins/resource/sql/plugin.d.ts.map +1 -1
  208. package/build/plugins/resource/sql/plugin.js +37 -27
  209. package/build/plugins/resource/sql/plugin.js.map +1 -1
  210. package/build/plugins/resource/sql/sqlClient.d.ts +1 -1
  211. package/build/plugins/resource/sql/sqlClient.d.ts.map +1 -1
  212. package/build/plugins/resource/sql/sqlClient.js +15 -24
  213. package/build/plugins/resource/sql/sqlClient.js.map +1 -1
  214. package/build/plugins/resource/sql/utils/checkInput.js +2 -2
  215. package/build/plugins/resource/sql/utils/checkInput.js.map +1 -1
  216. package/build/plugins/resource/sql/utils/message.d.ts +0 -1
  217. package/build/plugins/resource/sql/utils/message.d.ts.map +1 -1
  218. package/build/plugins/resource/sql/utils/message.js +0 -1
  219. package/build/plugins/resource/sql/utils/message.js.map +1 -1
  220. package/build/plugins/solution/fx-solution/arm.d.ts +18 -11
  221. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  222. package/build/plugins/solution/fx-solution/arm.js +387 -120
  223. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  224. package/build/plugins/solution/fx-solution/commonQuestions.d.ts +13 -2
  225. package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
  226. package/build/plugins/solution/fx-solution/commonQuestions.js +24 -26
  227. package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
  228. package/build/plugins/solution/fx-solution/debug/constants.d.ts +9 -0
  229. package/build/plugins/solution/fx-solution/debug/constants.d.ts.map +1 -0
  230. package/build/plugins/solution/fx-solution/debug/constants.js +16 -0
  231. package/build/plugins/solution/fx-solution/debug/constants.js.map +1 -0
  232. package/build/plugins/solution/fx-solution/debug/error.d.ts +7 -0
  233. package/build/plugins/solution/fx-solution/debug/error.d.ts.map +1 -0
  234. package/build/plugins/solution/fx-solution/debug/error.js +28 -0
  235. package/build/plugins/solution/fx-solution/debug/error.js.map +1 -0
  236. package/build/plugins/solution/fx-solution/debug/provisionLocal.d.ts +3 -0
  237. package/build/plugins/solution/fx-solution/debug/provisionLocal.d.ts.map +1 -0
  238. package/build/plugins/solution/fx-solution/debug/provisionLocal.js +107 -0
  239. package/build/plugins/solution/fx-solution/debug/provisionLocal.js.map +1 -0
  240. package/build/plugins/solution/fx-solution/debug/scaffolding.d.ts +3 -0
  241. package/build/plugins/solution/fx-solution/debug/scaffolding.d.ts.map +1 -0
  242. package/build/plugins/solution/fx-solution/debug/scaffolding.js +153 -0
  243. package/build/plugins/solution/fx-solution/debug/scaffolding.js.map +1 -0
  244. package/build/plugins/{resource/localdebug → solution/fx-solution/debug}/util/codespace.d.ts +0 -0
  245. package/build/plugins/solution/fx-solution/debug/util/codespace.d.ts.map +1 -0
  246. package/build/plugins/{resource/localdebug → solution/fx-solution/debug}/util/codespace.js +0 -0
  247. package/build/plugins/solution/fx-solution/debug/util/codespace.js.map +1 -0
  248. package/build/plugins/solution/fx-solution/debug/util/contextHelper.d.ts +10 -0
  249. package/build/plugins/solution/fx-solution/debug/util/contextHelper.d.ts.map +1 -0
  250. package/build/plugins/solution/fx-solution/debug/util/contextHelper.js +34 -0
  251. package/build/plugins/solution/fx-solution/debug/util/contextHelper.js.map +1 -0
  252. package/build/plugins/{resource/localdebug → solution/fx-solution/debug/util}/launch.d.ts +0 -0
  253. package/build/plugins/solution/fx-solution/debug/util/launch.d.ts.map +1 -0
  254. package/build/plugins/{resource/localdebug → solution/fx-solution/debug/util}/launch.js +1 -1
  255. package/build/plugins/solution/fx-solution/debug/util/launch.js.map +1 -0
  256. package/build/plugins/{resource/localdebug → solution/fx-solution/debug}/util/ngrok.d.ts +0 -0
  257. package/build/plugins/solution/fx-solution/debug/util/ngrok.d.ts.map +1 -0
  258. package/build/plugins/{resource/localdebug → solution/fx-solution/debug}/util/ngrok.js +2 -2
  259. package/build/plugins/solution/fx-solution/debug/util/ngrok.js.map +1 -0
  260. package/build/plugins/solution/fx-solution/debug/util/settings.d.ts +2 -0
  261. package/build/plugins/solution/fx-solution/debug/util/settings.d.ts.map +1 -0
  262. package/build/plugins/solution/fx-solution/debug/util/settings.js +22 -0
  263. package/build/plugins/solution/fx-solution/debug/util/settings.js.map +1 -0
  264. package/build/plugins/{resource/localdebug → solution/fx-solution/debug/util}/tasks.d.ts +0 -0
  265. package/build/plugins/solution/fx-solution/debug/util/tasks.d.ts.map +1 -0
  266. package/build/plugins/{resource/localdebug → solution/fx-solution/debug/util}/tasks.js +6 -6
  267. package/build/plugins/solution/fx-solution/debug/util/tasks.js.map +1 -0
  268. package/build/plugins/solution/fx-solution/debug/util/telemetry.d.ts +27 -0
  269. package/build/plugins/solution/fx-solution/debug/util/telemetry.d.ts.map +1 -0
  270. package/build/plugins/solution/fx-solution/debug/util/telemetry.js +81 -0
  271. package/build/plugins/solution/fx-solution/debug/util/telemetry.js.map +1 -0
  272. package/build/plugins/solution/fx-solution/index.d.ts +1 -0
  273. package/build/plugins/solution/fx-solution/index.d.ts.map +1 -1
  274. package/build/plugins/solution/fx-solution/index.js +1 -0
  275. package/build/plugins/solution/fx-solution/index.js.map +1 -1
  276. package/build/plugins/solution/fx-solution/question.d.ts +2 -2
  277. package/build/plugins/solution/fx-solution/question.d.ts.map +1 -1
  278. package/build/plugins/solution/fx-solution/question.js +2 -32
  279. package/build/plugins/solution/fx-solution/question.js.map +1 -1
  280. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  281. package/build/plugins/solution/fx-solution/solution.js +9 -5
  282. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  283. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.d.ts +2 -2
  284. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.d.ts.map +1 -1
  285. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.js +13 -14
  286. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.js.map +1 -1
  287. package/build/plugins/solution/fx-solution/utils/progressHelper.d.ts +2 -2
  288. package/build/plugins/solution/fx-solution/utils/progressHelper.d.ts.map +1 -1
  289. package/build/plugins/solution/fx-solution/utils/progressHelper.js +4 -4
  290. package/build/plugins/solution/fx-solution/utils/progressHelper.js.map +1 -1
  291. package/build/plugins/solution/fx-solution/v2/constants.d.ts +2 -0
  292. package/build/plugins/solution/fx-solution/v2/constants.d.ts.map +1 -0
  293. package/build/plugins/solution/fx-solution/v2/constants.js +7 -0
  294. package/build/plugins/solution/fx-solution/v2/constants.js.map +1 -0
  295. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -1
  296. package/build/plugins/solution/fx-solution/v2/createEnv.js +1 -1
  297. package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -1
  298. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  299. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +7 -4
  300. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  301. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -1
  302. package/build/plugins/solution/fx-solution/v2/getQuestions.js +67 -25
  303. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -1
  304. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.js.map +1 -1
  305. package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -1
  306. package/build/plugins/solution/fx-solution/v2/provision.js +9 -1
  307. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -1
  308. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
  309. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +5 -0
  310. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
  311. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts.map +1 -1
  312. package/build/plugins/solution/fx-solution/v2/scaffolding.js +5 -0
  313. package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
  314. package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -1
  315. package/build/plugins/solution/fx-solution/v2/solution.js +2 -1
  316. package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -1
  317. package/build/plugins/solution/fx-solution/v3/addModule.d.ts +6 -0
  318. package/build/plugins/solution/fx-solution/v3/addModule.d.ts.map +1 -0
  319. package/build/plugins/solution/fx-solution/v3/addModule.js +35 -0
  320. package/build/plugins/solution/fx-solution/v3/addModule.js.map +1 -0
  321. package/build/plugins/solution/fx-solution/v3/addResource.d.ts +37 -0
  322. package/build/plugins/solution/fx-solution/v3/addResource.d.ts.map +1 -0
  323. package/build/plugins/solution/fx-solution/v3/addResource.js +260 -0
  324. package/build/plugins/solution/fx-solution/v3/addResource.js.map +1 -0
  325. package/build/plugins/solution/fx-solution/v3/constants.d.ts +20 -0
  326. package/build/plugins/solution/fx-solution/v3/constants.d.ts.map +1 -0
  327. package/build/plugins/solution/fx-solution/v3/constants.js +25 -0
  328. package/build/plugins/solution/fx-solution/v3/constants.js.map +1 -0
  329. package/build/plugins/solution/fx-solution/v3/deploy.d.ts +6 -0
  330. package/build/plugins/solution/fx-solution/v3/deploy.d.ts.map +1 -0
  331. package/build/plugins/solution/fx-solution/v3/deploy.js +78 -0
  332. package/build/plugins/solution/fx-solution/v3/deploy.js.map +1 -0
  333. package/build/plugins/solution/fx-solution/v3/error.d.ts +11 -0
  334. package/build/plugins/solution/fx-solution/v3/error.d.ts.map +1 -0
  335. package/build/plugins/solution/fx-solution/v3/error.js +23 -0
  336. package/build/plugins/solution/fx-solution/v3/error.js.map +1 -0
  337. package/build/plugins/solution/fx-solution/v3/init.d.ts +4 -0
  338. package/build/plugins/solution/fx-solution/v3/init.d.ts.map +1 -0
  339. package/build/plugins/solution/fx-solution/v3/init.js +35 -0
  340. package/build/plugins/solution/fx-solution/v3/init.js.map +1 -0
  341. package/build/plugins/solution/fx-solution/v3/provision.d.ts +4 -0
  342. package/build/plugins/solution/fx-solution/v3/provision.d.ts.map +1 -0
  343. package/build/plugins/solution/fx-solution/v3/provision.js +124 -0
  344. package/build/plugins/solution/fx-solution/v3/provision.js.map +1 -0
  345. package/build/plugins/solution/fx-solution/v3/provisionLocal.d.ts +4 -0
  346. package/build/plugins/solution/fx-solution/v3/provisionLocal.d.ts.map +1 -0
  347. package/build/plugins/solution/fx-solution/v3/provisionLocal.js +13 -0
  348. package/build/plugins/solution/fx-solution/v3/provisionLocal.js.map +1 -0
  349. package/build/plugins/solution/fx-solution/v3/publish.d.ts +4 -0
  350. package/build/plugins/solution/fx-solution/v3/publish.d.ts.map +1 -0
  351. package/build/plugins/solution/fx-solution/v3/publish.js +15 -0
  352. package/build/plugins/solution/fx-solution/v3/publish.js.map +1 -0
  353. package/build/plugins/solution/fx-solution/v3/questions.d.ts +16 -0
  354. package/build/plugins/solution/fx-solution/v3/questions.d.ts.map +1 -0
  355. package/build/plugins/solution/fx-solution/v3/questions.js +86 -0
  356. package/build/plugins/solution/fx-solution/v3/questions.js.map +1 -0
  357. package/build/plugins/solution/fx-solution/v3/scaffold.d.ts +27 -0
  358. package/build/plugins/solution/fx-solution/v3/scaffold.d.ts.map +1 -0
  359. package/build/plugins/solution/fx-solution/v3/scaffold.js +241 -0
  360. package/build/plugins/solution/fx-solution/v3/scaffold.js.map +1 -0
  361. package/build/plugins/solution/fx-solution/v3/solution.d.ts +32 -0
  362. package/build/plugins/solution/fx-solution/v3/solution.d.ts.map +1 -0
  363. package/build/plugins/solution/fx-solution/v3/solution.js +45 -0
  364. package/build/plugins/solution/fx-solution/v3/solution.js.map +1 -0
  365. package/build/plugins/solution/fx-solution/v3/userTask.d.ts +4 -0
  366. package/build/plugins/solution/fx-solution/v3/userTask.d.ts.map +1 -0
  367. package/build/plugins/solution/fx-solution/v3/userTask.js +15 -0
  368. package/build/plugins/solution/fx-solution/v3/userTask.js.map +1 -0
  369. package/build/plugins/solution/fx-solution/v3/utils.d.ts +3 -0
  370. package/build/plugins/solution/fx-solution/v3/utils.d.ts.map +1 -0
  371. package/build/plugins/solution/fx-solution/v3/utils.js +16 -0
  372. package/build/plugins/solution/fx-solution/v3/utils.js.map +1 -0
  373. package/build/plugins/solution/index.d.ts +1 -0
  374. package/build/plugins/solution/index.d.ts.map +1 -1
  375. package/build/plugins/solution/index.js +1 -0
  376. package/build/plugins/solution/index.js.map +1 -1
  377. package/build/plugins/solution/spfx-solution/constants.d.ts +2 -0
  378. package/build/plugins/solution/spfx-solution/constants.d.ts.map +1 -0
  379. package/build/plugins/solution/spfx-solution/constants.js +7 -0
  380. package/build/plugins/solution/spfx-solution/constants.js.map +1 -0
  381. package/build/plugins/solution/spfx-solution/index.d.ts +2 -0
  382. package/build/plugins/solution/spfx-solution/index.d.ts.map +1 -0
  383. package/build/plugins/solution/spfx-solution/index.js +5 -0
  384. package/build/plugins/solution/spfx-solution/index.js.map +1 -0
  385. package/build/plugins/solution/spfx-solution/init.d.ts +3 -0
  386. package/build/plugins/solution/spfx-solution/init.d.ts.map +1 -0
  387. package/build/plugins/solution/spfx-solution/init.js +20 -0
  388. package/build/plugins/solution/spfx-solution/init.js.map +1 -0
  389. package/build/plugins/solution/spfx-solution/questions.d.ts +6 -0
  390. package/build/plugins/solution/spfx-solution/questions.d.ts.map +1 -0
  391. package/build/plugins/solution/spfx-solution/questions.js +36 -0
  392. package/build/plugins/solution/spfx-solution/questions.js.map +1 -0
  393. package/build/plugins/solution/spfx-solution/scaffolding.d.ts +17 -0
  394. package/build/plugins/solution/spfx-solution/scaffolding.d.ts.map +1 -0
  395. package/build/plugins/solution/spfx-solution/scaffolding.js +29 -0
  396. package/build/plugins/solution/spfx-solution/scaffolding.js.map +1 -0
  397. package/build/plugins/solution/spfx-solution/solution.d.ts +23 -0
  398. package/build/plugins/solution/spfx-solution/solution.d.ts.map +1 -0
  399. package/build/plugins/solution/spfx-solution/solution.js +29 -0
  400. package/build/plugins/solution/spfx-solution/solution.js.map +1 -0
  401. package/package.json +9 -4
  402. package/resource/strings.json +0 -1
  403. package/templates/plugins/resource/apim/bicep/apimConfiguration.bicep +16 -16
  404. package/templates/plugins/resource/apim/bicep/config.template.bicep +1 -1
  405. package/templates/plugins/resource/apim/bicep/provision.template.bicep +1 -1
  406. package/templates/plugins/resource/bot/bicep/botConfiguration.template.bicep +28 -29
  407. package/templates/plugins/resource/bot/bicep/config.template.bicep +1 -1
  408. package/templates/plugins/resource/bot/bicep/provision.template.bicep +2 -2
  409. package/templates/plugins/resource/frontend/bicep/provision.template.bicep +1 -1
  410. package/templates/plugins/resource/function/bicep/config.template.bicep +1 -1
  411. package/templates/plugins/resource/function/bicep/functionConfiguration.template.bicep +33 -31
  412. package/templates/plugins/resource/function/bicep/provision.template.bicep +2 -2
  413. package/templates/plugins/resource/identity/bicep/provision.template.bicep +1 -1
  414. package/templates/plugins/resource/keyvault/bicep/provision.template.bicep +3 -2
  415. package/templates/plugins/resource/simpleauth/bicep/config.template.bicep +1 -1
  416. package/templates/plugins/resource/simpleauth/bicep/provision.template.bicep +2 -2
  417. package/templates/plugins/resource/simpleauth/bicep/simpleAuthConfiguration.template.bicep +20 -24
  418. package/templates/plugins/resource/simpleauth/version.txt +2 -1
  419. package/templates/plugins/resource/sql/bicep/provision.template.bicep +1 -1
  420. package/build/plugins/resource/localdebug/launch.d.ts.map +0 -1
  421. package/build/plugins/resource/localdebug/launch.js.map +0 -1
  422. package/build/plugins/resource/localdebug/legacyPlugin.d.ts +0 -6
  423. package/build/plugins/resource/localdebug/legacyPlugin.d.ts.map +0 -1
  424. package/build/plugins/resource/localdebug/legacyPlugin.js +0 -208
  425. package/build/plugins/resource/localdebug/legacyPlugin.js.map +0 -1
  426. package/build/plugins/resource/localdebug/settings.d.ts +0 -2
  427. package/build/plugins/resource/localdebug/settings.d.ts.map +0 -1
  428. package/build/plugins/resource/localdebug/settings.js +0 -18
  429. package/build/plugins/resource/localdebug/settings.js.map +0 -1
  430. package/build/plugins/resource/localdebug/tasks.d.ts.map +0 -1
  431. package/build/plugins/resource/localdebug/tasks.js.map +0 -1
  432. package/build/plugins/resource/localdebug/util/codespace.d.ts.map +0 -1
  433. package/build/plugins/resource/localdebug/util/codespace.js.map +0 -1
  434. package/build/plugins/resource/localdebug/util/ngrok.d.ts.map +0 -1
  435. package/build/plugins/resource/localdebug/util/ngrok.js.map +0 -1
  436. package/templates/azure/config.bicep +0 -25
  437. package/templates/azure/main.bicep +0 -20
  438. package/templates/azure/provision/azureSql.bicep +0 -39
  439. package/templates/azure/provision/frontendHosting.bicep +0 -23
  440. package/templates/azure/provision/function.bicep +0 -79
  441. package/templates/azure/provision/simpleAuth.bicep +0 -44
  442. package/templates/azure/provision.bicep +0 -58
  443. package/templates/azure/teamsFx/bot.bicep +0 -34
  444. package/templates/azure/teamsFx/function.bicep +0 -71
  445. package/templates/azure/teamsFx/simpleAuth.bicep +0 -40
  446. package/templates/plugins/resource/aad/bicep/param.template.bicep +0 -6
  447. package/templates/plugins/resource/aad/bicep/variables.template.bicep +0 -13
@@ -2,14 +2,16 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getProjectSettingsVersion = exports.undefinedName = exports.createV2Context = exports.newProjectSettings = exports.downloadSample = exports.createBasicFolderStructure = exports.FxCore = exports.TOOLS = exports.currentStage = exports.telemetryReporter = exports.Logger = exports.isVsCallingCli = exports.isV2 = void 0;
5
+ exports.getProjectSettingsVersion = exports.undefinedName = exports.createV2Context = exports.newProjectSettings = exports.downloadSample = exports.createBasicFolderStructure = exports.FxCore = exports.setTools = exports.TOOLS = exports.currentStage = exports.telemetryReporter = exports.Logger = exports.isVsCallingCli = exports.isV3 = void 0;
6
6
  const tslib_1 = require("tslib");
7
7
  const hooks_1 = require("@feathersjs/hooks");
8
8
  const teamsfx_api_1 = require("@microsoft/teamsfx-api");
9
9
  const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
10
10
  const fs = tslib_1.__importStar(require("fs-extra"));
11
11
  const jsonschema = tslib_1.__importStar(require("jsonschema"));
12
+ const lodash_1 = require("lodash");
12
13
  const path = tslib_1.__importStar(require("path"));
14
+ const typedi_1 = require("typedi");
13
15
  const uuid = tslib_1.__importStar(require("uuid"));
14
16
  const __1 = require("..");
15
17
  const constants_1 = require("../common/constants");
@@ -18,13 +20,17 @@ const localSettingsProvider_1 = require("../common/localSettingsProvider");
18
20
  const telemetry_1 = require("../common/telemetry");
19
21
  const tools_1 = require("../common/tools");
20
22
  const plugins_1 = require("../plugins");
23
+ const question_1 = require("../plugins/solution/fx-solution/question");
21
24
  const ResourcePluginContainer_1 = require("../plugins/solution/fx-solution/ResourcePluginContainer");
25
+ const constants_2 = require("../plugins/solution/fx-solution/v3/constants");
22
26
  const callback_1 = require("./callback");
27
+ const crypto_1 = require("./crypto");
23
28
  const error_1 = require("./error");
24
29
  const concurrentLocker_1 = require("./middleware/concurrentLocker");
25
30
  const contextInjector_1 = require("./middleware/contextInjector");
26
31
  const envInfoLoader_1 = require("./middleware/envInfoLoader");
27
32
  const envInfoWriter_1 = require("./middleware/envInfoWriter");
33
+ const envInfoWriterV3_1 = require("./middleware/envInfoWriterV3");
28
34
  const errorHandler_1 = require("./middleware/errorHandler");
29
35
  const localSettingsLoader_1 = require("./middleware/localSettingsLoader");
30
36
  const localSettingsWriter_1 = require("./middleware/localSettingsWriter");
@@ -35,12 +41,13 @@ const projectSettingsWriter_1 = require("./middleware/projectSettingsWriter");
35
41
  const projectUpgrader_1 = require("./middleware/projectUpgrader");
36
42
  const questionModel_1 = require("./middleware/questionModel");
37
43
  const solutionLoader_1 = require("./middleware/solutionLoader");
38
- const question_1 = require("./question");
44
+ const question_2 = require("./question");
39
45
  const SolutionPluginContainer_1 = require("./SolutionPluginContainer");
40
46
  const tools_2 = require("./tools");
41
- const crypto_1 = require("./crypto");
42
47
  const supportV1ConditionHandler_1 = require("./middleware/supportV1ConditionHandler");
43
- const lodash_1 = require("lodash");
48
+ const projectSettingsLoaderV3_1 = require("./middleware/projectSettingsLoaderV3");
49
+ const solutionLoaderV3_1 = require("./middleware/solutionLoaderV3");
50
+ const envInfoLoaderV3_1 = require("./middleware/envInfoLoaderV3");
44
51
  // TODO: For package.json,
45
52
  // use require instead of import because of core building/packaging method.
46
53
  // Using import will cause the build folder structure to change.
@@ -54,18 +61,36 @@ function featureFlagEnabled(flagName) {
54
61
  return false;
55
62
  }
56
63
  }
57
- // API V2 feature flag
58
- function isV2() {
59
- return tools_1.isMultiEnvEnabled();
64
+ function isV3() {
65
+ return featureFlagEnabled(constants_1.FeatureFlagName.APIV3);
60
66
  }
61
- exports.isV2 = isV2;
67
+ exports.isV3 = isV3;
62
68
  // On VS calling CLI, interactive questions need to be skipped.
63
69
  function isVsCallingCli() {
64
70
  return featureFlagEnabled(constants_1.FeatureFlagName.VSCallingCLI);
65
71
  }
66
72
  exports.isVsCallingCli = isVsCallingCli;
73
+ function setTools(tools) {
74
+ exports.TOOLS = tools;
75
+ }
76
+ exports.setTools = setTools;
67
77
  class FxCore {
68
78
  constructor(tools) {
79
+ //V1,V2 questions
80
+ this._getQuestionsForCreateProjectV2 = questionModel_1.getQuestionsForCreateProjectV2;
81
+ this._getQuestionsForCreateProjectV3 = questionModel_1.getQuestionsForCreateProjectV3;
82
+ this._getQuestionsForUserTask = questionModel_1.getQuestionsForUserTaskV2;
83
+ this._getQuestions = questionModel_1.getQuestionsV2;
84
+ this._getQuestionsForMigrateV1Project = questionModel_1.getQuestionsForMigrateV1Project;
85
+ //v3 questions
86
+ this._getQuestionsForScaffold = questionModel_1.getQuestionsForScaffold;
87
+ this._getQuestionsForAddModule = questionModel_1.getQuestionsForAddModule;
88
+ this._getQuestionsForAddResource = questionModel_1.getQuestionsForAddResource;
89
+ this._getQuestionsForProvision = questionModel_1.getQuestionsForProvision;
90
+ this._getQuestionsForDeploy = questionModel_1.getQuestionsForDeploy;
91
+ this._getQuestionsForLocalProvision = questionModel_1.getQuestionsForLocalProvision;
92
+ this._getQuestionsForPublish = questionModel_1.getQuestionsForPublish;
93
+ this._getQuestionsForInit = questionModel_1.getQuestionsForInit;
69
94
  this.tools = tools;
70
95
  exports.TOOLS = tools;
71
96
  exports.Logger = tools.logProvider;
@@ -78,24 +103,37 @@ class FxCore {
78
103
  on(event, callback) {
79
104
  return callback_1.CallbackRegistry.set(event, callback);
80
105
  }
81
- async createProject(inputs, ctx) {
106
+ async createProject(inputs) {
107
+ if (isV3()) {
108
+ return this.createProjectV3(inputs);
109
+ }
110
+ else {
111
+ return this.createProjectV2(inputs);
112
+ }
113
+ }
114
+ async createProjectV2(inputs, ctx) {
82
115
  if (!ctx) {
83
116
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
84
117
  }
85
118
  exports.currentStage = teamsfx_api_1.Stage.create;
86
119
  inputs.stage = teamsfx_api_1.Stage.create;
87
- let folder = inputs[question_1.QuestionRootFolder.name];
120
+ let folder = inputs[question_2.QuestionRootFolder.name];
88
121
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
89
122
  folder = tools_1.getRootDirectory();
90
- await fs.ensureDir(folder);
123
+ try {
124
+ await fs.ensureDir(folder);
125
+ }
126
+ catch (e) {
127
+ throw error_1.ProjectFolderInvalidError(folder);
128
+ }
91
129
  }
92
- const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
130
+ const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
93
131
  let projectPath;
94
132
  let globalStateDescription = "openReadme";
95
133
  const multiEnv = tools_1.isMultiEnvEnabled();
96
- if (scratch === question_1.ScratchOptionNo.id) {
134
+ if (scratch === question_2.ScratchOptionNo.id) {
97
135
  // create from sample
98
- const downloadRes = await downloadSample(this, inputs, ctx);
136
+ const downloadRes = await downloadSample(inputs, ctx);
99
137
  if (downloadRes.isErr()) {
100
138
  return teamsfx_api_1.err(downloadRes.error);
101
139
  }
@@ -104,11 +142,11 @@ class FxCore {
104
142
  }
105
143
  else {
106
144
  // create from new
107
- const appName = inputs[question_1.QuestionAppName.name];
145
+ const appName = inputs[question_2.QuestionAppName.name];
108
146
  if (undefined === appName)
109
147
  return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
110
148
  const validateResult = jsonschema.validate(appName, {
111
- pattern: question_1.ProjectNamePattern,
149
+ pattern: question_2.ProjectNamePattern,
112
150
  });
113
151
  if (validateResult.errors && validateResult.errors.length > 0) {
114
152
  return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
@@ -143,71 +181,222 @@ class FxCore {
143
181
  return teamsfx_api_1.err(createEnvResult.error);
144
182
  }
145
183
  }
146
- if (isV2()) {
147
- const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_1.CoreQuestionNames.Solution]);
148
- if (!solution) {
149
- return teamsfx_api_1.err(new error_1.LoadSolutionError());
150
- }
151
- ctx.solutionV2 = solution;
152
- projectSettings.solutionSettings.name = solution.name;
153
- const contextV2 = createV2Context(this, projectSettings);
154
- ctx.contextV2 = contextV2;
155
- const scaffoldSourceCodeRes = await solution.scaffoldSourceCode(contextV2, inputs);
156
- if (scaffoldSourceCodeRes.isErr()) {
157
- return teamsfx_api_1.err(scaffoldSourceCodeRes.error);
158
- }
159
- const generateResourceTemplateRes = await solution.generateResourceTemplate(contextV2, inputs);
160
- if (generateResourceTemplateRes.isErr()) {
161
- return teamsfx_api_1.err(generateResourceTemplateRes.error);
162
- }
163
- // ctx.provisionInputConfig = generateResourceTemplateRes.value;
164
- if (multiEnv) {
165
- if (solution.createEnv) {
166
- inputs.copy = false;
167
- const createEnvRes = await solution.createEnv(contextV2, inputs);
168
- if (createEnvRes.isErr()) {
169
- return teamsfx_api_1.err(createEnvRes.error);
170
- }
171
- }
172
- }
173
- else {
174
- //TODO lagacy env.default.json
175
- const state = { solution: {} };
176
- for (const plugin of ResourcePluginContainer_1.getAllV2ResourcePlugins()) {
177
- state[plugin.name] = {};
184
+ const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_2.CoreQuestionNames.Solution]);
185
+ if (!solution) {
186
+ return teamsfx_api_1.err(new error_1.LoadSolutionError());
187
+ }
188
+ ctx.solutionV2 = solution;
189
+ projectSettings.solutionSettings.name = solution.name;
190
+ const contextV2 = createV2Context(projectSettings);
191
+ ctx.contextV2 = contextV2;
192
+ const scaffoldSourceCodeRes = await solution.scaffoldSourceCode(contextV2, inputs);
193
+ if (scaffoldSourceCodeRes.isErr()) {
194
+ return teamsfx_api_1.err(scaffoldSourceCodeRes.error);
195
+ }
196
+ const generateResourceTemplateRes = await solution.generateResourceTemplate(contextV2, inputs);
197
+ if (generateResourceTemplateRes.isErr()) {
198
+ return teamsfx_api_1.err(generateResourceTemplateRes.error);
199
+ }
200
+ // ctx.provisionInputConfig = generateResourceTemplateRes.value;
201
+ if (multiEnv) {
202
+ if (solution.createEnv) {
203
+ inputs.copy = false;
204
+ const createEnvRes = await solution.createEnv(contextV2, inputs);
205
+ if (createEnvRes.isErr()) {
206
+ return teamsfx_api_1.err(createEnvRes.error);
178
207
  }
179
- state[plugins_1.PluginNames.LDEBUG]["trustDevCert"] = "true";
180
- ctx.envInfoV2 = {
181
- envName: __1.environmentManager.getDefaultEnvName(),
182
- config: {},
183
- state: state,
184
- };
185
208
  }
186
209
  }
187
210
  else {
188
- const solution = await SolutionPluginContainer_1.getSolutionPluginByName(inputs[question_1.CoreQuestionNames.Solution]);
189
- if (!solution) {
190
- return teamsfx_api_1.err(new error_1.LoadSolutionError());
211
+ //TODO lagacy env.default.json
212
+ const state = { solution: {} };
213
+ for (const plugin of ResourcePluginContainer_1.getAllV2ResourcePlugins()) {
214
+ state[plugin.name] = {};
191
215
  }
192
- ctx.solution = solution;
193
- projectSettings.solutionSettings.name = solution.name;
194
- const solutionContext = Object.assign(Object.assign(Object.assign({ projectSettings: projectSettings, envInfo: tools_2.newEnvInfo(), root: projectPath }, this.tools), this.tools.tokenProvider), { answers: inputs, cryptoProvider: new crypto_1.LocalCrypto(projectSettings.projectId) });
195
- ctx.solutionContext = solutionContext;
196
- const createRes = await solution.create(solutionContext);
197
- if (createRes.isErr()) {
198
- return createRes;
216
+ state[plugins_1.PluginNames.LDEBUG]["trustDevCert"] = "true";
217
+ ctx.envInfoV2 = {
218
+ envName: __1.environmentManager.getDefaultEnvName(),
219
+ config: {},
220
+ state: state,
221
+ };
222
+ }
223
+ }
224
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
225
+ await globalState_1.globalStateUpdate(globalStateDescription, true);
226
+ }
227
+ return teamsfx_api_1.ok(projectPath);
228
+ }
229
+ async createProjectV3(inputs, ctx) {
230
+ if (!ctx) {
231
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
232
+ }
233
+ exports.currentStage = teamsfx_api_1.Stage.create;
234
+ inputs.stage = teamsfx_api_1.Stage.create;
235
+ let folder = inputs[question_2.QuestionRootFolder.name];
236
+ if (inputs.platform === teamsfx_api_1.Platform.VSCode || inputs.platform === teamsfx_api_1.Platform.VS) {
237
+ folder = tools_1.getRootDirectory();
238
+ try {
239
+ await fs.ensureDir(folder);
240
+ }
241
+ catch (e) {
242
+ throw error_1.ProjectFolderInvalidError(folder);
243
+ }
244
+ }
245
+ const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
246
+ let projectPath;
247
+ let globalStateDescription = "openReadme";
248
+ if (scratch === question_2.ScratchOptionNo.id) {
249
+ // create from sample
250
+ const downloadRes = await downloadSample(inputs, ctx);
251
+ if (downloadRes.isErr()) {
252
+ return teamsfx_api_1.err(downloadRes.error);
253
+ }
254
+ projectPath = downloadRes.value;
255
+ globalStateDescription = "openSampleReadme";
256
+ }
257
+ else {
258
+ // create from new
259
+ const appName = inputs[question_2.QuestionAppName.name];
260
+ if (undefined === appName)
261
+ return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
262
+ const validateResult = jsonschema.validate(appName, {
263
+ pattern: question_2.ProjectNamePattern,
264
+ });
265
+ if (validateResult.errors && validateResult.errors.length > 0) {
266
+ return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
267
+ }
268
+ projectPath = path.join(folder, appName);
269
+ inputs.projectPath = projectPath;
270
+ const folderExist = await fs.pathExists(projectPath);
271
+ if (folderExist) {
272
+ return teamsfx_api_1.err(error_1.ProjectFolderExistError(projectPath));
273
+ }
274
+ await fs.ensureDir(projectPath);
275
+ await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
276
+ let capabilities = inputs[question_2.CoreQuestionNames.Capabilities];
277
+ let projectType = "";
278
+ if (capabilities.includes(question_2.TabSPFxItem.id))
279
+ projectType = "spfx";
280
+ else if (capabilities.includes(question_2.TabOptionItem.id) && capabilities.length === 1)
281
+ projectType = "tab";
282
+ else if ((capabilities.includes(question_2.BotOptionItem.id) ||
283
+ capabilities.includes(question_1.MessageExtensionItem.id)) &&
284
+ !capabilities.includes(question_2.TabOptionItem.id))
285
+ projectType = "bot";
286
+ else if ((capabilities.includes(question_2.BotOptionItem.id) ||
287
+ capabilities.includes(question_1.MessageExtensionItem.id)) &&
288
+ capabilities.includes(question_2.TabOptionItem.id))
289
+ projectType = "tab+bot";
290
+ const programmingLanguage = inputs[question_2.CoreQuestionNames.ProgrammingLanguage];
291
+ // const solution = capabilities.includes(TabSPFxItem.id)
292
+ // ? BuiltInSolutionNames.spfx
293
+ // : BuiltInSolutionNames.azure;
294
+ // init
295
+ const initInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath });
296
+ const initRes = await this._init(initInputs, ctx);
297
+ if (initRes.isErr()) {
298
+ return teamsfx_api_1.err(initRes.error);
299
+ }
300
+ // addModule, scaffold and addResource
301
+ if (inputs.platform === teamsfx_api_1.Platform.VS) {
302
+ // addModule
303
+ const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities });
304
+ const addModuleRes = await this._addModule(addModuleInputs, ctx);
305
+ if (addModuleRes.isErr()) {
306
+ return teamsfx_api_1.err(addModuleRes.error);
199
307
  }
200
- const scaffoldRes = await solution.scaffold(solutionContext);
308
+ // addResource
309
+ const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", resource: constants_2.BuiltInResourcePluginNames.webApp });
310
+ const addResourceRes = await this._addResource(addResourceInputs, ctx);
311
+ if (addResourceRes.isErr()) {
312
+ return teamsfx_api_1.err(addResourceRes.error);
313
+ }
314
+ // scaffold
315
+ let templateName = "";
316
+ if (projectType === "tab")
317
+ templateName = "BlazorTab";
318
+ else if (projectType === "bot")
319
+ templateName = "BlazorBot";
320
+ else if (projectType === "tabbot")
321
+ templateName = "BlazorTabBot";
322
+ const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", template: {
323
+ id: `${constants_2.BuiltInScaffoldPluginNames.blazor}/${templateName}`,
324
+ label: `${constants_2.BuiltInScaffoldPluginNames.blazor}/${templateName}`,
325
+ data: {
326
+ pluginName: constants_2.BuiltInScaffoldPluginNames.blazor,
327
+ templateName: templateName,
328
+ },
329
+ } });
330
+ const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
201
331
  if (scaffoldRes.isErr()) {
202
- return scaffoldRes;
332
+ return teamsfx_api_1.err(scaffoldRes.error);
203
333
  }
204
- if (multiEnv) {
205
- if (solution.createEnv) {
206
- solutionContext.answers.copy = false;
207
- const createEnvRes = await solution.createEnv(solutionContext);
208
- if (createEnvRes.isErr()) {
209
- return teamsfx_api_1.err(createEnvRes.error);
210
- }
334
+ }
335
+ else {
336
+ if (capabilities.includes(question_2.TabOptionItem.id) || capabilities.includes(question_2.TabSPFxItem.id)) {
337
+ const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities.includes(question_2.TabOptionItem.id)
338
+ ? [question_2.TabOptionItem.id]
339
+ : [question_2.TabSPFxItem.id] });
340
+ const addModuleRes = await this._addModule(addModuleInputs, ctx);
341
+ if (addModuleRes.isErr()) {
342
+ return teamsfx_api_1.err(addModuleRes.error);
343
+ }
344
+ // addResource
345
+ const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", resource: capabilities.includes(question_2.TabOptionItem.id)
346
+ ? constants_2.BuiltInResourcePluginNames.storage
347
+ : constants_2.BuiltInResourcePluginNames.spfx });
348
+ const addResourceRes = await this._addResource(addResourceInputs, ctx);
349
+ if (addResourceRes.isErr()) {
350
+ return teamsfx_api_1.err(addResourceRes.error);
351
+ }
352
+ // scaffold
353
+ const pluginName = capabilities.includes(question_2.TabOptionItem.id)
354
+ ? constants_2.BuiltInScaffoldPluginNames.tab
355
+ : constants_2.BuiltInScaffoldPluginNames.spfx;
356
+ const templateName = capabilities.includes(question_2.TabOptionItem.id)
357
+ ? programmingLanguage === "javascript"
358
+ ? "ReactTab_JS"
359
+ : "ReactTab_TS"
360
+ : "SPFxTab";
361
+ const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", template: {
362
+ id: `${pluginName}/${templateName}`,
363
+ label: `${pluginName}/${templateName}`,
364
+ data: {
365
+ pluginName: pluginName,
366
+ templateName: templateName, //TODO
367
+ },
368
+ } });
369
+ const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
370
+ if (scaffoldRes.isErr()) {
371
+ return teamsfx_api_1.err(scaffoldRes.error);
372
+ }
373
+ }
374
+ capabilities = capabilities.filter((c) => c !== question_2.TabOptionItem.id && c !== question_2.TabSPFxItem.id);
375
+ if (capabilities.length > 0) {
376
+ const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities });
377
+ const addModuleRes = await this._addModule(addModuleInputs, ctx);
378
+ if (addModuleRes.isErr()) {
379
+ return teamsfx_api_1.err(addModuleRes.error);
380
+ }
381
+ // addResource
382
+ const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "1", resource: constants_2.BuiltInResourcePluginNames.bot });
383
+ const addResourceRes = await this._addResource(addResourceInputs, ctx);
384
+ if (addResourceRes.isErr()) {
385
+ return teamsfx_api_1.err(addResourceRes.error);
386
+ }
387
+ // scaffold
388
+ const templateName = programmingLanguage === "javascript" ? "NodejsBot_JS" : "NodejsBot_TS";
389
+ const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "1", resource: constants_2.BuiltInScaffoldPluginNames.bot, template: {
390
+ id: `${constants_2.BuiltInScaffoldPluginNames.bot}/${templateName}`,
391
+ label: `${constants_2.BuiltInScaffoldPluginNames.bot}/${templateName}`,
392
+ data: {
393
+ pluginName: constants_2.BuiltInScaffoldPluginNames.bot,
394
+ templateName: templateName, //TODO
395
+ },
396
+ } });
397
+ const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
398
+ if (scaffoldRes.isErr()) {
399
+ return teamsfx_api_1.err(scaffoldRes.error);
211
400
  }
212
401
  }
213
402
  }
@@ -222,11 +411,11 @@ class FxCore {
222
411
  exports.currentStage = teamsfx_api_1.Stage.migrateV1;
223
412
  inputs.stage = teamsfx_api_1.Stage.migrateV1;
224
413
  const globalStateDescription = "openReadme";
225
- const appName = ((_a = inputs[question_1.DefaultAppNameFunc.name]) !== null && _a !== void 0 ? _a : inputs[question_1.QuestionV1AppName.name]);
414
+ const appName = ((_a = inputs[question_2.DefaultAppNameFunc.name]) !== null && _a !== void 0 ? _a : inputs[question_2.QuestionV1AppName.name]);
226
415
  if (undefined === appName)
227
416
  return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
228
417
  const validateResult = jsonschema.validate(appName, {
229
- pattern: question_1.ProjectNamePattern,
418
+ pattern: question_2.ProjectNamePattern,
230
419
  });
231
420
  if (validateResult.errors && validateResult.errors.length > 0) {
232
421
  return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
@@ -302,104 +491,131 @@ class FxCore {
302
491
  return teamsfx_api_1.err(error_1.ArchiveProjectError(e.message));
303
492
  }
304
493
  }
305
- async provisionResources(inputs, ctx) {
494
+ /**
495
+ * switch to different versions of provisionResources
496
+ */
497
+ async provisionResources(inputs) {
498
+ if (isV3()) {
499
+ return this.provisionResourcesV3(inputs);
500
+ }
501
+ else {
502
+ return this.provisionResourcesV2(inputs);
503
+ }
504
+ }
505
+ async provisionResourcesV2(inputs, ctx) {
306
506
  exports.currentStage = teamsfx_api_1.Stage.provision;
307
507
  inputs.stage = teamsfx_api_1.Stage.provision;
308
- // provision is not ready yet, so use API v1
309
- if (isV2()) {
310
- if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
311
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Provision input stuff"));
312
- }
313
- const envInfo = ctx.envInfoV2;
314
- const result = await ctx.solutionV2.provisionResources(ctx.contextV2, inputs, envInfo, this.tools.tokenProvider);
315
- if (result.kind === "success") {
316
- ctx.envInfoV2.state = lodash_1.assign(ctx.envInfoV2.state, result.output);
317
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
318
- }
319
- else if (result.kind === "partialSuccess") {
320
- ctx.envInfoV2.state = lodash_1.assign(ctx.envInfoV2.state, result.output);
321
- return teamsfx_api_1.err(result.error);
322
- }
323
- else {
324
- return teamsfx_api_1.err(result.error);
325
- }
508
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
509
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Provision input stuff"));
510
+ }
511
+ const envInfo = ctx.envInfoV2;
512
+ const result = await ctx.solutionV2.provisionResources(ctx.contextV2, inputs, envInfo, this.tools.tokenProvider);
513
+ if (result.kind === "success") {
514
+ ctx.envInfoV2.state = lodash_1.assign(ctx.envInfoV2.state, result.output);
515
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
516
+ }
517
+ else if (result.kind === "partialSuccess") {
518
+ ctx.envInfoV2.state = lodash_1.assign(ctx.envInfoV2.state, result.output);
519
+ return teamsfx_api_1.err(result.error);
326
520
  }
327
521
  else {
328
- if (!ctx || !ctx.solution || !ctx.solutionContext) {
329
- const name = undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solution, ctx === null || ctx === void 0 ? void 0 : ctx.solutionContext], ["ctx", "ctx.solution", "ctx.solutionContext"]);
330
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`Provision input stuff: ${name}`));
331
- }
332
- const provisionRes = await ctx.solution.provision(ctx.solutionContext);
333
- if (provisionRes.isErr()) {
334
- return provisionRes;
522
+ return teamsfx_api_1.err(result.error);
523
+ }
524
+ }
525
+ async provisionResourcesV3(inputs, ctx) {
526
+ exports.currentStage = teamsfx_api_1.Stage.provision;
527
+ inputs.stage = teamsfx_api_1.Stage.provision;
528
+ if (ctx &&
529
+ ctx.solutionV3 &&
530
+ ctx.contextV2 &&
531
+ ctx.envInfoV3 &&
532
+ ctx.solutionV3.provisionResources) {
533
+ const res = await ctx.solutionV3.provisionResources(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider);
534
+ if (res.isOk()) {
535
+ ctx.envInfoV3 = res.value;
335
536
  }
336
- this._setEnvInfoV2(ctx);
337
- return provisionRes;
537
+ return res;
338
538
  }
539
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
540
+ }
541
+ async deployArtifacts(inputs) {
542
+ if (isV3())
543
+ return this.deployArtifactsV3(inputs);
544
+ else
545
+ return this.deployArtifactsV2(inputs);
339
546
  }
340
- async deployArtifacts(inputs, ctx) {
547
+ async deployArtifactsV2(inputs, ctx) {
341
548
  exports.currentStage = teamsfx_api_1.Stage.deploy;
342
549
  inputs.stage = teamsfx_api_1.Stage.deploy;
343
- if (isV2()) {
344
- if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
345
- const name = 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"]);
346
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`Deploy input stuff: ${name}`));
347
- }
348
- if (ctx.solutionV2.deploy)
349
- return await ctx.solutionV2.deploy(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider);
350
- else
550
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
551
+ const name = 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"]);
552
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`Deploy input stuff: ${name}`));
553
+ }
554
+ if (ctx.solutionV2.deploy)
555
+ return await ctx.solutionV2.deploy(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider);
556
+ else
557
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
558
+ }
559
+ async deployArtifactsV3(inputs, ctx) {
560
+ exports.currentStage = teamsfx_api_1.Stage.deploy;
561
+ inputs.stage = teamsfx_api_1.Stage.deploy;
562
+ if (ctx && ctx.solutionV3 && ctx.contextV2 && ctx.envInfoV3 && ctx.solutionV3.deploy) {
563
+ const res = await ctx.solutionV3.deploy(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider);
564
+ return res;
565
+ }
566
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
567
+ }
568
+ async localDebug(inputs) {
569
+ if (isV3())
570
+ return this.localDebugV3(inputs);
571
+ else
572
+ return this.localDebugV2(inputs);
573
+ }
574
+ async localDebugV2(inputs, ctx) {
575
+ exports.currentStage = teamsfx_api_1.Stage.debug;
576
+ inputs.stage = teamsfx_api_1.Stage.debug;
577
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2) {
578
+ const name = 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"]);
579
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`localDebug input stuff (${name})`));
580
+ }
581
+ if (!ctx.localSettings)
582
+ ctx.localSettings = {};
583
+ if (ctx.solutionV2.provisionLocalResource) {
584
+ const res = await ctx.solutionV2.provisionLocalResource(ctx.contextV2, inputs, ctx.localSettings, this.tools.tokenProvider);
585
+ if (res.kind === "success") {
586
+ ctx.localSettings = res.output;
351
587
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
588
+ }
589
+ else if (res.kind === "partialSuccess") {
590
+ ctx.localSettings = res.output;
591
+ return teamsfx_api_1.err(res.error);
592
+ }
593
+ else {
594
+ return teamsfx_api_1.err(res.error);
595
+ }
352
596
  }
353
597
  else {
354
- if (!ctx || !ctx.solution || !ctx.solutionContext) {
355
- const name = undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solution, ctx === null || ctx === void 0 ? void 0 : ctx.solutionContext], ["ctx", "ctx.solution", "ctx.solutionContext"]);
356
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`Deploy input stuff: ${name}`));
357
- }
358
- return await ctx.solution.deploy(ctx.solutionContext);
598
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
359
599
  }
360
600
  }
361
- async localDebug(inputs, ctx) {
601
+ async localDebugV3(inputs, ctx) {
362
602
  exports.currentStage = teamsfx_api_1.Stage.debug;
363
603
  inputs.stage = teamsfx_api_1.Stage.debug;
364
- if (isV2()) {
365
- if (tools_1.isMultiEnvEnabled()) {
366
- if (!ctx || !ctx.solutionV2 || !ctx.contextV2) {
367
- const name = 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"]);
368
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`localDebug input stuff (${name})`));
369
- }
370
- if (!ctx.localSettings)
371
- ctx.localSettings = {};
372
- if (ctx.solutionV2.provisionLocalResource) {
373
- const res = await ctx.solutionV2.provisionLocalResource(ctx.contextV2, inputs, ctx.localSettings, this.tools.tokenProvider);
374
- if (res.kind === "success") {
375
- ctx.localSettings = res.output;
376
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
377
- }
378
- else if (res.kind === "partialSuccess") {
379
- ctx.localSettings = res.output;
380
- return teamsfx_api_1.err(res.error);
381
- }
382
- else {
383
- return teamsfx_api_1.err(res.error);
384
- }
385
- }
386
- else {
387
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
388
- }
604
+ if (ctx &&
605
+ ctx.solutionV3 &&
606
+ ctx.contextV2 &&
607
+ ctx.localSettings &&
608
+ ctx.solutionV3.provisionLocalResources) {
609
+ const res = await ctx.solutionV3.provisionLocalResources(ctx.contextV2, inputs, ctx.localSettings, exports.TOOLS.tokenProvider);
610
+ if (res.isOk()) {
611
+ ctx.localSettings = res.value;
389
612
  }
613
+ return res;
390
614
  }
391
- if (!ctx || !ctx.solution || !ctx.solutionContext || !ctx.projectSettings) {
392
- const name = undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solution, ctx === null || ctx === void 0 ? void 0 : ctx.solutionContext, ctx === null || ctx === void 0 ? void 0 : ctx.projectSettings], ["ctx", "ctx.solution", "ctx.solutionContext", "ctx.projectSettings"]);
393
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`localDebug input stuff (${name})`));
394
- }
395
- envInfoLoader_1.upgradeProgrammingLanguage(ctx.solutionContext.envInfo.state, ctx.projectSettings);
396
- envInfoLoader_1.upgradeDefaultFunctionName(ctx.solutionContext.envInfo.state, ctx.projectSettings);
397
- const res = await ctx.solution.localDebug(ctx.solutionContext);
398
- this._setEnvInfoV2(ctx);
399
- return res;
615
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
400
616
  }
401
617
  _setEnvInfoV2(ctx) {
402
- if (isV2() && ctx && ctx.solutionContext) {
618
+ if (ctx && ctx.solutionContext) {
403
619
  //workaround, compatible to api v2
404
620
  ctx.envInfoV2 = {
405
621
  envName: ctx.solutionContext.envInfo.envName,
@@ -409,23 +625,33 @@ class FxCore {
409
625
  ctx.envInfoV2.state = tools_1.mapToJson(ctx.solutionContext.envInfo.state);
410
626
  }
411
627
  }
412
- async publishApplication(inputs, ctx) {
628
+ async publishApplication(inputs) {
629
+ if (isV3())
630
+ return this.publishApplicationV3(inputs);
631
+ else
632
+ return this.publishApplicationV2(inputs);
633
+ }
634
+ async publishApplicationV2(inputs, ctx) {
413
635
  exports.currentStage = teamsfx_api_1.Stage.publish;
414
636
  inputs.stage = teamsfx_api_1.Stage.publish;
415
- if (isV2()) {
416
- if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
417
- const name = 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"]);
418
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`publish input stuff: ${name}`));
419
- }
420
- return await ctx.solutionV2.publishApplication(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider.appStudioToken);
637
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2) {
638
+ const name = 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"]);
639
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`publish input stuff: ${name}`));
421
640
  }
422
- else {
423
- if (!ctx || !ctx.solution || !ctx.solutionContext) {
424
- const name = undefinedName([ctx, ctx === null || ctx === void 0 ? void 0 : ctx.solution, ctx === null || ctx === void 0 ? void 0 : ctx.solutionContext], ["ctx", "ctx.solution", "ctx.solutionContext"]);
425
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`publish input stuff: ${name}`));
426
- }
427
- return await ctx.solution.publish(ctx.solutionContext);
641
+ return await ctx.solutionV2.publishApplication(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider.appStudioToken);
642
+ }
643
+ async publishApplicationV3(inputs, ctx) {
644
+ exports.currentStage = teamsfx_api_1.Stage.publish;
645
+ inputs.stage = teamsfx_api_1.Stage.publish;
646
+ if (ctx &&
647
+ ctx.solutionV3 &&
648
+ ctx.contextV2 &&
649
+ ctx.envInfoV3 &&
650
+ ctx.solutionV3.publishApplication) {
651
+ const res = await ctx.solutionV3.publishApplication(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider.appStudioToken);
652
+ return res;
428
653
  }
654
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
429
655
  }
430
656
  async executeUserTask(func, inputs, ctx) {
431
657
  exports.currentStage = teamsfx_api_1.Stage.userTask;
@@ -433,32 +659,20 @@ class FxCore {
433
659
  const namespace = func.namespace;
434
660
  const array = namespace ? namespace.split("/") : [];
435
661
  if ("" !== namespace && array.length > 0) {
436
- if (isV2()) {
437
- if (!ctx || !ctx.solutionV2 || !ctx.envInfoV2) {
438
- const name = 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"]);
439
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`executeUserTask input stuff: ${name}`));
440
- }
441
- if (!ctx.contextV2)
442
- ctx.contextV2 = createV2Context(this, newProjectSettings());
443
- if (ctx.solutionV2.executeUserTask) {
444
- if (!ctx.localSettings)
445
- ctx.localSettings = {};
446
- const res = await ctx.solutionV2.executeUserTask(ctx.contextV2, inputs, func, ctx.localSettings, ctx.envInfoV2, this.tools.tokenProvider);
447
- return res;
448
- }
449
- else
450
- return teamsfx_api_1.err(error_1.FunctionRouterError(func));
662
+ if (!ctx || !ctx.solutionV2 || !ctx.envInfoV2) {
663
+ const name = 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"]);
664
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`executeUserTask input stuff: ${name}`));
451
665
  }
452
- else {
453
- if (!ctx || !ctx.solution)
454
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("executeUserTask input stuff"));
455
- if (!ctx.solutionContext)
456
- ctx.solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
457
- if (ctx.solution.executeUserTask)
458
- return await ctx.solution.executeUserTask(func, ctx.solutionContext);
459
- else
460
- return teamsfx_api_1.err(error_1.FunctionRouterError(func));
666
+ if (!ctx.contextV2)
667
+ ctx.contextV2 = createV2Context(newProjectSettings());
668
+ if (ctx.solutionV2.executeUserTask) {
669
+ if (!ctx.localSettings)
670
+ ctx.localSettings = {};
671
+ const res = await ctx.solutionV2.executeUserTask(ctx.contextV2, inputs, func, ctx.localSettings, ctx.envInfoV2, this.tools.tokenProvider);
672
+ return res;
461
673
  }
674
+ else
675
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
462
676
  }
463
677
  return teamsfx_api_1.err(error_1.FunctionRouterError(func));
464
678
  }
@@ -469,27 +683,16 @@ class FxCore {
469
683
  exports.currentStage = teamsfx_api_1.Stage.getQuestions;
470
684
  if (stage === teamsfx_api_1.Stage.create) {
471
685
  delete inputs.projectPath;
472
- return await this._getQuestionsForCreateProject(inputs);
686
+ return await this._getQuestionsForCreateProjectV2(inputs);
473
687
  }
474
688
  else {
475
- if (isV2()) {
476
- const contextV2 = ctx.contextV2
477
- ? ctx.contextV2
478
- : createV2Context(this, newProjectSettings());
479
- const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
480
- const envInfoV2 = ctx.envInfoV2
481
- ? ctx.envInfoV2
482
- : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
483
- inputs.stage = stage;
484
- return await this._getQuestions(contextV2, solutionV2, stage, inputs, envInfoV2);
485
- }
486
- else {
487
- const solutionContext = ctx.solutionContext
488
- ? ctx.solutionContext
489
- : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
490
- const solution = ctx.solution ? ctx.solution : SolutionPluginContainer_1.getAllSolutionPlugins()[0];
491
- return await this._getQuestions(solutionContext, solution, stage, inputs);
492
- }
689
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(newProjectSettings());
690
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
691
+ const envInfoV2 = ctx.envInfoV2
692
+ ? ctx.envInfoV2
693
+ : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
694
+ inputs.stage = stage;
695
+ return await this._getQuestions(contextV2, solutionV2, stage, inputs, envInfoV2);
493
696
  }
494
697
  }
495
698
  async getQuestionsForUserTask(func, inputs, ctx) {
@@ -497,21 +700,12 @@ class FxCore {
497
700
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getQuestionsForUserTask input stuff"));
498
701
  inputs.stage = teamsfx_api_1.Stage.getQuestions;
499
702
  exports.currentStage = teamsfx_api_1.Stage.getQuestions;
500
- if (isV2()) {
501
- const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(this, newProjectSettings());
502
- const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
503
- const envInfoV2 = ctx.envInfoV2
504
- ? ctx.envInfoV2
505
- : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
506
- return await this._getQuestionsForUserTask(contextV2, solutionV2, func, inputs, envInfoV2);
507
- }
508
- else {
509
- const solutionContext = ctx.solutionContext
510
- ? ctx.solutionContext
511
- : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
512
- const solution = ctx.solution ? ctx.solution : SolutionPluginContainer_1.getAllSolutionPlugins()[0];
513
- return await this._getQuestionsForUserTask(solutionContext, solution, func, inputs);
514
- }
703
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(newProjectSettings());
704
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
705
+ const envInfoV2 = ctx.envInfoV2
706
+ ? ctx.envInfoV2
707
+ : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, state: {} };
708
+ return await this._getQuestionsForUserTask(contextV2, solutionV2, func, inputs, envInfoV2);
515
709
  }
516
710
  async getProjectConfig(inputs, ctx) {
517
711
  var _a, _b;
@@ -528,175 +722,59 @@ class FxCore {
528
722
  async grantPermission(inputs, ctx) {
529
723
  exports.currentStage = teamsfx_api_1.Stage.grantPermission;
530
724
  inputs.stage = teamsfx_api_1.Stage.grantPermission;
531
- if (!isV2()) {
532
- return ctx.solution.grantPermission(ctx.solutionContext);
533
- }
534
- else {
535
- const projectPath = inputs.projectPath;
536
- if (!projectPath) {
537
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
538
- }
539
- return ctx.solutionV2.grantPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
725
+ const projectPath = inputs.projectPath;
726
+ if (!projectPath) {
727
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
540
728
  }
729
+ return ctx.solutionV2.grantPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
541
730
  }
542
731
  async checkPermission(inputs, ctx) {
543
732
  exports.currentStage = teamsfx_api_1.Stage.checkPermission;
544
733
  inputs.stage = teamsfx_api_1.Stage.checkPermission;
545
- if (!isV2()) {
546
- return ctx.solution.checkPermission(ctx.solutionContext);
547
- }
548
- else {
549
- const projectPath = inputs.projectPath;
550
- if (!projectPath) {
551
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
552
- }
553
- return ctx.solutionV2.checkPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
734
+ const projectPath = inputs.projectPath;
735
+ if (!projectPath) {
736
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
554
737
  }
738
+ return ctx.solutionV2.checkPermission(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
555
739
  }
556
740
  async listCollaborator(inputs, ctx) {
557
741
  exports.currentStage = teamsfx_api_1.Stage.listCollaborator;
558
742
  inputs.stage = teamsfx_api_1.Stage.listCollaborator;
559
- if (!isV2()) {
560
- return ctx.solution.listCollaborator(ctx.solutionContext);
561
- }
562
- else {
563
- const projectPath = inputs.projectPath;
564
- if (!projectPath) {
565
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
566
- }
567
- return ctx.solutionV2.listCollaborator(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
743
+ const projectPath = inputs.projectPath;
744
+ if (!projectPath) {
745
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
568
746
  }
747
+ return ctx.solutionV2.listCollaborator(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
569
748
  }
570
749
  async listAllCollaborators(inputs, ctx) {
571
750
  exports.currentStage = teamsfx_api_1.Stage.listAllCollaborators;
572
751
  inputs.stage = teamsfx_api_1.Stage.listAllCollaborators;
573
- if (!isV2()) {
574
- return ctx.solution.listAllCollaborators(ctx.solutionContext);
575
- }
576
- else {
577
- const projectPath = inputs.projectPath;
578
- if (!projectPath) {
579
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
580
- }
581
- return ctx.solutionV2.listAllCollaborators(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
752
+ const projectPath = inputs.projectPath;
753
+ if (!projectPath) {
754
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
582
755
  }
756
+ return ctx.solutionV2.listAllCollaborators(ctx.contextV2, Object.assign(Object.assign({}, inputs), { projectPath: projectPath }), ctx.envInfoV2, this.tools.tokenProvider);
583
757
  }
584
758
  async getSelectedEnv(inputs, ctx) {
585
- var _a, _b;
759
+ var _a;
586
760
  if (!tools_1.isMultiEnvEnabled()) {
587
761
  return teamsfx_api_1.err(new error_1.TaskNotSupportError("getSelectedEnv"));
588
762
  }
589
- if (isV2()) {
590
- return teamsfx_api_1.ok((_a = ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2) === null || _a === void 0 ? void 0 : _a.envName);
591
- }
592
- else {
593
- return teamsfx_api_1.ok((_b = ctx === null || ctx === void 0 ? void 0 : ctx.solutionContext) === null || _b === void 0 ? void 0 : _b.envInfo.envName);
594
- }
595
- }
596
- async _getQuestionsForUserTask(ctx, solution, func, inputs, envInfo) {
597
- const namespace = func.namespace;
598
- const array = namespace ? namespace.split("/") : [];
599
- if (namespace && "" !== namespace && array.length > 0) {
600
- let res = teamsfx_api_1.ok(undefined);
601
- if (isV2()) {
602
- const solutionV2 = solution;
603
- if (solutionV2.getQuestionsForUserTask) {
604
- res = await solutionV2.getQuestionsForUserTask(ctx, inputs, func, envInfo, this.tools.tokenProvider);
605
- }
606
- }
607
- else {
608
- const solutionv1 = solution;
609
- if (solutionv1.getQuestionsForUserTask) {
610
- res = await solutionv1.getQuestionsForUserTask(func, ctx);
611
- }
612
- }
613
- if (res.isOk()) {
614
- if (res.value) {
615
- const node = res.value.trim();
616
- return teamsfx_api_1.ok(node);
617
- }
618
- }
619
- return res;
620
- }
621
- return teamsfx_api_1.err(error_1.FunctionRouterError(func));
622
- }
623
- async _getQuestionsForMigrateV1Project(inputs) {
624
- const node = new teamsfx_api_1.QTreeNode({ type: "group" });
625
- const globalSolutions = await SolutionPluginContainer_1.getAllSolutionPlugins();
626
- const solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
627
- for (const v of globalSolutions) {
628
- if (v.getQuestions) {
629
- const res = await v.getQuestions(teamsfx_api_1.Stage.migrateV1, solutionContext);
630
- if (res.isErr())
631
- return res;
632
- if (res.value) {
633
- const solutionNode = res.value;
634
- solutionNode.condition = { equals: v.name };
635
- if (solutionNode.data)
636
- node.addChild(solutionNode);
637
- }
638
- }
639
- }
640
- const defaultAppNameFunc = new teamsfx_api_1.QTreeNode(question_1.DefaultAppNameFunc);
641
- node.addChild(defaultAppNameFunc);
642
- const appNameQuestion = new teamsfx_api_1.QTreeNode(question_1.QuestionV1AppName);
643
- appNameQuestion.condition = {
644
- validFunc: (input) => (!input ? undefined : "App name is auto generated."),
645
- };
646
- defaultAppNameFunc.addChild(appNameQuestion);
647
- return teamsfx_api_1.ok(node.trim());
648
- }
649
- async _getQuestions(ctx, solution, stage, inputs, envInfo) {
650
- if (stage !== teamsfx_api_1.Stage.create) {
651
- let res = teamsfx_api_1.ok(undefined);
652
- if (isV2()) {
653
- const solutionV2 = solution;
654
- if (solutionV2.getQuestions) {
655
- inputs.stage = stage;
656
- res = await solutionV2.getQuestions(ctx, inputs, envInfo, this.tools.tokenProvider);
657
- }
658
- }
659
- else {
660
- res = await solution.getQuestions(stage, ctx);
661
- }
662
- if (res.isErr())
663
- return res;
664
- if (res.value) {
665
- const node = res.value;
666
- if (node.data) {
667
- return teamsfx_api_1.ok(node.trim());
668
- }
669
- }
670
- }
671
- return teamsfx_api_1.ok(undefined);
763
+ return teamsfx_api_1.ok((_a = ctx === null || ctx === void 0 ? void 0 : ctx.envInfoV2) === null || _a === void 0 ? void 0 : _a.envName);
672
764
  }
673
765
  async encrypt(plaintext, inputs, ctx) {
674
766
  if (!ctx)
675
767
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx"));
676
- if (isV2()) {
677
- if (!ctx.contextV2)
678
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
679
- return ctx.contextV2.cryptoProvider.encrypt(plaintext);
680
- }
681
- else {
682
- if (!ctx.solutionContext)
683
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionContext"));
684
- return ctx.solutionContext.cryptoProvider.encrypt(plaintext);
685
- }
768
+ if (!ctx.contextV2)
769
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
770
+ return ctx.contextV2.cryptoProvider.encrypt(plaintext);
686
771
  }
687
772
  async decrypt(ciphertext, inputs, ctx) {
688
773
  if (!ctx)
689
774
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx"));
690
- if (isV2()) {
691
- if (!ctx.contextV2)
692
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
693
- return ctx.contextV2.cryptoProvider.decrypt(ciphertext);
694
- }
695
- else {
696
- if (!ctx.solutionContext)
697
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionContext"));
698
- return ctx.solutionContext.cryptoProvider.decrypt(ciphertext);
699
- }
775
+ if (!ctx.contextV2)
776
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.contextV2"));
777
+ return ctx.contextV2.cryptoProvider.decrypt(ciphertext);
700
778
  }
701
779
  async buildArtifacts(inputs) {
702
780
  throw new error_1.TaskNotSupportError(teamsfx_api_1.Stage.build);
@@ -721,21 +799,11 @@ class FxCore {
721
799
  }
722
800
  inputs.sourceEnvName = createEnvCopyInput.sourceEnvName;
723
801
  inputs.targetEnvName = createEnvCopyInput.targetEnvName;
724
- if (isV2()) {
725
- if (!ctx.solutionV2 || !ctx.contextV2)
726
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionV2, ctx.contextV2"));
727
- if (ctx.solutionV2.createEnv) {
728
- inputs.copy = true;
729
- return await ctx.solutionV2.createEnv(ctx.contextV2, inputs);
730
- }
731
- }
732
- else {
733
- if (!ctx.solution || !ctx.solutionContext)
734
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solution, ctx.solutionContext"));
735
- if (ctx.solution.createEnv) {
736
- ctx.solutionContext.answers.copy = true;
737
- return await ctx.solution.createEnv(ctx.solutionContext);
738
- }
802
+ if (!ctx.solutionV2 || !ctx.contextV2)
803
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionV2, ctx.contextV2"));
804
+ if (ctx.solutionV2.createEnv) {
805
+ inputs.copy = true;
806
+ return await ctx.solutionV2.createEnv(ctx.contextV2, inputs);
739
807
  }
740
808
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
741
809
  }
@@ -759,7 +827,7 @@ class FxCore {
759
827
  catch (e) {
760
828
  return teamsfx_api_1.err(error_1.CopyFileError(e));
761
829
  }
762
- core.tools.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
830
+ exports.TOOLS.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
763
831
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
764
832
  }
765
833
  // deprecated
@@ -779,73 +847,78 @@ class FxCore {
779
847
  return teamsfx_api_1.err(error_1.NonExistEnvNameError(env));
780
848
  }
781
849
  const core = ctx.self;
782
- const solutionContext = await envInfoLoader_1.loadSolutionContext(core.tools, inputs, ctx.projectSettings, env);
850
+ const solutionContext = await envInfoLoader_1.loadSolutionContext(inputs, ctx.projectSettings, env);
783
851
  if (!solutionContext.isErr()) {
784
- if (isV2()) {
785
- //TODO core should not know the details of envInfo
786
- ctx.provisionInputConfig = solutionContext.value.envInfo.config;
787
- ctx.provisionOutputs = solutionContext.value.envInfo.state;
788
- ctx.envName = solutionContext.value.envInfo.envName;
789
- }
790
- else {
791
- ctx.solutionContext = solutionContext.value;
792
- }
852
+ ctx.provisionInputConfig = solutionContext.value.envInfo.config;
853
+ ctx.provisionOutputs = solutionContext.value.envInfo.state;
854
+ ctx.envName = solutionContext.value.envInfo.envName;
793
855
  }
794
856
  this.tools.ui.showMessage("info", `[${env}] is activated.`, false);
795
857
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
796
858
  }
797
- async _getQuestionsForCreateProject(inputs) {
798
- const node = new teamsfx_api_1.QTreeNode(question_1.getCreateNewOrFromSampleQuestion(inputs.platform));
799
- // create new
800
- const createNew = new teamsfx_api_1.QTreeNode({ type: "group" });
801
- node.addChild(createNew);
802
- createNew.condition = { equals: question_1.ScratchOptionYes.id };
803
- const globalSolutions = isV2()
804
- ? await SolutionPluginContainer_1.getAllSolutionPluginsV2()
805
- : await SolutionPluginContainer_1.getAllSolutionPlugins();
806
- const solutionNames = globalSolutions.map((s) => s.name);
807
- const selectSolution = question_1.QuestionSelectSolution;
808
- selectSolution.staticOptions = solutionNames;
809
- const solutionSelectNode = new teamsfx_api_1.QTreeNode(selectSolution);
810
- createNew.addChild(solutionSelectNode);
811
- const context = isV2()
812
- ? createV2Context(this, newProjectSettings())
813
- : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
814
- for (const solutionPlugin of globalSolutions) {
815
- let res = teamsfx_api_1.ok(undefined);
816
- if (isV2()) {
817
- const v2plugin = solutionPlugin;
818
- res = v2plugin.getQuestionsForScaffolding
819
- ? await v2plugin.getQuestionsForScaffolding(context, inputs)
820
- : teamsfx_api_1.ok(undefined);
821
- }
822
- else {
823
- const v1plugin = solutionPlugin;
824
- res = v1plugin.getQuestions
825
- ? await v1plugin.getQuestions(teamsfx_api_1.Stage.create, context)
826
- : teamsfx_api_1.ok(undefined);
827
- }
828
- if (res.isErr())
829
- return res;
830
- if (res.value) {
831
- const solutionNode = res.value;
832
- solutionNode.condition = { equals: solutionPlugin.name };
833
- if (solutionNode.data)
834
- solutionSelectNode.addChild(solutionNode);
835
- }
859
+ async _init(inputs, ctx) {
860
+ if (!ctx) {
861
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
836
862
  }
837
- if (inputs.platform !== teamsfx_api_1.Platform.VSCode) {
838
- createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
863
+ const appName = inputs[question_2.QuestionAppName.name];
864
+ const validateResult = jsonschema.validate(appName, {
865
+ pattern: question_2.ProjectNamePattern,
866
+ });
867
+ if (validateResult.errors && validateResult.errors.length > 0) {
868
+ return teamsfx_api_1.err(error_1.InvalidInputError("invalid app-name", inputs));
839
869
  }
840
- createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionAppName));
841
- // create from sample
842
- const sampleNode = new teamsfx_api_1.QTreeNode(question_1.SampleSelect);
843
- node.addChild(sampleNode);
844
- sampleNode.condition = { equals: question_1.ScratchOptionNo.id };
845
- if (inputs.platform !== teamsfx_api_1.Platform.VSCode) {
846
- sampleNode.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
870
+ const projectSettings = newProjectSettings();
871
+ projectSettings.appName = appName;
872
+ ctx.projectSettings = projectSettings;
873
+ if (!inputs.solution) {
874
+ return teamsfx_api_1.err(error_1.InvalidInputError("solution is undefined", inputs));
847
875
  }
848
- return teamsfx_api_1.ok(node.trim());
876
+ const createEnvResult = await this.createEnvWithName(__1.environmentManager.getDefaultEnvName(), projectSettings, inputs);
877
+ if (createEnvResult.isErr()) {
878
+ return teamsfx_api_1.err(createEnvResult.error);
879
+ }
880
+ await fs.ensureDir(path.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
881
+ await fs.ensureDir(path.join(inputs.projectPath, "templates", `${teamsfx_api_1.AppPackageFolderName}`));
882
+ const basicFolderRes = await createBasicFolderStructure(inputs);
883
+ if (basicFolderRes.isErr()) {
884
+ return teamsfx_api_1.err(basicFolderRes.error);
885
+ }
886
+ const solution = typedi_1.Container.get(inputs.solution);
887
+ projectSettings.solutionSettings.name = inputs.solution;
888
+ const context = createV2Context(projectSettings);
889
+ ctx.contextV2 = context;
890
+ ctx.solutionV3 = solution;
891
+ return await solution.init(context, inputs);
892
+ }
893
+ async init(inputs, ctx) {
894
+ return this._init(inputs, ctx);
895
+ }
896
+ async _addModule(inputs, ctx) {
897
+ if (ctx && ctx.solutionV3 && ctx.contextV2) {
898
+ return await ctx.solutionV3.addModule(ctx.contextV2, {}, inputs);
899
+ }
900
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
901
+ }
902
+ async addModule(inputs, ctx) {
903
+ return this._addModule(inputs, ctx);
904
+ }
905
+ async scaffold(inputs, ctx) {
906
+ return this._scaffold(inputs, ctx);
907
+ }
908
+ async _scaffold(inputs, ctx) {
909
+ if (ctx && ctx.solutionV3 && ctx.contextV2) {
910
+ return await ctx.solutionV3.scaffold(ctx.contextV2, inputs);
911
+ }
912
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
913
+ }
914
+ async addResource(inputs, ctx) {
915
+ return this._addResource(inputs, ctx);
916
+ }
917
+ async _addResource(inputs, ctx) {
918
+ if (ctx && ctx.solutionV3 && ctx.contextV2) {
919
+ return await ctx.solutionV3.addResource(ctx.contextV2, inputs);
920
+ }
921
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
849
922
  }
850
923
  }
851
924
  tslib_1.__decorate([
@@ -860,7 +933,20 @@ tslib_1.__decorate([
860
933
  tslib_1.__metadata("design:type", Function),
861
934
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
862
935
  tslib_1.__metadata("design:returntype", Promise)
863
- ], FxCore.prototype, "createProject", null);
936
+ ], FxCore.prototype, "createProjectV2", null);
937
+ tslib_1.__decorate([
938
+ hooks_1.hooks([
939
+ errorHandler_1.ErrorHandlerMW,
940
+ supportV1ConditionHandler_1.SupportV1ConditionMW(true),
941
+ questionModel_1.QuestionModelMW,
942
+ contextInjector_1.ContextInjectorMW,
943
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
944
+ envInfoWriterV3_1.EnvInfoWriterMW_V3(true),
945
+ ]),
946
+ tslib_1.__metadata("design:type", Function),
947
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
948
+ tslib_1.__metadata("design:returntype", Promise)
949
+ ], FxCore.prototype, "createProjectV3", null);
864
950
  tslib_1.__decorate([
865
951
  hooks_1.hooks([
866
952
  errorHandler_1.ErrorHandlerMW,
@@ -883,7 +969,7 @@ tslib_1.__decorate([
883
969
  projectMigrator_1.ProjectMigratorMW,
884
970
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
885
971
  envInfoLoader_1.EnvInfoLoaderMW(false),
886
- solutionLoader_1.SolutionLoaderMW(),
972
+ solutionLoader_1.SolutionLoaderMW,
887
973
  questionModel_1.QuestionModelMW,
888
974
  contextInjector_1.ContextInjectorMW,
889
975
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -892,7 +978,25 @@ tslib_1.__decorate([
892
978
  tslib_1.__metadata("design:type", Function),
893
979
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
894
980
  tslib_1.__metadata("design:returntype", Promise)
895
- ], FxCore.prototype, "provisionResources", null);
981
+ ], FxCore.prototype, "provisionResourcesV2", null);
982
+ tslib_1.__decorate([
983
+ hooks_1.hooks([
984
+ errorHandler_1.ErrorHandlerMW,
985
+ concurrentLocker_1.ConcurrentLockerMW,
986
+ supportV1ConditionHandler_1.SupportV1ConditionMW(false),
987
+ projectMigrator_1.ProjectMigratorMW,
988
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
989
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
990
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
991
+ questionModel_1.QuestionModelMW,
992
+ contextInjector_1.ContextInjectorMW,
993
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
994
+ envInfoWriterV3_1.EnvInfoWriterMW_V3(),
995
+ ]),
996
+ tslib_1.__metadata("design:type", Function),
997
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
998
+ tslib_1.__metadata("design:returntype", Promise)
999
+ ], FxCore.prototype, "provisionResourcesV3", null);
896
1000
  tslib_1.__decorate([
897
1001
  hooks_1.hooks([
898
1002
  errorHandler_1.ErrorHandlerMW,
@@ -901,7 +1005,7 @@ tslib_1.__decorate([
901
1005
  projectMigrator_1.ProjectMigratorMW,
902
1006
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
903
1007
  envInfoLoader_1.EnvInfoLoaderMW(false),
904
- solutionLoader_1.SolutionLoaderMW(),
1008
+ solutionLoader_1.SolutionLoaderMW,
905
1009
  questionModel_1.QuestionModelMW,
906
1010
  contextInjector_1.ContextInjectorMW,
907
1011
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -910,7 +1014,25 @@ tslib_1.__decorate([
910
1014
  tslib_1.__metadata("design:type", Function),
911
1015
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
912
1016
  tslib_1.__metadata("design:returntype", Promise)
913
- ], FxCore.prototype, "deployArtifacts", null);
1017
+ ], FxCore.prototype, "deployArtifactsV2", null);
1018
+ tslib_1.__decorate([
1019
+ hooks_1.hooks([
1020
+ errorHandler_1.ErrorHandlerMW,
1021
+ concurrentLocker_1.ConcurrentLockerMW,
1022
+ supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1023
+ projectMigrator_1.ProjectMigratorMW,
1024
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1025
+ envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1026
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1027
+ questionModel_1.QuestionModelMW,
1028
+ contextInjector_1.ContextInjectorMW,
1029
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1030
+ envInfoWriterV3_1.EnvInfoWriterMW_V3(),
1031
+ ]),
1032
+ tslib_1.__metadata("design:type", Function),
1033
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1034
+ tslib_1.__metadata("design:returntype", Promise)
1035
+ ], FxCore.prototype, "deployArtifactsV3", null);
914
1036
  tslib_1.__decorate([
915
1037
  hooks_1.hooks([
916
1038
  errorHandler_1.ErrorHandlerMW,
@@ -921,7 +1043,7 @@ tslib_1.__decorate([
921
1043
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
922
1044
  envInfoLoader_1.EnvInfoLoaderMW(true),
923
1045
  localSettingsLoader_1.LocalSettingsLoaderMW,
924
- solutionLoader_1.SolutionLoaderMW(),
1046
+ solutionLoader_1.SolutionLoaderMW,
925
1047
  questionModel_1.QuestionModelMW,
926
1048
  contextInjector_1.ContextInjectorMW,
927
1049
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -931,7 +1053,26 @@ tslib_1.__decorate([
931
1053
  tslib_1.__metadata("design:type", Function),
932
1054
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
933
1055
  tslib_1.__metadata("design:returntype", Promise)
934
- ], FxCore.prototype, "localDebug", null);
1056
+ ], FxCore.prototype, "localDebugV2", null);
1057
+ tslib_1.__decorate([
1058
+ hooks_1.hooks([
1059
+ errorHandler_1.ErrorHandlerMW,
1060
+ concurrentLocker_1.ConcurrentLockerMW,
1061
+ supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1062
+ projectMigrator_1.ProjectMigratorMW,
1063
+ projectUpgrader_1.ProjectUpgraderMW,
1064
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1065
+ localSettingsLoader_1.LocalSettingsLoaderMW,
1066
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1067
+ questionModel_1.QuestionModelMW,
1068
+ contextInjector_1.ContextInjectorMW,
1069
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1070
+ localSettingsWriter_1.LocalSettingsWriterMW,
1071
+ ]),
1072
+ tslib_1.__metadata("design:type", Function),
1073
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1074
+ tslib_1.__metadata("design:returntype", Promise)
1075
+ ], FxCore.prototype, "localDebugV3", null);
935
1076
  tslib_1.__decorate([
936
1077
  hooks_1.hooks([
937
1078
  errorHandler_1.ErrorHandlerMW,
@@ -940,7 +1081,7 @@ tslib_1.__decorate([
940
1081
  projectMigrator_1.ProjectMigratorMW,
941
1082
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
942
1083
  envInfoLoader_1.EnvInfoLoaderMW(false),
943
- solutionLoader_1.SolutionLoaderMW(),
1084
+ solutionLoader_1.SolutionLoaderMW,
944
1085
  questionModel_1.QuestionModelMW,
945
1086
  contextInjector_1.ContextInjectorMW,
946
1087
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -949,7 +1090,25 @@ tslib_1.__decorate([
949
1090
  tslib_1.__metadata("design:type", Function),
950
1091
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
951
1092
  tslib_1.__metadata("design:returntype", Promise)
952
- ], FxCore.prototype, "publishApplication", null);
1093
+ ], FxCore.prototype, "publishApplicationV2", null);
1094
+ tslib_1.__decorate([
1095
+ hooks_1.hooks([
1096
+ errorHandler_1.ErrorHandlerMW,
1097
+ concurrentLocker_1.ConcurrentLockerMW,
1098
+ supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1099
+ projectMigrator_1.ProjectMigratorMW,
1100
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
1101
+ envInfoLoader_1.EnvInfoLoaderMW(false),
1102
+ solutionLoader_1.SolutionLoaderMW,
1103
+ questionModel_1.QuestionModelMW,
1104
+ contextInjector_1.ContextInjectorMW,
1105
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1106
+ envInfoWriter_1.EnvInfoWriterMW(),
1107
+ ]),
1108
+ tslib_1.__metadata("design:type", Function),
1109
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1110
+ tslib_1.__metadata("design:returntype", Promise)
1111
+ ], FxCore.prototype, "publishApplicationV3", null);
953
1112
  tslib_1.__decorate([
954
1113
  hooks_1.hooks([
955
1114
  errorHandler_1.ErrorHandlerMW,
@@ -959,7 +1118,7 @@ tslib_1.__decorate([
959
1118
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
960
1119
  envInfoLoader_1.EnvInfoLoaderMW(false),
961
1120
  localSettingsLoader_1.LocalSettingsLoaderMW,
962
- solutionLoader_1.SolutionLoaderMW(),
1121
+ solutionLoader_1.SolutionLoaderMW,
963
1122
  questionModel_1.QuestionModelMW,
964
1123
  contextInjector_1.ContextInjectorMW,
965
1124
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -976,7 +1135,7 @@ tslib_1.__decorate([
976
1135
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
977
1136
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
978
1137
  envInfoLoader_1.EnvInfoLoaderMW(true),
979
- solutionLoader_1.SolutionLoaderMW(),
1138
+ solutionLoader_1.SolutionLoaderMW,
980
1139
  contextInjector_1.ContextInjectorMW,
981
1140
  envInfoWriter_1.EnvInfoWriterMW(),
982
1141
  ]),
@@ -991,7 +1150,7 @@ tslib_1.__decorate([
991
1150
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
992
1151
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
993
1152
  envInfoLoader_1.EnvInfoLoaderMW(true),
994
- solutionLoader_1.SolutionLoaderMW(),
1153
+ solutionLoader_1.SolutionLoaderMW,
995
1154
  contextInjector_1.ContextInjectorMW,
996
1155
  envInfoWriter_1.EnvInfoWriterMW(),
997
1156
  ]),
@@ -1022,7 +1181,7 @@ tslib_1.__decorate([
1022
1181
  projectMigrator_1.ProjectMigratorMW,
1023
1182
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1024
1183
  envInfoLoader_1.EnvInfoLoaderMW(false),
1025
- solutionLoader_1.SolutionLoaderMW(),
1184
+ solutionLoader_1.SolutionLoaderMW,
1026
1185
  questionModel_1.QuestionModelMW,
1027
1186
  contextInjector_1.ContextInjectorMW,
1028
1187
  ]),
@@ -1038,7 +1197,7 @@ tslib_1.__decorate([
1038
1197
  projectMigrator_1.ProjectMigratorMW,
1039
1198
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1040
1199
  envInfoLoader_1.EnvInfoLoaderMW(false),
1041
- solutionLoader_1.SolutionLoaderMW(),
1200
+ solutionLoader_1.SolutionLoaderMW,
1042
1201
  questionModel_1.QuestionModelMW,
1043
1202
  contextInjector_1.ContextInjectorMW,
1044
1203
  ]),
@@ -1054,7 +1213,7 @@ tslib_1.__decorate([
1054
1213
  projectMigrator_1.ProjectMigratorMW,
1055
1214
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1056
1215
  envInfoLoader_1.EnvInfoLoaderMW(false),
1057
- solutionLoader_1.SolutionLoaderMW(),
1216
+ solutionLoader_1.SolutionLoaderMW,
1058
1217
  questionModel_1.QuestionModelMW,
1059
1218
  contextInjector_1.ContextInjectorMW,
1060
1219
  ]),
@@ -1069,7 +1228,7 @@ tslib_1.__decorate([
1069
1228
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1070
1229
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1071
1230
  envInfoLoader_1.EnvInfoLoaderMW(true),
1072
- solutionLoader_1.SolutionLoaderMW(),
1231
+ solutionLoader_1.SolutionLoaderMW,
1073
1232
  questionModel_1.QuestionModelMW,
1074
1233
  contextInjector_1.ContextInjectorMW,
1075
1234
  ]),
@@ -1121,7 +1280,7 @@ tslib_1.__decorate([
1121
1280
  concurrentLocker_1.ConcurrentLockerMW,
1122
1281
  supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1123
1282
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1124
- solutionLoader_1.SolutionLoaderMW(),
1283
+ solutionLoader_1.SolutionLoaderMW,
1125
1284
  envInfoLoader_1.EnvInfoLoaderMW(true),
1126
1285
  contextInjector_1.ContextInjectorMW,
1127
1286
  ]),
@@ -1136,7 +1295,7 @@ tslib_1.__decorate([
1136
1295
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1137
1296
  projectMigrator_1.ProjectMigratorMW,
1138
1297
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1139
- solutionLoader_1.SolutionLoaderMW(),
1298
+ solutionLoader_1.SolutionLoaderMW,
1140
1299
  contextInjector_1.ContextInjectorMW,
1141
1300
  projectSettingsWriter_1.ProjectSettingsWriterMW,
1142
1301
  ]),
@@ -1144,26 +1303,73 @@ tslib_1.__decorate([
1144
1303
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1145
1304
  tslib_1.__metadata("design:returntype", Promise)
1146
1305
  ], FxCore.prototype, "activateEnv", null);
1306
+ tslib_1.__decorate([
1307
+ hooks_1.hooks([errorHandler_1.ErrorHandlerMW, questionModel_1.QuestionModelMW, contextInjector_1.ContextInjectorMW, projectSettingsWriter_1.ProjectSettingsWriterMW]),
1308
+ tslib_1.__metadata("design:type", Function),
1309
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1310
+ tslib_1.__metadata("design:returntype", Promise)
1311
+ ], FxCore.prototype, "init", null);
1312
+ tslib_1.__decorate([
1313
+ hooks_1.hooks([
1314
+ errorHandler_1.ErrorHandlerMW,
1315
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1316
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1317
+ questionModel_1.QuestionModelMW,
1318
+ contextInjector_1.ContextInjectorMW,
1319
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1320
+ ]),
1321
+ tslib_1.__metadata("design:type", Function),
1322
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1323
+ tslib_1.__metadata("design:returntype", Promise)
1324
+ ], FxCore.prototype, "addModule", null);
1325
+ tslib_1.__decorate([
1326
+ hooks_1.hooks([
1327
+ errorHandler_1.ErrorHandlerMW,
1328
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1329
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1330
+ questionModel_1.QuestionModelMW,
1331
+ contextInjector_1.ContextInjectorMW,
1332
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1333
+ ]),
1334
+ tslib_1.__metadata("design:type", Function),
1335
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1336
+ tslib_1.__metadata("design:returntype", Promise)
1337
+ ], FxCore.prototype, "scaffold", null);
1338
+ tslib_1.__decorate([
1339
+ hooks_1.hooks([
1340
+ errorHandler_1.ErrorHandlerMW,
1341
+ projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1342
+ solutionLoaderV3_1.SolutionLoaderMW_V3,
1343
+ questionModel_1.QuestionModelMW,
1344
+ contextInjector_1.ContextInjectorMW,
1345
+ projectSettingsWriter_1.ProjectSettingsWriterMW,
1346
+ ]),
1347
+ tslib_1.__metadata("design:type", Function),
1348
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
1349
+ tslib_1.__metadata("design:returntype", Promise)
1350
+ ], FxCore.prototype, "addResource", null);
1147
1351
  exports.FxCore = FxCore;
1148
1352
  async function createBasicFolderStructure(inputs) {
1149
1353
  if (!inputs.projectPath) {
1150
1354
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
1151
1355
  }
1152
1356
  try {
1153
- const appName = inputs[question_1.QuestionAppName.name];
1154
- await fs.writeFile(path.join(inputs.projectPath, `package.json`), JSON.stringify({
1155
- name: appName,
1156
- version: "0.0.1",
1157
- description: "",
1158
- author: "",
1159
- scripts: {
1160
- test: 'echo "Error: no test specified" && exit 1',
1161
- },
1162
- devDependencies: {
1163
- "@microsoft/teamsfx-cli": "0.*",
1164
- },
1165
- license: "MIT",
1166
- }, null, 4));
1357
+ const appName = inputs[question_2.QuestionAppName.name];
1358
+ if (inputs.platform !== teamsfx_api_1.Platform.VS) {
1359
+ await fs.writeFile(path.join(inputs.projectPath, `package.json`), JSON.stringify({
1360
+ name: appName,
1361
+ version: "0.0.1",
1362
+ description: "",
1363
+ author: "",
1364
+ scripts: {
1365
+ test: 'echo "Error: no test specified" && exit 1',
1366
+ },
1367
+ devDependencies: {
1368
+ "@microsoft/teamsfx-cli": "0.*",
1369
+ },
1370
+ license: "MIT",
1371
+ }, null, 4));
1372
+ }
1167
1373
  await fs.writeFile(path.join(inputs.projectPath, `.gitignore`), tools_1.isMultiEnvEnabled()
1168
1374
  ? [
1169
1375
  "node_modules",
@@ -1184,23 +1390,23 @@ async function createBasicFolderStructure(inputs) {
1184
1390
  return teamsfx_api_1.ok(null);
1185
1391
  }
1186
1392
  exports.createBasicFolderStructure = createBasicFolderStructure;
1187
- async function downloadSample(fxCore, inputs, ctx) {
1393
+ async function downloadSample(inputs, ctx) {
1188
1394
  let fxError;
1189
- const progress = fxCore.tools.ui.createProgressBar("Fetch sample app", 3);
1395
+ const progress = exports.TOOLS.ui.createProgressBar("Fetch sample app", 3);
1190
1396
  progress.start();
1191
1397
  const telemetryProperties = {
1192
1398
  [telemetry_1.TelemetryProperty.Success]: telemetry_1.TelemetrySuccess.Yes,
1193
1399
  module: "fx-core",
1194
1400
  };
1195
1401
  try {
1196
- let folder = inputs[question_1.QuestionRootFolder.name];
1402
+ let folder = inputs[question_2.QuestionRootFolder.name];
1197
1403
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
1198
1404
  folder = tools_1.getRootDirectory();
1199
1405
  await fs.ensureDir(folder);
1200
1406
  }
1201
- const sampleId = inputs[question_1.CoreQuestionNames.Samples];
1407
+ const sampleId = inputs[question_2.CoreQuestionNames.Samples];
1202
1408
  if (!(sampleId && folder)) {
1203
- throw error_1.InvalidInputError(`invalid answer for '${question_1.CoreQuestionNames.Samples}'`, inputs);
1409
+ throw error_1.InvalidInputError(`invalid answer for '${question_2.CoreQuestionNames.Samples}'`, inputs);
1204
1410
  }
1205
1411
  telemetryProperties[telemetry_1.TelemetryProperty.SampleAppName] = sampleId;
1206
1412
  const samples = __1.sampleProvider.SampleCollection.samples.filter((sample) => sample.id.toLowerCase() === sampleId.toLowerCase());
@@ -1217,12 +1423,15 @@ async function downloadSample(fxCore, inputs, ctx) {
1217
1423
  }
1218
1424
  }
1219
1425
  progress.next(`Downloading from ${url}`);
1220
- const fetchRes = await tools_1.fetchCodeZip(url);
1221
- if (fetchRes === undefined) {
1222
- throw new teamsfx_api_1.SystemError("FetchSampleError", "Fetch sample app error: empty zip file", error_1.CoreSource);
1426
+ const fetchRes = await tools_1.fetchCodeZip(url, sample.id);
1427
+ if (fetchRes.isErr()) {
1428
+ throw fetchRes.error;
1429
+ }
1430
+ else if (!fetchRes.value) {
1431
+ throw error_1.FetchSampleError(sample.id);
1223
1432
  }
1224
1433
  progress.next("Unzipping the sample package");
1225
- await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.data), sampleId, sampleAppPath);
1434
+ await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.value.data), sampleId, sampleAppPath);
1226
1435
  await tools_1.downloadSampleHook(sampleId, sampleAppPath);
1227
1436
  progress.next("Update project settings");
1228
1437
  const loadInputs = Object.assign(Object.assign({}, inputs), { projectPath: sampleAppPath });
@@ -1230,11 +1439,16 @@ async function downloadSample(fxCore, inputs, ctx) {
1230
1439
  if (projectSettingsRes.isOk()) {
1231
1440
  const projectSettings = projectSettingsRes.value;
1232
1441
  projectSettings.projectId = inputs.projectId ? inputs.projectId : uuid.v4();
1442
+ projectSettings.isFromSample = true;
1233
1443
  inputs.projectId = projectSettings.projectId;
1234
1444
  telemetryProperties[telemetry_1.TelemetryProperty.ProjectId] = projectSettings.projectId;
1235
1445
  ctx.projectSettings = projectSettings;
1236
1446
  inputs.projectPath = sampleAppPath;
1237
1447
  }
1448
+ else {
1449
+ telemetryProperties[telemetry_1.TelemetryProperty.ProjectId] =
1450
+ "unknown, failed to set projectId in projectSettings.json";
1451
+ }
1238
1452
  progress.end(true);
1239
1453
  telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, telemetryProperties);
1240
1454
  return teamsfx_api_1.ok(sampleAppPath);
@@ -1260,13 +1474,13 @@ function newProjectSettings() {
1260
1474
  return projectSettings;
1261
1475
  }
1262
1476
  exports.newProjectSettings = newProjectSettings;
1263
- function createV2Context(core, projectSettings) {
1477
+ function createV2Context(projectSettings) {
1264
1478
  const context = {
1265
- userInteraction: core.tools.ui,
1266
- logProvider: core.tools.logProvider,
1267
- telemetryReporter: core.tools.telemetryReporter,
1479
+ userInteraction: exports.TOOLS.ui,
1480
+ logProvider: exports.TOOLS.logProvider,
1481
+ telemetryReporter: exports.TOOLS.telemetryReporter,
1268
1482
  cryptoProvider: new crypto_1.LocalCrypto(projectSettings.projectId),
1269
- permissionRequestProvider: core.tools.permissionRequest,
1483
+ permissionRequestProvider: exports.TOOLS.permissionRequest,
1270
1484
  projectSetting: projectSettings,
1271
1485
  };
1272
1486
  return context;