@microsoft/teamsfx-core 1.1.2-alpha.9f3cd667.0 → 1.1.2

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 (429) 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 +1 -3
  4. package/build/common/constants.d.ts.map +1 -1
  5. package/build/common/constants.js +1 -3
  6. package/build/common/constants.js.map +1 -1
  7. package/build/common/localSettingsProvider.d.ts +3 -3
  8. package/build/common/localSettingsProvider.d.ts.map +1 -1
  9. package/build/common/localSettingsProvider.js +6 -11
  10. package/build/common/localSettingsProvider.js.map +1 -1
  11. package/build/common/samples-config.json +0 -14
  12. package/build/common/tools.d.ts +1 -11
  13. package/build/common/tools.d.ts.map +1 -1
  14. package/build/common/tools.js +10 -23
  15. package/build/common/tools.js.map +1 -1
  16. package/build/core/SolutionPluginContainer.d.ts +1 -2
  17. package/build/core/SolutionPluginContainer.d.ts.map +1 -1
  18. package/build/core/SolutionPluginContainer.js +1 -9
  19. package/build/core/SolutionPluginContainer.js.map +1 -1
  20. package/build/core/environment.d.ts +3 -4
  21. package/build/core/environment.d.ts.map +1 -1
  22. package/build/core/environment.js +7 -37
  23. package/build/core/environment.js.map +1 -1
  24. package/build/core/error.d.ts +1 -2
  25. package/build/core/error.d.ts.map +1 -1
  26. package/build/core/error.js +3 -7
  27. package/build/core/error.js.map +1 -1
  28. package/build/core/index.d.ts +13 -52
  29. package/build/core/index.d.ts.map +1 -1
  30. package/build/core/index.js +201 -580
  31. package/build/core/index.js.map +1 -1
  32. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  33. package/build/core/middleware/concurrentLocker.js +8 -6
  34. package/build/core/middleware/concurrentLocker.js.map +1 -1
  35. package/build/core/middleware/envInfoLoader.d.ts +1 -5
  36. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  37. package/build/core/middleware/envInfoLoader.js +39 -48
  38. package/build/core/middleware/envInfoLoader.js.map +1 -1
  39. package/build/core/middleware/envInfoWriter.js +3 -2
  40. package/build/core/middleware/envInfoWriter.js.map +1 -1
  41. package/build/core/middleware/errorHandler.d.ts.map +1 -1
  42. package/build/core/middleware/errorHandler.js +5 -3
  43. package/build/core/middleware/errorHandler.js.map +1 -1
  44. package/build/core/middleware/localSettingsWriter.d.ts.map +1 -1
  45. package/build/core/middleware/localSettingsWriter.js +2 -1
  46. package/build/core/middleware/localSettingsWriter.js.map +1 -1
  47. package/build/core/middleware/projectMigrator.d.ts.map +1 -1
  48. package/build/core/middleware/projectMigrator.js +51 -21
  49. package/build/core/middleware/projectMigrator.js.map +1 -1
  50. package/build/core/middleware/projectSettingsLoader.js +1 -1
  51. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  52. package/build/core/middleware/projectSettingsWriter.d.ts.map +1 -1
  53. package/build/core/middleware/projectSettingsWriter.js +2 -2
  54. package/build/core/middleware/projectSettingsWriter.js.map +1 -1
  55. package/build/core/middleware/questionModel.d.ts +1 -14
  56. package/build/core/middleware/questionModel.d.ts.map +1 -1
  57. package/build/core/middleware/questionModel.js +14 -335
  58. package/build/core/middleware/questionModel.js.map +1 -1
  59. package/build/core/middleware/solutionLoader.d.ts +2 -3
  60. package/build/core/middleware/solutionLoader.d.ts.map +1 -1
  61. package/build/core/middleware/solutionLoader.js +23 -21
  62. package/build/core/middleware/solutionLoader.js.map +1 -1
  63. package/build/core/question.d.ts +1 -9
  64. package/build/core/question.d.ts.map +1 -1
  65. package/build/core/question.js +3 -113
  66. package/build/core/question.js.map +1 -1
  67. package/build/core/tools.d.ts +1 -2
  68. package/build/core/tools.d.ts.map +1 -1
  69. package/build/core/tools.js +1 -15
  70. package/build/core/tools.js.map +1 -1
  71. package/build/plugins/resource/aad/plugin.d.ts.map +1 -1
  72. package/build/plugins/resource/aad/plugin.js +10 -1
  73. package/build/plugins/resource/aad/plugin.js.map +1 -1
  74. package/build/plugins/resource/apim/managers/apimManager.d.ts.map +1 -1
  75. package/build/plugins/resource/apim/managers/apimManager.js +7 -5
  76. package/build/plugins/resource/apim/managers/apimManager.js.map +1 -1
  77. package/build/plugins/resource/appstudio/appStudio.d.ts +1 -1
  78. package/build/plugins/resource/appstudio/appStudio.d.ts.map +1 -1
  79. package/build/plugins/resource/appstudio/appStudio.js +85 -106
  80. package/build/plugins/resource/appstudio/appStudio.js.map +1 -1
  81. package/build/plugins/resource/appstudio/constants.d.ts +1 -6
  82. package/build/plugins/resource/appstudio/constants.d.ts.map +1 -1
  83. package/build/plugins/resource/appstudio/constants.js +1 -6
  84. package/build/plugins/resource/appstudio/constants.js.map +1 -1
  85. package/build/plugins/resource/appstudio/errors.d.ts +1 -1
  86. package/build/plugins/resource/appstudio/errors.d.ts.map +1 -1
  87. package/build/plugins/resource/appstudio/errors.js +1 -2
  88. package/build/plugins/resource/appstudio/errors.js.map +1 -1
  89. package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
  90. package/build/plugins/resource/appstudio/index.js +2 -10
  91. package/build/plugins/resource/appstudio/index.js.map +1 -1
  92. package/build/plugins/resource/appstudio/plugin.d.ts +3 -2
  93. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  94. package/build/plugins/resource/appstudio/plugin.js +116 -92
  95. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  96. package/build/plugins/resource/bot/index.d.ts.map +1 -1
  97. package/build/plugins/resource/bot/index.js +1 -5
  98. package/build/plugins/resource/bot/index.js.map +1 -1
  99. package/build/plugins/resource/bot/languageStrategy.js +1 -1
  100. package/build/plugins/resource/bot/languageStrategy.js.map +1 -1
  101. package/build/plugins/resource/bot/plugin.d.ts.map +1 -1
  102. package/build/plugins/resource/bot/plugin.js +11 -9
  103. package/build/plugins/resource/bot/plugin.js.map +1 -1
  104. package/build/plugins/resource/frontend/constants.d.ts +7 -1
  105. package/build/plugins/resource/frontend/constants.d.ts.map +1 -1
  106. package/build/plugins/resource/frontend/constants.js +9 -2
  107. package/build/plugins/resource/frontend/constants.js.map +1 -1
  108. package/build/plugins/resource/frontend/ops/deploy.d.ts +1 -2
  109. package/build/plugins/resource/frontend/ops/deploy.d.ts.map +1 -1
  110. package/build/plugins/resource/frontend/ops/deploy.js +2 -2
  111. package/build/plugins/resource/frontend/ops/deploy.js.map +1 -1
  112. package/build/plugins/resource/frontend/plugin.d.ts +0 -2
  113. package/build/plugins/resource/frontend/plugin.d.ts.map +1 -1
  114. package/build/plugins/resource/frontend/plugin.js +16 -28
  115. package/build/plugins/resource/frontend/plugin.js.map +1 -1
  116. package/build/plugins/resource/frontend/utils/environment-utils.d.ts.map +1 -1
  117. package/build/plugins/resource/frontend/utils/environment-utils.js +2 -4
  118. package/build/plugins/resource/frontend/utils/environment-utils.js.map +1 -1
  119. package/build/plugins/resource/frontend/utils.d.ts +1 -6
  120. package/build/plugins/resource/frontend/utils.d.ts.map +1 -1
  121. package/build/plugins/resource/frontend/utils.js +6 -17
  122. package/build/plugins/resource/frontend/utils.js.map +1 -1
  123. package/build/plugins/resource/function/plugin.d.ts.map +1 -1
  124. package/build/plugins/resource/function/plugin.js +9 -7
  125. package/build/plugins/resource/function/plugin.js.map +1 -1
  126. package/build/plugins/resource/function/utils/depsChecker/checker.d.ts +1 -0
  127. package/build/plugins/resource/function/utils/depsChecker/checker.d.ts.map +1 -1
  128. package/build/plugins/resource/function/utils/depsChecker/checker.js +2 -2
  129. package/build/plugins/resource/function/utils/depsChecker/checker.js.map +1 -1
  130. package/build/plugins/resource/function/utils/depsChecker/common.d.ts +2 -1
  131. package/build/plugins/resource/function/utils/depsChecker/common.d.ts.map +1 -1
  132. package/build/plugins/resource/function/utils/depsChecker/common.js +6 -2
  133. package/build/plugins/resource/function/utils/depsChecker/common.js.map +1 -1
  134. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.d.ts +1 -0
  135. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.d.ts.map +1 -1
  136. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.js +23 -1
  137. package/build/plugins/resource/function/utils/depsChecker/funcPluginAdapter.js.map +1 -1
  138. package/build/plugins/resource/identity/index.d.ts.map +1 -1
  139. package/build/plugins/resource/identity/index.js +13 -11
  140. package/build/plugins/resource/identity/index.js.map +1 -1
  141. package/build/plugins/resource/keyvault/plugin.d.ts.map +1 -1
  142. package/build/plugins/resource/keyvault/plugin.js +9 -7
  143. package/build/plugins/resource/keyvault/plugin.js.map +1 -1
  144. package/build/plugins/resource/localdebug/certificate.js +3 -3
  145. package/build/plugins/resource/localdebug/certificate.js.map +1 -1
  146. package/build/plugins/resource/localdebug/index.d.ts +1 -0
  147. package/build/plugins/resource/localdebug/index.d.ts.map +1 -1
  148. package/build/plugins/resource/localdebug/index.js +280 -3
  149. package/build/plugins/resource/localdebug/index.js.map +1 -1
  150. package/build/plugins/{solution/fx-solution/debug/util → resource/localdebug}/launch.d.ts +0 -0
  151. package/build/plugins/resource/localdebug/launch.d.ts.map +1 -0
  152. package/build/plugins/{solution/fx-solution/debug/util → resource/localdebug}/launch.js +1 -1
  153. package/build/plugins/resource/localdebug/launch.js.map +1 -0
  154. package/build/plugins/resource/localdebug/legacyPlugin.d.ts +6 -0
  155. package/build/plugins/resource/localdebug/legacyPlugin.d.ts.map +1 -0
  156. package/build/plugins/resource/localdebug/legacyPlugin.js +208 -0
  157. package/build/plugins/resource/localdebug/legacyPlugin.js.map +1 -0
  158. package/build/plugins/resource/localdebug/settings.d.ts +2 -0
  159. package/build/plugins/resource/localdebug/settings.d.ts.map +1 -0
  160. package/build/plugins/resource/localdebug/settings.js +18 -0
  161. package/build/plugins/resource/localdebug/settings.js.map +1 -0
  162. package/build/plugins/{solution/fx-solution/debug/util → resource/localdebug}/tasks.d.ts +0 -0
  163. package/build/plugins/resource/localdebug/tasks.d.ts.map +1 -0
  164. package/build/plugins/{solution/fx-solution/debug/util → resource/localdebug}/tasks.js +6 -6
  165. package/build/plugins/resource/localdebug/tasks.js.map +1 -0
  166. package/build/plugins/{solution/fx-solution/debug → resource/localdebug}/util/codespace.d.ts +0 -0
  167. package/build/plugins/resource/localdebug/util/codespace.d.ts.map +1 -0
  168. package/build/plugins/{solution/fx-solution/debug → resource/localdebug}/util/codespace.js +0 -0
  169. package/build/plugins/resource/localdebug/util/codespace.js.map +1 -0
  170. package/build/plugins/resource/localdebug/util/error.d.ts.map +1 -1
  171. package/build/plugins/resource/localdebug/util/error.js +1 -1
  172. package/build/plugins/resource/localdebug/util/error.js.map +1 -1
  173. package/build/plugins/{solution/fx-solution/debug → resource/localdebug}/util/ngrok.d.ts +0 -0
  174. package/build/plugins/resource/localdebug/util/ngrok.d.ts.map +1 -0
  175. package/build/plugins/{solution/fx-solution/debug → resource/localdebug}/util/ngrok.js +2 -2
  176. package/build/plugins/resource/localdebug/util/ngrok.js.map +1 -0
  177. package/build/plugins/resource/localdebug/v2/index.d.ts.map +1 -1
  178. package/build/plugins/resource/localdebug/v2/index.js +1 -34
  179. package/build/plugins/resource/localdebug/v2/index.js.map +1 -1
  180. package/build/plugins/resource/simpleauth/plugin.d.ts.map +1 -1
  181. package/build/plugins/resource/simpleauth/plugin.js +9 -7
  182. package/build/plugins/resource/simpleauth/plugin.js.map +1 -1
  183. package/build/plugins/resource/simpleauth/utils/common.d.ts.map +1 -1
  184. package/build/plugins/resource/simpleauth/utils/common.js +1 -3
  185. package/build/plugins/resource/simpleauth/utils/common.js.map +1 -1
  186. package/build/plugins/resource/sql/config.d.ts +1 -0
  187. package/build/plugins/resource/sql/config.d.ts.map +1 -1
  188. package/build/plugins/resource/sql/config.js +1 -0
  189. package/build/plugins/resource/sql/config.js.map +1 -1
  190. package/build/plugins/resource/sql/constants.d.ts +0 -1
  191. package/build/plugins/resource/sql/constants.d.ts.map +1 -1
  192. package/build/plugins/resource/sql/constants.js +0 -1
  193. package/build/plugins/resource/sql/constants.js.map +1 -1
  194. package/build/plugins/resource/sql/errors.d.ts +0 -1
  195. package/build/plugins/resource/sql/errors.d.ts.map +1 -1
  196. package/build/plugins/resource/sql/errors.js +0 -1
  197. package/build/plugins/resource/sql/errors.js.map +1 -1
  198. package/build/plugins/resource/sql/managementClient.d.ts +1 -3
  199. package/build/plugins/resource/sql/managementClient.d.ts.map +1 -1
  200. package/build/plugins/resource/sql/managementClient.js +2 -11
  201. package/build/plugins/resource/sql/managementClient.js.map +1 -1
  202. package/build/plugins/resource/sql/plugin.d.ts +0 -3
  203. package/build/plugins/resource/sql/plugin.d.ts.map +1 -1
  204. package/build/plugins/resource/sql/plugin.js +27 -37
  205. package/build/plugins/resource/sql/plugin.js.map +1 -1
  206. package/build/plugins/resource/sql/sqlClient.d.ts +1 -1
  207. package/build/plugins/resource/sql/sqlClient.d.ts.map +1 -1
  208. package/build/plugins/resource/sql/sqlClient.js +24 -15
  209. package/build/plugins/resource/sql/sqlClient.js.map +1 -1
  210. package/build/plugins/resource/sql/utils/checkInput.js +2 -2
  211. package/build/plugins/resource/sql/utils/checkInput.js.map +1 -1
  212. package/build/plugins/resource/sql/utils/message.d.ts +1 -0
  213. package/build/plugins/resource/sql/utils/message.d.ts.map +1 -1
  214. package/build/plugins/resource/sql/utils/message.js +1 -0
  215. package/build/plugins/resource/sql/utils/message.js.map +1 -1
  216. package/build/plugins/solution/fx-solution/arm.d.ts +5 -15
  217. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  218. package/build/plugins/solution/fx-solution/arm.js +102 -373
  219. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  220. package/build/plugins/solution/fx-solution/commonQuestions.d.ts +2 -13
  221. package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
  222. package/build/plugins/solution/fx-solution/commonQuestions.js +26 -24
  223. package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
  224. package/build/plugins/solution/fx-solution/index.d.ts +0 -1
  225. package/build/plugins/solution/fx-solution/index.d.ts.map +1 -1
  226. package/build/plugins/solution/fx-solution/index.js +0 -1
  227. package/build/plugins/solution/fx-solution/index.js.map +1 -1
  228. package/build/plugins/solution/fx-solution/question.d.ts +2 -2
  229. package/build/plugins/solution/fx-solution/question.d.ts.map +1 -1
  230. package/build/plugins/solution/fx-solution/question.js +32 -2
  231. package/build/plugins/solution/fx-solution/question.js.map +1 -1
  232. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  233. package/build/plugins/solution/fx-solution/solution.js +5 -9
  234. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  235. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.d.ts +2 -2
  236. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.d.ts.map +1 -1
  237. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.js +14 -13
  238. package/build/plugins/solution/fx-solution/utils/depsChecker/bicepChecker.js.map +1 -1
  239. package/build/plugins/solution/fx-solution/utils/progressHelper.d.ts +2 -2
  240. package/build/plugins/solution/fx-solution/utils/progressHelper.d.ts.map +1 -1
  241. package/build/plugins/solution/fx-solution/utils/progressHelper.js +4 -4
  242. package/build/plugins/solution/fx-solution/utils/progressHelper.js.map +1 -1
  243. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -1
  244. package/build/plugins/solution/fx-solution/v2/createEnv.js +1 -1
  245. package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -1
  246. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  247. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +4 -7
  248. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  249. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -1
  250. package/build/plugins/solution/fx-solution/v2/getQuestions.js +25 -67
  251. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -1
  252. package/build/plugins/solution/fx-solution/v2/listAllCollaborators.js.map +1 -1
  253. package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -1
  254. package/build/plugins/solution/fx-solution/v2/provision.js +0 -8
  255. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -1
  256. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -1
  257. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +0 -5
  258. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -1
  259. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts.map +1 -1
  260. package/build/plugins/solution/fx-solution/v2/scaffolding.js +0 -5
  261. package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
  262. package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -1
  263. package/build/plugins/solution/fx-solution/v2/solution.js +1 -2
  264. package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -1
  265. package/build/plugins/solution/index.d.ts +0 -1
  266. package/build/plugins/solution/index.d.ts.map +1 -1
  267. package/build/plugins/solution/index.js +0 -1
  268. package/build/plugins/solution/index.js.map +1 -1
  269. package/package.json +4 -9
  270. package/resource/strings.json +1 -0
  271. package/templates/azure/config.bicep +25 -0
  272. package/templates/azure/main.bicep +20 -0
  273. package/templates/azure/provision/azureSql.bicep +39 -0
  274. package/templates/azure/provision/frontendHosting.bicep +23 -0
  275. package/templates/azure/provision/function.bicep +79 -0
  276. package/templates/azure/provision/simpleAuth.bicep +44 -0
  277. package/templates/azure/provision.bicep +58 -0
  278. package/templates/azure/teamsFx/bot.bicep +34 -0
  279. package/templates/azure/teamsFx/function.bicep +71 -0
  280. package/templates/azure/teamsFx/simpleAuth.bicep +40 -0
  281. package/templates/plugins/resource/aad/bicep/param.template.bicep +6 -0
  282. package/templates/plugins/resource/aad/bicep/variables.template.bicep +13 -0
  283. package/templates/plugins/resource/bot/bicep/botProvision.template.bicep +1 -1
  284. package/templates/plugins/resource/keyvault/bicep/provision.template.bicep +0 -1
  285. package/templates/plugins/resource/simpleauth/version.txt +1 -2
  286. package/build/common/local/localEnvManager.d.ts +0 -17
  287. package/build/common/local/localEnvManager.d.ts.map +0 -1
  288. package/build/common/local/localEnvManager.js +0 -72
  289. package/build/common/local/localEnvManager.js.map +0 -1
  290. package/build/core/middleware/envInfoLoaderV3.d.ts +0 -3
  291. package/build/core/middleware/envInfoLoaderV3.d.ts.map +0 -1
  292. package/build/core/middleware/envInfoLoaderV3.js +0 -64
  293. package/build/core/middleware/envInfoLoaderV3.js.map +0 -1
  294. package/build/core/middleware/envInfoWriterV3.d.ts +0 -6
  295. package/build/core/middleware/envInfoWriterV3.d.ts.map +0 -1
  296. package/build/core/middleware/envInfoWriterV3.js +0 -63
  297. package/build/core/middleware/envInfoWriterV3.js.map +0 -1
  298. package/build/core/middleware/projectSettingsLoaderV3.d.ts +0 -4
  299. package/build/core/middleware/projectSettingsLoaderV3.d.ts.map +0 -1
  300. package/build/core/middleware/projectSettingsLoaderV3.js +0 -49
  301. package/build/core/middleware/projectSettingsLoaderV3.js.map +0 -1
  302. package/build/core/middleware/solutionLoaderV3.d.ts +0 -4
  303. package/build/core/middleware/solutionLoaderV3.d.ts.map +0 -1
  304. package/build/core/middleware/solutionLoaderV3.js +0 -19
  305. package/build/core/middleware/solutionLoaderV3.js.map +0 -1
  306. package/build/plugins/resource/frontend/env.d.ts +0 -21
  307. package/build/plugins/resource/frontend/env.d.ts.map +0 -1
  308. package/build/plugins/resource/frontend/env.js +0 -82
  309. package/build/plugins/resource/frontend/env.js.map +0 -1
  310. package/build/plugins/solution/fx-solution/debug/constants.d.ts +0 -9
  311. package/build/plugins/solution/fx-solution/debug/constants.d.ts.map +0 -1
  312. package/build/plugins/solution/fx-solution/debug/constants.js +0 -16
  313. package/build/plugins/solution/fx-solution/debug/constants.js.map +0 -1
  314. package/build/plugins/solution/fx-solution/debug/error.d.ts +0 -7
  315. package/build/plugins/solution/fx-solution/debug/error.d.ts.map +0 -1
  316. package/build/plugins/solution/fx-solution/debug/error.js +0 -28
  317. package/build/plugins/solution/fx-solution/debug/error.js.map +0 -1
  318. package/build/plugins/solution/fx-solution/debug/provisionLocal.d.ts +0 -3
  319. package/build/plugins/solution/fx-solution/debug/provisionLocal.d.ts.map +0 -1
  320. package/build/plugins/solution/fx-solution/debug/provisionLocal.js +0 -107
  321. package/build/plugins/solution/fx-solution/debug/provisionLocal.js.map +0 -1
  322. package/build/plugins/solution/fx-solution/debug/scaffolding.d.ts +0 -3
  323. package/build/plugins/solution/fx-solution/debug/scaffolding.d.ts.map +0 -1
  324. package/build/plugins/solution/fx-solution/debug/scaffolding.js +0 -153
  325. package/build/plugins/solution/fx-solution/debug/scaffolding.js.map +0 -1
  326. package/build/plugins/solution/fx-solution/debug/util/codespace.d.ts.map +0 -1
  327. package/build/plugins/solution/fx-solution/debug/util/codespace.js.map +0 -1
  328. package/build/plugins/solution/fx-solution/debug/util/contextHelper.d.ts +0 -10
  329. package/build/plugins/solution/fx-solution/debug/util/contextHelper.d.ts.map +0 -1
  330. package/build/plugins/solution/fx-solution/debug/util/contextHelper.js +0 -34
  331. package/build/plugins/solution/fx-solution/debug/util/contextHelper.js.map +0 -1
  332. package/build/plugins/solution/fx-solution/debug/util/launch.d.ts.map +0 -1
  333. package/build/plugins/solution/fx-solution/debug/util/launch.js.map +0 -1
  334. package/build/plugins/solution/fx-solution/debug/util/ngrok.d.ts.map +0 -1
  335. package/build/plugins/solution/fx-solution/debug/util/ngrok.js.map +0 -1
  336. package/build/plugins/solution/fx-solution/debug/util/settings.d.ts +0 -2
  337. package/build/plugins/solution/fx-solution/debug/util/settings.d.ts.map +0 -1
  338. package/build/plugins/solution/fx-solution/debug/util/settings.js +0 -22
  339. package/build/plugins/solution/fx-solution/debug/util/settings.js.map +0 -1
  340. package/build/plugins/solution/fx-solution/debug/util/tasks.d.ts.map +0 -1
  341. package/build/plugins/solution/fx-solution/debug/util/tasks.js.map +0 -1
  342. package/build/plugins/solution/fx-solution/debug/util/telemetry.d.ts +0 -27
  343. package/build/plugins/solution/fx-solution/debug/util/telemetry.d.ts.map +0 -1
  344. package/build/plugins/solution/fx-solution/debug/util/telemetry.js +0 -81
  345. package/build/plugins/solution/fx-solution/debug/util/telemetry.js.map +0 -1
  346. package/build/plugins/solution/fx-solution/v2/constants.d.ts +0 -2
  347. package/build/plugins/solution/fx-solution/v2/constants.d.ts.map +0 -1
  348. package/build/plugins/solution/fx-solution/v2/constants.js +0 -7
  349. package/build/plugins/solution/fx-solution/v2/constants.js.map +0 -1
  350. package/build/plugins/solution/fx-solution/v3/addModule.d.ts +0 -6
  351. package/build/plugins/solution/fx-solution/v3/addModule.d.ts.map +0 -1
  352. package/build/plugins/solution/fx-solution/v3/addModule.js +0 -35
  353. package/build/plugins/solution/fx-solution/v3/addModule.js.map +0 -1
  354. package/build/plugins/solution/fx-solution/v3/addResource.d.ts +0 -37
  355. package/build/plugins/solution/fx-solution/v3/addResource.d.ts.map +0 -1
  356. package/build/plugins/solution/fx-solution/v3/addResource.js +0 -260
  357. package/build/plugins/solution/fx-solution/v3/addResource.js.map +0 -1
  358. package/build/plugins/solution/fx-solution/v3/constants.d.ts +0 -20
  359. package/build/plugins/solution/fx-solution/v3/constants.d.ts.map +0 -1
  360. package/build/plugins/solution/fx-solution/v3/constants.js +0 -25
  361. package/build/plugins/solution/fx-solution/v3/constants.js.map +0 -1
  362. package/build/plugins/solution/fx-solution/v3/deploy.d.ts +0 -6
  363. package/build/plugins/solution/fx-solution/v3/deploy.d.ts.map +0 -1
  364. package/build/plugins/solution/fx-solution/v3/deploy.js +0 -78
  365. package/build/plugins/solution/fx-solution/v3/deploy.js.map +0 -1
  366. package/build/plugins/solution/fx-solution/v3/error.d.ts +0 -11
  367. package/build/plugins/solution/fx-solution/v3/error.d.ts.map +0 -1
  368. package/build/plugins/solution/fx-solution/v3/error.js +0 -23
  369. package/build/plugins/solution/fx-solution/v3/error.js.map +0 -1
  370. package/build/plugins/solution/fx-solution/v3/init.d.ts +0 -4
  371. package/build/plugins/solution/fx-solution/v3/init.d.ts.map +0 -1
  372. package/build/plugins/solution/fx-solution/v3/init.js +0 -35
  373. package/build/plugins/solution/fx-solution/v3/init.js.map +0 -1
  374. package/build/plugins/solution/fx-solution/v3/provision.d.ts +0 -4
  375. package/build/plugins/solution/fx-solution/v3/provision.d.ts.map +0 -1
  376. package/build/plugins/solution/fx-solution/v3/provision.js +0 -124
  377. package/build/plugins/solution/fx-solution/v3/provision.js.map +0 -1
  378. package/build/plugins/solution/fx-solution/v3/provisionLocal.d.ts +0 -4
  379. package/build/plugins/solution/fx-solution/v3/provisionLocal.d.ts.map +0 -1
  380. package/build/plugins/solution/fx-solution/v3/provisionLocal.js +0 -13
  381. package/build/plugins/solution/fx-solution/v3/provisionLocal.js.map +0 -1
  382. package/build/plugins/solution/fx-solution/v3/publish.d.ts +0 -4
  383. package/build/plugins/solution/fx-solution/v3/publish.d.ts.map +0 -1
  384. package/build/plugins/solution/fx-solution/v3/publish.js +0 -15
  385. package/build/plugins/solution/fx-solution/v3/publish.js.map +0 -1
  386. package/build/plugins/solution/fx-solution/v3/questions.d.ts +0 -16
  387. package/build/plugins/solution/fx-solution/v3/questions.d.ts.map +0 -1
  388. package/build/plugins/solution/fx-solution/v3/questions.js +0 -86
  389. package/build/plugins/solution/fx-solution/v3/questions.js.map +0 -1
  390. package/build/plugins/solution/fx-solution/v3/scaffold.d.ts +0 -27
  391. package/build/plugins/solution/fx-solution/v3/scaffold.d.ts.map +0 -1
  392. package/build/plugins/solution/fx-solution/v3/scaffold.js +0 -241
  393. package/build/plugins/solution/fx-solution/v3/scaffold.js.map +0 -1
  394. package/build/plugins/solution/fx-solution/v3/solution.d.ts +0 -32
  395. package/build/plugins/solution/fx-solution/v3/solution.d.ts.map +0 -1
  396. package/build/plugins/solution/fx-solution/v3/solution.js +0 -45
  397. package/build/plugins/solution/fx-solution/v3/solution.js.map +0 -1
  398. package/build/plugins/solution/fx-solution/v3/userTask.d.ts +0 -4
  399. package/build/plugins/solution/fx-solution/v3/userTask.d.ts.map +0 -1
  400. package/build/plugins/solution/fx-solution/v3/userTask.js +0 -15
  401. package/build/plugins/solution/fx-solution/v3/userTask.js.map +0 -1
  402. package/build/plugins/solution/fx-solution/v3/utils.d.ts +0 -3
  403. package/build/plugins/solution/fx-solution/v3/utils.d.ts.map +0 -1
  404. package/build/plugins/solution/fx-solution/v3/utils.js +0 -16
  405. package/build/plugins/solution/fx-solution/v3/utils.js.map +0 -1
  406. package/build/plugins/solution/spfx-solution/constants.d.ts +0 -2
  407. package/build/plugins/solution/spfx-solution/constants.d.ts.map +0 -1
  408. package/build/plugins/solution/spfx-solution/constants.js +0 -7
  409. package/build/plugins/solution/spfx-solution/constants.js.map +0 -1
  410. package/build/plugins/solution/spfx-solution/index.d.ts +0 -2
  411. package/build/plugins/solution/spfx-solution/index.d.ts.map +0 -1
  412. package/build/plugins/solution/spfx-solution/index.js +0 -5
  413. package/build/plugins/solution/spfx-solution/index.js.map +0 -1
  414. package/build/plugins/solution/spfx-solution/init.d.ts +0 -3
  415. package/build/plugins/solution/spfx-solution/init.d.ts.map +0 -1
  416. package/build/plugins/solution/spfx-solution/init.js +0 -20
  417. package/build/plugins/solution/spfx-solution/init.js.map +0 -1
  418. package/build/plugins/solution/spfx-solution/questions.d.ts +0 -6
  419. package/build/plugins/solution/spfx-solution/questions.d.ts.map +0 -1
  420. package/build/plugins/solution/spfx-solution/questions.js +0 -36
  421. package/build/plugins/solution/spfx-solution/questions.js.map +0 -1
  422. package/build/plugins/solution/spfx-solution/scaffolding.d.ts +0 -17
  423. package/build/plugins/solution/spfx-solution/scaffolding.d.ts.map +0 -1
  424. package/build/plugins/solution/spfx-solution/scaffolding.js +0 -29
  425. package/build/plugins/solution/spfx-solution/scaffolding.js.map +0 -1
  426. package/build/plugins/solution/spfx-solution/solution.d.ts +0 -23
  427. package/build/plugins/solution/spfx-solution/solution.d.ts.map +0 -1
  428. package/build/plugins/solution/spfx-solution/solution.js +0 -29
  429. package/build/plugins/solution/spfx-solution/solution.js.map +0 -1
