@microsoft/teamsfx-core 0.7.0 → 0.7.1-alpha.5e8f6dea.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 (494) hide show
  1. package/build/common/constants.d.ts +5 -0
  2. package/build/common/constants.d.ts.map +1 -1
  3. package/build/common/constants.js +6 -1
  4. package/build/common/constants.js.map +1 -1
  5. package/build/common/fileUtils.d.ts.map +1 -1
  6. package/build/common/fileUtils.js +12 -6
  7. package/build/common/fileUtils.js.map +1 -1
  8. package/build/common/localSettingsProvider.d.ts +4 -2
  9. package/build/common/localSettingsProvider.d.ts.map +1 -1
  10. package/build/common/localSettingsProvider.js +32 -1
  11. package/build/common/localSettingsProvider.js.map +1 -1
  12. package/build/common/templates.d.ts.map +1 -1
  13. package/build/common/templates.js +9 -9
  14. package/build/common/templates.js.map +1 -1
  15. package/build/common/templatesActions.d.ts +39 -0
  16. package/build/common/templatesActions.d.ts.map +1 -0
  17. package/build/common/templatesActions.js +120 -0
  18. package/build/common/templatesActions.js.map +1 -0
  19. package/build/common/templatesUtils.d.ts +14 -0
  20. package/build/common/templatesUtils.d.ts.map +1 -0
  21. package/build/common/templatesUtils.js +94 -0
  22. package/build/common/templatesUtils.js.map +1 -0
  23. package/build/common/tools.d.ts +12 -2
  24. package/build/common/tools.d.ts.map +1 -1
  25. package/build/common/tools.js +52 -7
  26. package/build/common/tools.js.map +1 -1
  27. package/build/core/SolutionPluginContainer.d.ts +15 -0
  28. package/build/core/SolutionPluginContainer.d.ts.map +1 -0
  29. package/build/core/SolutionPluginContainer.js +54 -0
  30. package/build/core/SolutionPluginContainer.js.map +1 -0
  31. package/build/core/callback.d.ts +9 -0
  32. package/build/core/callback.d.ts.map +1 -0
  33. package/build/core/callback.js +33 -0
  34. package/build/core/callback.js.map +1 -0
  35. package/build/core/environment.d.ts +7 -3
  36. package/build/core/environment.d.ts.map +1 -1
  37. package/build/core/environment.js +68 -13
  38. package/build/core/environment.js.map +1 -1
  39. package/build/core/error.d.ts +19 -2
  40. package/build/core/error.d.ts.map +1 -1
  41. package/build/core/error.js +72 -34
  42. package/build/core/error.js.map +1 -1
  43. package/build/core/index.d.ts +24 -12
  44. package/build/core/index.d.ts.map +1 -1
  45. package/build/core/index.js +604 -309
  46. package/build/core/index.js.map +1 -1
  47. package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
  48. package/build/core/middleware/concurrentLocker.js +13 -6
  49. package/build/core/middleware/concurrentLocker.js.map +1 -1
  50. package/build/core/middleware/contextInjector.d.ts +3 -0
  51. package/build/core/middleware/contextInjector.d.ts.map +1 -0
  52. package/build/core/middleware/{contextInjecter.js → contextInjector.js} +4 -4
  53. package/build/core/middleware/contextInjector.js.map +1 -0
  54. package/build/core/middleware/envInfoLoader.d.ts +8 -4
  55. package/build/core/middleware/envInfoLoader.d.ts.map +1 -1
  56. package/build/core/middleware/envInfoLoader.js +77 -40
  57. package/build/core/middleware/envInfoLoader.js.map +1 -1
  58. package/build/core/middleware/envInfoWriter.d.ts +1 -1
  59. package/build/core/middleware/envInfoWriter.d.ts.map +1 -1
  60. package/build/core/middleware/envInfoWriter.js +30 -13
  61. package/build/core/middleware/envInfoWriter.js.map +1 -1
  62. package/build/core/middleware/localSettingsLoader.d.ts.map +1 -1
  63. package/build/core/middleware/localSettingsLoader.js +18 -8
  64. package/build/core/middleware/localSettingsLoader.js.map +1 -1
  65. package/build/core/middleware/localSettingsWriter.d.ts.map +1 -1
  66. package/build/core/middleware/localSettingsWriter.js +14 -5
  67. package/build/core/middleware/localSettingsWriter.js.map +1 -1
  68. package/build/core/middleware/projectMigrator.d.ts +5 -0
  69. package/build/core/middleware/projectMigrator.d.ts.map +1 -0
  70. package/build/core/middleware/projectMigrator.js +382 -0
  71. package/build/core/middleware/projectMigrator.js.map +1 -0
  72. package/build/core/middleware/projectSettingsLoader.d.ts +2 -2
  73. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  74. package/build/core/middleware/projectSettingsLoader.js +13 -9
  75. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  76. package/build/core/middleware/projectSettingsWriter.d.ts.map +1 -1
  77. package/build/core/middleware/projectSettingsWriter.js +6 -7
  78. package/build/core/middleware/projectSettingsWriter.js.map +1 -1
  79. package/build/core/middleware/projectUpgrader.d.ts.map +1 -1
  80. package/build/core/middleware/projectUpgrader.js +15 -7
  81. package/build/core/middleware/projectUpgrader.js.map +1 -1
  82. package/build/core/middleware/questionModel.d.ts.map +1 -1
  83. package/build/core/middleware/questionModel.js +25 -17
  84. package/build/core/middleware/questionModel.js.map +1 -1
  85. package/build/core/middleware/solutionLoader.d.ts +1 -2
  86. package/build/core/middleware/solutionLoader.d.ts.map +1 -1
  87. package/build/core/middleware/solutionLoader.js +24 -4
  88. package/build/core/middleware/solutionLoader.js.map +1 -1
  89. package/build/core/question.d.ts +2 -0
  90. package/build/core/question.d.ts.map +1 -1
  91. package/build/core/question.js +12 -1
  92. package/build/core/question.js.map +1 -1
  93. package/build/core/tools.d.ts +2 -2
  94. package/build/core/tools.d.ts.map +1 -1
  95. package/build/core/tools.js +15 -5
  96. package/build/core/tools.js.map +1 -1
  97. package/build/index.d.ts +1 -0
  98. package/build/index.d.ts.map +1 -1
  99. package/build/index.js +1 -0
  100. package/build/index.js.map +1 -1
  101. package/build/plugins/resource/aad/appStudio.js +1 -1
  102. package/build/plugins/resource/aad/appStudio.js.map +1 -1
  103. package/build/plugins/resource/aad/errors.d.ts.map +1 -1
  104. package/build/plugins/resource/aad/errors.js +1 -0
  105. package/build/plugins/resource/aad/errors.js.map +1 -1
  106. package/build/plugins/resource/aad/index.d.ts +1 -0
  107. package/build/plugins/resource/aad/index.d.ts.map +1 -1
  108. package/build/plugins/resource/aad/index.js +2 -1
  109. package/build/plugins/resource/aad/index.js.map +1 -1
  110. package/build/plugins/resource/aad/utils/configs.d.ts.map +1 -1
  111. package/build/plugins/resource/aad/utils/configs.js +9 -10
  112. package/build/plugins/resource/aad/utils/configs.js.map +1 -1
  113. package/build/plugins/resource/aad/utils/telemetry.js +1 -1
  114. package/build/plugins/resource/aad/utils/telemetry.js.map +1 -1
  115. package/build/plugins/resource/aad/v2/index.d.ts +7 -7
  116. package/build/plugins/resource/aad/v2/index.d.ts.map +1 -1
  117. package/build/plugins/resource/aad/v2/index.js +6 -6
  118. package/build/plugins/resource/aad/v2/index.js.map +1 -1
  119. package/build/plugins/resource/apim/config.d.ts +1 -0
  120. package/build/plugins/resource/apim/config.d.ts.map +1 -1
  121. package/build/plugins/resource/apim/config.js.map +1 -1
  122. package/build/plugins/resource/apim/constants.d.ts +3 -0
  123. package/build/plugins/resource/apim/constants.d.ts.map +1 -1
  124. package/build/plugins/resource/apim/constants.js +5 -1
  125. package/build/plugins/resource/apim/constants.js.map +1 -1
  126. package/build/plugins/resource/apim/factory.d.ts +2 -1
  127. package/build/plugins/resource/apim/factory.d.ts.map +1 -1
  128. package/build/plugins/resource/apim/factory.js +19 -8
  129. package/build/plugins/resource/apim/factory.js.map +1 -1
  130. package/build/plugins/resource/apim/index.d.ts +2 -0
  131. package/build/plugins/resource/apim/index.d.ts.map +1 -1
  132. package/build/plugins/resource/apim/index.js +15 -8
  133. package/build/plugins/resource/apim/index.js.map +1 -1
  134. package/build/plugins/resource/apim/questions/vscodeQuestion.js +1 -1
  135. package/build/plugins/resource/apim/questions/vscodeQuestion.js.map +1 -1
  136. package/build/plugins/resource/apim/v2/index.d.ts +9 -11
  137. package/build/plugins/resource/apim/v2/index.d.ts.map +1 -1
  138. package/build/plugins/resource/apim/v2/index.js +25 -29
  139. package/build/plugins/resource/apim/v2/index.js.map +1 -1
  140. package/build/plugins/resource/appstudio/appStudio.d.ts.map +1 -1
  141. package/build/plugins/resource/appstudio/appStudio.js +9 -8
  142. package/build/plugins/resource/appstudio/appStudio.js.map +1 -1
  143. package/build/plugins/resource/appstudio/constants.d.ts +6 -2
  144. package/build/plugins/resource/appstudio/constants.d.ts.map +1 -1
  145. package/build/plugins/resource/appstudio/constants.js +124 -13
  146. package/build/plugins/resource/appstudio/constants.js.map +1 -1
  147. package/build/plugins/resource/appstudio/errors.d.ts +4 -0
  148. package/build/plugins/resource/appstudio/errors.d.ts.map +1 -1
  149. package/build/plugins/resource/appstudio/errors.js +8 -0
  150. package/build/plugins/resource/appstudio/errors.js.map +1 -1
  151. package/build/plugins/resource/appstudio/index.d.ts +1 -0
  152. package/build/plugins/resource/appstudio/index.d.ts.map +1 -1
  153. package/build/plugins/resource/appstudio/index.js +23 -5
  154. package/build/plugins/resource/appstudio/index.js.map +1 -1
  155. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts +1 -0
  156. package/build/plugins/resource/appstudio/interfaces/IAppDefinition.d.ts.map +1 -1
  157. package/build/plugins/resource/appstudio/plugin.d.ts +2 -1
  158. package/build/plugins/resource/appstudio/plugin.d.ts.map +1 -1
  159. package/build/plugins/resource/appstudio/plugin.js +197 -68
  160. package/build/plugins/resource/appstudio/plugin.js.map +1 -1
  161. package/build/plugins/resource/appstudio/utils/telemetry.d.ts +2 -1
  162. package/build/plugins/resource/appstudio/utils/telemetry.d.ts.map +1 -1
  163. package/build/plugins/resource/appstudio/utils/telemetry.js +17 -12
  164. package/build/plugins/resource/appstudio/utils/telemetry.js.map +1 -1
  165. package/build/plugins/resource/appstudio/v2/index.d.ts +10 -13
  166. package/build/plugins/resource/appstudio/v2/index.d.ts.map +1 -1
  167. package/build/plugins/resource/appstudio/v2/index.js +25 -20
  168. package/build/plugins/resource/appstudio/v2/index.js.map +1 -1
  169. package/build/plugins/resource/bot/appStudio/appStudio.js +2 -2
  170. package/build/plugins/resource/bot/appStudio/appStudio.js.map +1 -1
  171. package/build/plugins/resource/bot/configs/localDebugConfig.d.ts +1 -1
  172. package/build/plugins/resource/bot/configs/localDebugConfig.d.ts.map +1 -1
  173. package/build/plugins/resource/bot/configs/localDebugConfig.js +3 -3
  174. package/build/plugins/resource/bot/configs/localDebugConfig.js.map +1 -1
  175. package/build/plugins/resource/bot/configs/provisionConfig.js +21 -20
  176. package/build/plugins/resource/bot/configs/provisionConfig.js.map +1 -1
  177. package/build/plugins/resource/bot/configs/scaffoldConfig.d.ts +1 -3
  178. package/build/plugins/resource/bot/configs/scaffoldConfig.d.ts.map +1 -1
  179. package/build/plugins/resource/bot/configs/scaffoldConfig.js +9 -10
  180. package/build/plugins/resource/bot/configs/scaffoldConfig.js.map +1 -1
  181. package/build/plugins/resource/bot/configs/teamsBotConfig.d.ts.map +1 -1
  182. package/build/plugins/resource/bot/configs/teamsBotConfig.js +5 -5
  183. package/build/plugins/resource/bot/configs/teamsBotConfig.js.map +1 -1
  184. package/build/plugins/resource/bot/constants.d.ts +0 -2
  185. package/build/plugins/resource/bot/constants.d.ts.map +1 -1
  186. package/build/plugins/resource/bot/constants.js +2 -14
  187. package/build/plugins/resource/bot/constants.js.map +1 -1
  188. package/build/plugins/resource/bot/index.d.ts +2 -3
  189. package/build/plugins/resource/bot/index.d.ts.map +1 -1
  190. package/build/plugins/resource/bot/index.js +1 -7
  191. package/build/plugins/resource/bot/index.js.map +1 -1
  192. package/build/plugins/resource/bot/plugin.d.ts +1 -4
  193. package/build/plugins/resource/bot/plugin.d.ts.map +1 -1
  194. package/build/plugins/resource/bot/plugin.js +21 -80
  195. package/build/plugins/resource/bot/plugin.js.map +1 -1
  196. package/build/plugins/resource/bot/resources/messages.d.ts +0 -1
  197. package/build/plugins/resource/bot/resources/messages.d.ts.map +1 -1
  198. package/build/plugins/resource/bot/resources/messages.js +0 -1
  199. package/build/plugins/resource/bot/resources/messages.js.map +1 -1
  200. package/build/plugins/resource/bot/resources/strings.d.ts +1 -1
  201. package/build/plugins/resource/bot/resources/strings.d.ts.map +1 -1
  202. package/build/plugins/resource/bot/resources/strings.js +1 -1
  203. package/build/plugins/resource/bot/resources/strings.js.map +1 -1
  204. package/build/plugins/resource/bot/utils/telemetry-helper.d.ts.map +1 -1
  205. package/build/plugins/resource/bot/utils/telemetry-helper.js +1 -1
  206. package/build/plugins/resource/bot/utils/telemetry-helper.js.map +1 -1
  207. package/build/plugins/resource/bot/v2/index.d.ts +9 -13
  208. package/build/plugins/resource/bot/v2/index.d.ts.map +1 -1
  209. package/build/plugins/resource/bot/v2/index.js +7 -7
  210. package/build/plugins/resource/bot/v2/index.js.map +1 -1
  211. package/build/plugins/resource/frontend/configs.d.ts +7 -2
  212. package/build/plugins/resource/frontend/configs.d.ts.map +1 -1
  213. package/build/plugins/resource/frontend/configs.js +49 -29
  214. package/build/plugins/resource/frontend/configs.js.map +1 -1
  215. package/build/plugins/resource/frontend/constants.d.ts +3 -2
  216. package/build/plugins/resource/frontend/constants.d.ts.map +1 -1
  217. package/build/plugins/resource/frontend/constants.js +4 -3
  218. package/build/plugins/resource/frontend/constants.js.map +1 -1
  219. package/build/plugins/resource/frontend/index.d.ts +1 -1
  220. package/build/plugins/resource/frontend/index.d.ts.map +1 -1
  221. package/build/plugins/resource/frontend/index.js +6 -5
  222. package/build/plugins/resource/frontend/index.js.map +1 -1
  223. package/build/plugins/resource/frontend/ops/deploy.d.ts.map +1 -1
  224. package/build/plugins/resource/frontend/ops/deploy.js +1 -0
  225. package/build/plugins/resource/frontend/ops/deploy.js.map +1 -1
  226. package/build/plugins/resource/frontend/plugin.d.ts +4 -1
  227. package/build/plugins/resource/frontend/plugin.d.ts.map +1 -1
  228. package/build/plugins/resource/frontend/plugin.js +32 -32
  229. package/build/plugins/resource/frontend/plugin.js.map +1 -1
  230. package/build/plugins/resource/frontend/resources/errors.d.ts +1 -1
  231. package/build/plugins/resource/frontend/resources/errors.d.ts.map +1 -1
  232. package/build/plugins/resource/frontend/resources/errors.js +5 -2
  233. package/build/plugins/resource/frontend/resources/errors.js.map +1 -1
  234. package/build/plugins/resource/frontend/utils/telemetry-helper.js +1 -1
  235. package/build/plugins/resource/frontend/utils/telemetry-helper.js.map +1 -1
  236. package/build/plugins/resource/frontend/v2/index.d.ts +6 -9
  237. package/build/plugins/resource/frontend/v2/index.d.ts.map +1 -1
  238. package/build/plugins/resource/frontend/v2/index.js +5 -2
  239. package/build/plugins/resource/frontend/v2/index.js.map +1 -1
  240. package/build/plugins/resource/function/constants.d.ts +2 -6
  241. package/build/plugins/resource/function/constants.d.ts.map +1 -1
  242. package/build/plugins/resource/function/constants.js +3 -8
  243. package/build/plugins/resource/function/constants.js.map +1 -1
  244. package/build/plugins/resource/function/enums.d.ts +2 -0
  245. package/build/plugins/resource/function/enums.d.ts.map +1 -1
  246. package/build/plugins/resource/function/enums.js +2 -0
  247. package/build/plugins/resource/function/enums.js.map +1 -1
  248. package/build/plugins/resource/function/index.d.ts +1 -0
  249. package/build/plugins/resource/function/index.d.ts.map +1 -1
  250. package/build/plugins/resource/function/index.js +1 -0
  251. package/build/plugins/resource/function/index.js.map +1 -1
  252. package/build/plugins/resource/function/ops/deploy.d.ts +1 -1
  253. package/build/plugins/resource/function/ops/deploy.d.ts.map +1 -1
  254. package/build/plugins/resource/function/ops/deploy.js +13 -5
  255. package/build/plugins/resource/function/ops/deploy.js.map +1 -1
  256. package/build/plugins/resource/function/ops/scaffold.d.ts +4 -7
  257. package/build/plugins/resource/function/ops/scaffold.d.ts.map +1 -1
  258. package/build/plugins/resource/function/ops/scaffold.js +42 -40
  259. package/build/plugins/resource/function/ops/scaffold.js.map +1 -1
  260. package/build/plugins/resource/function/plugin.d.ts +4 -0
  261. package/build/plugins/resource/function/plugin.d.ts.map +1 -1
  262. package/build/plugins/resource/function/plugin.js +57 -41
  263. package/build/plugins/resource/function/plugin.js.map +1 -1
  264. package/build/plugins/resource/function/resources/errors.d.ts +2 -5
  265. package/build/plugins/resource/function/resources/errors.d.ts.map +1 -1
  266. package/build/plugins/resource/function/resources/errors.js +5 -13
  267. package/build/plugins/resource/function/resources/errors.js.map +1 -1
  268. package/build/plugins/resource/function/resources/message.d.ts +1 -0
  269. package/build/plugins/resource/function/resources/message.d.ts.map +1 -1
  270. package/build/plugins/resource/function/resources/message.js +1 -0
  271. package/build/plugins/resource/function/resources/message.js.map +1 -1
  272. package/build/plugins/resource/function/utils/telemetry-helper.js +1 -1
  273. package/build/plugins/resource/function/utils/telemetry-helper.js.map +1 -1
  274. package/build/plugins/resource/function/v2/index.d.ts +8 -11
  275. package/build/plugins/resource/function/v2/index.d.ts.map +1 -1
  276. package/build/plugins/resource/function/v2/index.js +9 -17
  277. package/build/plugins/resource/function/v2/index.js.map +1 -1
  278. package/build/plugins/resource/identity/index.d.ts +1 -0
  279. package/build/plugins/resource/identity/index.d.ts.map +1 -1
  280. package/build/plugins/resource/identity/index.js +7 -9
  281. package/build/plugins/resource/identity/index.js.map +1 -1
  282. package/build/plugins/resource/identity/utils/contextUtils.js +1 -1
  283. package/build/plugins/resource/identity/utils/contextUtils.js.map +1 -1
  284. package/build/plugins/resource/identity/utils/telemetryUtil.d.ts.map +1 -1
  285. package/build/plugins/resource/identity/utils/telemetryUtil.js +1 -1
  286. package/build/plugins/resource/identity/utils/telemetryUtil.js.map +1 -1
  287. package/build/plugins/resource/identity/v2/index.d.ts +3 -3
  288. package/build/plugins/resource/identity/v2/index.d.ts.map +1 -1
  289. package/build/plugins/resource/identity/v2/index.js +2 -2
  290. package/build/plugins/resource/identity/v2/index.js.map +1 -1
  291. package/build/plugins/resource/localdebug/constants.d.ts +4 -0
  292. package/build/plugins/resource/localdebug/constants.d.ts.map +1 -1
  293. package/build/plugins/resource/localdebug/constants.js +6 -1
  294. package/build/plugins/resource/localdebug/constants.js.map +1 -1
  295. package/build/plugins/resource/localdebug/index.d.ts +1 -0
  296. package/build/plugins/resource/localdebug/index.d.ts.map +1 -1
  297. package/build/plugins/resource/localdebug/index.js +12 -6
  298. package/build/plugins/resource/localdebug/index.js.map +1 -1
  299. package/build/plugins/resource/localdebug/launch.d.ts +1 -0
  300. package/build/plugins/resource/localdebug/launch.d.ts.map +1 -1
  301. package/build/plugins/resource/localdebug/launch.js +66 -1
  302. package/build/plugins/resource/localdebug/launch.js.map +1 -1
  303. package/build/plugins/resource/localdebug/legacyPlugin.js +4 -4
  304. package/build/plugins/resource/localdebug/legacyPlugin.js.map +1 -1
  305. package/build/plugins/resource/localdebug/tasks.d.ts.map +1 -1
  306. package/build/plugins/resource/localdebug/tasks.js +12 -2
  307. package/build/plugins/resource/localdebug/tasks.js.map +1 -1
  308. package/build/plugins/resource/localdebug/util/telemetry.js +1 -1
  309. package/build/plugins/resource/localdebug/util/telemetry.js.map +1 -1
  310. package/build/plugins/resource/localdebug/v2/index.d.ts +6 -8
  311. package/build/plugins/resource/localdebug/v2/index.d.ts.map +1 -1
  312. package/build/plugins/resource/localdebug/v2/index.js +2 -2
  313. package/build/plugins/resource/localdebug/v2/index.js.map +1 -1
  314. package/build/plugins/resource/simpleauth/index.d.ts +1 -0
  315. package/build/plugins/resource/simpleauth/index.d.ts.map +1 -1
  316. package/build/plugins/resource/simpleauth/index.js +1 -0
  317. package/build/plugins/resource/simpleauth/index.js.map +1 -1
  318. package/build/plugins/resource/simpleauth/plugin.d.ts.map +1 -1
  319. package/build/plugins/resource/simpleauth/plugin.js +1 -6
  320. package/build/plugins/resource/simpleauth/plugin.js.map +1 -1
  321. package/build/plugins/resource/simpleauth/utils/common.js +1 -1
  322. package/build/plugins/resource/simpleauth/utils/common.js.map +1 -1
  323. package/build/plugins/resource/simpleauth/utils/telemetry.d.ts.map +1 -1
  324. package/build/plugins/resource/simpleauth/utils/telemetry.js +2 -1
  325. package/build/plugins/resource/simpleauth/utils/telemetry.js.map +1 -1
  326. package/build/plugins/resource/simpleauth/v2/index.d.ts +4 -4
  327. package/build/plugins/resource/simpleauth/v2/index.d.ts.map +1 -1
  328. package/build/plugins/resource/simpleauth/v2/index.js.map +1 -1
  329. package/build/plugins/resource/spfx/index.d.ts +1 -0
  330. package/build/plugins/resource/spfx/index.d.ts.map +1 -1
  331. package/build/plugins/resource/spfx/index.js +1 -0
  332. package/build/plugins/resource/spfx/index.js.map +1 -1
  333. package/build/plugins/resource/spfx/v2/index.d.ts +4 -8
  334. package/build/plugins/resource/spfx/v2/index.d.ts.map +1 -1
  335. package/build/plugins/resource/spfx/v2/index.js.map +1 -1
  336. package/build/plugins/resource/sql/config.d.ts +0 -1
  337. package/build/plugins/resource/sql/config.d.ts.map +1 -1
  338. package/build/plugins/resource/sql/config.js +0 -1
  339. package/build/plugins/resource/sql/config.js.map +1 -1
  340. package/build/plugins/resource/sql/errors.d.ts +4 -0
  341. package/build/plugins/resource/sql/errors.d.ts.map +1 -1
  342. package/build/plugins/resource/sql/errors.js +4 -0
  343. package/build/plugins/resource/sql/errors.js.map +1 -1
  344. package/build/plugins/resource/sql/index.d.ts +1 -0
  345. package/build/plugins/resource/sql/index.d.ts.map +1 -1
  346. package/build/plugins/resource/sql/index.js +1 -0
  347. package/build/plugins/resource/sql/index.js.map +1 -1
  348. package/build/plugins/resource/sql/plugin.d.ts +4 -0
  349. package/build/plugins/resource/sql/plugin.d.ts.map +1 -1
  350. package/build/plugins/resource/sql/plugin.js +68 -69
  351. package/build/plugins/resource/sql/plugin.js.map +1 -1
  352. package/build/plugins/resource/sql/utils/contextUtils.js +1 -1
  353. package/build/plugins/resource/sql/utils/contextUtils.js.map +1 -1
  354. package/build/plugins/resource/sql/utils/telemetryUtils.d.ts.map +1 -1
  355. package/build/plugins/resource/sql/utils/telemetryUtils.js +2 -1
  356. package/build/plugins/resource/sql/utils/telemetryUtils.js.map +1 -1
  357. package/build/plugins/resource/sql/v2/index.d.ts +5 -4
  358. package/build/plugins/resource/sql/v2/index.d.ts.map +1 -1
  359. package/build/plugins/resource/sql/v2/index.js +18 -16
  360. package/build/plugins/resource/sql/v2/index.js.map +1 -1
  361. package/build/plugins/resource/utils4v2.d.ts +16 -14
  362. package/build/plugins/resource/utils4v2.d.ts.map +1 -1
  363. package/build/plugins/resource/utils4v2.js +127 -92
  364. package/build/plugins/resource/utils4v2.js.map +1 -1
  365. package/build/plugins/solution/fx-solution/ResourcePluginContainer.d.ts.map +1 -1
  366. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js +4 -2
  367. package/build/plugins/solution/fx-solution/ResourcePluginContainer.js.map +1 -1
  368. package/build/plugins/solution/fx-solution/arm.d.ts +11 -0
  369. package/build/plugins/solution/fx-solution/arm.d.ts.map +1 -1
  370. package/build/plugins/solution/fx-solution/arm.js +118 -40
  371. package/build/plugins/solution/fx-solution/arm.js.map +1 -1
  372. package/build/plugins/solution/fx-solution/commonQuestions.d.ts +2 -2
  373. package/build/plugins/solution/fx-solution/commonQuestions.d.ts.map +1 -1
  374. package/build/plugins/solution/fx-solution/commonQuestions.js +120 -47
  375. package/build/plugins/solution/fx-solution/commonQuestions.js.map +1 -1
  376. package/build/plugins/solution/fx-solution/constants.d.ts +16 -2
  377. package/build/plugins/solution/fx-solution/constants.d.ts.map +1 -1
  378. package/build/plugins/solution/fx-solution/constants.js +15 -1
  379. package/build/plugins/solution/fx-solution/constants.js.map +1 -1
  380. package/build/plugins/solution/fx-solution/executor.d.ts.map +1 -1
  381. package/build/plugins/solution/fx-solution/executor.js +39 -21
  382. package/build/plugins/solution/fx-solution/executor.js.map +1 -1
  383. package/build/plugins/solution/fx-solution/index.d.ts +2 -0
  384. package/build/plugins/solution/fx-solution/index.d.ts.map +1 -1
  385. package/build/plugins/solution/fx-solution/index.js +2 -0
  386. package/build/plugins/solution/fx-solution/index.js.map +1 -1
  387. package/build/plugins/solution/fx-solution/question.d.ts +2 -1
  388. package/build/plugins/solution/fx-solution/question.d.ts.map +1 -1
  389. package/build/plugins/solution/fx-solution/question.js +18 -1
  390. package/build/plugins/solution/fx-solution/question.js.map +1 -1
  391. package/build/plugins/solution/fx-solution/solution.d.ts +3 -6
  392. package/build/plugins/solution/fx-solution/solution.d.ts.map +1 -1
  393. package/build/plugins/solution/fx-solution/solution.js +406 -379
  394. package/build/plugins/solution/fx-solution/solution.js.map +1 -1
  395. package/build/plugins/solution/fx-solution/utils/util.js +1 -1
  396. package/build/plugins/solution/fx-solution/utils/util.js.map +1 -1
  397. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts +3 -0
  398. package/build/plugins/solution/fx-solution/v2/adaptor.d.ts.map +1 -1
  399. package/build/plugins/solution/fx-solution/v2/adaptor.js +37 -3
  400. package/build/plugins/solution/fx-solution/v2/adaptor.js.map +1 -1
  401. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts +3 -0
  402. package/build/plugins/solution/fx-solution/v2/createEnv.d.ts.map +1 -0
  403. package/build/plugins/solution/fx-solution/v2/createEnv.js +28 -0
  404. package/build/plugins/solution/fx-solution/v2/createEnv.js.map +1 -0
  405. package/build/plugins/solution/fx-solution/v2/deploy.d.ts +2 -4
  406. package/build/plugins/solution/fx-solution/v2/deploy.d.ts.map +1 -1
  407. package/build/plugins/solution/fx-solution/v2/deploy.js +19 -14
  408. package/build/plugins/solution/fx-solution/v2/deploy.js.map +1 -1
  409. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts +2 -2
  410. package/build/plugins/solution/fx-solution/v2/executeUserTask.d.ts.map +1 -1
  411. package/build/plugins/solution/fx-solution/v2/executeUserTask.js +20 -4
  412. package/build/plugins/solution/fx-solution/v2/executeUserTask.js.map +1 -1
  413. package/build/plugins/solution/fx-solution/v2/executor.d.ts +2 -2
  414. package/build/plugins/solution/fx-solution/v2/executor.d.ts.map +1 -1
  415. package/build/plugins/solution/fx-solution/v2/executor.js +27 -3
  416. package/build/plugins/solution/fx-solution/v2/executor.js.map +1 -1
  417. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts +2 -2
  418. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.d.ts.map +1 -1
  419. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js +8 -2
  420. package/build/plugins/solution/fx-solution/v2/generateResourceTemplate.js.map +1 -1
  421. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts +8 -0
  422. package/build/plugins/solution/fx-solution/v2/getQuestions.d.ts.map +1 -0
  423. package/build/plugins/solution/fx-solution/v2/getQuestions.js +393 -0
  424. package/build/plugins/solution/fx-solution/v2/getQuestions.js.map +1 -0
  425. package/build/plugins/solution/fx-solution/v2/package.d.ts.map +1 -1
  426. package/build/plugins/solution/fx-solution/v2/package.js +12 -2
  427. package/build/plugins/solution/fx-solution/v2/package.js.map +1 -1
  428. package/build/plugins/solution/fx-solution/v2/provision.d.ts +4 -0
  429. package/build/plugins/solution/fx-solution/v2/provision.d.ts.map +1 -0
  430. package/build/plugins/solution/fx-solution/v2/provision.js +153 -0
  431. package/build/plugins/solution/fx-solution/v2/provision.js.map +1 -0
  432. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts +3 -0
  433. package/build/plugins/solution/fx-solution/v2/provisionLocal.d.ts.map +1 -0
  434. package/build/plugins/solution/fx-solution/v2/provisionLocal.js +73 -0
  435. package/build/plugins/solution/fx-solution/v2/provisionLocal.js.map +1 -0
  436. package/build/plugins/solution/fx-solution/v2/publish.d.ts +2 -2
  437. package/build/plugins/solution/fx-solution/v2/publish.d.ts.map +1 -1
  438. package/build/plugins/solution/fx-solution/v2/publish.js +11 -11
  439. package/build/plugins/solution/fx-solution/v2/publish.js.map +1 -1
  440. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts +3 -7
  441. package/build/plugins/solution/fx-solution/v2/scaffolding.d.ts.map +1 -1
  442. package/build/plugins/solution/fx-solution/v2/scaffolding.js +21 -6
  443. package/build/plugins/solution/fx-solution/v2/scaffolding.js.map +1 -1
  444. package/build/plugins/solution/fx-solution/v2/solution.d.ts +18 -0
  445. package/build/plugins/solution/fx-solution/v2/solution.d.ts.map +1 -0
  446. package/build/plugins/solution/fx-solution/v2/solution.js +38 -0
  447. package/build/plugins/solution/fx-solution/v2/solution.js.map +1 -0
  448. package/build/plugins/solution/fx-solution/v2/utils.d.ts +11 -9
  449. package/build/plugins/solution/fx-solution/v2/utils.d.ts.map +1 -1
  450. package/build/plugins/solution/fx-solution/v2/utils.js +81 -1
  451. package/build/plugins/solution/fx-solution/v2/utils.js.map +1 -1
  452. package/package.json +8 -5
  453. package/resource/strings.json +2 -1
  454. package/templates/plugins/resource/bot/bicep/botConfiguration.template.bicep +0 -4
  455. package/templates/plugins/resource/bot/bicep/botProvision.template.bicep +0 -6
  456. package/templates/plugins/resource/bot/bicep/module.template.bicep +0 -4
  457. package/templates/plugins/resource/bot/bicep/output.template.bicep +0 -2
  458. package/templates/plugins/resource/bot/bicep/param.template.bicep +0 -2
  459. package/templates/plugins/resource/bot/bot-msgext.js.default.zip +0 -0
  460. package/templates/plugins/resource/bot/bot-msgext.ts.default.zip +0 -0
  461. package/templates/plugins/resource/bot/bot.js.default.zip +0 -0
  462. package/templates/plugins/resource/bot/bot.ts.default.zip +0 -0
  463. package/templates/plugins/resource/bot/msgext.js.default.zip +0 -0
  464. package/templates/plugins/resource/bot/msgext.ts.default.zip +0 -0
  465. package/templates/plugins/resource/frontend/bicep/frontendHosting.bicep +1 -1
  466. package/templates/plugins/resource/frontend/bicep/output.template.bicep +1 -1
  467. package/templates/plugins/resource/frontend/tab.js.default.zip +0 -0
  468. package/templates/plugins/resource/frontend/tab.ts.default.zip +0 -0
  469. package/templates/plugins/resource/function/bicep/functionProvision.template.bicep +1 -3
  470. package/templates/plugins/resource/function/bicep/output.template.bicep +1 -3
  471. package/templates/plugins/resource/function/function-base.js.default.zip +0 -0
  472. package/templates/plugins/resource/function/function-base.ts.default.zip +0 -0
  473. package/templates/plugins/resource/function/function-triggers.js.HTTPTrigger.zip +0 -0
  474. package/templates/plugins/resource/function/function-triggers.ts.HTTPTrigger.zip +0 -0
  475. package/templates/plugins/resource/spfx/solution/manifest_multi_env.json +62 -0
  476. package/build/core/loader.d.ts +0 -11
  477. package/build/core/loader.d.ts.map +0 -1
  478. package/build/core/loader.js +0 -17
  479. package/build/core/loader.js.map +0 -1
  480. package/build/core/middleware/contextInjecter.d.ts +0 -3
  481. package/build/core/middleware/contextInjecter.d.ts.map +0 -1
  482. package/build/core/middleware/contextInjecter.js.map +0 -1
  483. package/build/plugins/resource/bot/enums/wayToRegisterBot.d.ts +0 -5
  484. package/build/plugins/resource/bot/enums/wayToRegisterBot.d.ts.map +0 -1
  485. package/build/plugins/resource/bot/enums/wayToRegisterBot.js +0 -11
  486. package/build/plugins/resource/bot/enums/wayToRegisterBot.js.map +0 -1
  487. package/build/plugins/resource/bot/questions.d.ts +0 -4
  488. package/build/plugins/resource/bot/questions.d.ts.map +0 -1
  489. package/build/plugins/resource/bot/questions.js +0 -65
  490. package/build/plugins/resource/bot/questions.js.map +0 -1
  491. package/build/plugins/resource/function/utils/templates-fetch.d.ts +0 -10
  492. package/build/plugins/resource/function/utils/templates-fetch.d.ts.map +0 -1
  493. package/build/plugins/resource/function/utils/templates-fetch.js +0 -107
  494. package/build/plugins/resource/function/utils/templates-fetch.js.map +0 -1
