microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
5940f996e19e33b2c611c0d447a7ffb66d249d80

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/configurationProviderHelper.ts

108lines · 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 {
5 MultiStepInput,
6 IQuickPickParameters,
7} from "../extension/debuggingConfiguration/multiStepInput";
8import { ILaunchRequestArgs } from "../debugger/debugSessionBase";
9import { ExpoHostType } from "../extension/launchArgs";
10import {
11 DebugConfigurationState,
12 DebugConfigurationQuickPickItem,
13 appTypePickConfig,
14 expoHostTypePickConfig,
15} from "../extension/debuggingConfiguration/debugConfigTypesAndConstants";
16import * as nls from "vscode-nls";
17nls.config({
18 messageFormat: nls.MessageFormat.bundle,
19 bundleFormat: nls.BundleFormat.standalone,
20})();
21const localize = nls.loadMessageBundle();
22
23export class ConfigurationProviderHelper {
24 public async selectPlatform(
25 input: MultiStepInput<DebugConfigurationState>,
26 config: Partial<ILaunchRequestArgs>,
27 platformTypePickConfig: DebugConfigurationQuickPickItem[],
28 step: number,
29 totalSteps: number,
30 ): Promise<Partial<ILaunchRequestArgs>> {
31 let pick = await input.showQuickPick<
32 DebugConfigurationQuickPickItem,
33 IQuickPickParameters<DebugConfigurationQuickPickItem>
34 >({
35 title: localize("PlatformSelectionTitle", "Select platform"),
36 placeholder: localize("PlatformSelectionPrompt", "Platform to run on"),
37 step,
38 totalSteps,
39 items: platformTypePickConfig,
40 activeItem: platformTypePickConfig[0],
41 });
42
43 if (!pick) {
44 throw new Error("Platform is not selected");
45 }
46
47 config.platform = pick.type;
48 return config;
49 }
50
51 public async selectApplicationType(
52 input: MultiStepInput<DebugConfigurationState>,
53 config: Partial<ILaunchRequestArgs>,
54 step: number,
55 totalSteps: number,
56 ): Promise<Partial<ILaunchRequestArgs>> {
57 let pick = await input.showQuickPick<
58 DebugConfigurationQuickPickItem,
59 IQuickPickParameters<DebugConfigurationQuickPickItem>
60 >({
61 title: localize(
62 "ApplicationTypeSelectionTitle",
63 "Select type of React Native application",
64 ),
65 placeholder: localize(
66 "ApplicationTypeSelectionPrompt",
67 "Type of React Native application",
68 ),
69 step,
70 totalSteps,
71 items: appTypePickConfig,
72 activeItem: appTypePickConfig[0],
73 });
74
75 if (!pick) {
76 throw new Error("Application type is not selected");
77 }
78
79 config.type = pick.type;
80 return config;
81 }
82
83 public async selectExpoHostType(
84 input: MultiStepInput<DebugConfigurationState>,
85 config: Partial<ILaunchRequestArgs>,
86 step: number,
87 totalSteps: number,
88 ): Promise<Partial<ILaunchRequestArgs>> {
89 let pick = await input.showQuickPick<
90 DebugConfigurationQuickPickItem,
91 IQuickPickParameters<DebugConfigurationQuickPickItem>
92 >({
93 title: localize("ExpoHostTypeSelectionTitle", "Select type of Expo host parameter"),
94 placeholder: localize("ExpoHostTypeSelectionPrompt", "Type of Expo host parameter"),
95 step,
96 totalSteps,
97 items: expoHostTypePickConfig,
98 activeItem: expoHostTypePickConfig[0],
99 });
100
101 if (!pick) {
102 throw new Error("Expo host type is not selected");
103 }
104
105 config.expoHostType = pick.type as ExpoHostType;
106 return config;
107 }
108}
109