@@ -2,16 +2,14 @@
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.setTools = exports.TOOLS = exports.currentStage = exports.telemetryReporter = exports.Logger = exports.isVsCallingCli = exports.isV2 = exports.isV3 = void 0;
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;
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");
13
12
  const path = tslib_1.__importStar(require("path"));
14
- const typedi_1 = require("typedi");
15
13
  const uuid = tslib_1.__importStar(require("uuid"));
16
14
  const __1 = require("..");
17
15
  const constants_1 = require("../common/constants");
@@ -20,17 +18,13 @@ const localSettingsProvider_1 = require("../common/localSettingsProvider");
20
18
  const telemetry_1 = require("../common/telemetry");
21
19
  const tools_1 = require("../common/tools");
22
20
  const plugins_1 = require("../plugins");
23
- const question_1 = require("../plugins/solution/fx-solution/question");
24
21
  const ResourcePluginContainer_1 = require("../plugins/solution/fx-solution/ResourcePluginContainer");
25
- const constants_2 = require("../plugins/solution/fx-solution/v3/constants");
26
22
  const callback_1 = require("./callback");
27
- const crypto_1 = require("./crypto");
28
23
  const error_1 = require("./error");
29
24
  const concurrentLocker_1 = require("./middleware/concurrentLocker");