@@ -2,54 +2,80 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.FxCore = exports.currentStage = exports.telemetryReporter = exports.Logger = void 0;
5
+ exports.createV2Context = exports.newProjectSettings = exports.downloadSample = exports.createBasicFolderStructure = exports.FxCore = exports.TOOLS = exports.currentStage = exports.telemetryReporter = exports.Logger = exports.isV2 = void 0;
6
6
  const tslib_1 = require("tslib");
7
- const fs = tslib_1.__importStar(require("fs-extra"));
7
+ const hooks_1 = require("@feathersjs/hooks");
8
8
  const teamsfx_api_1 = require("@microsoft/teamsfx-api");
9
- const path = tslib_1.__importStar(require("path"));
10
- const tools_1 = require("../common/tools");
11
- const question_1 = require("./question");
12
- const jsonschema = tslib_1.__importStar(require("jsonschema"));
13
9
  const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
14
- const hooks_1 = require("@feathersjs/hooks");
15
- const errorHandler_1 = require("./middleware/errorHandler");
16
- const questionModel_1 = require("./middleware/questionModel");
17
- const projectSettingsWriter_1 = require("./middleware/projectSettingsWriter");
18
- const projectSettingsLoader_1 = require("./middleware/projectSettingsLoader");
19
- const concurrentLocker_1 = require("./middleware/concurrentLocker");
20
- const error_1 = require("./error");
21
- const solutionLoader_1 = require("./middleware/solutionLoader");
22
- const contextInjecter_1 = require("./middleware/contextInjecter");
23
- const loader_1 = require("./loader");
24
- const telemetry_1 = require("../common/telemetry");
10
+ const fs = tslib_1.__importStar(require("fs-extra"));
11
+ const jsonschema = tslib_1.__importStar(require("jsonschema"));
12
+ const path = tslib_1.__importStar(require("path"));
25
13
  const uuid = tslib_1.__importStar(require("uuid"));
