@microsoft/teamsfx-core 1.21.1 → 1.22.0-rc.1

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 (169) hide show
  1. package/build/common/m365/packageService.d.ts +13 -0
  2. package/build/common/m365/packageService.d.ts.map +1 -0
  3. package/build/common/m365/packageService.js +209 -0
  4. package/build/common/m365/packageService.js.map +1 -0
  5. package/build/common/m365/serviceConstant.d.ts +3 -0
  6. package/build/common/m365/serviceConstant.d.ts.map +1 -0
  7. package/build/common/m365/serviceConstant.js +8 -0
  8. package/build/common/m365/serviceConstant.js.map +1 -0
  9. package/build/common/templates-config.json +4 -2
  10. package/build/common/versionMetadata.d.ts +12 -3
  11. package/build/common/versionMetadata.d.ts.map +1 -1
  12. package/build/common/versionMetadata.js +12 -5
  13. package/build/common/versionMetadata.js.map +1 -1
  14. package/build/component/constant/deployConstant.d.ts +7 -0
  15. package/build/component/constant/deployConstant.d.ts.map +1 -1
  16. package/build/component/constant/deployConstant.js +9 -1
  17. package/build/component/constant/deployConstant.js.map +1 -1
  18. package/build/component/coordinator/index.d.ts.map +1 -1
  19. package/build/component/coordinator/index.js +0 -16
  20. package/build/component/coordinator/index.js.map +1 -1
  21. package/build/component/core.js +1 -1
  22. package/build/component/core.js.map +1 -1
  23. package/build/component/driver/botFramework/createOrUpdateBot.d.ts.map +1 -1
  24. package/build/component/driver/botFramework/createOrUpdateBot.js +40 -1
  25. package/build/component/driver/botFramework/createOrUpdateBot.js.map +1 -1
  26. package/build/component/driver/botFramework/interface/createOrUpdateBotFrameworkBotArgs.d.ts +7 -0
  27. package/build/component/driver/botFramework/interface/createOrUpdateBotFrameworkBotArgs.d.ts.map +1 -1
  28. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js +1 -1
  29. package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js.map +1 -1
  30. package/build/component/driver/deploy/azure/azureDeployDriver.d.ts +2 -2
  31. package/build/component/driver/deploy/azure/azureDeployDriver.d.ts.map +1 -1
  32. package/build/component/driver/deploy/azure/azureDeployDriver.js +26 -5
  33. package/build/component/driver/deploy/azure/azureDeployDriver.js.map +1 -1
  34. package/build/component/driver/interface/buildAndDeployArgs.d.ts +16 -0
  35. package/build/component/driver/interface/buildAndDeployArgs.d.ts.map +1 -1
  36. package/build/component/error/deployError.d.ts +1 -0
  37. package/build/component/error/deployError.d.ts.map +1 -1
  38. package/build/component/error/deployError.js +3 -0
  39. package/build/component/error/deployError.js.map +1 -1
  40. package/build/component/middleware/questionMW.d.ts +4 -0
  41. package/build/component/middleware/questionMW.d.ts.map +1 -0
  42. package/build/component/middleware/questionMW.js +26 -0
  43. package/build/component/middleware/questionMW.js.map +1 -0
  44. package/build/component/question.d.ts +1 -1
  45. package/build/component/question.d.ts.map +1 -1
  46. package/build/component/question.js +1 -1
  47. package/build/component/question.js.map +1 -1
  48. package/build/component/resource/appManifest/appStudio.d.ts.map +1 -1
  49. package/build/component/resource/appManifest/appStudio.js +16 -2
  50. package/build/component/resource/appManifest/appStudio.js.map +1 -1
  51. package/build/component/resource/appManifest/appStudioClient.d.ts.map +1 -1
  52. package/build/component/resource/appManifest/appStudioClient.js +1 -3
  53. package/build/component/resource/appManifest/appStudioClient.js.map +1 -1
  54. package/build/component/resource/appManifest/constants.d.ts +1 -1
  55. package/build/component/resource/appManifest/constants.d.ts.map +1 -1
  56. package/build/component/resource/appManifest/constants.js +1 -1
  57. package/build/component/resource/appManifest/constants.js.map +1 -1
  58. package/build/component/resource/botService/appStudio/interfaces/IBotRegistration.d.ts +5 -0
  59. package/build/component/resource/botService/appStudio/interfaces/IBotRegistration.d.ts.map +1 -1
  60. package/build/component/resource/botService/appStudio/interfaces/IBotRegistration.js +6 -0
  61. package/build/component/resource/botService/appStudio/interfaces/IBotRegistration.js.map +1 -1
  62. package/build/component/resource/botService/botRegistration/utils.d.ts.map +1 -1
  63. package/build/component/resource/botService/botRegistration/utils.js +1 -0
  64. package/build/component/resource/botService/botRegistration/utils.js.map +1 -1
  65. package/build/component/utils/envUtil.d.ts +1 -0
  66. package/build/component/utils/envUtil.d.ts.map +1 -1
  67. package/build/component/utils/envUtil.js +24 -13
  68. package/build/component/utils/envUtil.js.map +1 -1
  69. package/build/core/FxCore.d.ts.map +1 -1
  70. package/build/core/FxCore.js +3 -10
  71. package/build/core/FxCore.js.map +1 -1
  72. package/build/core/FxCoreImplementV3.d.ts.map +1 -1
  73. package/build/core/FxCoreImplementV3.js +24 -4
  74. package/build/core/FxCoreImplementV3.js.map +1 -1
  75. package/build/core/environment.d.ts +1 -1
  76. package/build/core/environment.d.ts.map +1 -1
  77. package/build/core/environment.js +2 -2
  78. package/build/core/environment.js.map +1 -1
  79. package/build/core/error.d.ts +2 -1
  80. package/build/core/error.d.ts.map +1 -1
  81. package/build/core/error.js +11 -3
  82. package/build/core/error.js.map +1 -1
  83. package/build/core/middleware/projectMigrator.d.ts +1 -2
  84. package/build/core/middleware/projectMigrator.d.ts.map +1 -1
  85. package/build/core/middleware/projectMigrator.js +4 -24
  86. package/build/core/middleware/projectMigrator.js.map +1 -1
  87. package/build/core/middleware/projectMigratorV3.d.ts +5 -3
  88. package/build/core/middleware/projectMigratorV3.d.ts.map +1 -1
  89. package/build/core/middleware/projectMigratorV3.js +67 -29
  90. package/build/core/middleware/projectMigratorV3.js.map +1 -1
  91. package/build/core/middleware/types.d.ts +8 -0
  92. package/build/core/middleware/types.d.ts.map +1 -0
  93. package/build/core/middleware/types.js +5 -0
  94. package/build/core/middleware/types.js.map +1 -0
  95. package/build/core/middleware/utils/MigrationUtils.d.ts.map +1 -1
  96. package/build/core/middleware/utils/MigrationUtils.js +18 -19
  97. package/build/core/middleware/utils/MigrationUtils.js.map +1 -1
  98. package/build/core/middleware/utils/appYmlGenerator.d.ts +4 -0
  99. package/build/core/middleware/utils/appYmlGenerator.d.ts.map +1 -1
  100. package/build/core/middleware/utils/appYmlGenerator.js +24 -0
  101. package/build/core/middleware/utils/appYmlGenerator.js.map +1 -1
  102. package/build/core/middleware/utils/debug/appLocalYmlGenerator.d.ts +3 -1
  103. package/build/core/middleware/utils/debug/appLocalYmlGenerator.d.ts.map +1 -1
  104. package/build/core/middleware/utils/debug/appLocalYmlGenerator.js +6 -5
  105. package/build/core/middleware/utils/debug/appLocalYmlGenerator.js.map +1 -1
  106. package/build/core/middleware/utils/debug/debugMigrationContext.d.ts +5 -1
  107. package/build/core/middleware/utils/debug/debugMigrationContext.d.ts.map +1 -1
  108. package/build/core/middleware/utils/debug/debugMigrationContext.js +3 -1
  109. package/build/core/middleware/utils/debug/debugMigrationContext.js.map +1 -1
  110. package/build/core/middleware/utils/debug/debugV3MigrationUtils.d.ts +17 -0
  111. package/build/core/middleware/utils/debug/debugV3MigrationUtils.d.ts.map +1 -1
  112. package/build/core/middleware/utils/debug/debugV3MigrationUtils.js +141 -1
  113. package/build/core/middleware/utils/debug/debugV3MigrationUtils.js.map +1 -1
  114. package/build/core/middleware/utils/debug/taskMigrator.d.ts +15 -7
  115. package/build/core/middleware/utils/debug/taskMigrator.d.ts.map +1 -1
  116. package/build/core/middleware/utils/debug/taskMigrator.js +561 -9
  117. package/build/core/middleware/utils/debug/taskMigrator.js.map +1 -1
  118. package/build/core/middleware/utils/v3MigrationUtils.d.ts +4 -0
  119. package/build/core/middleware/utils/v3MigrationUtils.d.ts.map +1 -1
  120. package/build/core/middleware/utils/v3MigrationUtils.js +40 -1
  121. package/build/core/middleware/utils/v3MigrationUtils.js.map +1 -1
  122. package/package.json +2 -2
  123. package/resource/package.nls.json +5 -3
  124. package/templates/core/v3Migration/csharp.app.local.yml +98 -0
  125. package/templates/core/v3Migration/csharp.app.yml +6 -0
  126. package/templates/core/v3Migration/js.ts.app.local.yml +13 -3
  127. package/templates/core/v3Migration/js.ts.app.yml +72 -4
  128. package/templates/core/v3Migration/migrationReport.md +37 -17
  129. package/templates/fallback/bot.csharp.command-and-response.zip +0 -0
  130. package/templates/fallback/bot.csharp.default.zip +0 -0
  131. package/templates/fallback/bot.csharp.notification-function-base.zip +0 -0
  132. package/templates/fallback/bot.csharp.notification-trigger-http.zip +0 -0
  133. package/templates/fallback/bot.csharp.notification-trigger-timer.zip +0 -0
  134. package/templates/fallback/bot.csharp.notification-webapi.zip +0 -0
  135. package/templates/fallback/bot.csharp.workflow.zip +0 -0
  136. package/templates/fallback/bot.js.command-and-response.zip +0 -0
  137. package/templates/fallback/bot.js.default.zip +0 -0
  138. package/templates/fallback/bot.js.m365.zip +0 -0
  139. package/templates/fallback/bot.js.notification-function-base.zip +0 -0
  140. package/templates/fallback/bot.js.notification-restify.zip +0 -0
  141. package/templates/fallback/bot.js.notification-trigger-http.zip +0 -0
  142. package/templates/fallback/bot.js.notification-trigger-timer.zip +0 -0
  143. package/templates/fallback/bot.js.workflow.zip +0 -0
  144. package/templates/fallback/bot.ts.command-and-response.zip +0 -0
  145. package/templates/fallback/bot.ts.default.zip +0 -0
  146. package/templates/fallback/bot.ts.m365.zip +0 -0
  147. package/templates/fallback/bot.ts.notification-function-base.zip +0 -0
  148. package/templates/fallback/bot.ts.notification-restify.zip +0 -0
  149. package/templates/fallback/bot.ts.notification-trigger-http.zip +0 -0
  150. package/templates/fallback/bot.ts.notification-trigger-timer.zip +0 -0
  151. package/templates/fallback/bot.ts.workflow.zip +0 -0
  152. package/templates/fallback/common.zip +0 -0
  153. package/templates/fallback/csharp.zip +0 -0
  154. package/templates/fallback/function-base.js.default.zip +0 -0
  155. package/templates/fallback/function-base.ts.default.zip +0 -0
  156. package/templates/fallback/function-triggers.js.HTTPTrigger.zip +0 -0
  157. package/templates/fallback/function-triggers.ts.HTTPTrigger.zip +0 -0
  158. package/templates/fallback/js.zip +0 -0
  159. package/templates/fallback/tab.csharp.default.zip +0 -0
  160. package/templates/fallback/tab.csharp.non-sso.zip +0 -0
  161. package/templates/fallback/tab.js.dashboard.zip +0 -0
  162. package/templates/fallback/tab.js.default.zip +0 -0
  163. package/templates/fallback/tab.js.m365.zip +0 -0
  164. package/templates/fallback/tab.js.non-sso.zip +0 -0
  165. package/templates/fallback/tab.ts.dashboard.zip +0 -0
  166. package/templates/fallback/tab.ts.default.zip +0 -0
  167. package/templates/fallback/tab.ts.m365.zip +0 -0
  168. package/templates/fallback/tab.ts.non-sso.zip +0 -0
  169. package/templates/fallback/ts.zip +0 -0