30
25
  const contextInjector_1 = require("./middleware/contextInjector");
31
26
  const envInfoLoader_1 = require("./middleware/envInfoLoader");
32
27
  const envInfoWriter_1 = require("./middleware/envInfoWriter");
33
- const envInfoWriterV3_1 = require("./middleware/envInfoWriterV3");
34
28
  const errorHandler_1 = require("./middleware/errorHandler");
35
29
  const localSettingsLoader_1 = require("./middleware/localSettingsLoader");
36
30
  const localSettingsWriter_1 = require("./middleware/localSettingsWriter");
@@ -41,13 +35,12 @@ const projectSettingsWriter_1 = require("./middleware/projectSettingsWriter");
41
35
  const projectUpgrader_1 = require("./middleware/projectUpgrader");
42
36
  const questionModel_1 = require("./middleware/questionModel");
43
37
  const solutionLoader_1 = require("./middleware/solutionLoader");
44
- const question_2 = require("./question");
38
+ const question_1 = require("./question");
45
39
  const SolutionPluginContainer_1 = require("./SolutionPluginContainer");
46
40
  const tools_2 = require("./tools");
41
+ const crypto_1 = require("./crypto");
47
42
  const supportV1ConditionHandler_1 = require("./middleware/supportV1ConditionHandler");