26
- const projectUpgrader_1 = require("./middleware/projectUpgrader");
14
+ const __1 = require("..");
15
+ const constants_1 = require("../common/constants");
27
16
  const globalState_1 = require("../common/globalState");
17
+ const localSettingsProvider_1 = require("../common/localSettingsProvider");
18
+ const telemetry_1 = require("../common/telemetry");
19
+ const tools_1 = require("../common/tools");
20
+ const plugins_1 = require("../plugins");
21
+ const ResourcePluginContainer_1 = require("../plugins/solution/fx-solution/ResourcePluginContainer");
22
+ const callback_1 = require("./callback");
23
+ const error_1 = require("./error");
24
+ const concurrentLocker_1 = require("./middleware/concurrentLocker");
25
+ const contextInjector_1 = require("./middleware/contextInjector");
28
26
  const envInfoLoader_1 = require("./middleware/envInfoLoader");
29
27
  const envInfoWriter_1 = require("./middleware/envInfoWriter");
28
+ const errorHandler_1 = require("./middleware/errorHandler");
30
29
  const localSettingsLoader_1 = require("./middleware/localSettingsLoader");
31
30
  const localSettingsWriter_1 = require("./middleware/localSettingsWriter");
32
31
  const migrateConditionHandler_1 = require("./middleware/migrateConditionHandler");
