microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.11.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/commands/openRNUpgradeHelper.ts

59lines · modeblame

65773981Ezio Li3 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as assert from "assert";
5import * as nls from "vscode-nls";
6import * as vscode from "vscode";
7import { OutputChannelLogger } from "../log/OutputChannelLogger";
8import { ErrorHelper } from "../../common/error/errorHelper";
9import { InternalErrorCode } from "../../common/error/internalErrorCode";
10import { wait } from "../../common/utils";
11import { Command } from "./util/command";
12
13nls.config({
14messageFormat: nls.MessageFormat.bundle,
15bundleFormat: nls.BundleFormat.standalone,
16})();
17const localize = nls.loadMessageBundle();
18const logger = OutputChannelLogger.getMainChannel();
19
20export class OpenRNUpgradeHelper extends Command {
21codeName = "openRNUpgradeHelper";
22label = "Open react native upgrade helper in web page";
23error = ErrorHelper.getInternalError(InternalErrorCode.FailedToOpenRNUpgradeHelper);
24
25async baseFn(): Promise<void> {
26assert(this.project);
27const RNUrl =
28"https://react-native-community.github.io/upgrade-helper/?package=react-native";
29const RNWUrl =
30"https://react-native-community.github.io/upgrade-helper/?package=react-native-windows&language=cpp";
31const RNMUrl =
32"https://react-native-community.github.io/upgrade-helper/?package=react-native-macos";
33
34await wait();
35const item = await vscode.window.showQuickPick(
36["React Native", "React Native Windows", "React Native MacOS"],
37{
38placeHolder: "Select type for your react native project",
39},
40);
41
42logger.info(
43localize("OpenInWebBrowser", "Open react native upgrade helper in web browser."),
44);
45
46switch (item) {
47case "React Native":
48await vscode.env.openExternal(vscode.Uri.parse(RNUrl));
49break;
50case "React Native Windows":
51await vscode.env.openExternal(vscode.Uri.parse(RNWUrl));
52break;
53case "React Native MacOS":
54await vscode.env.openExternal(vscode.Uri.parse(RNMUrl));
55break;
56default:
57}
58}
59}