48
- const projectSettingsLoaderV3_1 = require("./middleware/projectSettingsLoaderV3");
49
- const solutionLoaderV3_1 = require("./middleware/solutionLoaderV3");
50
- const envInfoLoaderV3_1 = require("./middleware/envInfoLoaderV3");
43
+ const lodash_1 = require("lodash");
51
44
  // TODO: For package.json,
52
45
  // use require instead of import because of core building/packaging method.
53
46
  // Using import will cause the build folder structure to change.
@@ -61,10 +54,6 @@ function featureFlagEnabled(flagName) {
61
54
  return false;
62
55
  }
63
56
  }
64
- function isV3() {
65
- return featureFlagEnabled(constants_1.FeatureFlagName.APIV3);
66
- }
67
- exports.isV3 = isV3;
68
57
  // API V2 feature flag
69
58
  function isV2() {
70
59
  return tools_1.isMultiEnvEnabled();
@@ -75,27 +64,8 @@ function isVsCallingCli() {
75
64
  return featureFlagEnabled(constants_1.FeatureFlagName.VSCallingCLI);
76
65
  }
77
66
  exports.isVsCallingCli = isVsCallingCli;
78
- function setTools(tools) {
79
- exports.TOOLS = tools;
80
- }
81
- exports.setTools = setTools;
82
67
  class FxCore {
83
68
  constructor(tools) {
84
- //V1,V2 questions
85
- this._getQuestionsForCreateProjectV2 = questionModel_1.getQuestionsForCreateProjectV2;
86
- this._getQuestionsForCreateProjectV3 = questionModel_1.getQuestionsForCreateProjectV3;
87
- this._getQuestionsForUserTask = questionModel_1.getQuestionsForUserTaskV2;
88
- this._getQuestions = questionModel_1.getQuestionsV2;
89
- this._getQuestionsForMigrateV1Project = questionModel_1.getQuestionsForMigrateV1Project;
90
- //v3 questions
91
- this._getQuestionsForScaffold = questionModel_1.getQuestionsForScaffold;
92
- this._getQuestionsForAddModule = questionModel_1.getQuestionsForAddModule;
93
- this._getQuestionsForAddResource = questionModel_1.getQuestionsForAddResource;
94
- this._getQuestionsForProvision = questionModel_1.getQuestionsForProvision;
95
- this._getQuestionsForDeploy = questionModel_1.getQuestionsForDeploy;
96
- this._getQuestionsForLocalProvision = questionModel_1.getQuestionsForLocalProvision;
97
- this._getQuestionsForPublish = questionModel_1.getQuestionsForPublish;
98
- this._getQuestionsForInit = questionModel_1.getQuestionsForInit;
99
69
  this.tools = tools;
100
70
  exports.TOOLS = tools;
101
71
  exports.Logger = tools.logProvider;
@@ -108,37 +78,24 @@ class FxCore {
108
78
  on(event, callback) {
109
79
  return callback_1.CallbackRegistry.set(event, callback);
110
80
  }
111
- async createProject(inputs) {
112
- if (isV3()) {
113
- return this.createProjectV3(inputs);
114
- }
115
- else {
116
- return this.createProjectV2(inputs);
117
- }
118
- }
119
- async createProjectV2(inputs, ctx) {
81
+ async createProject(inputs, ctx) {
120
82
  if (!ctx) {
121
83
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
122
84
  }
123
85
  exports.currentStage = teamsfx_api_1.Stage.create;
124
86
  inputs.stage = teamsfx_api_1.Stage.create;
125
- let folder = inputs[question_2.QuestionRootFolder.name];
87
+ let folder = inputs[question_1.QuestionRootFolder.name];
126
88
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
127
89
  folder = tools_1.getRootDirectory();
128
- try {
129
- await fs.ensureDir(folder);
130
- }
131
- catch (e) {
132
- throw error_1.ProjectFolderInvalidError(folder);
133
- }
90
+ await fs.ensureDir(folder);
134
91
  }
135
- const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
92
+ const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
136
93
  let projectPath;
137
94
  let globalStateDescription = "openReadme";
138
95
  const multiEnv = tools_1.isMultiEnvEnabled();
139
- if (scratch === question_2.ScratchOptionNo.id) {
96
+ if (scratch === question_1.ScratchOptionNo.id) {
140
97
  // create from sample
141
- const downloadRes = await downloadSample(inputs, ctx);
98
+ const downloadRes = await downloadSample(this, inputs, ctx);
142
99
  if (downloadRes.isErr()) {
143
100
  return teamsfx_api_1.err(downloadRes.error);
144
101
  }
@@ -147,11 +104,11 @@ class FxCore {
147
104
  }
148
105
  else {
149
106
  // create from new
150
- const appName = inputs[question_2.QuestionAppName.name];
107
+ const appName = inputs[question_1.QuestionAppName.name];
151
108
  if (undefined === appName)
152
109
  return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
153
110
  const validateResult = jsonschema.validate(appName, {
154
- pattern: question_2.ProjectNamePattern,
111
+ pattern: question_1.ProjectNamePattern,
155
112
  });
156
113
  if (validateResult.errors && validateResult.errors.length > 0) {
157
114
  return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
@@ -187,13 +144,13 @@ class FxCore {
187
144
  }
188
145
  }
189
146
  if (isV2()) {
190
- const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_2.CoreQuestionNames.Solution]);
147
+ const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_1.CoreQuestionNames.Solution]);
191
148
  if (!solution) {
192
149
  return teamsfx_api_1.err(new error_1.LoadSolutionError());
193
150
  }
194
151
  ctx.solutionV2 = solution;
195
152
  projectSettings.solutionSettings.name = solution.name;
196
- const contextV2 = createV2Context(projectSettings);
153
+ const contextV2 = createV2Context(this, projectSettings);
197
154
  ctx.contextV2 = contextV2;
198
155
  const scaffoldSourceCodeRes = await solution.scaffoldSourceCode(contextV2, inputs);
199
156
  if (scaffoldSourceCodeRes.isErr()) {
@@ -228,7 +185,7 @@ class FxCore {
228
185
  }
229
186
  }
230
187
  else {
231
- const solution = await SolutionPluginContainer_1.getSolutionPluginByName(inputs[question_2.CoreQuestionNames.Solution]);
188
+ const solution = await SolutionPluginContainer_1.getSolutionPluginByName(inputs[question_1.CoreQuestionNames.Solution]);
232
189
  if (!solution) {
233
190
  return teamsfx_api_1.err(new error_1.LoadSolutionError());
234
191
  }
@@ -260,196 +217,16 @@ class FxCore {
260
217
  }
261
218
  return teamsfx_api_1.ok(projectPath);
262
219
  }
263
- async createProjectV3(inputs, ctx) {
264
- if (!ctx) {
265
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
266
- }
267
- exports.currentStage = teamsfx_api_1.Stage.create;
268
- inputs.stage = teamsfx_api_1.Stage.create;
269
- let folder = inputs[question_2.QuestionRootFolder.name];
270
- if (inputs.platform === teamsfx_api_1.Platform.VSCode || inputs.platform === teamsfx_api_1.Platform.VS) {
271
- folder = tools_1.getRootDirectory();
272
- try {
273
- await fs.ensureDir(folder);
274
- }
275
- catch (e) {
276
- throw error_1.ProjectFolderInvalidError(folder);
277
- }
278
- }
279
- const scratch = inputs[question_2.CoreQuestionNames.CreateFromScratch];
280
- let projectPath;
281
- let globalStateDescription = "openReadme";
282
- if (scratch === question_2.ScratchOptionNo.id) {
283
- // create from sample
284
- const downloadRes = await downloadSample(inputs, ctx);
285
- if (downloadRes.isErr()) {
286
- return teamsfx_api_1.err(downloadRes.error);
287
- }
288
- projectPath = downloadRes.value;
289
- globalStateDescription = "openSampleReadme";
290
- }
291
- else {
292
- // create from new
293
- const appName = inputs[question_2.QuestionAppName.name];
294
- if (undefined === appName)
295
- return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
296
- const validateResult = jsonschema.validate(appName, {
297
- pattern: question_2.ProjectNamePattern,
298
- });
299
- if (validateResult.errors && validateResult.errors.length > 0) {
300
- return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
301
- }
302
- projectPath = path.join(folder, appName);
303
- inputs.projectPath = projectPath;
304
- const folderExist = await fs.pathExists(projectPath);
305
- if (folderExist) {
306
- return teamsfx_api_1.err(error_1.ProjectFolderExistError(projectPath));
307
- }
308
- await fs.ensureDir(projectPath);
309
- await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
310
- let capabilities = inputs[question_2.CoreQuestionNames.Capabilities];
311
- let projectType = "";
312
- if (capabilities.includes(question_2.TabSPFxItem.id))
313
- projectType = "spfx";
314
- else if (capabilities.includes(question_2.TabOptionItem.id) && capabilities.length === 1)
315
- projectType = "tab";
316
- else if ((capabilities.includes(question_2.BotOptionItem.id) ||
317
- capabilities.includes(question_1.MessageExtensionItem.id)) &&
318
- !capabilities.includes(question_2.TabOptionItem.id))
319
- projectType = "bot";
320
- else if ((capabilities.includes(question_2.BotOptionItem.id) ||
321
- capabilities.includes(question_1.MessageExtensionItem.id)) &&
322
- capabilities.includes(question_2.TabOptionItem.id))
323
- projectType = "tab+bot";
324
- const programmingLanguage = inputs[question_2.CoreQuestionNames.ProgrammingLanguage];
325
- // const solution = capabilities.includes(TabSPFxItem.id)
326
- // ? BuiltInSolutionNames.spfx
327
- // : BuiltInSolutionNames.azure;
328
- // init
329
- const initInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath });
330
- const initRes = await this._init(initInputs, ctx);
331
- if (initRes.isErr()) {
332
- return teamsfx_api_1.err(initRes.error);
333
- }
334
- // addModule, scaffold and addResource
335
- if (inputs.platform === teamsfx_api_1.Platform.VS) {
336
- // addModule
337
- const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities });
338
- const addModuleRes = await this._addModule(addModuleInputs, ctx);
339
- if (addModuleRes.isErr()) {
340
- return teamsfx_api_1.err(addModuleRes.error);
341
- }
342
- // addResource
343
- const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", resource: constants_2.BuiltInResourcePluginNames.webApp });
344
- const addResourceRes = await this._addResource(addResourceInputs, ctx);
345
- if (addResourceRes.isErr()) {
346
- return teamsfx_api_1.err(addResourceRes.error);
347
- }
348
- // scaffold
349
- let templateName = "";
350
- if (projectType === "tab")
351
- templateName = "BlazorTab";
352
- else if (projectType === "bot")
353
- templateName = "BlazorBot";
354
- else if (projectType === "tabbot")
355
- templateName = "BlazorTabBot";
356
- const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", template: {
357
- id: `${constants_2.BuiltInScaffoldPluginNames.blazor}/${templateName}`,
358
- label: `${constants_2.BuiltInScaffoldPluginNames.blazor}/${templateName}`,
359
- data: {
360
- pluginName: constants_2.BuiltInScaffoldPluginNames.blazor,
361
- templateName: templateName,
362
- },
363
- } });
364
- const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
365
- if (scaffoldRes.isErr()) {
366
- return teamsfx_api_1.err(scaffoldRes.error);
367
- }
368
- }
369
- else {
370
- if (capabilities.includes(question_2.TabOptionItem.id) || capabilities.includes(question_2.TabSPFxItem.id)) {
371
- const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities.includes(question_2.TabOptionItem.id)
372
- ? [question_2.TabOptionItem.id]
373
- : [question_2.TabSPFxItem.id] });
374
- const addModuleRes = await this._addModule(addModuleInputs, ctx);
375
- if (addModuleRes.isErr()) {
376
- return teamsfx_api_1.err(addModuleRes.error);
377
- }
378
- // addResource
379
- const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", resource: capabilities.includes(question_2.TabOptionItem.id)
380
- ? constants_2.BuiltInResourcePluginNames.storage
381
- : constants_2.BuiltInResourcePluginNames.spfx });
382
- const addResourceRes = await this._addResource(addResourceInputs, ctx);
383
- if (addResourceRes.isErr()) {
384
- return teamsfx_api_1.err(addResourceRes.error);
385
- }
386
- // scaffold
387
- const pluginName = capabilities.includes(question_2.TabOptionItem.id)
388
- ? constants_2.BuiltInScaffoldPluginNames.tab
389
- : constants_2.BuiltInScaffoldPluginNames.spfx;
390
- const templateName = capabilities.includes(question_2.TabOptionItem.id)
391
- ? programmingLanguage === "javascript"
392
- ? "ReactTab_JS"
393
- : "ReactTab_TS"
394
- : "SPFxTab";
395
- const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "0", template: {
396
- id: `${pluginName}/${templateName}`,
397
- label: `${pluginName}/${templateName}`,
398
- data: {
399
- pluginName: pluginName,
400
- templateName: templateName, //TODO
401
- },
402
- } });
403
- const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
404
- if (scaffoldRes.isErr()) {
405
- return teamsfx_api_1.err(scaffoldRes.error);
406
- }
407
- }
408
- capabilities = capabilities.filter((c) => c !== question_2.TabOptionItem.id && c !== question_2.TabSPFxItem.id);
409
- if (capabilities.length > 0) {
410
- const addModuleInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, capabilities: capabilities });
411
- const addModuleRes = await this._addModule(addModuleInputs, ctx);
412
- if (addModuleRes.isErr()) {
413
- return teamsfx_api_1.err(addModuleRes.error);
414
- }
415
- // addResource
416
- const addResourceInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "1", resource: constants_2.BuiltInResourcePluginNames.bot });
417
- const addResourceRes = await this._addResource(addResourceInputs, ctx);
418
- if (addResourceRes.isErr()) {
419
- return teamsfx_api_1.err(addResourceRes.error);
420
- }
421
- // scaffold
422
- const templateName = programmingLanguage === "javascript" ? "NodejsBot_JS" : "NodejsBot_TS";
423
- const scaffoldInputs = Object.assign(Object.assign({}, inputs), { projectPath: projectPath, module: "1", resource: constants_2.BuiltInScaffoldPluginNames.bot, template: {
424
- id: `${constants_2.BuiltInScaffoldPluginNames.bot}/${templateName}`,
425
- label: `${constants_2.BuiltInScaffoldPluginNames.bot}/${templateName}`,
426
- data: {
427
- pluginName: constants_2.BuiltInScaffoldPluginNames.bot,
428
- templateName: templateName, //TODO
429
- },
430
- } });
431
- const scaffoldRes = await this._scaffold(scaffoldInputs, ctx);
432
- if (scaffoldRes.isErr()) {
433
- return teamsfx_api_1.err(scaffoldRes.error);
434
- }
435
- }
436
- }
437
- }
438
- if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
439
- await globalState_1.globalStateUpdate(globalStateDescription, true);
440
- }
441
- return teamsfx_api_1.ok(projectPath);
442
- }
443
220
  async migrateV1Project(inputs, ctx) {
444
221
  var _a;
445
222
  exports.currentStage = teamsfx_api_1.Stage.migrateV1;
446
223
  inputs.stage = teamsfx_api_1.Stage.migrateV1;
447
224
  const globalStateDescription = "openReadme";
448
- const appName = ((_a = inputs[question_2.DefaultAppNameFunc.name]) !== null && _a !== void 0 ? _a : inputs[question_2.QuestionV1AppName.name]);
225
+ const appName = ((_a = inputs[question_1.DefaultAppNameFunc.name]) !== null && _a !== void 0 ? _a : inputs[question_1.QuestionV1AppName.name]);
449
226
  if (undefined === appName)
450
227
  return teamsfx_api_1.err(error_1.InvalidInputError(`App Name is empty`, inputs));
451
228
  const validateResult = jsonschema.validate(appName, {
452
- pattern: question_2.ProjectNamePattern,
229
+ pattern: question_1.ProjectNamePattern,
453
230
  });
454
231
  if (validateResult.errors && validateResult.errors.length > 0) {
455
232
  return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
@@ -525,18 +302,7 @@ class FxCore {
525
302
  return teamsfx_api_1.err(error_1.ArchiveProjectError(e.message));
526
303
  }
527
304
  }
528
- /**
529
- * switch to different versions of provisionResources
530
- */
531
- async provisionResources(inputs) {
532
- if (isV3()) {
533
- return this.provisionResourcesV3(inputs);
534
- }
535
- else {
536
- return this.provisionResourcesV2(inputs);
537
- }
538
- }
539
- async provisionResourcesV2(inputs, ctx) {
305
+ async provisionResources(inputs, ctx) {
540
306
  exports.currentStage = teamsfx_api_1.Stage.provision;
541
307
  inputs.stage = teamsfx_api_1.Stage.provision;
542
308
  // provision is not ready yet, so use API v1
@@ -571,29 +337,7 @@ class FxCore {
571
337
  return provisionRes;
572
338
  }
573
339
  }
574
- async provisionResourcesV3(inputs, ctx) {
575
- exports.currentStage = teamsfx_api_1.Stage.provision;
576
- inputs.stage = teamsfx_api_1.Stage.provision;
577
- if (ctx &&
578
- ctx.solutionV3 &&
579
- ctx.contextV2 &&
580
- ctx.envInfoV3 &&
581
- ctx.solutionV3.provisionResources) {
582
- const res = await ctx.solutionV3.provisionResources(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider);
583
- if (res.isOk()) {
584
- ctx.envInfoV3 = res.value;
585
- }
586
- return res;
587
- }
588
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
589
- }
590
- async deployArtifacts(inputs) {
591
- if (isV3())
592
- return this.deployArtifactsV3(inputs);
593
- else
594
- return this.deployArtifactsV2(inputs);
595
- }
596
- async deployArtifactsV2(inputs, ctx) {
340
+ async deployArtifacts(inputs, ctx) {
597
341
  exports.currentStage = teamsfx_api_1.Stage.deploy;
598
342
  inputs.stage = teamsfx_api_1.Stage.deploy;
599
343
  if (isV2()) {
@@ -614,22 +358,7 @@ class FxCore {
614
358
  return await ctx.solution.deploy(ctx.solutionContext);
615
359
  }
616
360
  }
617
- async deployArtifactsV3(inputs, ctx) {
618
- exports.currentStage = teamsfx_api_1.Stage.deploy;
619
- inputs.stage = teamsfx_api_1.Stage.deploy;
620
- if (ctx && ctx.solutionV3 && ctx.contextV2 && ctx.envInfoV3 && ctx.solutionV3.deploy) {
621
- const res = await ctx.solutionV3.deploy(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider);
622
- return res;
623
- }
624
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
625
- }
626
- async localDebug(inputs) {
627
- if (isV3())
628
- return this.localDebugV3(inputs);
629
- else
630
- return this.localDebugV2(inputs);
631
- }
632
- async localDebugV2(inputs, ctx) {
361
+ async localDebug(inputs, ctx) {
633
362
  exports.currentStage = teamsfx_api_1.Stage.debug;
634
363
  inputs.stage = teamsfx_api_1.Stage.debug;
635
364
  if (isV2()) {
@@ -669,22 +398,6 @@ class FxCore {
669
398
  this._setEnvInfoV2(ctx);
670
399
  return res;
671
400
  }
672
- async localDebugV3(inputs, ctx) {
673
- exports.currentStage = teamsfx_api_1.Stage.debug;
674
- inputs.stage = teamsfx_api_1.Stage.debug;
675
- if (ctx &&
676
- ctx.solutionV3 &&
677
- ctx.contextV2 &&
678
- ctx.localSettings &&
679
- ctx.solutionV3.provisionLocalResources) {
680
- const res = await ctx.solutionV3.provisionLocalResources(ctx.contextV2, inputs, ctx.localSettings, exports.TOOLS.tokenProvider);
681
- if (res.isOk()) {
682
- ctx.localSettings = res.value;
683
- }
684
- return res;
685
- }
686
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
687
- }
688
401
  _setEnvInfoV2(ctx) {
689
402
  if (isV2() && ctx && ctx.solutionContext) {
690
403
  //workaround, compatible to api v2
@@ -696,13 +409,7 @@ class FxCore {
696
409
  ctx.envInfoV2.state = tools_1.mapToJson(ctx.solutionContext.envInfo.state);
697
410
  }
698
411
  }
699
- async publishApplication(inputs) {
700
- if (isV3())
701
- return this.publishApplicationV3(inputs);
702
- else
703
- return this.publishApplicationV2(inputs);
704
- }
705
- async publishApplicationV2(inputs, ctx) {
412
+ async publishApplication(inputs, ctx) {
706
413
  exports.currentStage = teamsfx_api_1.Stage.publish;
707
414
  inputs.stage = teamsfx_api_1.Stage.publish;
708
415
  if (isV2()) {
@@ -720,19 +427,6 @@ class FxCore {
720
427
  return await ctx.solution.publish(ctx.solutionContext);
721
428
  }
722
429
  }
723
- async publishApplicationV3(inputs, ctx) {
724
- exports.currentStage = teamsfx_api_1.Stage.publish;
725
- inputs.stage = teamsfx_api_1.Stage.publish;
726
- if (ctx &&
727
- ctx.solutionV3 &&
728
- ctx.contextV2 &&
729
- ctx.envInfoV3 &&
730
- ctx.solutionV3.publishApplication) {
731
- const res = await ctx.solutionV3.publishApplication(ctx.contextV2, inputs, ctx.envInfoV3, exports.TOOLS.tokenProvider.appStudioToken);
732
- return res;
733
- }
734
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
735
- }
736
430
  async executeUserTask(func, inputs, ctx) {
737
431
  exports.currentStage = teamsfx_api_1.Stage.userTask;
738
432
  inputs.stage = teamsfx_api_1.Stage.userTask;
@@ -745,7 +439,7 @@ class FxCore {
745
439
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError(`executeUserTask input stuff: ${name}`));
746
440
  }
747
441
  if (!ctx.contextV2)
748
- ctx.contextV2 = createV2Context(newProjectSettings());
442
+ ctx.contextV2 = createV2Context(this, newProjectSettings());
749
443
  if (ctx.solutionV2.executeUserTask) {
750
444
  if (!ctx.localSettings)
751
445
  ctx.localSettings = {};
@@ -775,11 +469,13 @@ class FxCore {
775
469
  exports.currentStage = teamsfx_api_1.Stage.getQuestions;
776
470
  if (stage === teamsfx_api_1.Stage.create) {
777
471
  delete inputs.projectPath;
778
- return await this._getQuestionsForCreateProjectV2(inputs);
472
+ return await this._getQuestionsForCreateProject(inputs);
779
473
  }
780
474
  else {
781
475
  if (isV2()) {
782
- const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(newProjectSettings());
476
+ const contextV2 = ctx.contextV2
477
+ ? ctx.contextV2
478
+ : createV2Context(this, newProjectSettings());
783
479
  const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
784
480
  const envInfoV2 = ctx.envInfoV2
785
481
  ? ctx.envInfoV2
@@ -802,7 +498,7 @@ class FxCore {
802
498
  inputs.stage = teamsfx_api_1.Stage.getQuestions;
803
499
  exports.currentStage = teamsfx_api_1.Stage.getQuestions;
804
500
  if (isV2()) {
805
- const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(newProjectSettings());
501
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(this, newProjectSettings());
806
502
  const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
807
503
  const envInfoV2 = ctx.envInfoV2
808
504
  ? ctx.envInfoV2
@@ -897,6 +593,83 @@ class FxCore {
897
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);
898
594
  }
899
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);
672
+ }
900
673
  async encrypt(plaintext, inputs, ctx) {
901
674
  if (!ctx)
902
675
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx"));
@@ -986,7 +759,7 @@ class FxCore {
986
759
  catch (e) {
987
760
  return teamsfx_api_1.err(error_1.CopyFileError(e));
988
761
  }
989
- exports.TOOLS.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
762
+ core.tools.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
990
763
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
991
764
  }
992
765
  // deprecated
@@ -1006,7 +779,7 @@ class FxCore {
1006
779
  return teamsfx_api_1.err(error_1.NonExistEnvNameError(env));
1007
780
  }
1008
781
  const core = ctx.self;
1009
- const solutionContext = await envInfoLoader_1.loadSolutionContext(inputs, ctx.projectSettings, env);
782
+ const solutionContext = await envInfoLoader_1.loadSolutionContext(core.tools, inputs, ctx.projectSettings, env);
1010
783
  if (!solutionContext.isErr()) {
1011
784
  if (isV2()) {
1012
785
  //TODO core should not know the details of envInfo
@@ -1021,69 +794,58 @@ class FxCore {
1021
794
  this.tools.ui.showMessage("info", `[${env}] is activated.`, false);
1022
795
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
1023
796
  }
1024
- async _init(inputs, ctx) {
1025
- if (!ctx) {
1026
- return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx for createProject"));
1027
- }
1028
- const appName = inputs[question_2.QuestionAppName.name];
1029
- const validateResult = jsonschema.validate(appName, {
1030
- pattern: question_2.ProjectNamePattern,
1031
- });
1032
- if (validateResult.errors && validateResult.errors.length > 0) {
1033
- return teamsfx_api_1.err(error_1.InvalidInputError("invalid app-name", inputs));
1034
- }
1035
- const projectSettings = newProjectSettings();
1036
- projectSettings.appName = appName;
1037
- ctx.projectSettings = projectSettings;
1038
- if (!inputs.solution) {
1039
- return teamsfx_api_1.err(error_1.InvalidInputError("solution is undefined", inputs));
1040
- }
1041
- const createEnvResult = await this.createEnvWithName(__1.environmentManager.getDefaultEnvName(), projectSettings, inputs);
1042
- if (createEnvResult.isErr()) {
1043
- return teamsfx_api_1.err(createEnvResult.error);
1044
- }
1045
- await fs.ensureDir(path.join(inputs.projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
1046
- await fs.ensureDir(path.join(inputs.projectPath, "templates", `${teamsfx_api_1.AppPackageFolderName}`));
1047
- const basicFolderRes = await createBasicFolderStructure(inputs);
1048
- if (basicFolderRes.isErr()) {
1049
- return teamsfx_api_1.err(basicFolderRes.error);
1050
- }
1051
- const solution = typedi_1.Container.get(inputs.solution);
1052
- projectSettings.solutionSettings.name = inputs.solution;
1053
- const context = createV2Context(projectSettings);
1054
- ctx.contextV2 = context;
1055
- ctx.solutionV3 = solution;
1056
- return await solution.init(context, inputs);
1057
- }
1058
- async init(inputs, ctx) {
1059
- return this._init(inputs, ctx);
1060
- }
1061
- async _addModule(inputs, ctx) {
1062
- if (ctx && ctx.solutionV3 && ctx.contextV2) {
1063
- return await ctx.solutionV3.addModule(ctx.contextV2, {}, inputs);
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
+ }
1064
836
  }
1065
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
1066
- }
1067
- async addModule(inputs, ctx) {
1068
- return this._addModule(inputs, ctx);
1069
- }
1070
- async scaffold(inputs, ctx) {
1071
- return this._scaffold(inputs, ctx);
1072
- }
1073
- async _scaffold(inputs, ctx) {
1074
- if (ctx && ctx.solutionV3 && ctx.contextV2) {
1075
- return await ctx.solutionV3.scaffold(ctx.contextV2, inputs);
837
+ if (inputs.platform !== teamsfx_api_1.Platform.VSCode) {
838
+ createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
1076
839
  }
1077
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
1078
- }
1079
- async addResource(inputs, ctx) {
1080
- return this._addResource(inputs, ctx);
1081
- }
1082
- async _addResource(inputs, ctx) {
1083
- if (ctx && ctx.solutionV3 && ctx.contextV2) {
1084
- return await ctx.solutionV3.addResource(ctx.contextV2, inputs);
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));
1085
847
  }
1086
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
848
+ return teamsfx_api_1.ok(node.trim());
1087
849
  }
1088
850
  }
1089
851
  tslib_1.__decorate([
@@ -1098,20 +860,7 @@ tslib_1.__decorate([
1098
860
  tslib_1.__metadata("design:type", Function),
1099
861
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1100
862
  tslib_1.__metadata("design:returntype", Promise)
1101
- ], FxCore.prototype, "createProjectV2", null);
1102
- tslib_1.__decorate([
1103
- hooks_1.hooks([
1104
- errorHandler_1.ErrorHandlerMW,
1105
- supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1106
- questionModel_1.QuestionModelMW,
1107
- contextInjector_1.ContextInjectorMW,
1108
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1109
- envInfoWriterV3_1.EnvInfoWriterMW_V3(true),
1110
- ]),
1111
- tslib_1.__metadata("design:type", Function),
1112
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1113
- tslib_1.__metadata("design:returntype", Promise)
1114
- ], FxCore.prototype, "createProjectV3", null);
863
+ ], FxCore.prototype, "createProject", null);
1115
864
  tslib_1.__decorate([
1116
865
  hooks_1.hooks([
1117
866
  errorHandler_1.ErrorHandlerMW,
@@ -1134,7 +883,7 @@ tslib_1.__decorate([
1134
883
  projectMigrator_1.ProjectMigratorMW,
1135
884
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1136
885
  envInfoLoader_1.EnvInfoLoaderMW(false),
1137
- solutionLoader_1.SolutionLoaderMW,
886
+ solutionLoader_1.SolutionLoaderMW(),
1138
887
  questionModel_1.QuestionModelMW,
1139
888
  contextInjector_1.ContextInjectorMW,
1140
889
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -1143,25 +892,7 @@ tslib_1.__decorate([
1143
892
  tslib_1.__metadata("design:type", Function),
1144
893
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1145
894
  tslib_1.__metadata("design:returntype", Promise)
1146
- ], FxCore.prototype, "provisionResourcesV2", null);
1147
- tslib_1.__decorate([
1148
- hooks_1.hooks([
1149
- errorHandler_1.ErrorHandlerMW,
1150
- concurrentLocker_1.ConcurrentLockerMW,
1151
- supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1152
- projectMigrator_1.ProjectMigratorMW,
1153
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1154
- envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1155
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1156
- questionModel_1.QuestionModelMW,
1157
- contextInjector_1.ContextInjectorMW,
1158
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1159
- envInfoWriterV3_1.EnvInfoWriterMW_V3(),
1160
- ]),
1161
- tslib_1.__metadata("design:type", Function),
1162
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1163
- tslib_1.__metadata("design:returntype", Promise)
1164
- ], FxCore.prototype, "provisionResourcesV3", null);
895
+ ], FxCore.prototype, "provisionResources", null);
1165
896
  tslib_1.__decorate([
1166
897
  hooks_1.hooks([
1167
898
  errorHandler_1.ErrorHandlerMW,
@@ -1170,7 +901,7 @@ tslib_1.__decorate([
1170
901
  projectMigrator_1.ProjectMigratorMW,
1171
902
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1172
903
  envInfoLoader_1.EnvInfoLoaderMW(false),
1173
- solutionLoader_1.SolutionLoaderMW,
904
+ solutionLoader_1.SolutionLoaderMW(),
1174
905
  questionModel_1.QuestionModelMW,
1175
906
  contextInjector_1.ContextInjectorMW,
1176
907
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -1179,25 +910,7 @@ tslib_1.__decorate([
1179
910
  tslib_1.__metadata("design:type", Function),
1180
911
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1181
912
  tslib_1.__metadata("design:returntype", Promise)
1182
- ], FxCore.prototype, "deployArtifactsV2", null);
1183
- tslib_1.__decorate([
1184
- hooks_1.hooks([
1185
- errorHandler_1.ErrorHandlerMW,
1186
- concurrentLocker_1.ConcurrentLockerMW,
1187
- supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1188
- projectMigrator_1.ProjectMigratorMW,
1189
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1190
- envInfoLoaderV3_1.EnvInfoLoaderMW_V3(false),
1191
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1192
- questionModel_1.QuestionModelMW,
1193
- contextInjector_1.ContextInjectorMW,
1194
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1195
- envInfoWriterV3_1.EnvInfoWriterMW_V3(),
1196
- ]),
1197
- tslib_1.__metadata("design:type", Function),
1198
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1199
- tslib_1.__metadata("design:returntype", Promise)
1200
- ], FxCore.prototype, "deployArtifactsV3", null);
913
+ ], FxCore.prototype, "deployArtifacts", null);
1201
914
  tslib_1.__decorate([
1202
915
  hooks_1.hooks([
1203
916
  errorHandler_1.ErrorHandlerMW,
@@ -1208,7 +921,7 @@ tslib_1.__decorate([
1208
921
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1209
922
  envInfoLoader_1.EnvInfoLoaderMW(true),
1210
923
  localSettingsLoader_1.LocalSettingsLoaderMW,
1211
- solutionLoader_1.SolutionLoaderMW,
924
+ solutionLoader_1.SolutionLoaderMW(),
1212
925
  questionModel_1.QuestionModelMW,
1213
926
  contextInjector_1.ContextInjectorMW,
1214
927
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -1218,44 +931,7 @@ tslib_1.__decorate([
1218
931
  tslib_1.__metadata("design:type", Function),
1219
932
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1220
933
  tslib_1.__metadata("design:returntype", Promise)
1221
- ], FxCore.prototype, "localDebugV2", null);
1222
- tslib_1.__decorate([
1223
- hooks_1.hooks([
1224
- errorHandler_1.ErrorHandlerMW,
1225
- concurrentLocker_1.ConcurrentLockerMW,
1226
- supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1227
- projectMigrator_1.ProjectMigratorMW,
1228
- projectUpgrader_1.ProjectUpgraderMW,
1229
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1230
- localSettingsLoader_1.LocalSettingsLoaderMW,
1231
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1232
- questionModel_1.QuestionModelMW,
1233
- contextInjector_1.ContextInjectorMW,
1234
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1235
- localSettingsWriter_1.LocalSettingsWriterMW,
1236
- ]),
1237
- tslib_1.__metadata("design:type", Function),
1238
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1239
- tslib_1.__metadata("design:returntype", Promise)
1240
- ], FxCore.prototype, "localDebugV3", null);
1241
- tslib_1.__decorate([
1242
- hooks_1.hooks([
1243
- errorHandler_1.ErrorHandlerMW,
1244
- concurrentLocker_1.ConcurrentLockerMW,
1245
- supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1246
- projectMigrator_1.ProjectMigratorMW,
1247
- projectSettingsLoader_1.ProjectSettingsLoaderMW,
1248
- envInfoLoader_1.EnvInfoLoaderMW(false),
1249
- solutionLoader_1.SolutionLoaderMW,
1250
- questionModel_1.QuestionModelMW,
1251
- contextInjector_1.ContextInjectorMW,
1252
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1253
- envInfoWriter_1.EnvInfoWriterMW(),
1254
- ]),
1255
- tslib_1.__metadata("design:type", Function),
1256
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1257
- tslib_1.__metadata("design:returntype", Promise)
1258
- ], FxCore.prototype, "publishApplicationV2", null);
934
+ ], FxCore.prototype, "localDebug", null);
1259
935
  tslib_1.__decorate([
1260
936
  hooks_1.hooks([
1261
937
  errorHandler_1.ErrorHandlerMW,
@@ -1264,7 +940,7 @@ tslib_1.__decorate([
1264
940
  projectMigrator_1.ProjectMigratorMW,
1265
941
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1266
942
  envInfoLoader_1.EnvInfoLoaderMW(false),
1267
- solutionLoader_1.SolutionLoaderMW,
943
+ solutionLoader_1.SolutionLoaderMW(),
1268
944
  questionModel_1.QuestionModelMW,
1269
945
  contextInjector_1.ContextInjectorMW,
1270
946
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -1273,7 +949,7 @@ tslib_1.__decorate([
1273
949
  tslib_1.__metadata("design:type", Function),
1274
950
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1275
951
  tslib_1.__metadata("design:returntype", Promise)
1276
- ], FxCore.prototype, "publishApplicationV3", null);
952
+ ], FxCore.prototype, "publishApplication", null);
1277
953
  tslib_1.__decorate([
1278
954
  hooks_1.hooks([
1279
955
  errorHandler_1.ErrorHandlerMW,
@@ -1283,7 +959,7 @@ tslib_1.__decorate([
1283
959
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1284
960
  envInfoLoader_1.EnvInfoLoaderMW(false),
1285
961
  localSettingsLoader_1.LocalSettingsLoaderMW,
1286
- solutionLoader_1.SolutionLoaderMW,
962
+ solutionLoader_1.SolutionLoaderMW(),
1287
963
  questionModel_1.QuestionModelMW,
1288
964
  contextInjector_1.ContextInjectorMW,
1289
965
  projectSettingsWriter_1.ProjectSettingsWriterMW,
@@ -1300,7 +976,7 @@ tslib_1.__decorate([
1300
976
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1301
977
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1302
978
  envInfoLoader_1.EnvInfoLoaderMW(true),
1303
- solutionLoader_1.SolutionLoaderMW,
979
+ solutionLoader_1.SolutionLoaderMW(),
1304
980
  contextInjector_1.ContextInjectorMW,
1305
981
  envInfoWriter_1.EnvInfoWriterMW(),
1306
982
  ]),
@@ -1315,7 +991,7 @@ tslib_1.__decorate([
1315
991
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1316
992
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1317
993
  envInfoLoader_1.EnvInfoLoaderMW(true),
1318
- solutionLoader_1.SolutionLoaderMW,
994
+ solutionLoader_1.SolutionLoaderMW(),
1319
995
  contextInjector_1.ContextInjectorMW,
1320
996
  envInfoWriter_1.EnvInfoWriterMW(),
1321
997
  ]),
@@ -1346,7 +1022,7 @@ tslib_1.__decorate([
1346
1022
  projectMigrator_1.ProjectMigratorMW,
1347
1023
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1348
1024
  envInfoLoader_1.EnvInfoLoaderMW(false),
1349
- solutionLoader_1.SolutionLoaderMW,
1025
+ solutionLoader_1.SolutionLoaderMW(),
1350
1026
  questionModel_1.QuestionModelMW,
1351
1027
  contextInjector_1.ContextInjectorMW,
1352
1028
  ]),
@@ -1362,7 +1038,7 @@ tslib_1.__decorate([
1362
1038
  projectMigrator_1.ProjectMigratorMW,
1363
1039
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1364
1040
  envInfoLoader_1.EnvInfoLoaderMW(false),
1365
- solutionLoader_1.SolutionLoaderMW,
1041
+ solutionLoader_1.SolutionLoaderMW(),
1366
1042
  questionModel_1.QuestionModelMW,
1367
1043
  contextInjector_1.ContextInjectorMW,
1368
1044
  ]),
@@ -1378,7 +1054,7 @@ tslib_1.__decorate([
1378
1054
  projectMigrator_1.ProjectMigratorMW,
1379
1055
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1380
1056
  envInfoLoader_1.EnvInfoLoaderMW(false),
1381
- solutionLoader_1.SolutionLoaderMW,
1057
+ solutionLoader_1.SolutionLoaderMW(),
1382
1058
  questionModel_1.QuestionModelMW,
1383
1059
  contextInjector_1.ContextInjectorMW,
1384
1060
  ]),
@@ -1393,7 +1069,7 @@ tslib_1.__decorate([
1393
1069
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1394
1070
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1395
1071
  envInfoLoader_1.EnvInfoLoaderMW(true),
1396
- solutionLoader_1.SolutionLoaderMW,
1072
+ solutionLoader_1.SolutionLoaderMW(),
1397
1073
  questionModel_1.QuestionModelMW,
1398
1074
  contextInjector_1.ContextInjectorMW,
1399
1075
  ]),
@@ -1445,7 +1121,7 @@ tslib_1.__decorate([
1445
1121
  concurrentLocker_1.ConcurrentLockerMW,
1446
1122
  supportV1ConditionHandler_1.SupportV1ConditionMW(false),
1447
1123
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1448
- solutionLoader_1.SolutionLoaderMW,
1124
+ solutionLoader_1.SolutionLoaderMW(),
1449
1125
  envInfoLoader_1.EnvInfoLoaderMW(true),
1450
1126
  contextInjector_1.ContextInjectorMW,
1451
1127
  ]),
@@ -1460,7 +1136,7 @@ tslib_1.__decorate([
1460
1136
  supportV1ConditionHandler_1.SupportV1ConditionMW(true),
1461
1137
  projectMigrator_1.ProjectMigratorMW,
1462
1138
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
1463
- solutionLoader_1.SolutionLoaderMW,
1139
+ solutionLoader_1.SolutionLoaderMW(),
1464
1140
  contextInjector_1.ContextInjectorMW,
1465
1141
  projectSettingsWriter_1.ProjectSettingsWriterMW,
1466
1142
  ]),
@@ -1468,73 +1144,26 @@ tslib_1.__decorate([
1468
1144
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
1469
1145
  tslib_1.__metadata("design:returntype", Promise)
1470
1146
  ], FxCore.prototype, "activateEnv", null);
1471
- tslib_1.__decorate([
1472
- hooks_1.hooks([errorHandler_1.ErrorHandlerMW, questionModel_1.QuestionModelMW, contextInjector_1.ContextInjectorMW, projectSettingsWriter_1.ProjectSettingsWriterMW]),
1473
- tslib_1.__metadata("design:type", Function),
1474
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1475
- tslib_1.__metadata("design:returntype", Promise)
1476
- ], FxCore.prototype, "init", null);
1477
- tslib_1.__decorate([
1478
- hooks_1.hooks([
1479
- errorHandler_1.ErrorHandlerMW,
1480
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1481
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1482
- questionModel_1.QuestionModelMW,
1483
- contextInjector_1.ContextInjectorMW,
1484
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1485
- ]),
1486
- tslib_1.__metadata("design:type", Function),
1487
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1488
- tslib_1.__metadata("design:returntype", Promise)
1489
- ], FxCore.prototype, "addModule", null);
1490
- tslib_1.__decorate([
1491
- hooks_1.hooks([
1492
- errorHandler_1.ErrorHandlerMW,
1493
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1494
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1495
- questionModel_1.QuestionModelMW,
1496
- contextInjector_1.ContextInjectorMW,
1497
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1498
- ]),
1499
- tslib_1.__metadata("design:type", Function),
1500
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1501
- tslib_1.__metadata("design:returntype", Promise)
1502
- ], FxCore.prototype, "scaffold", null);
1503
- tslib_1.__decorate([
1504
- hooks_1.hooks([
1505
- errorHandler_1.ErrorHandlerMW,
1506
- projectSettingsLoaderV3_1.ProjectSettingsLoaderMW_V3,
1507
- solutionLoaderV3_1.SolutionLoaderMW_V3,
1508
- questionModel_1.QuestionModelMW,
1509
- contextInjector_1.ContextInjectorMW,
1510
- projectSettingsWriter_1.ProjectSettingsWriterMW,
1511
- ]),
1512
- tslib_1.__metadata("design:type", Function),
1513
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
1514
- tslib_1.__metadata("design:returntype", Promise)
1515
- ], FxCore.prototype, "addResource", null);
1516
1147
  exports.FxCore = FxCore;
1517
1148
  async function createBasicFolderStructure(inputs) {
1518
1149
  if (!inputs.projectPath) {
1519
1150
  return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
1520
1151
  }
1521
1152
  try {
1522
- const appName = inputs[question_2.QuestionAppName.name];
1523
- if (inputs.platform !== teamsfx_api_1.Platform.VS) {
1524
- await fs.writeFile(path.join(inputs.projectPath, `package.json`), JSON.stringify({
1525
- name: appName,
1526
- version: "0.0.1",
1527
- description: "",
1528
- author: "",
1529
- scripts: {
1530
- test: 'echo "Error: no test specified" && exit 1',
1531
- },
1532
- devDependencies: {
1533
- "@microsoft/teamsfx-cli": "0.*",
1534
- },
1535
- license: "MIT",
1536
- }, null, 4));
1537
- }
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));
1538
1167
  await fs.writeFile(path.join(inputs.projectPath, `.gitignore`), tools_1.isMultiEnvEnabled()
1539
1168
  ? [
1540
1169
  "node_modules",
@@ -1555,23 +1184,23 @@ async function createBasicFolderStructure(inputs) {
1555
1184
  return teamsfx_api_1.ok(null);
1556
1185
  }
1557
1186
  exports.createBasicFolderStructure = createBasicFolderStructure;
1558
- async function downloadSample(inputs, ctx) {
1187
+ async function downloadSample(fxCore, inputs, ctx) {
1559
1188
  let fxError;
1560
- const progress = exports.TOOLS.ui.createProgressBar("Fetch sample app", 3);
1189
+ const progress = fxCore.tools.ui.createProgressBar("Fetch sample app", 3);
1561
1190
  progress.start();
1562
1191
  const telemetryProperties = {
1563
1192
  [telemetry_1.TelemetryProperty.Success]: telemetry_1.TelemetrySuccess.Yes,
1564
1193
  module: "fx-core",
1565
1194
  };
1566
1195
  try {
1567
- let folder = inputs[question_2.QuestionRootFolder.name];
1196
+ let folder = inputs[question_1.QuestionRootFolder.name];
1568
1197
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
1569
1198
  folder = tools_1.getRootDirectory();
1570
1199
  await fs.ensureDir(folder);
1571
1200
  }
1572
- const sampleId = inputs[question_2.CoreQuestionNames.Samples];
1201
+ const sampleId = inputs[question_1.CoreQuestionNames.Samples];
1573
1202
  if (!(sampleId && folder)) {
1574
- throw error_1.InvalidInputError(`invalid answer for '${question_2.CoreQuestionNames.Samples}'`, inputs);
1203
+ throw error_1.InvalidInputError(`invalid answer for '${question_1.CoreQuestionNames.Samples}'`, inputs);
1575
1204
  }
1576
1205
  telemetryProperties[telemetry_1.TelemetryProperty.SampleAppName] = sampleId;
1577
1206
  const samples = __1.sampleProvider.SampleCollection.samples.filter((sample) => sample.id.toLowerCase() === sampleId.toLowerCase());
@@ -1588,15 +1217,12 @@ async function downloadSample(inputs, ctx) {
1588
1217
  }
1589
1218
  }
1590
1219
  progress.next(`Downloading from ${url}`);
1591
- const fetchRes = await tools_1.fetchCodeZip(url, sample.id);
1592
- if (fetchRes.isErr()) {
1593
- throw fetchRes.error;
1594
- }
1595
- else if (!fetchRes.value) {
1596
- throw error_1.FetchSampleError(sample.id);
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);
1597
1223
  }
1598
1224
  progress.next("Unzipping the sample package");
1599
- await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.value.data), sampleId, sampleAppPath);
1225
+ await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.data), sampleId, sampleAppPath);
1600
1226
  await tools_1.downloadSampleHook(sampleId, sampleAppPath);
1601
1227
  progress.next("Update project settings");
1602
1228
  const loadInputs = Object.assign(Object.assign({}, inputs), { projectPath: sampleAppPath });
@@ -1604,16 +1230,11 @@ async function downloadSample(inputs, ctx) {
1604
1230
  if (projectSettingsRes.isOk()) {
1605
1231
  const projectSettings = projectSettingsRes.value;
1606
1232
  projectSettings.projectId = inputs.projectId ? inputs.projectId : uuid.v4();
1607
- projectSettings.isFromSample = true;
1608
1233
  inputs.projectId = projectSettings.projectId;
1609
1234
  telemetryProperties[telemetry_1.TelemetryProperty.ProjectId] = projectSettings.projectId;
1610
1235
  ctx.projectSettings = projectSettings;
1611
1236
  inputs.projectPath = sampleAppPath;
1612
1237
  }
1613
- else {
1614
- telemetryProperties[telemetry_1.TelemetryProperty.ProjectId] =
1615
- "unknown, failed to set projectId in projectSettings.json";
1616
- }
1617
1238
  progress.end(true);
1618
1239
  telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, telemetryProperties);
1619
1240
  return teamsfx_api_1.ok(sampleAppPath);
@@ -1639,13 +1260,13 @@ function newProjectSettings() {
1639
1260
  return projectSettings;
1640
1261
  }
1641
1262
  exports.newProjectSettings = newProjectSettings;
1642
- function createV2Context(projectSettings) {
1263
+ function createV2Context(core, projectSettings) {
1643
1264
  const context = {
1644
- userInteraction: exports.TOOLS.ui,
1645
- logProvider: exports.TOOLS.logProvider,
1646
- telemetryReporter: exports.TOOLS.telemetryReporter,
1265
+ userInteraction: core.tools.ui,
1266
+ logProvider: core.tools.logProvider,
1267
+ telemetryReporter: core.tools.telemetryReporter,
1647
1268
  cryptoProvider: new crypto_1.LocalCrypto(projectSettings.projectId),
1648
- permissionRequestProvider: exports.TOOLS.permissionRequest,
1269
+ permissionRequestProvider: core.tools.permissionRequest,
1649
1270
  projectSetting: projectSettings,
1650
1271
  };
1651
1272
  return context;