33
- const __1 = require("..");
32
+ const projectMigrator_1 = require("./middleware/projectMigrator");
33
+ const projectSettingsLoader_1 = require("./middleware/projectSettingsLoader");
34
+ const projectSettingsWriter_1 = require("./middleware/projectSettingsWriter");
35
+ const projectUpgrader_1 = require("./middleware/projectUpgrader");
36
+ const questionModel_1 = require("./middleware/questionModel");
37
+ const solutionLoader_1 = require("./middleware/solutionLoader");
38
+ const question_1 = require("./question");
39
+ const SolutionPluginContainer_1 = require("./SolutionPluginContainer");
34
40
  const tools_2 = require("./tools");
35
- const arm_1 = require("../plugins/solution/fx-solution/arm");
36
- const crypto_1 = require("./crypto");
37
- const permissionRequest_1 = require("./permissionRequest");
41
+ // API V2 feature flag
42
+ function isV2() {
43
+ const flag = process.env[constants_1.FeatureFlagName.APIV2];
44
+ if (flag === undefined) {
45
+ return false;
46
+ }
47
+ else {
48
+ return flag === "1" || flag.toLowerCase() === "true";
49
+ }
50
+ }
51
+ exports.isV2 = isV2;
38
52
  class FxCore {
39
53
  constructor(tools) {
40
54
  this.tools = tools;
55
+ exports.TOOLS = tools;
41
56
  exports.Logger = tools.logProvider;
42
57
  exports.telemetryReporter = tools.telemetryReporter;
43
58
  }
59
+ /**
60
+ * @todo this's a really primitive implement. Maybe could use Subscription Model to
61
+ * refactor later.
62
+ */
63
+ on(event, callback) {
64
+ return callback_1.CallbackRegistry.set(event, callback);
65
+ }
44
66
  async createProject(inputs, ctx) {
67
+ if (!ctx) {
68
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("CoreHookContext"));
69
+ }
45
70
  exports.currentStage = teamsfx_api_1.Stage.create;
46
71
  const folder = inputs[question_1.QuestionRootFolder.name];
47
72
  const scratch = inputs[question_1.CoreQuestionNames.CreateFromScratch];
48
73
  let projectPath;
49
74
  let globalStateDescription = "openReadme";
75
+ const multiEnv = tools_1.isMultiEnvEnabled();
50
76
  if (scratch === question_1.ScratchOptionNo.id) {
51
77
  // create from sample
52
- const downloadRes = await this.downloadSample(inputs);
78
+ const downloadRes = await downloadSample(this, inputs);
53
79
  if (downloadRes.isErr()) {
54
80
  return teamsfx_api_1.err(downloadRes.error);
55
81
  }
@@ -68,46 +94,104 @@ class FxCore {
68
94
  return teamsfx_api_1.err(error_1.InvalidInputError(`${validateResult.errors[0].message}`, inputs));
69
95
  }
70
96
  projectPath = path.join(folder, appName);
97
+ inputs.projectPath = projectPath;
71
98
  const folderExist = await fs.pathExists(projectPath);
72
99
  if (folderExist) {
73
100
  return teamsfx_api_1.err(error_1.ProjectFolderExistError(projectPath));
74
101
  }
75
- inputs.projectPath = projectPath;
76
- const solution = await loader_1.defaultSolutionLoader.loadSolution(inputs);
102
+ await fs.ensureDir(projectPath);
103
+ await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
104
+ await fs.ensureDir(path.join(projectPath, multiEnv ? path.join("templates", `${teamsfx_api_1.AppPackageFolderName}`) : `${teamsfx_api_1.AppPackageFolderName}`));
105
+ const basicFolderRes = await createBasicFolderStructure(inputs);
106
+ if (basicFolderRes.isErr()) {
107
+ return teamsfx_api_1.err(basicFolderRes.error);
108
+ }
77
109
  const projectSettings = {
78
110
  appName: appName,
79
111
  projectId: uuid.v4(),
80
112
  solutionSettings: {
81
- name: solution.name,
113
+ name: "",
82
114
  version: "1.0.0",
83
115
  },
116
+ version: "1.0.0",
117
+ activeEnvironment: multiEnv ? __1.environmentManager.getDefaultEnvName() : "default",
84
118
  };
85
- const solutionContext = Object.assign(Object.assign(Object.assign({ projectSettings: projectSettings, envInfo: tools_2.newEnvInfo(), root: projectPath }, this.tools), this.tools.tokenProvider), { answers: inputs });
86
- await fs.ensureDir(projectPath);
87
- await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
88
- await fs.ensureDir(path.join(projectPath, tools_1.isMultiEnvEnabled()
89
- ? path.join("templates", `${teamsfx_api_1.AppPackageFolderName}`)
90
- : `${teamsfx_api_1.AppPackageFolderName}`));
91
- const createResult = await this.createBasicFolderStructure(inputs);
92
- if (createResult.isErr()) {
93
- return teamsfx_api_1.err(createResult.error);
94
- }
95
- const createRes = await solution.create(solutionContext);
96
- if (createRes.isErr()) {
97
- return createRes;
98
- }
99
- const scaffoldRes = await solution.scaffold(solutionContext);
100
- if (scaffoldRes.isErr()) {
101
- return scaffoldRes;
102
- }
103
- if (tools_1.isMultiEnvEnabled()) {
104
- const createEnvResult = await this.createEnvWithName(__1.environmentManager.getDefaultEnvName(), projectSettings, inputs, ctx.self);
119
+ ctx.projectSettings = projectSettings;
120
+ if (multiEnv) {
121
+ const createEnvResult = await this.createEnvWithName(__1.environmentManager.getDefaultEnvName(), projectSettings, inputs);
105
122
  if (createEnvResult.isErr()) {
106
123
  return teamsfx_api_1.err(createEnvResult.error);
107
124
  }
108
125
  }
109
- ctx.solution = solution;
110
- ctx.solutionContext = solutionContext;
126
+ if (isV2()) {
127
+ const solution = await SolutionPluginContainer_1.getSolutionPluginV2ByName(inputs[question_1.CoreQuestionNames.Solution]);
128
+ if (!solution) {
129
+ return teamsfx_api_1.err(new error_1.LoadSolutionError());
130
+ }
131
+ ctx.solutionV2 = solution;
132
+ projectSettings.solutionSettings.name = solution.name;
133
+ projectSettings.version = "2.0.0";
134
+ const contextV2 = createV2Context(this, projectSettings);
135
+ ctx.contextV2 = contextV2;
136
+ const scaffoldSourceCodeRes = await solution.scaffoldSourceCode(contextV2, inputs);
137
+ if (scaffoldSourceCodeRes.isErr()) {
138
+ return teamsfx_api_1.err(scaffoldSourceCodeRes.error);
139
+ }
140
+ const generateResourceTemplateRes = await solution.generateResourceTemplate(contextV2, inputs);
141
+ if (generateResourceTemplateRes.isErr()) {
142
+ return teamsfx_api_1.err(generateResourceTemplateRes.error);
143
+ }
144
+ // ctx.provisionInputConfig = generateResourceTemplateRes.value;
145
+ if (multiEnv) {
146
+ if (solution.createEnv) {
147
+ inputs.copy = false;
148
+ const createEnvRes = await solution.createEnv(contextV2, inputs);
149
+ if (createEnvRes.isErr()) {
150
+ return teamsfx_api_1.err(createEnvRes.error);
151
+ }
152
+ }
153
+ }
154
+ else {
155
+ //TODO lagacy env.default.json
156
+ const profile = { solution: {} };
157
+ for (const plugin of ResourcePluginContainer_1.getAllV2ResourcePlugins()) {
158
+ profile[plugin.name] = {};
159
+ }
160
+ profile[plugins_1.PluginNames.LDEBUG]["trustDevCert"] = "true";
161
+ ctx.envInfoV2 = {
162
+ envName: __1.environmentManager.getDefaultEnvName(),
163
+ config: {},
164
+ profile: profile,
165
+ };
166
+ }
167
+ }
168
+ else {
169
+ const solution = await SolutionPluginContainer_1.getSolutionPluginByName(inputs[question_1.CoreQuestionNames.Solution]);
170
+ if (!solution) {
171
+ return teamsfx_api_1.err(new error_1.LoadSolutionError());
172
+ }
173
+ ctx.solution = solution;
174
+ projectSettings.solutionSettings.name = solution.name;
175
+ const solutionContext = Object.assign(Object.assign(Object.assign({ projectSettings: projectSettings, envInfo: tools_2.newEnvInfo(), root: projectPath }, this.tools), this.tools.tokenProvider), { answers: inputs });
176
+ ctx.solutionContext = solutionContext;
177
+ const createRes = await solution.create(solutionContext);
178
+ if (createRes.isErr()) {
179
+ return createRes;
180
+ }
181
+ const scaffoldRes = await solution.scaffold(solutionContext);
182
+ if (scaffoldRes.isErr()) {
183
+ return scaffoldRes;
184
+ }
185
+ if (multiEnv) {
186
+ if (solution.createEnv) {
187
+ solutionContext.answers.copy = false;
188
+ const createEnvRes = await solution.createEnv(solutionContext);
189
+ if (createEnvRes.isErr()) {
190
+ return teamsfx_api_1.err(createEnvRes.error);
191
+ }
192
+ }
193
+ }
194
+ }
111
195
  }
112
196
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
113
197
  await globalState_1.globalStateUpdate(globalStateDescription, true);
@@ -131,7 +215,10 @@ class FxCore {
131
215
  if (!projectPath || !(await fs.pathExists(projectPath))) {
132
216
  return teamsfx_api_1.err(error_1.ProjectFolderNotExistError(projectPath !== null && projectPath !== void 0 ? projectPath : ""));
133
217
  }
134
- const solution = await loader_1.defaultSolutionLoader.loadSolution(inputs);
218
+ if (isV2()) {
219
+ return teamsfx_api_1.err(new error_1.NotImplementedError("migrateV1Project"));
220
+ }
221
+ const solution = await SolutionPluginContainer_1.getAllSolutionPlugins()[0];
135
222
  const projectSettings = {
136
223
  appName: appName,
137
224
  projectId: uuid.v4(),
@@ -145,7 +232,7 @@ class FxCore {
145
232
  await this.archive(projectPath);
146
233
  await fs.ensureDir(projectPath);
147
234
  await fs.ensureDir(path.join(projectPath, `.${teamsfx_api_1.ConfigFolderName}`));
148
- const createResult = await this.createBasicFolderStructure(inputs);
235
+ const createResult = await createBasicFolderStructure(inputs);
149
236
  if (createResult.isErr()) {
150
237
  return teamsfx_api_1.err(createResult.error);
151
238
  }
@@ -158,6 +245,7 @@ class FxCore {
158
245
  }
159
246
  ctx.solution = solution;
160
247
  ctx.solutionContext = solutionContext;
248
+ ctx.projectSettings = projectSettings;
161
249
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
162
250
  await globalState_1.globalStateUpdate(globalStateDescription, true);
163
251
  }
@@ -187,153 +275,186 @@ class FxCore {
187
275
  await archiveLog(projectPath, `'${fileName}' has been moved to '${teamsfx_api_1.ArchiveFolderName}' folder.`);
188
276
  }
189
277
  }
190
- async downloadSample(inputs) {
191
- const folder = inputs[question_1.QuestionRootFolder.name];
192
- const sample = inputs[question_1.CoreQuestionNames.Samples];
193
- if (sample && sample.data && folder) {
194
- const url = sample.data;
195
- const sampleId = sample.id;
196
- const sampleAppPath = path.resolve(folder, sampleId);
197
- if ((await fs.pathExists(sampleAppPath)) && (await fs.readdir(sampleAppPath)).length > 0) {
198
- return teamsfx_api_1.err(error_1.ProjectFolderExistError(sampleAppPath));
199
- }
200
- let fetchRes;
201
- const task1 = {
202
- name: `Download code from '${url}'`,
203
- run: async (...args) => {
204
- try {
205
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSampleStart, {
206
- [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
207
- module: "fx-core",
208
- });
209
- fetchRes = await tools_1.fetchCodeZip(url);
210
- if (fetchRes !== undefined) {
211
- telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, {
212
- [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
213
- [telemetry_1.TelemetryProperty.Success]: telemetry_1.TelemetrySuccess.Yes,
214
- module: "fx-core",
215
- });
216
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
217
- }
218
- else
219
- return teamsfx_api_1.err(error_1.FetchSampleError());
220
- }
221
- catch (e) {
222
- telemetry_1.sendTelemetryErrorEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, teamsfx_api_1.assembleError(e), {
223
- [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
224
- module: "fx-core",
225
- });
226
- return teamsfx_api_1.err(teamsfx_api_1.assembleError(e));
227
- }
228
- },
229
- };
230
- const task2 = {
231
- name: "Save and unzip package",
232
- run: async (...args) => {
233
- if (fetchRes) {
234
- await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.data), sampleId, folder);
235
- }
236
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
237
- },
238
- };
239
- const task3 = {
240
- name: "post process",
241
- run: async (...args) => {
242
- await tools_1.downloadSampleHook(sampleId, sampleAppPath);
243
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
244
- },
278
+ async provisionResources(inputs, ctx) {
279
+ exports.currentStage = teamsfx_api_1.Stage.provision;
280
+ if (isV2()) {
281
+ if (!ctx ||
282
+ !ctx.solutionV2 ||
283
+ !ctx.contextV2 ||
284
+ !ctx.provisionInputConfig ||
285
+ !ctx.contextV2.projectSetting.activeEnvironment ||
286
+ !ctx.provisionOutputs)
287
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Provision input stuff"));
288
+ const envInfo = {
289
+ envName: ctx.contextV2.projectSetting.activeEnvironment,
290
+ config: ctx.provisionInputConfig,
291
+ profile: ctx.provisionOutputs,
245
292
  };
246
- const group = new teamsfx_api_1.GroupOfTasks([task1, task2, task3], {
247
- sequential: true,
248
- fastFail: true,
249
- });
250
- const runRes = await this.tools.ui.runWithProgress(group, {
251
- showProgress: true,
252
- cancellable: false,
253
- });
254
- if (runRes.isOk()) {
255
- return teamsfx_api_1.ok(sampleAppPath);
293
+ const result = await ctx.solutionV2.provisionResources(ctx.contextV2, inputs, envInfo, this.tools.tokenProvider);
294
+ // todo(yefuwang): persist profile on success and partialSuccess
295
+ if (result.kind === "success") {
296
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
256
297
  }
257
298
  else {
258
- return teamsfx_api_1.err(runRes.error);
299
+ return teamsfx_api_1.err(result.error);
259
300
  }
260
301
  }
261
- return teamsfx_api_1.err(error_1.InvalidInputError(`invalid answer for '${question_1.CoreQuestionNames.Samples}'`, inputs));
262
- }
263
- async provisionResources(inputs, ctx) {
264
- exports.currentStage = teamsfx_api_1.Stage.provision;
265
- return await ctx.solution.provision(ctx.solutionContext);
302
+ else {
303
+ if (!ctx || !ctx.solution || !ctx.solutionContext)
304
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Provision input stuff"));
305
+ return await ctx.solution.provision(ctx.solutionContext);
306
+ }
266
307
  }
267
308
  async deployArtifacts(inputs, ctx) {
268
309
  exports.currentStage = teamsfx_api_1.Stage.deploy;
269
- return await ctx.solution.deploy(ctx.solutionContext);
310
+ if (isV2()) {
311
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.provisionOutputs)
312
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Deploy input stuff"));
313
+ if (ctx.solutionV2.deploy)
314
+ return await ctx.solutionV2.deploy(ctx.contextV2, inputs, ctx.provisionOutputs, this.tools.tokenProvider.azureAccountProvider);
315
+ else
316
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
317
+ }
318
+ else {
319
+ if (!ctx || !ctx.solution || !ctx.solutionContext)
320
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("Deploy input stuff"));
321
+ return await ctx.solution.deploy(ctx.solutionContext);
322
+ }
270
323
  }
271
324
  async localDebug(inputs, ctx) {
272
325
  exports.currentStage = teamsfx_api_1.Stage.debug;
273
- envInfoLoader_1.upgradeProgrammingLanguage(ctx.solutionContext.envInfo.profile, ctx.projectSettings);
274
- envInfoLoader_1.upgradeDefaultFunctionName(ctx.solutionContext.envInfo.profile, ctx.projectSettings);
275
- return await ctx.solution.localDebug(ctx.solutionContext);
326
+ if (isV2()) {
327
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.localSettings)
328
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("localDebug input stuff"));
329
+ if (ctx.solutionV2.provisionLocalResource) {
330
+ const res = await ctx.solutionV2.provisionLocalResource(ctx.contextV2, inputs, ctx.localSettings, this.tools.tokenProvider);
331
+ if (res.kind === "success") {
332
+ ctx.localSettings = res.output;
333
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
334
+ }
335
+ else if (res.kind === "partialSuccess") {
336
+ ctx.localSettings = res.output;
337
+ return teamsfx_api_1.err(res.error);
338
+ }
339
+ else {
340
+ return teamsfx_api_1.err(res.error);
341
+ }
342
+ }
343
+ else
344
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
345
+ }
346
+ else {
347
+ if (!ctx || !ctx.solution || !ctx.solutionContext || !ctx.projectSettings)
348
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("localDebug input stuff"));
349
+ envInfoLoader_1.upgradeProgrammingLanguage(ctx.solutionContext.envInfo.profile, ctx.projectSettings);
350
+ envInfoLoader_1.upgradeDefaultFunctionName(ctx.solutionContext.envInfo.profile, ctx.projectSettings);
351
+ return await ctx.solution.localDebug(ctx.solutionContext);
352
+ }
276
353
  }