@@ -2,11 +2,14 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.migratePrepareManifest = exports.migrateSetUpSSO = exports.migrateSetUpBot = exports.migrateSetUpTab = exports.migrateTransparentNpmInstall = exports.migrateTransparentLocalTunnel = exports.migrateTransparentPrerequisite = void 0;
5
+ exports.migrateNgrokStartCommand = exports.migrateNgrokStartTask = exports.migrateValidateLocalPrerequisites = exports.migrateBotStart = exports.migrateAuthStart = exports.migrateFrontendStart = exports.migrateBackendExtensionsInstall = exports.migrateValidateDependencies = exports.migratePrepareManifest = exports.migrateSetUpSSO = exports.migrateSetUpBot = exports.migrateSetUpTab = exports.migrateTransparentNpmInstall = exports.migrateTransparentLocalTunnel = exports.migrateTransparentPrerequisite = void 0;
6
+ const tslib_1 = require("tslib");
6
7
  const comment_json_1 = require("comment-json");
7
8
  const local_1 = require("../../../../common/local");
8
9
  const debugV3MigrationUtils_1 = require("./debugV3MigrationUtils");
9
- function migrateTransparentPrerequisite(context) {
10
+ const crypto_1 = require("../../../crypto");
11
+ const util = tslib_1.__importStar(require("util"));
12
+ async function migrateTransparentPrerequisite(context) {
10
13
  for (const task of context.tasks) {
11
14
  if (!debugV3MigrationUtils_1.isCommentObject(task) ||
12
15
  !(task["type"] === "teamsfx") ||
@@ -49,7 +52,7 @@ function migrateTransparentPrerequisite(context) {
49
52
  }
50
53
  }
51
54
  exports.migrateTransparentPrerequisite = migrateTransparentPrerequisite;
52
- function migrateTransparentLocalTunnel(context) {
55
+ async function migrateTransparentLocalTunnel(context) {
53
56
  for (const task of context.tasks) {
54
57
  if (!debugV3MigrationUtils_1.isCommentObject(task) ||
55
58
  !(task["type"] === "teamsfx") ||
@@ -71,7 +74,7 @@ function migrateTransparentLocalTunnel(context) {
71
74
  }
72
75
  }
73
76
  exports.migrateTransparentLocalTunnel = migrateTransparentLocalTunnel;
74
- function migrateTransparentNpmInstall(context) {
77
+ async function migrateTransparentNpmInstall(context) {
75
78
  let index = 0;
76
79
  while (index < context.tasks.length) {
77
80
  const task = context.tasks[index];
@@ -112,7 +115,7 @@ function migrateTransparentNpmInstall(context) {
112
115
  }
113
116
  }
114
117
  exports.migrateTransparentNpmInstall = migrateTransparentNpmInstall;
115
- function migrateSetUpTab(context) {
118
+ async function migrateSetUpTab(context) {
116
119
  let index = 0;
117
120
  while (index < context.tasks.length) {
118
121
  const task = context.tasks[index];
@@ -153,7 +156,7 @@ function migrateSetUpTab(context) {
153
156
  }
154
157
  }
155
158
  exports.migrateSetUpTab = migrateSetUpTab;
156
- function migrateSetUpBot(context) {
159
+ async function migrateSetUpBot(context) {
157
160
  let index = 0;
158
161
  while (index < context.tasks.length) {
159
162
  const task = context.tasks[index];
@@ -170,17 +173,48 @@ function migrateSetUpBot(context) {
170
173
  if (!context.appYmlConfig.provision) {
171
174
  context.appYmlConfig.provision = {};
172
175
  }
173
- context.appYmlConfig.provision.bot = true;
176
+ context.appYmlConfig.provision.bot = {
177
+ messagingEndpoint: `$\{{${context.placeholderMapping.botEndpoint}}}/api/messages`,
178
+ };
174
179
  if (!context.appYmlConfig.deploy) {
175
180
  context.appYmlConfig.deploy = {};
176
181
  }
177
182
  context.appYmlConfig.deploy.bot = true;
183
+ const envs = {};
184
+ if (debugV3MigrationUtils_1.isCommentObject(task["args"])) {
185
+ if (task["args"]["botId"] && typeof task["args"]["botId"] === "string") {
186
+ envs["BOT_ID"] = task["args"]["botId"];
187
+ }
188
+ if (task["args"]["botPassword"] && typeof task["args"]["botPassword"] === "string") {
189
+ const envReferencePattern = /^\$\{env:(.*)\}$/;
190
+ const matchResult = task["args"]["botPassword"].match(envReferencePattern);
191
+ const botPassword = matchResult ? process.env[matchResult[1]] : task["args"]["botPassword"];
192
+ if (botPassword) {
193
+ const cryptoProvider = new crypto_1.LocalCrypto(context.oldProjectSettings.projectId);
194
+ const result = cryptoProvider.encrypt(botPassword);
195
+ if (result.isOk()) {
196
+ envs["SECRET_BOT_PASSWORD"] = result.value;
197
+ }
198
+ }
199
+ }
200
+ if (task["args"]["botMessagingEndpoint"] &&
201
+ typeof task["args"]["botMessagingEndpoint"] === "string") {
202
+ if (task["args"]["botMessagingEndpoint"].startsWith("http")) {
203
+ context.appYmlConfig.provision.bot.messagingEndpoint =
204
+ task["args"]["botMessagingEndpoint"];
205
+ }
206
+ else if (task["args"]["botMessagingEndpoint"].startsWith("/")) {
207
+ context.appYmlConfig.provision.bot.messagingEndpoint = `$\{{${context.placeholderMapping.botEndpoint}}}${task["args"]["botMessagingEndpoint"]}`;
208
+ }
209
+ }
210
+ }
211
+ await debugV3MigrationUtils_1.updateLocalEnv(context.migrationContext, envs);
178
212
  const label = task["label"];
179
213
  index = handleProvisionAndDeploy(context, index, label);
180
214
  }
181
215
  }
182
216
  exports.migrateSetUpBot = migrateSetUpBot;
183
- function migrateSetUpSSO(context) {
217
+ async function migrateSetUpSSO(context) {
184
218
  let index = 0;
185
219
  while (index < context.tasks.length) {
186
220
  const task = context.tasks[index];
@@ -206,12 +240,40 @@ function migrateSetUpSSO(context) {
206
240
  context.appYmlConfig.deploy = {};
207
241
  }
208
242
  context.appYmlConfig.deploy.sso = true;
243
+ const envs = {};
244
+ if (debugV3MigrationUtils_1.isCommentObject(task["args"])) {
245
+ if (task["args"]["objectId"] && typeof task["args"]["objectId"] === "string") {
246
+ envs["AAD_APP_OBJECT_ID"] = task["args"]["objectId"];
247
+ }
248
+ if (task["args"]["clientId"] && typeof task["args"]["clientId"] === "string") {
249
+ envs["AAD_APP_CLIENT_ID"] = task["args"]["clientId"];
250
+ }
251
+ if (task["args"]["clientSecret"] && typeof task["args"]["clientSecret"] === "string") {
252
+ const envReferencePattern = /^\$\{env:(.*)\}$/;
253
+ const matchResult = task["args"]["clientSecret"].match(envReferencePattern);
254
+ const clientSecret = matchResult
255
+ ? process.env[matchResult[1]]
256
+ : task["args"]["clientSecret"];
257
+ if (clientSecret) {
258
+ const cryptoProvider = new crypto_1.LocalCrypto(context.oldProjectSettings.projectId);
259
+ const result = cryptoProvider.encrypt(clientSecret);
260
+ if (result.isOk()) {
261
+ envs["SECRET_AAD_APP_CLIENT_SECRET"] = result.value;
262
+ }
263
+ }
264
+ }
265
+ if (task["args"]["accessAsUserScopeId"] &&
266
+ typeof task["args"]["accessAsUserScopeId"] === "string") {
267
+ envs["AAD_APP_ACCESS_AS_USER_PERMISSION_ID"] = task["args"]["accessAsUserScopeId"];
268
+ }
269
+ }
270
+ await debugV3MigrationUtils_1.updateLocalEnv(context.migrationContext, envs);
209
271
  const label = task["label"];
210
272
  index = handleProvisionAndDeploy(context, index, label);
211
273
  }
212
274
  }
213
275
  exports.migrateSetUpSSO = migrateSetUpSSO;
214
- function migratePrepareManifest(context) {
276
+ async function migratePrepareManifest(context) {
215
277
  let index = 0;
216
278
  while (index < context.tasks.length) {
217
279
  const task = context.tasks[index];
@@ -247,6 +309,337 @@ function migratePrepareManifest(context) {
247
309
  }
248
310
  }
249
311
  exports.migratePrepareManifest = migratePrepareManifest;
312
+ async function migrateValidateDependencies(context) {
313
+ let index = 0;
314
+ while (index < context.tasks.length) {
315
+ const task = context.tasks[index];
316
+ if (!debugV3MigrationUtils_1.isCommentObject(task) ||
317
+ !(task["type"] === "shell") ||
318
+ !(typeof task["command"] === "string") ||
319
+ !task["command"].includes("${command:fx-extension.validate-dependencies}")) {
320
+ ++index;
321
+ continue;
322
+ }
323
+ const newTask = generatePrerequisiteTask(task, context);
324
+ context.tasks.splice(index, 1, newTask);
325
+ ++index;
326
+ const toolsArgs = {};
327
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeTab(context.oldProjectSettings)) {
328
+ toolsArgs.devCert = {
329
+ trust: true,
330
+ };
331
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeSSO(context.oldProjectSettings)) {
332
+ toolsArgs.dotnet = true;
333
+ }
334
+ }
335
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFunction(context.oldProjectSettings)) {
336
+ toolsArgs.func = true;
337
+ toolsArgs.dotnet = true;
338
+ }
339
+ if (Object.keys(toolsArgs).length > 0) {
340
+ if (!context.appYmlConfig.deploy) {
341
+ context.appYmlConfig.deploy = {};
342
+ }
343
+ context.appYmlConfig.deploy.tools = toolsArgs;
344
+ }
345
+ }
346
+ }
347
+ exports.migrateValidateDependencies = migrateValidateDependencies;
348
+ async function migrateBackendExtensionsInstall(context) {
349
+ let index = 0;
350
+ while (index < context.tasks.length) {
351
+ const task = context.tasks[index];
352
+ if (!debugV3MigrationUtils_1.isCommentObject(task) ||
353
+ !(task["type"] === "shell") ||
354
+ !(typeof task["command"] === "string" &&
355
+ task["command"].includes("${command:fx-extension.backend-extensions-install}"))) {
356
+ ++index;
357
+ continue;
358
+ }
359
+ if (!context.appYmlConfig.deploy) {
360
+ context.appYmlConfig.deploy = {};
361
+ }
362
+ context.appYmlConfig.deploy.dotnetCommand = {
363
+ args: "build extensions.csproj -o ./bin --ignore-failed-sources",
364
+ workingDirectory: `./${local_1.FolderName.Function}`,
365
+ execPath: "${{DOTNET_PATH}}",
366
+ };
367
+ const label = task["label"];
368
+ if (typeof label === "string") {
369
+ replaceInDependsOn(label, context.tasks);
370
+ }
371
+ context.tasks.splice(index, 1);
372
+ }
373
+ }
374
+ exports.migrateBackendExtensionsInstall = migrateBackendExtensionsInstall;
375
+ async function migrateFrontendStart(context) {
376
+ let index = 0;
377
+ while (index < context.tasks.length) {
378
+ const task = context.tasks[index];
379
+ if (debugV3MigrationUtils_1.isCommentObject(task) &&
380
+ ((typeof task["dependsOn"] === "string" && task["dependsOn"] === "teamsfx: frontend start") ||
381
+ (debugV3MigrationUtils_1.isCommentArray(task["dependsOn"]) &&
382
+ task["dependsOn"].includes("teamsfx: frontend start")))) {
383
+ const newLabel = debugV3MigrationUtils_1.generateLabel("Start frontend", getLabels(context.tasks));
384
+ const newTask = debugV3MigrationUtils_1.startFrontendTask(newLabel);
385
+ context.tasks.splice(index + 1, 0, newTask);
386
+ replaceInDependsOn("teamsfx: frontend start", context.tasks, newLabel);
387
+ if (!context.appYmlConfig.deploy) {
388
+ context.appYmlConfig.deploy = {};
389
+ }
390
+ if (!context.appYmlConfig.deploy.npmCommands) {
391
+ context.appYmlConfig.deploy.npmCommands = [];
392
+ }
393
+ const existing = context.appYmlConfig.deploy.npmCommands.find((value) => value.args === "install -D @microsoft/teamsfx-run-utils@alpha");
394
+ if (!existing) {
395
+ context.appYmlConfig.deploy.npmCommands.push({
396
+ args: "install -D @microsoft/teamsfx-run-utils@alpha",
397
+ workingDirectory: ".",
398
+ });
399
+ }
400
+ await debugV3MigrationUtils_1.saveRunScript(context.migrationContext, "run.tab.js", generateRunTabScript(context));
401
+ break;
402
+ }
403
+ else {
404
+ ++index;
405
+ }
406
+ }
407
+ }
408
+ exports.migrateFrontendStart = migrateFrontendStart;
409
+ async function migrateAuthStart(context) {
410
+ let index = 0;
411
+ while (index < context.tasks.length) {
412
+ const task = context.tasks[index];
413
+ if (debugV3MigrationUtils_1.isCommentObject(task) &&
414
+ ((typeof task["dependsOn"] === "string" && task["dependsOn"] === "teamsfx: auth start") ||
415
+ (debugV3MigrationUtils_1.isCommentArray(task["dependsOn"]) && task["dependsOn"].includes("teamsfx: auth start")))) {
416
+ const newLabel = debugV3MigrationUtils_1.generateLabel("Start auth", getLabels(context.tasks));
417
+ const newTask = debugV3MigrationUtils_1.startAuthTask(newLabel);
418
+ context.tasks.splice(index + 1, 0, newTask);
419
+ replaceInDependsOn("teamsfx: auth start", context.tasks, newLabel);
420
+ if (!context.appYmlConfig.deploy) {
421
+ context.appYmlConfig.deploy = {};
422
+ }
423
+ if (!context.appYmlConfig.deploy.npmCommands) {
424
+ context.appYmlConfig.deploy.npmCommands = [];
425
+ }
426
+ const existing = context.appYmlConfig.deploy.npmCommands.find((value) => value.args === "install -D @microsoft/teamsfx-run-utils@alpha");
427
+ if (!existing) {
428
+ context.appYmlConfig.deploy.npmCommands.push({
429
+ args: "install -D @microsoft/teamsfx-run-utils@alpha",
430
+ workingDirectory: ".",
431
+ });
432
+ }
433
+ await debugV3MigrationUtils_1.saveRunScript(context.migrationContext, "run.auth.js", generateRunAuthScript(context));
434
+ break;
435
+ }
436
+ else {
437
+ ++index;
438
+ }
439
+ }
440
+ }
441
+ exports.migrateAuthStart = migrateAuthStart;
442
+ async function migrateBotStart(context) {
443
+ let index = 0;
444
+ while (index < context.tasks.length) {
445
+ const task = context.tasks[index];
446
+ if (debugV3MigrationUtils_1.isCommentObject(task) &&
447
+ ((typeof task["dependsOn"] === "string" && task["dependsOn"] === "teamsfx: bot start") ||
448
+ (debugV3MigrationUtils_1.isCommentArray(task["dependsOn"]) && task["dependsOn"].includes("teamsfx: bot start")))) {
449
+ const newLabel = debugV3MigrationUtils_1.generateLabel("Start bot", getLabels(context.tasks));
450
+ const newTask = debugV3MigrationUtils_1.startBotTask(newLabel);
451
+ context.tasks.splice(index + 1, 0, newTask);
452
+ replaceInDependsOn("teamsfx: bot start", context.tasks, newLabel);
453
+ if (!context.appYmlConfig.deploy) {
454
+ context.appYmlConfig.deploy = {};
455
+ }
456
+ if (!context.appYmlConfig.deploy.npmCommands) {
457
+ context.appYmlConfig.deploy.npmCommands = [];
458
+ }
459
+ const existing = context.appYmlConfig.deploy.npmCommands.find((value) => value.args === "install -D @microsoft/teamsfx-run-utils@alpha");
460
+ if (!existing) {
461
+ context.appYmlConfig.deploy.npmCommands.push({
462
+ args: "install -D @microsoft/teamsfx-run-utils@alpha",
463
+ workingDirectory: ".",
464
+ });
465
+ }
466
+ await debugV3MigrationUtils_1.saveRunScript(context.migrationContext, "run.bot.js", generateRunBotScript(context));
467
+ break;
468
+ }
469
+ else {
470
+ ++index;
471
+ }
472
+ }
473
+ }
474
+ exports.migrateBotStart = migrateBotStart;
475
+ async function migrateValidateLocalPrerequisites(context) {
476
+ let index = 0;
477
+ while (index < context.tasks.length) {
478
+ const task = context.tasks[index];
479
+ if (!debugV3MigrationUtils_1.isCommentObject(task) ||
480
+ !(task["type"] === "shell") ||
481
+ !(typeof task["command"] === "string" &&
482
+ task["command"].includes("${command:fx-extension.validate-local-prerequisites}"))) {
483
+ ++index;
484
+ continue;
485
+ }
486
+ const newTask = generatePrerequisiteTask(task, context);
487
+ context.tasks.splice(index, 1, newTask);
488
+ ++index;
489
+ const toolsArgs = {};
490
+ const npmCommands = [];
491
+ let dotnetCommand;
492
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeTab(context.oldProjectSettings)) {
493
+ toolsArgs.devCert = {
494
+ trust: true,
495
+ };
496
+ npmCommands.push({
497
+ args: `install ${local_1.defaultNpmInstallArg}`,
498
+ workingDirectory: `./${local_1.FolderName.Frontend}`,
499
+ });
500
+ }
501
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFunction(context.oldProjectSettings)) {
502
+ toolsArgs.func = true;
503
+ toolsArgs.dotnet = true;
504
+ npmCommands.push({
505
+ args: `install ${local_1.defaultNpmInstallArg}`,
506
+ workingDirectory: `./${local_1.FolderName.Function}`,
507
+ });
508
+ dotnetCommand = {
509
+ args: "build extensions.csproj -o ./bin --ignore-failed-sources",
510
+ workingDirectory: `./${local_1.FolderName.Function}`,
511
+ execPath: "${{DOTNET_PATH}}",
512
+ };
513
+ }
514
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeBot(context.oldProjectSettings)) {
515
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFuncHostedBot(context.oldProjectSettings)) {
516
+ toolsArgs.func = true;
517
+ }
518
+ npmCommands.push({
519
+ args: `install ${local_1.defaultNpmInstallArg}`,
520
+ workingDirectory: `./${local_1.FolderName.Bot}`,
521
+ });
522
+ }
523
+ if (Object.keys(toolsArgs).length > 0 || npmCommands.length > 0 || dotnetCommand) {
524
+ if (!context.appYmlConfig.deploy) {
525
+ context.appYmlConfig.deploy = {};
526
+ }
527
+ if (Object.keys(toolsArgs).length > 0) {
528
+ context.appYmlConfig.deploy.tools = toolsArgs;
529
+ }
530
+ if (npmCommands.length > 0) {
531
+ context.appYmlConfig.deploy.npmCommands = npmCommands;
532
+ }
533
+ context.appYmlConfig.deploy.dotnetCommand = dotnetCommand;
534
+ }
535
+ }
536
+ }
537
+ exports.migrateValidateLocalPrerequisites = migrateValidateLocalPrerequisites;
538
+ async function migrateNgrokStartTask(context) {
539
+ let index = 0;
540
+ while (index < context.tasks.length) {
541
+ const task = context.tasks[index];
542
+ if (debugV3MigrationUtils_1.isCommentObject(task) &&
543
+ ((typeof task["dependsOn"] === "string" && task["dependsOn"] === "teamsfx: ngrok start") ||
544
+ (debugV3MigrationUtils_1.isCommentArray(task["dependsOn"]) && task["dependsOn"].includes("teamsfx: ngrok start")))) {
545
+ const newTask = generateLocalTunnelTask(context);
546
+ context.tasks.splice(index + 1, 0, newTask);
547
+ break;
548
+ }
549
+ else {
550
+ ++index;
551
+ }
552
+ }
553
+ replaceInDependsOn("teamsfx: ngrok start", context.tasks, local_1.TaskLabel.StartLocalTunnel);
554
+ }
555
+ exports.migrateNgrokStartTask = migrateNgrokStartTask;
556
+ async function migrateNgrokStartCommand(context) {
557
+ let index = 0;
558
+ while (index < context.tasks.length) {
559
+ const task = context.tasks[index];
560
+ if (!debugV3MigrationUtils_1.isCommentObject(task) ||
561
+ !(task["type"] === "teamsfx") ||
562
+ !(task["command"] === "ngrok start")) {
563
+ ++index;
564
+ continue;
565
+ }
566
+ const newTask = generateLocalTunnelTask(context, task);
567
+ context.tasks.splice(index, 1, newTask);
568
+ ++index;
569
+ }
570
+ }
571
+ exports.migrateNgrokStartCommand = migrateNgrokStartCommand;
572
+ function generatePrerequisiteTask(task, context) {
573
+ const comment = `{
574
+ // Check if all required prerequisites are installed and will install them if not.
575
+ // See https://aka.ms/teamsfx-check-prerequisites-task to know the details and how to customize the args.
576
+ }`;
577
+ const newTask = comment_json_1.assign(comment_json_1.parse(comment), task);
578
+ newTask["type"] = "teamsfx";
579
+ newTask["command"] = "debug-check-prerequisites";
580
+ const prerequisites = [
581
+ `"${local_1.Prerequisite.nodejs}", // Validate if Node.js is installed.`,
582
+ `"${local_1.Prerequisite.m365Account}", // Sign-in prompt for Microsoft 365 account, then validate if the account enables the sideloading permission.`,
583
+ `"${local_1.Prerequisite.portOccupancy}", // Validate available ports to ensure those debug ones are not occupied.`,
584
+ ];
585
+ const prerequisitesComment = `
586
+ [
587
+ ${prerequisites.join("\n ")}
588
+ ]`;
589
+ const ports = [];
590
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeTab(context.oldProjectSettings)) {
591
+ ports.push(`${local_1.TaskDefaultValue.checkPrerequisites.ports.tabService}, // tab service port`);
592
+ }
593
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeBot(context.oldProjectSettings)) {
594
+ ports.push(`${local_1.TaskDefaultValue.checkPrerequisites.ports.botService}, // bot service port`);
595
+ ports.push(`${local_1.TaskDefaultValue.checkPrerequisites.ports.botDebug}, // bot inspector port for Node.js debugger`);
596
+ }
597
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFunction(context.oldProjectSettings)) {
598
+ ports.push(`${local_1.TaskDefaultValue.checkPrerequisites.ports.backendService}, // backend service port`);
599
+ ports.push(`${local_1.TaskDefaultValue.checkPrerequisites.ports.backendDebug}, // backend inspector port for Node.js debugger`);
600
+ }
601
+ const portsComment = `
602
+ [
603
+ ${ports.join("\n ")}
604
+ ]
605
+ `;
606
+ const args = {
607
+ prerequisites: comment_json_1.parse(prerequisitesComment),
608
+ portOccupancy: comment_json_1.parse(portsComment),
609
+ };
610
+ newTask["args"] = args;
611
+ return newTask;
612
+ }
613
+ function generateLocalTunnelTask(context, task) {
614
+ const comment = `{
615
+ // Start the local tunnel service to forward public ngrok URL to local port and inspect traffic.
616
+ // See https://aka.ms/teamsfx-local-tunnel-task for the detailed args definitions,
617
+ // as well as samples to:
618
+ // - use your own ngrok command / configuration / binary
619
+ // - use your own tunnel solution
620
+ // - provide alternatives if ngrok does not work on your dev machine
621
+ }`;
622
+ const placeholderComment = `
623
+ {
624
+ // Keep consistency with migrated configuration.
625
+ }
626
+ `;
627
+ const newTask = comment_json_1.assign(task !== null && task !== void 0 ? task : comment_json_1.parse(`{"label": "${local_1.TaskLabel.StartLocalTunnel}"}`), {
628
+ type: "teamsfx",
629
+ command: local_1.TaskCommand.startLocalTunnel,
630
+ args: {
631
+ ngrokArgs: local_1.TaskDefaultValue.startLocalTunnel.ngrokArgs,
632
+ env: "local",
633
+ output: comment_json_1.assign(comment_json_1.parse(placeholderComment), {
634
+ endpoint: context.placeholderMapping.botEndpoint,
635
+ domain: context.placeholderMapping.botDomain,
636
+ }),
637
+ },
638
+ isBackground: true,
639
+ problemMatcher: "$teamsfx-local-tunnel-watch",
640
+ });
641
+ return comment_json_1.assign(comment_json_1.parse(comment), newTask);
642
+ }
250
643
  function handleProvisionAndDeploy(context, index, label) {
251
644
  context.tasks.splice(index, 1);
252
645
  const existingLabels = getLabels(context.tasks);
@@ -303,4 +696,163 @@ function getLabels(tasks) {
303
696
  }
304
697
  return labels;
305
698
  }
699
+ function generateRunTabScript(context) {
700
+ const ssoSnippet = debugV3MigrationUtils_1.OldProjectSettingsHelper.includeSSO(context.oldProjectSettings)
701
+ ? util.format(tabSSOSnippet, context.placeholderMapping.tabEndpoint)
702
+ : "";
703
+ const functionSnippet = debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFunction(context.oldProjectSettings)
704
+ ? util.format(tabFunctionSnippet, debugV3MigrationUtils_1.OldProjectSettingsHelper.getFunctionName(context.oldProjectSettings))
705
+ : "";
706
+ return util.format(runTabScriptTemplate, ssoSnippet, functionSnippet);
707
+ }
708
+ function generateRunAuthScript(context) {
709
+ return util.format(runAuthScriptTemplate, context.placeholderMapping.tabDomain, context.placeholderMapping.tabEndpoint);
710
+ }
711
+ function generateRunBotScript(context) {
712
+ let ssoSnippet = "";
713
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeSSO(context.oldProjectSettings)) {
714
+ if (debugV3MigrationUtils_1.OldProjectSettingsHelper.includeTab(context.oldProjectSettings)) {
715
+ ssoSnippet = util.format(botSSOSnippet, context.placeholderMapping.botEndpoint, `\`api://\${envs.${context.placeholderMapping.tabDomain}}/botid-\${envs.BOT_ID}\`;`);
716
+ }
717
+ else {
718
+ ssoSnippet = util.format(botSSOSnippet, context.placeholderMapping.botEndpoint, `\`api://botid-\${envs.BOT_ID}\`;`);
719
+ }
720
+ }
721
+ const functionSnippet = debugV3MigrationUtils_1.OldProjectSettingsHelper.includeFunction(context.oldProjectSettings)
722
+ ? botFunctionSnippet
723
+ : "";
724
+ const startSnippet = context.oldProjectSettings.programmingLanguage === "javascript"
725
+ ? botStartJSSnippet
726
+ : botStartTSSnippet;
727
+ return util.format(runBotScriptTemplate, ssoSnippet, functionSnippet, startSnippet);
728
+ }
729
+ const tabSSOSnippet = `
730
+ process.env.REACT_APP_CLIENT_ID = envs.AAD_APP_CLIENT_ID;
731
+ process.env.REACT_APP_START_LOGIN_PAGE_URL = \`\${envs.%s}/auth-start.html\`;
732
+ process.env.REACT_APP_TEAMSFX_ENDPOINT = "https://localhost:55000";`;
733
+ const tabFunctionSnippet = `
734
+ process.env.REACT_APP_FUNC_ENDPOINT = "http://localhost:7071";
735
+ process.env.REACT_APP_FUNC_NAME = "%s";`;
736
+ const runTabScriptTemplate = `const cp = require("child_process");
737
+ const utils = require("@microsoft/teamsfx-run-utils");
738
+
739
+ // This script is used by Teams Toolkit to launch your service locally
740
+
741
+ async function run() {
742
+ const args = process.argv.slice(2);
743
+
744
+ if (args.length !== 2) {
745
+ console.log(\`Usage: node \${__filename} [project path] [env path].\`);
746
+ process.exit(1);
747
+ }
748
+
749
+ const envs = await utils.loadEnv(args[0], args[1]);
750
+
751
+ // set up environment variables required by teamsfx
752
+ process.env.BROWSER = "none";
753
+ process.env.HTTPS = true;
754
+ process.env.PORT = 53000;
755
+ process.env.SSL_CRT_FILE = envs.SSL_CRT_FILE;
756
+ process.env.SSL_KEY_FILE = envs.SSL_KEY_FILE;%s%s
757
+
758
+ // launch service locally
759
+ cp.spawn(/^win/.test(process.platform) ? "npx.cmd" : "npx", ["react-scripts", "start"], {
760
+ stdio: "inherit",
761
+ });
762
+ }
763
+
764
+ run();
765
+ `;
766
+ const runAuthScriptTemplate = `const cp = require("child_process");
767
+ const os = require("os");
768
+ const path = require("path");
769
+ const utils = require("@microsoft/teamsfx-run-utils");
770
+
771
+ // This script is used by Teams Toolkit to launch your service locally
772
+
773
+ async function run() {
774
+ const args = process.argv.slice(2);
775
+
776
+ if (args.length !== 2) {
777
+ console.log(\`Usage: node \${__filename} [project path] [env path].\`);
778
+ process.exit(1);
779
+ }
780
+
781
+ const envs = await utils.loadEnv(args[0], args[1]);
782
+
783
+ // set up environment variables required by teamsfx
784
+ process.env.CLIENT_ID = envs.CLIENT_ID;
785
+ process.env.CLIENT_SECRET = envs.CLIENT_SECRET;
786
+ process.env.IDENTIFIER_URI = \`api://\${envs.%s}/\${envs.CLIENT_ID}\`;
787
+ process.env.AAD_METADATA_ADDRESS = \`\${envs.AAD_APP_OAUTH_AUTHORITY}/v2.0/.well-known/openid-configuration\`;
788
+ process.env.OAUTH_AUTHORITY = envs.AAD_APP_OAUTH_AUTHORITY;
789
+ process.env.TAB_APP_ENDPOINT = envs.%s;
790
+ process.env.AUTH_ALLOWED_APP_IDS =
791
+ "1fec8e78-bce4-4aaf-ab1b-5451cc387264;5e3ce6c0-2b1f-4285-8d4b-75ee78787346;0ec893e0-5785-4de6-99da-4ed124e5296c;4345a7b9-9a63-4910-a426-35363201d503;4765445b-32c6-49b0-83e6-1d93765276ca;d3590ed6-52b3-4102-aeff-aad2292ab01c;00000002-0000-0ff1-ce00-000000000000;bc59ab01-8403-45c6-8796-ac3ef710b3e3";
792
+ process.env.urls = "http://localhost:55000";
793
+
794
+ // launch service locally
795
+ cp.spawn(envs.DOTNET_PATH, ["Microsoft.TeamsFx.SimpleAuth.dll"], {
796
+ cwd: path.join(os.homedir(), ".fx", "localauth"),
797
+ stdio: "inherit",
798
+ });
799
+ }
800
+
801
+ run();
802
+ `;
803
+ const botSSOSnippet = `
804
+ process.env.M365_CLIENT_ID = envs.AAD_APP_CLIENT_ID;
805
+ process.env.M365_CLIENT_SECRET = envs.SECRET_AAD_APP_CLIENT_SECRET;
806
+ process.env.M365_TENANT_ID = envs.AAD_APP_TENANT_ID;
807
+ process.env.M365_AUTHORITY_HOST = envs.AAD_APP_OAUTH_AUTHORITY_HOST;
808
+ process.env.INITIATE_LOGIN_ENDPOINT = \`\${envs.%s}/auth-start.html\`;
809
+ process.env.M365_APPLICATION_ID_URI = %s`;
810
+ const botFunctionSnippet = `
811
+ process.env.API_ENDPOINT = "http://localhost:7071";`;
812
+ const botStartJSSnippet = `
813
+ cp.spawn(
814
+ /^win/.test(process.platform) ? "npx.cmd" : "npx",
815
+ ["nodemon", "--inspect=9239", "--signal", "SIGINT", "index.js"],
816
+ { stdio: "inherit" }
817
+ );`;
818
+ const botStartTSSnippet = `
819
+ cp.spawn(
820
+ /^win/.test(process.platform) ? "npx.cmd" : "npx",
821
+ [
822
+ "nodemon",
823
+ "--exec",
824
+ "node",
825
+ "--inspect=9239",
826
+ "--signal",
827
+ "SIGINT",
828
+ "-r",
829
+ "ts-node/register",
830
+ "index.ts",
831
+ ],
832
+ { stdio: "inherit" }
833
+ );`;
834
+ const runBotScriptTemplate = `const cp = require("child_process");
835
+ const utils = require("@microsoft/teamsfx-run-utils");
836
+
837
+ // This script is used by Teams Toolkit to launch your service locally
838
+
839
+ async function run() {
840
+ const args = process.argv.slice(2);
841
+
842
+ if (args.length !== 2) {
843
+ console.log(\`Usage: node \${__filename} [project path] [env path].\`);
844
+ process.exit(1);
845
+ }
846
+
847
+ const envs = await utils.loadEnv(args[0], args[1]);
848
+
849
+ // set up environment variables required by teamsfx
850
+ process.env.BOT_ID = envs.BOT_ID;
851
+ process.env.BOT_PASSWORD = envs.SECRET_BOT_PASSWORD;%s%s
852
+
853
+ // launch service locally%s
854
+ }
855
+
856
+ run();
857
+ `;
306
858
  //# sourceMappingURL=taskMigrator.js.map