microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.11.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/commands/openRNUpgradeHelper.ts

59lines · modecode

1// 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({
14 messageFormat: nls.MessageFormat.bundle,
15 bundleFormat: nls.BundleFormat.standalone,
16})();
17const localize = nls.loadMessageBundle();
18const logger = OutputChannelLogger.getMainChannel();
19
20export class OpenRNUpgradeHelper extends Command {
21 codeName = "openRNUpgradeHelper";
22 label = "Open react native upgrade helper in web page";
23 error = ErrorHelper.getInternalError(InternalErrorCode.FailedToOpenRNUpgradeHelper);
24
25 async baseFn(): Promise<void> {
26 assert(this.project);
27 const RNUrl =
28 "https://react-native-community.github.io/upgrade-helper/?package=react-native";
29 const RNWUrl =
30 "https://react-native-community.github.io/upgrade-helper/?package=react-native-windows&language=cpp";
31 const RNMUrl =
32 "https://react-native-community.github.io/upgrade-helper/?package=react-native-macos";
33
34 await wait();
35 const item = await vscode.window.showQuickPick(
36 ["React Native", "React Native Windows", "React Native MacOS"],
37 {
38 placeHolder: "Select type for your react native project",
39 },
40 );
41
42 logger.info(
43 localize("OpenInWebBrowser", "Open react native upgrade helper in web browser."),
44 );
45
46 switch (item) {
47 case "React Native":
48 await vscode.env.openExternal(vscode.Uri.parse(RNUrl));
49 break;
50 case "React Native Windows":
51 await vscode.env.openExternal(vscode.Uri.parse(RNWUrl));
52 break;
53 case "React Native MacOS":
54 await vscode.env.openExternal(vscode.Uri.parse(RNMUrl));
55 break;
56 default:
57 }
58 }
59}
60