277
354
  async publishApplication(inputs, ctx) {
278
355
  exports.currentStage = teamsfx_api_1.Stage.publish;
279
- return await ctx.solution.publish(ctx.solutionContext);
356
+ if (isV2()) {
357
+ if (!ctx || !ctx.solutionV2 || !ctx.contextV2 || !ctx.envInfoV2)
358
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("publish input stuff"));
359
+ return await ctx.solutionV2.publishApplication(ctx.contextV2, inputs, ctx.envInfoV2, this.tools.tokenProvider.appStudioToken);
360
+ }
361
+ else {
362
+ if (!ctx || !ctx.solution || !ctx.solutionContext)
363
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("publish input stuff"));
364
+ return await ctx.solution.publish(ctx.solutionContext);
365
+ }
280
366
  }
281
367
  async executeUserTask(func, inputs, ctx) {
282
368
  exports.currentStage = teamsfx_api_1.Stage.userTask;
283
- if (ctx.solutionContext === undefined)
284
- ctx.solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
285
- const solution = ctx.solution;
286
369
  const namespace = func.namespace;
287
370
  const array = namespace ? namespace.split("/") : [];
288
- if ("" !== namespace && array.length > 0 && solution.executeUserTask) {
289
- return await solution.executeUserTask(func, ctx.solutionContext);
371
+ if ("" !== namespace && array.length > 0) {
372
+ if (isV2()) {
373
+ if (!ctx || !ctx.solutionV2 || !ctx.envInfoV2)
374
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("executeUserTask input stuff"));
375
+ if (!ctx.contextV2)
376
+ ctx.contextV2 = createV2Context(this, newProjectSettings());
377
+ if (ctx.solutionV2.executeUserTask)
378
+ return await ctx.solutionV2.executeUserTask(ctx.contextV2, inputs, func, ctx.envInfoV2, this.tools.tokenProvider);
379
+ else
380
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
381
+ }
382
+ else {
383
+ if (!ctx || !ctx.solution)
384
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("executeUserTask input stuff"));
385
+ if (!ctx.solutionContext)
386
+ ctx.solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
387
+ if (ctx.solution.executeUserTask)
388
+ return await ctx.solution.executeUserTask(func, ctx.solutionContext);
389
+ else
390
+ return teamsfx_api_1.err(error_1.FunctionRouterError(func));
391
+ }
290
392
  }
291
393
  return teamsfx_api_1.err(error_1.FunctionRouterError(func));
292
394
  }
293
- async getQuestions(task, inputs, ctx) {
294
- if (task === teamsfx_api_1.Stage.create) {
395
+ async getQuestions(stage, inputs, ctx) {
396
+ if (!ctx)
397
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getQuestions input stuff"));
398
+ if (stage === teamsfx_api_1.Stage.create) {
295
399
  delete inputs.projectPath;
296
400
  return await this._getQuestionsForCreateProject(inputs);
297
401
  }
298
402
  else {
299
- const solutionContext = ctx.solutionContext === undefined
300
- ? await projectSettingsLoader_1.newSolutionContext(this.tools, inputs)
301
- : ctx.solutionContext;
302
- const solution = ctx.solution === undefined
303
- ? await loader_1.defaultSolutionLoader.loadSolution(inputs)
304
- : ctx.solution;
305
- return await this._getQuestions(solutionContext, solution, task, inputs);
403
+ if (isV2()) {
404
+ const contextV2 = ctx.contextV2
405
+ ? ctx.contextV2
406
+ : createV2Context(this, newProjectSettings());
407
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
408
+ const envInfoV2 = ctx.envInfoV2
409
+ ? ctx.envInfoV2
410
+ : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, profile: {} };
411
+ inputs.stage = stage;
412
+ return await this._getQuestions(contextV2, solutionV2, stage, inputs, envInfoV2);
413
+ }
414
+ else {
415
+ const solutionContext = ctx.solutionContext
416
+ ? ctx.solutionContext
417
+ : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
418
+ const solution = ctx.solution ? ctx.solution : SolutionPluginContainer_1.getAllSolutionPlugins()[0];
419
+ return await this._getQuestions(solutionContext, solution, stage, inputs);
420
+ }
306
421
  }
307
422
  }
308
423
  async getQuestionsForUserTask(func, inputs, ctx) {
309
- const solutionContext = ctx.solutionContext === undefined
310
- ? await projectSettingsLoader_1.newSolutionContext(this.tools, inputs)
311
- : ctx.solutionContext;
312
- const solution = ctx.solution === undefined
313
- ? await loader_1.defaultSolutionLoader.loadSolution(inputs)
314
- : ctx.solution;
315
- return await this._getQuestionsForUserTask(solutionContext, solution, func, inputs);
424
+ if (!ctx)
425
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("getQuestionsForUserTask input stuff"));
426
+ if (isV2()) {
427
+ const contextV2 = ctx.contextV2 ? ctx.contextV2 : createV2Context(this, newProjectSettings());
428
+ const solutionV2 = ctx.solutionV2 ? ctx.solutionV2 : await SolutionPluginContainer_1.getAllSolutionPluginsV2()[0];
429
+ const envInfoV2 = ctx.envInfoV2
430
+ ? ctx.envInfoV2
431
+ : { envName: __1.environmentManager.getDefaultEnvName(), config: {}, profile: {} };
432
+ return await this._getQuestionsForUserTask(contextV2, solutionV2, func, inputs, envInfoV2);
433
+ }
434
+ else {
435
+ const solutionContext = ctx.solutionContext
436
+ ? ctx.solutionContext
437
+ : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
438
+ const solution = ctx.solution ? ctx.solution : SolutionPluginContainer_1.getAllSolutionPlugins()[0];
439
+ return await this._getQuestionsForUserTask(solutionContext, solution, func, inputs);
440
+ }
316
441
  }
