-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hui/api-key-improvement' of github.com:OfficeDev/TeamsF…
…x into hui/api-key-improvement
- Loading branch information
Showing
77 changed files
with
2,027 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,81 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { CLICommand, err, ok } from "@microsoft/teamsfx-api"; | ||
import { PackageService } from "@microsoft/teamsfx-core"; | ||
import { UninstallInputs, QuestionNames } from "@microsoft/teamsfx-core"; | ||
import { logger } from "../../commonlib/logger"; | ||
import { MissingRequiredOptionError } from "../../error"; | ||
import { commands } from "../../resource"; | ||
import { TelemetryEvent } from "../../telemetry/cliTelemetryEvents"; | ||
import { m365utils, sideloadingServiceEndpoint } from "./m365Sideloading"; | ||
import { getFxCore } from "../../activate"; | ||
|
||
export const m365UnacquireCommand: CLICommand = { | ||
name: "uninstall", | ||
aliases: ["unacquire"], | ||
description: commands.uninstall.description, | ||
options: [ | ||
{ | ||
name: "title-id", | ||
name: QuestionNames.UninstallMode, | ||
description: commands.uninstall.options["mode"], | ||
type: "string", | ||
}, | ||
{ | ||
name: QuestionNames.TitleId, | ||
description: commands.uninstall.options["title-id"], | ||
type: "string", | ||
}, | ||
{ | ||
name: "manifest-id", | ||
name: QuestionNames.ManifestId, | ||
description: commands.uninstall.options["manifest-id"], | ||
type: "string", | ||
}, | ||
{ | ||
name: QuestionNames.Env, | ||
description: commands.uninstall.options["env"], | ||
type: "string", | ||
}, | ||
{ | ||
name: "folder", | ||
questionName: QuestionNames.ProjectPath, | ||
description: commands.uninstall.options["folder"], | ||
type: "string", | ||
}, | ||
{ | ||
name: QuestionNames.UninstallOptions, | ||
description: commands.uninstall.options["options"], | ||
type: "array", | ||
}, | ||
], | ||
examples: [ | ||
{ | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall --title-id U_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, | ||
description: "Remove the acquired M365 App by Title ID", | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall -i false --mode title-id --title-id U_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, | ||
description: "Remove the acquired Microsoft 365 Application using Title ID", | ||
}, | ||
{ | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall -i false --mode manifest-id --manifest-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --options 'm365-app,app-registration,bot-framework-registration'`, | ||
description: "Remove the acquired Microsoft 365 Application using Manifest ID", | ||
}, | ||
{ | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall -i false --mode env --env xxx --options 'm365-app,app-registration,bot-framework-registration' --folder ./myapp`, | ||
description: | ||
"Remove the acquired Microsoft 365 Application using environment in Teams Toolkit generated project", | ||
}, | ||
{ | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall --manifest-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, | ||
description: "Remove the acquired M365 App by Manifest ID", | ||
command: `${process.env.TEAMSFX_CLI_BIN_NAME} uninstall`, | ||
description: "Uninstall in interactive mode", | ||
}, | ||
], | ||
telemetry: { | ||
event: TelemetryEvent.M365Unacquire, | ||
}, | ||
defaultInteractiveOption: false, | ||
defaultInteractiveOption: true, | ||
handler: async (ctx) => { | ||
const packageService = new PackageService(sideloadingServiceEndpoint, logger); | ||
let titleId = ctx.optionValues["title-id"] as string; | ||
const manifestId = ctx.optionValues["manifest-id"] as string; | ||
if (titleId === undefined && manifestId === undefined) { | ||
return err( | ||
new MissingRequiredOptionError(ctx.command.fullName, `--title-id or --manifest-id`) | ||
); | ||
} | ||
const tokenAndUpn = await m365utils.getTokenAndUpn(); | ||
if (titleId === undefined) { | ||
titleId = await packageService.retrieveTitleId(tokenAndUpn[0], manifestId); | ||
const inputs = ctx.optionValues as UninstallInputs; | ||
const core = getFxCore(); | ||
const res = await core.uninstall(inputs); | ||
if (res.isErr()) { | ||
return err(res.error); | ||
} | ||
await packageService.unacquire(tokenAndUpn[0], titleId); | ||
return ok(undefined); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.