317
442
  async getProjectConfig(inputs, ctx) {
318
443
  var _a, _b;
319
- return teamsfx_api_1.ok({
320
- settings: ctx.projectSettings,
321
- config: (_a = ctx.solutionContext) === null || _a === void 0 ? void 0 : _a.envInfo.profile,
322
- localSettings: (_b = ctx.solutionContext) === null || _b === void 0 ? void 0 : _b.localSettings,
323
- });
324
- }
325
- async setSubscriptionInfo(inputs, ctx) {
326
- var _a, _b, _c, _d;
327
- const solutionContext = ctx.solutionContext;
328
- if (inputs.tenantId)
329
- (_a = solutionContext.envInfo.profile.get("solution")) === null || _a === void 0 ? void 0 : _a.set("tenantId", inputs.tenantId);
330
- else
331
- (_b = solutionContext.envInfo.profile.get("solution")) === null || _b === void 0 ? void 0 : _b.delete("tenantId");
332
- if (inputs.subscriptionId)
333
- (_c = solutionContext.envInfo.profile.get("solution")) === null || _c === void 0 ? void 0 : _c.set("subscriptionId", inputs.subscriptionId);
334
- else
335
- (_d = solutionContext.envInfo.profile.get("solution")) === null || _d === void 0 ? void 0 : _d.delete("subscriptionId");
336
- return teamsfx_api_1.ok(teamsfx_api_1.Void);
444
+ if (isV2()) {
445
+ return teamsfx_api_1.ok({
446
+ settings: ctx.projectSettings,
447
+ config: ctx.provisionOutputs,
448
+ localSettings: ctx.localSettings,
449
+ });
450
+ }
451
+ else {
452
+ return teamsfx_api_1.ok({
453
+ settings: ctx.projectSettings,
454
+ config: (_a = ctx.solutionContext) === null || _a === void 0 ? void 0 : _a.envInfo.profile,
455
+ localSettings: (_b = ctx.solutionContext) === null || _b === void 0 ? void 0 : _b.localSettings,
456
+ });
457
+ }
337
458
  }
338
459
  async grantPermission(inputs, ctx) {
339
460
  exports.currentStage = teamsfx_api_1.Stage.grantPermission;
@@ -347,12 +468,23 @@ class FxCore {
347
468
  exports.currentStage = teamsfx_api_1.Stage.listCollaborator;
348
469
  return await ctx.solution.listCollaborator(ctx.solutionContext);
349
470
  }
350
- async _getQuestionsForUserTask(ctx, solution, func, inputs) {
471
+ async _getQuestionsForUserTask(ctx, solution, func, inputs, envInfo) {
351
472
  const namespace = func.namespace;
352
473
  const array = namespace ? namespace.split("/") : [];
353
- if (namespace && "" !== namespace && array.length > 0 && solution.getQuestionsForUserTask) {
354
- ctx.answers = inputs;
355
- const res = await solution.getQuestionsForUserTask(func, ctx);
474
+ if (namespace && "" !== namespace && array.length > 0) {
475
+ let res = teamsfx_api_1.ok(undefined);
476
+ if (isV2()) {
477
+ const solutionV2 = solution;
478
+ if (solutionV2.getQuestionsForUserTask) {
479
+ res = await solutionV2.getQuestionsForUserTask(ctx, inputs, func, envInfo, this.tools.tokenProvider);
480
+ }
481
+ }
482
+ else {
483
+ const solutionv1 = solution;
484
+ if (solutionv1.getQuestionsForUserTask) {
485
+ res = await solutionv1.getQuestionsForUserTask(func, ctx);
486
+ }
487
+ }
356
488
  if (res.isOk()) {
357
489
  if (res.value) {
358
490
  const node = res.value.trim();
@@ -363,44 +495,9 @@ class FxCore {
363
495
  }
364
496
  return teamsfx_api_1.err(error_1.FunctionRouterError(func));
365
497
  }
366
- async _getQuestionsForCreateProject(inputs) {
367
- const node = new teamsfx_api_1.QTreeNode(question_1.getCreateNewOrFromSampleQuestion(inputs.platform));
368
- // create new
369
- const createNew = new teamsfx_api_1.QTreeNode({ type: "group" });
370
- node.addChild(createNew);
371
- createNew.condition = { equals: question_1.ScratchOptionYes.id };
372
- const globalSolutions = await loader_1.defaultSolutionLoader.loadGlobalSolutions(inputs);
373
- const solutionNames = globalSolutions.map((s) => s.name);
374
- const selectSolution = question_1.QuestionSelectSolution;
375
- selectSolution.staticOptions = solutionNames;
376
- const solutionSelectNode = new teamsfx_api_1.QTreeNode(selectSolution);
377
- createNew.addChild(solutionSelectNode);
378
- const solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
379
- for (const v of globalSolutions) {
380
- if (v.getQuestions) {
381
- const res = await v.getQuestions(teamsfx_api_1.Stage.create, solutionContext);
382
- if (res.isErr())
383
- return res;
384
- if (res.value) {
385
- const solutionNode = res.value;
386
- solutionNode.condition = { equals: v.name };
387
- if (solutionNode.data)
388
- solutionSelectNode.addChild(solutionNode);
389
- }
390
- }
391
- }
392
- createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
393
- createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionAppName));
394
- // create from sample
395
- const sampleNode = new teamsfx_api_1.QTreeNode(question_1.SampleSelect);
396
- node.addChild(sampleNode);
397
- sampleNode.condition = { equals: question_1.ScratchOptionNo.id };
398
- sampleNode.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
399
- return teamsfx_api_1.ok(node.trim());
400
- }
401
498
  async _getQuestionsForMigrateV1Project(inputs) {
402
499
  const node = new teamsfx_api_1.QTreeNode({ type: "group" });
403
- const globalSolutions = await loader_1.defaultSolutionLoader.loadGlobalSolutions(inputs);
500
+ const globalSolutions = await SolutionPluginContainer_1.getAllSolutionPlugins();
404
501
  const solutionContext = await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
405
502
  for (const v of globalSolutions) {
406
503
  if (v.getQuestions) {
@@ -424,42 +521,28 @@ class FxCore {
424
521
  defaultAppNameFunc.addChild(appNameQuestion);
425
522
  return teamsfx_api_1.ok(node.trim());
426
523
  }
427
- async _getQuestions(ctx, solution, stage, inputs) {
428
- const node = new teamsfx_api_1.QTreeNode({ type: "group" });
524
+ async _getQuestions(ctx, solution, stage, inputs, envInfo) {
429
525
  if (stage !== teamsfx_api_1.Stage.create) {
430
- const res = await solution.getQuestions(stage, ctx);
526
+ let res = teamsfx_api_1.ok(undefined);
527
+ if (isV2()) {
528
+ const solutionV2 = solution;
529
+ if (solutionV2.getQuestions) {
530
+ res = await solutionV2.getQuestions(ctx, inputs, envInfo, this.tools.tokenProvider);
531
+ }
532
+ }
533
+ else {
534
+ res = await solution.getQuestions(stage, ctx);
535
+ }
431
536
  if (res.isErr())
432
537
  return res;
433
538
  if (res.value) {
434
- const child = res.value;
435
- if (child.data)
436
- node.addChild(child);
539
+ const node = res.value;
540
+ if (node.data) {
541
+ return teamsfx_api_1.ok(node.trim());
542
+ }
437
543
  }
438
544
  }
439
- return teamsfx_api_1.ok(node.trim());
440
- }
441
- async createBasicFolderStructure(inputs) {
442
- try {
443
- const appName = inputs[question_1.QuestionAppName.name];
444
- await fs.writeFile(path.join(inputs.projectPath, `package.json`), JSON.stringify({
445
- name: appName,
446
- version: "0.0.1",
447
- description: "",
448
- author: "",
449
- scripts: {
450
- test: "echo \"Error: no test specified\" && exit 1",
451
- },
452
- devDependencies: {
453
- "@microsoft/teamsfx-cli": "0.*",
454
- },
455
- license: "MIT",
456
- }, null, 4));
457
- await fs.writeFile(path.join(inputs.projectPath, `.gitignore`), `node_modules\n/.${teamsfx_api_1.ConfigFolderName}/*.env\n/.${teamsfx_api_1.ConfigFolderName}/*.userdata\n.DS_Store\n${teamsfx_api_1.ArchiveFolderName}\n${teamsfx_api_1.ArchiveLogFileName}`);
458
- }
459
- catch (e) {
460
- return teamsfx_api_1.err(error_1.WriteFileError(e));
461
- }
462
- return teamsfx_api_1.ok(null);
545
+ return teamsfx_api_1.ok(undefined);
463
546
  }
464
547
  async encrypt(plaintext, inputs, ctx) {
465
548
  return ctx.solutionContext.cryptoProvider.encrypt(plaintext);
@@ -471,39 +554,71 @@ class FxCore {
471
554
  throw error_1.TaskNotSupportError(teamsfx_api_1.Stage.build);
472
555
  }
473
556
  async createEnv(inputs, ctx) {
557
+ if (!ctx)
558
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("createEnv input stuff"));
474
559
  const projectSettings = ctx.projectSettings;
475
560
  if (!tools_1.isMultiEnvEnabled() || !projectSettings) {
476
561
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
477
562
  }
478
563
  const core = ctx.self;
479
- const targetEnvName = await envInfoLoader_1.askNewEnvironment(ctx, inputs);
480
- if (!targetEnvName) {
564
+ const createEnvCopyInput = await envInfoLoader_1.askNewEnvironment(ctx, inputs);
565
+ if (!createEnvCopyInput ||
566
+ !createEnvCopyInput.targetEnvName ||
567
+ !createEnvCopyInput.sourceEnvName) {
481
568
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
482
569
  }
483
- if (targetEnvName) {
484
- const createEnvResult = await this.createEnvWithName(targetEnvName, projectSettings, inputs, core);
485
- if (createEnvResult.isErr()) {
486
- return createEnvResult;
570
+ const createEnvResult = await this.createEnvCopy(createEnvCopyInput.targetEnvName, createEnvCopyInput.sourceEnvName, projectSettings, inputs, core);
571
+ if (createEnvResult.isErr()) {
572
+ return createEnvResult;
573
+ }
574
+ inputs.sourceEnvName = createEnvCopyInput.sourceEnvName;
575
+ inputs.targetEnvName = createEnvCopyInput.targetEnvName;
576
+ if (isV2()) {
577
+ if (!ctx.solutionV2 || !ctx.contextV2)
578
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solutionV2, ctx.contextV2"));
579
+ if (ctx.solutionV2.createEnv) {
580
+ inputs.copy = true;
581
+ return await ctx.solutionV2.createEnv(ctx.contextV2, inputs);
582
+ }
583
+ }
584
+ else {
585
+ if (!ctx.solution || !ctx.solutionContext)
586
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("ctx.solution, ctx.solutionContext"));
587
+ if (ctx.solution.createEnv) {
588
+ ctx.solutionContext.answers.copy = true;
589
+ return await ctx.solution.createEnv(ctx.solutionContext);
487
590
  }
488
591
  }
489
592
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
490
593
  }
491
- async createEnvWithName(targetEnvName, projectSettings, inputs, core) {
492
- const newEnvConfig = __1.environmentManager.newEnvConfigData();
594
+ async createEnvWithName(targetEnvName, projectSettings, inputs) {
595
+ const appName = projectSettings.appName;
596
+ const newEnvConfig = __1.environmentManager.newEnvConfigData(appName);
493
597
  const writeEnvResult = await __1.environmentManager.writeEnvConfig(inputs.projectPath, newEnvConfig, targetEnvName);
494
598
  if (writeEnvResult.isErr()) {
495
599
  return teamsfx_api_1.err(writeEnvResult.error);
496
600
  }
497
- core.tools.logProvider.debug(`[core] persist ${targetEnvName} env profile to path ${writeEnvResult.value}: ${JSON.stringify(newEnvConfig)}`);
498
- if (tools_1.isArmSupportEnabled()) {
499
- const solutionContext = Object.assign(Object.assign(Object.assign({ projectSettings, envInfo: tools_2.newEnvInfo(targetEnvName), root: inputs.projectPath || "" }, core.tools), core.tools.tokenProvider), { answers: inputs, cryptoProvider: new crypto_1.LocalCrypto(projectSettings.projectId), permissionRequestProvider: inputs.projectPath
500
- ? new permissionRequest_1.PermissionRequestFileProvider(inputs.projectPath)
501
- : undefined });
502
- await arm_1.getParameterJson(solutionContext);
601
+ this.tools.logProvider.debug(`[core] persist ${targetEnvName} env profile to path ${writeEnvResult.value}: ${JSON.stringify(newEnvConfig)}`);
602
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
603
+ }
604
+ async createEnvCopy(targetEnvName, sourceEnvName, projectSettings, inputs, core) {
605
+ // copy env config file
606
+ const targetEnvConfigFilePath = __1.environmentManager.getEnvConfigPath(targetEnvName, inputs.projectPath);
607
+ const sourceEnvConfigFilePath = __1.environmentManager.getEnvConfigPath(sourceEnvName, inputs.projectPath);
608
+ try {
609
+ await fs.copy(sourceEnvConfigFilePath, targetEnvConfigFilePath);
610
+ }
611
+ catch (e) {
612
+ return teamsfx_api_1.err(error_1.CopyFileError(e));
503
613
  }
614
+ core.tools.logProvider.debug(`[core] copy env config file for ${targetEnvName} environment to path ${targetEnvConfigFilePath}`);
504
615
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
505
616
  }
506
- async activateEnv(env, inputs, ctx) {
617
+ async activateEnv(inputs, ctx) {
618
+ const env = inputs.env;
619
+ if (!env) {
620
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("env"));
621
+ }
507
622
  if (!tools_1.isMultiEnvEnabled() || !ctx.projectSettings) {
508
623
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
509
624
  }
@@ -511,32 +626,83 @@ class FxCore {
511
626
  if (envConfigs.isErr()) {
512
627
  return envConfigs;
513
628
  }
514
- if (envConfigs.isErr() && envConfigs.value.indexOf(env) < 0) {
629
+ if (envConfigs.isErr() || envConfigs.value.indexOf(env) < 0) {
515
630
  return teamsfx_api_1.err(error_1.NonExistEnvNameError(env));
516
631
  }
517
632
  ctx.projectSettings.activeEnvironment = env;
518
633
  const core = ctx.self;
519
634
  const solutionContext = await envInfoLoader_1.loadSolutionContext(core.tools, inputs, ctx.projectSettings, ctx.projectIdMissing, env);
520
635
  if (!solutionContext.isErr()) {
521
- ctx.solutionContext = solutionContext.value;
636
+ if (isV2()) {
637
+ //TODO core should not know the details of envInfo
638
+ ctx.provisionInputConfig = solutionContext.value.envInfo.config;
639
+ ctx.provisionOutputs = solutionContext.value.envInfo.profile;
640
+ ctx.envName = solutionContext.value.envInfo.envName;
641
+ }
642
+ else {
643
+ ctx.solutionContext = solutionContext.value;
644
+ }
522
645
  }
523
646
  this.tools.ui.showMessage("info", `[${env}] is activated.`, false);
524
647
  return teamsfx_api_1.ok(teamsfx_api_1.Void);
525
648
  }
526
- async removeEnv(inputs) {
527
- throw error_1.TaskNotSupportError(teamsfx_api_1.Stage.removeEnv);
528
- }
529
- async switchEnv(inputs) {
530
- throw error_1.TaskNotSupportError(teamsfx_api_1.Stage.switchEnv);
649
+ async _getQuestionsForCreateProject(inputs) {
650
+ const node = new teamsfx_api_1.QTreeNode(question_1.getCreateNewOrFromSampleQuestion(inputs.platform));
651
+ // create new
652
+ const createNew = new teamsfx_api_1.QTreeNode({ type: "group" });
653
+ node.addChild(createNew);
654
+ createNew.condition = { equals: question_1.ScratchOptionYes.id };
655
+ const globalSolutions = isV2()
656
+ ? await SolutionPluginContainer_1.getAllSolutionPluginsV2()
657
+ : await SolutionPluginContainer_1.getAllSolutionPlugins();
658
+ const solutionNames = globalSolutions.map((s) => s.name);
659
+ const selectSolution = question_1.QuestionSelectSolution;
660
+ selectSolution.staticOptions = solutionNames;
661
+ const solutionSelectNode = new teamsfx_api_1.QTreeNode(selectSolution);
662
+ createNew.addChild(solutionSelectNode);
663
+ const context = isV2()
664
+ ? createV2Context(this, newProjectSettings())
665
+ : await projectSettingsLoader_1.newSolutionContext(this.tools, inputs);
666
+ for (const solutionPlugin of globalSolutions) {
667
+ let res = teamsfx_api_1.ok(undefined);
668
+ if (isV2()) {
669
+ const v2plugin = solutionPlugin;
670
+ res = v2plugin.getQuestionsForScaffolding
671
+ ? await v2plugin.getQuestionsForScaffolding(context, inputs)
672
+ : teamsfx_api_1.ok(undefined);
673
+ }
674
+ else {
675
+ const v1plugin = solutionPlugin;
676
+ res = v1plugin.getQuestions
677
+ ? await v1plugin.getQuestions(teamsfx_api_1.Stage.create, context)
678
+ : teamsfx_api_1.ok(undefined);
679
+ }
680
+ if (res.isErr())
681
+ return res;
682
+ if (res.value) {
683
+ const solutionNode = res.value;
684
+ solutionNode.condition = { equals: solutionPlugin.name };
685
+ if (solutionNode.data)
686
+ solutionSelectNode.addChild(solutionNode);
687
+ }
688
+ }
689
+ createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
690
+ createNew.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionAppName));
691
+ // create from sample
692
+ const sampleNode = new teamsfx_api_1.QTreeNode(question_1.SampleSelect);
693
+ node.addChild(sampleNode);
694
+ sampleNode.condition = { equals: question_1.ScratchOptionNo.id };
695
+ sampleNode.addChild(new teamsfx_api_1.QTreeNode(question_1.QuestionRootFolder));
696
+ return teamsfx_api_1.ok(node.trim());
531
697
  }
532
698
  }
533
699
  tslib_1.__decorate([
534
700
  hooks_1.hooks([
535
701
  errorHandler_1.ErrorHandlerMW,
536
702
  questionModel_1.QuestionModelMW,
537
- contextInjecter_1.ContextInjecterMW,
703
+ contextInjector_1.ContextInjectorMW,
538
704
  projectSettingsWriter_1.ProjectSettingsWriterMW,
539
- envInfoWriter_1.EnvInfoWriterMW(tools_1.isMultiEnvEnabled()),
705
+ envInfoWriter_1.EnvInfoWriterMW(true),
540
706
  ]),
541
707
  tslib_1.__metadata("design:type", Function),
542
708
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
@@ -547,7 +713,7 @@ tslib_1.__decorate([
547
713
  errorHandler_1.ErrorHandlerMW,
548
714
  migrateConditionHandler_1.MigrateConditionHandlerMW,
549
715
  questionModel_1.QuestionModelMW,
550
- contextInjecter_1.ContextInjecterMW,
716
+ contextInjector_1.ContextInjectorMW,
551
717
  projectSettingsWriter_1.ProjectSettingsWriterMW,
552
718
  envInfoWriter_1.EnvInfoWriterMW(),
553
719
  ]),
@@ -559,11 +725,12 @@ tslib_1.__decorate([
559
725
  hooks_1.hooks([
560
726
  errorHandler_1.ErrorHandlerMW,
561
727
  concurrentLocker_1.ConcurrentLockerMW,
728
+ projectMigrator_1.ProjectMigratorMW,
562
729
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
563
730
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
564
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
731
+ solutionLoader_1.SolutionLoaderMW(),
565
732
  questionModel_1.QuestionModelMW,
566
- contextInjecter_1.ContextInjecterMW,
733
+ contextInjector_1.ContextInjectorMW,
567
734
  projectSettingsWriter_1.ProjectSettingsWriterMW,
568
735
  envInfoWriter_1.EnvInfoWriterMW(),
569
736
  ]),
@@ -575,11 +742,12 @@ tslib_1.__decorate([
575
742
  hooks_1.hooks([
576
743
  errorHandler_1.ErrorHandlerMW,
577
744
  concurrentLocker_1.ConcurrentLockerMW,
745
+ projectMigrator_1.ProjectMigratorMW,
578
746
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
579
747
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
580
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
748
+ solutionLoader_1.SolutionLoaderMW(),
581
749
  questionModel_1.QuestionModelMW,
582
- contextInjecter_1.ContextInjecterMW,
750
+ contextInjector_1.ContextInjectorMW,
583
751
  projectSettingsWriter_1.ProjectSettingsWriterMW,
584
752
  envInfoWriter_1.EnvInfoWriterMW(),
585
753
  ]),
@@ -591,13 +759,14 @@ tslib_1.__decorate([
591
759
  hooks_1.hooks([
592
760
  errorHandler_1.ErrorHandlerMW,
593
761
  concurrentLocker_1.ConcurrentLockerMW,
762
+ projectMigrator_1.ProjectMigratorMW,
594
763
  projectUpgrader_1.ProjectUpgraderMW,
595
764
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
596
765
  envInfoLoader_1.EnvInfoLoaderMW(false),
597
766
  localSettingsLoader_1.LocalSettingsLoaderMW,
598
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
767
+ solutionLoader_1.SolutionLoaderMW(),
599
768
  questionModel_1.QuestionModelMW,
600
- contextInjecter_1.ContextInjecterMW,
769
+ contextInjector_1.ContextInjectorMW,
601
770
  projectSettingsWriter_1.ProjectSettingsWriterMW,
602
771
  envInfoWriter_1.EnvInfoWriterMW(),
603
772
  localSettingsWriter_1.LocalSettingsWriterMW,
@@ -610,11 +779,12 @@ tslib_1.__decorate([
610
779
  hooks_1.hooks([
611
780
  errorHandler_1.ErrorHandlerMW,
612
781
  concurrentLocker_1.ConcurrentLockerMW,
782
+ projectMigrator_1.ProjectMigratorMW,
613
783
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
614
784
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
615
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
785
+ solutionLoader_1.SolutionLoaderMW(),
616
786
  questionModel_1.QuestionModelMW,
617
- contextInjecter_1.ContextInjecterMW,
787
+ contextInjector_1.ContextInjectorMW,
618
788
  projectSettingsWriter_1.ProjectSettingsWriterMW,
619
789
  envInfoWriter_1.EnvInfoWriterMW(),
620
790
  ]),
@@ -626,12 +796,13 @@ tslib_1.__decorate([
626
796
  hooks_1.hooks([
627
797
  errorHandler_1.ErrorHandlerMW,
628
798
  concurrentLocker_1.ConcurrentLockerMW,
799
+ projectMigrator_1.ProjectMigratorMW,
629
800
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
630
801
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
631
802
  localSettingsLoader_1.LocalSettingsLoaderMW,
632
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
803
+ solutionLoader_1.SolutionLoaderMW(),
633
804
  questionModel_1.QuestionModelMW,
634
- contextInjecter_1.ContextInjecterMW,
805
+ contextInjector_1.ContextInjectorMW,
635
806
  projectSettingsWriter_1.ProjectSettingsWriterMW,
636
807
  envInfoWriter_1.EnvInfoWriterMW(),
637
808
  localSettingsWriter_1.LocalSettingsWriterMW,
@@ -645,8 +816,8 @@ tslib_1.__decorate([
645
816
  errorHandler_1.ErrorHandlerMW,
646
817
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
647
818
  envInfoLoader_1.EnvInfoLoaderMW(false),
648
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
649
- contextInjecter_1.ContextInjecterMW,
819
+ solutionLoader_1.SolutionLoaderMW(),
820
+ contextInjector_1.ContextInjectorMW,
650
821
  envInfoWriter_1.EnvInfoWriterMW(),
651
822
  ]),
652
823
  tslib_1.__metadata("design:type", Function),
@@ -658,8 +829,8 @@ tslib_1.__decorate([
658
829
  errorHandler_1.ErrorHandlerMW,
659
830
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
660
831
  envInfoLoader_1.EnvInfoLoaderMW(false),
661
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
662
- contextInjecter_1.ContextInjecterMW,
832
+ solutionLoader_1.SolutionLoaderMW(),
833
+ contextInjector_1.ContextInjectorMW,
663
834
  envInfoWriter_1.EnvInfoWriterMW(),
664
835
  ]),
665
836
  tslib_1.__metadata("design:type", Function),
@@ -669,10 +840,12 @@ tslib_1.__decorate([
669
840
  tslib_1.__decorate([
670
841
  hooks_1.hooks([
671
842
  errorHandler_1.ErrorHandlerMW,
843
+ concurrentLocker_1.ConcurrentLockerMW,
844
+ projectMigrator_1.ProjectMigratorMW,
672
845
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
673
846
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
674
847
  localSettingsLoader_1.LocalSettingsLoaderMW,
675
- contextInjecter_1.ContextInjecterMW,
848
+ contextInjector_1.ContextInjectorMW,
676
849
  ]),
677
850
  tslib_1.__metadata("design:type", Function),
678
851
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
@@ -681,27 +854,12 @@ tslib_1.__decorate([
681
854
  tslib_1.__decorate([
682
855
  hooks_1.hooks([
683
856
  errorHandler_1.ErrorHandlerMW,
684
- projectSettingsLoader_1.ProjectSettingsLoaderMW,
685
- envInfoLoader_1.EnvInfoLoaderMW(false),
686
- contextInjecter_1.ContextInjecterMW,
687
- projectSettingsWriter_1.ProjectSettingsWriterMW,
688
- envInfoWriter_1.EnvInfoWriterMW(),
689
- ]),
690
- tslib_1.__metadata("design:type", Function),
691
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
692
- tslib_1.__metadata("design:returntype", Promise)
693
- ], FxCore.prototype, "setSubscriptionInfo", null);
694
- tslib_1.__decorate([
695
- hooks_1.hooks([
696
- errorHandler_1.ErrorHandlerMW,
697
- concurrentLocker_1.ConcurrentLockerMW,
857
+ projectMigrator_1.ProjectMigratorMW,
698
858
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
699
859
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
700
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
860
+ solutionLoader_1.SolutionLoaderMW(),
701
861
  questionModel_1.QuestionModelMW,
702
- contextInjecter_1.ContextInjecterMW,
703
- projectSettingsWriter_1.ProjectSettingsWriterMW,
704
- envInfoWriter_1.EnvInfoWriterMW(),
862
+ contextInjector_1.ContextInjectorMW,
705
863
  ]),
706
864
  tslib_1.__metadata("design:type", Function),
707
865
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
@@ -710,14 +868,12 @@ tslib_1.__decorate([
710
868
  tslib_1.__decorate([
711
869
  hooks_1.hooks([
712
870
  errorHandler_1.ErrorHandlerMW,
713
- concurrentLocker_1.ConcurrentLockerMW,
871
+ projectMigrator_1.ProjectMigratorMW,
714
872
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
715
873
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
716
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
874
+ solutionLoader_1.SolutionLoaderMW(),
717
875
  questionModel_1.QuestionModelMW,
718
- contextInjecter_1.ContextInjecterMW,
719
- projectSettingsWriter_1.ProjectSettingsWriterMW,
720
- envInfoWriter_1.EnvInfoWriterMW(),
876
+ contextInjector_1.ContextInjectorMW,
721
877
  ]),
722
878
  tslib_1.__metadata("design:type", Function),
723
879
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
@@ -726,14 +882,12 @@ tslib_1.__decorate([
726
882
  tslib_1.__decorate([
727
883
  hooks_1.hooks([
728
884
  errorHandler_1.ErrorHandlerMW,
729
- concurrentLocker_1.ConcurrentLockerMW,
885
+ projectMigrator_1.ProjectMigratorMW,
730
886
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
731
887
  envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
732
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
888
+ solutionLoader_1.SolutionLoaderMW(),
733
889
  questionModel_1.QuestionModelMW,
734
- contextInjecter_1.ContextInjecterMW,
735
- projectSettingsWriter_1.ProjectSettingsWriterMW,
736
- envInfoWriter_1.EnvInfoWriterMW(),
890
+ contextInjector_1.ContextInjectorMW,
737
891
  ]),
738
892
  tslib_1.__metadata("design:type", Function),
739
893
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
@@ -744,7 +898,7 @@ tslib_1.__decorate([
744
898
  errorHandler_1.ErrorHandlerMW,
745
899
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
746
900
  envInfoLoader_1.EnvInfoLoaderMW(false),
747
- contextInjecter_1.ContextInjecterMW,
901
+ contextInjector_1.ContextInjectorMW,
748
902
  envInfoWriter_1.EnvInfoWriterMW(),
749
903
  ]),
750
904
  tslib_1.__metadata("design:type", Function),
@@ -756,7 +910,7 @@ tslib_1.__decorate([
756
910
  errorHandler_1.ErrorHandlerMW,
757
911
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
758
912
  envInfoLoader_1.EnvInfoLoaderMW(false),
759
- contextInjecter_1.ContextInjecterMW,
913
+ contextInjector_1.ContextInjectorMW,
760
914
  envInfoWriter_1.EnvInfoWriterMW(),
761
915
  ]),
762
916
  tslib_1.__metadata("design:type", Function),
@@ -764,7 +918,13 @@ tslib_1.__decorate([
764
918
  tslib_1.__metadata("design:returntype", Promise)
765
919
  ], FxCore.prototype, "decrypt", null);
766
920
  tslib_1.__decorate([
767
- hooks_1.hooks([errorHandler_1.ErrorHandlerMW, projectSettingsLoader_1.ProjectSettingsLoaderMW, contextInjecter_1.ContextInjecterMW]),
921
+ hooks_1.hooks([
922
+ errorHandler_1.ErrorHandlerMW,
923
+ projectSettingsLoader_1.ProjectSettingsLoaderMW,
924
+ solutionLoader_1.SolutionLoaderMW(),
925
+ envInfoLoader_1.EnvInfoLoaderMW(tools_1.isMultiEnvEnabled()),
926
+ contextInjector_1.ContextInjectorMW,
927
+ ]),
768
928
  tslib_1.__metadata("design:type", Function),
769
929
  tslib_1.__metadata("design:paramtypes", [Object, Object]),
770
930
  tslib_1.__metadata("design:returntype", Promise)
@@ -772,16 +932,151 @@ tslib_1.__decorate([
772
932
  tslib_1.__decorate([
773
933
  hooks_1.hooks([
774
934
  errorHandler_1.ErrorHandlerMW,
935
+ projectMigrator_1.ProjectMigratorMW,
775
936
  projectSettingsLoader_1.ProjectSettingsLoaderMW,
776
- solutionLoader_1.SolutionLoaderMW(loader_1.defaultSolutionLoader),
777
- contextInjecter_1.ContextInjecterMW,
937
+ solutionLoader_1.SolutionLoaderMW(),
938
+ contextInjector_1.ContextInjectorMW,
778
939
  projectSettingsWriter_1.ProjectSettingsWriterMW,
779
940
  ]),
780
941
  tslib_1.__metadata("design:type", Function),
781
- tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
942
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
782
943
  tslib_1.__metadata("design:returntype", Promise)
783
944
  ], FxCore.prototype, "activateEnv", null);
784
945
  exports.FxCore = FxCore;
946
+ async function createBasicFolderStructure(inputs) {
947
+ if (!inputs.projectPath) {
948
+ return teamsfx_api_1.err(new error_1.ObjectIsUndefinedError("projectPath"));
949
+ }
950
+ try {
951
+ const appName = inputs[question_1.QuestionAppName.name];
952
+ await fs.writeFile(path.join(inputs.projectPath, `package.json`), JSON.stringify({
953
+ name: appName,
954
+ version: "0.0.1",
955
+ description: "",
956
+ author: "",
957
+ scripts: {
958
+ test: 'echo "Error: no test specified" && exit 1',
959
+ },
960
+ devDependencies: {
961
+ "@microsoft/teamsfx-cli": "0.*",
962
+ },
963
+ license: "MIT",
964
+ }, null, 4));
965
+ await fs.writeFile(path.join(inputs.projectPath, `.gitignore`), tools_1.isMultiEnvEnabled()
966
+ ? [
967
+ "node_modules",
968
+ `.${teamsfx_api_1.ConfigFolderName}/${teamsfx_api_1.InputConfigsFolderName}/${localSettingsProvider_1.localSettingsFileName}`,
969
+ `.${teamsfx_api_1.ConfigFolderName}/${teamsfx_api_1.PublishProfilesFolderName}/*.userdata`,
970
+ ".DS_Store",
971
+ `${teamsfx_api_1.ArchiveFolderName}`,
972
+ `${teamsfx_api_1.ArchiveLogFileName}`,
973
+ ].join("\n")
974
+ : `node_modules\n/.${teamsfx_api_1.ConfigFolderName}/*.env\n/.${teamsfx_api_1.ConfigFolderName}/*.userdata\n.DS_Store\n${teamsfx_api_1.ArchiveFolderName}\n${teamsfx_api_1.ArchiveLogFileName}`);
975
+ }
976
+ catch (e) {
977
+ return teamsfx_api_1.err(error_1.WriteFileError(e));
978
+ }
979
+ return teamsfx_api_1.ok(null);
980
+ }
981
+ exports.createBasicFolderStructure = createBasicFolderStructure;
982
+ async function downloadSample(fxcore, inputs) {
983
+ const folder = inputs[question_1.QuestionRootFolder.name];
984
+ const sample = inputs[question_1.CoreQuestionNames.Samples];
985
+ if (sample && sample.data && folder) {
986
+ const url = sample.data;
987
+ const sampleId = sample.id;
988
+ const sampleAppPath = path.resolve(folder, sampleId);
989
+ if ((await fs.pathExists(sampleAppPath)) && (await fs.readdir(sampleAppPath)).length > 0) {
990
+ return teamsfx_api_1.err(error_1.ProjectFolderExistError(sampleAppPath));
991
+ }
992
+ let fetchRes;
993
+ const task1 = {
994
+ name: `Download code from '${url}'`,
995
+ run: async (...args) => {
996
+ try {
997
+ telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSampleStart, {
998
+ [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
999
+ module: "fx-core",
1000
+ });
1001
+ fetchRes = await tools_1.fetchCodeZip(url);
1002
+ if (fetchRes !== undefined) {
1003
+ telemetry_1.sendTelemetryEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, {
1004
+ [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
1005
+ [telemetry_1.TelemetryProperty.Success]: telemetry_1.TelemetrySuccess.Yes,
1006
+ module: "fx-core",
1007
+ });
1008
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
1009
+ }
1010
+ else
1011
+ return teamsfx_api_1.err(error_1.FetchSampleError());
1012
+ }
1013
+ catch (e) {
1014
+ telemetry_1.sendTelemetryErrorEvent(telemetry_1.Component.core, telemetry_1.TelemetryEvent.DownloadSample, teamsfx_api_1.assembleError(e), {
1015
+ [telemetry_1.TelemetryProperty.SampleAppName]: sample.id,
1016
+ module: "fx-core",
1017
+ });
1018
+ return teamsfx_api_1.err(teamsfx_api_1.assembleError(e));
1019
+ }
1020
+ },
1021
+ };
1022
+ const task2 = {
1023
+ name: "Save and unzip package",
1024
+ run: async (...args) => {
1025
+ if (fetchRes) {
1026
+ await tools_1.saveFilesRecursively(new adm_zip_1.default(fetchRes.data), sampleId, folder);
1027
+ }
1028
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
1029
+ },
1030
+ };
1031
+ const task3 = {
1032
+ name: "post process",
1033
+ run: async (...args) => {
1034
+ await tools_1.downloadSampleHook(sampleId, sampleAppPath);
1035
+ return teamsfx_api_1.ok(teamsfx_api_1.Void);
1036
+ },
1037
+ };
1038
+ const group = new teamsfx_api_1.GroupOfTasks([task1, task2, task3], {
1039
+ sequential: true,
1040
+ fastFail: true,
1041
+ });
1042
+ const runRes = await fxcore.tools.ui.runWithProgress(group, {
1043
+ showProgress: true,
1044
+ cancellable: false,
1045
+ });
1046
+ if (runRes.isOk()) {
1047
+ return teamsfx_api_1.ok(sampleAppPath);
1048
+ }
1049
+ else {
1050
+ return teamsfx_api_1.err(runRes.error);
1051
+ }
1052
+ }
1053
+ return teamsfx_api_1.err(error_1.InvalidInputError(`invalid answer for '${question_1.CoreQuestionNames.Samples}'`, inputs));
1054
+ }
1055
+ exports.downloadSample = downloadSample;
1056
+ function newProjectSettings() {
1057
+ const projectSettings = {
1058
+ appName: "",
1059
+ projectId: uuid.v4(),
1060
+ version: "2.0.0",
1061
+ solutionSettings: {
1062
+ name: "",
1063
+ },
1064
+ };
1065
+ return projectSettings;
1066
+ }
1067
+ exports.newProjectSettings = newProjectSettings;
1068
+ function createV2Context(core, projectSettings) {
1069
+ const context = {
1070
+ userInteraction: core.tools.ui,
1071
+ logProvider: core.tools.logProvider,
1072
+ telemetryReporter: core.tools.telemetryReporter,
1073
+ cryptoProvider: core.tools.cryptoProvider,
1074
+ permissionRequestProvider: core.tools.permissionRequest,
1075
+ projectSetting: projectSettings,
1076
+ };
1077
+ return context;
1078
+ }
1079
+ exports.createV2Context = createV2Context;
785
1080
  tslib_1.__exportStar(require("./error"), exports);
786
1081
  tslib_1.__exportStar(require("./tools"), exports);
787
1082
  //# sourceMappingURL=index.js.map