microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.4.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/exponent/xdlInterface.ts

108lines · modeblame

7059d307Patricio Beltran9 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 XDLPackage from "xdl";
242759feJiglioNero5 years ago5import * as MetroConfigPackage from "metro-config";
6import PackageLoader from "../../common/packageLoader";
0a68f8dbArtem Egorov8 years ago7
00a26245RedMickey5 years ago8const XDL_PACKAGE = "xdl";
242759feJiglioNero5 years ago9const METRO_CONFIG_PACKAGE = "@expo/metro-config";
10const NGROK_PACKAGE = "@expo/ngrok";
11
12const EXPO_DEPS: string[] = [XDL_PACKAGE, NGROK_PACKAGE];
13
14let getXDLPackage: () => Promise<
15typeof XDLPackage
16> = PackageLoader.getInstance().generateGetPackageFunction<typeof XDLPackage>(
66412fdfRuslan Bikkinin7 years ago17XDL_PACKAGE,
242759feJiglioNero5 years ago18...EXPO_DEPS,
19);
20let getMetroConfigPackage: () => Promise<
21typeof MetroConfigPackage
22> = PackageLoader.getInstance().generateGetPackageFunction<typeof MetroConfigPackage>(
23METRO_CONFIG_PACKAGE,
24...EXPO_DEPS,
25);
7059d307Patricio Beltran9 years ago26
27export type IUser = XDLPackage.IUser;
28
ce5e88eeYuri Skorokhodov5 years ago29export function configReactNativeVersionWargnings(): Promise<void> {
242759feJiglioNero5 years ago30return getXDLPackage().then(xdl => {
34472878RedMickey5 years ago31xdl.Config.validation.reactNativeVersionWarnings = false;
32});
7059d307Patricio Beltran9 years ago33}
34
34472878RedMickey5 years ago35export function attachLoggerStream(
36rootPath: string,
37options?: XDLPackage.IBunyanStream | any,
38): Promise<void> {
242759feJiglioNero5 years ago39return getXDLPackage().then(xdl => xdl.ProjectUtils.attachLoggerStream(rootPath, options));
7059d307Patricio Beltran9 years ago40}
41
ce5e88eeYuri Skorokhodov5 years ago42export function currentUser(): Promise<XDLPackage.IUser> {
242759feJiglioNero5 years ago43return getXDLPackage().then(xdl =>
34472878RedMickey5 years ago44xdl.User ? xdl.User.getCurrentUserAsync() : xdl.UserManager.getCurrentUserAsync(),
45);
7059d307Patricio Beltran9 years ago46}
47
ce5e88eeYuri Skorokhodov5 years ago48export function login(username: string, password: string): Promise<XDLPackage.IUser> {
242759feJiglioNero5 years ago49return getXDLPackage().then(xdl =>
34472878RedMickey5 years ago50xdl.User
51? xdl.User.loginAsync("user-pass", { username: username, password: password })
242759feJiglioNero5 years ago52: xdl.UserManager.loginAsync("user-pass", {
53username: username,
54password: password,
55}),
34472878RedMickey5 years ago56);
7059d307Patricio Beltran9 years ago57}
58
8f50947fRedMickey5 years ago59export function getExpoSdkVersions(): Promise<XDLPackage.SDKVersions> {
60return getXDLPackage().then(xdl => xdl.Versions.sdkVersionsAsync());
61}
62
63export function getReleasedExpoSdkVersions(): Promise<XDLPackage.SDKVersions> {
64return getXDLPackage().then(xdl => xdl.Versions.releasedSdkVersionsAsync());
7059d307Patricio Beltran9 years ago65}
66
34472878RedMickey5 years ago67export function publish(
68projectRoot: string,
69options?: XDLPackage.IPublishOptions,
70): Promise<XDLPackage.IPublishResponse> {
242759feJiglioNero5 years ago71return getXDLPackage().then(xdl => xdl.Project.publishAsync(projectRoot, options));
7059d307Patricio Beltran9 years ago72}
73
ce5e88eeYuri Skorokhodov5 years ago74export function setOptions(projectRoot: string, options?: XDLPackage.IOptions): Promise<void> {
242759feJiglioNero5 years ago75return getXDLPackage().then(xdl => xdl.Project.setOptionsAsync(projectRoot, options));
7059d307Patricio Beltran9 years ago76}
77
ce5e88eeYuri Skorokhodov5 years ago78export function startExponentServer(projectRoot: string): Promise<void> {
242759feJiglioNero5 years ago79return getXDLPackage().then(xdl => xdl.Project.startExpoServerAsync(projectRoot));
7059d307Patricio Beltran9 years ago80}
81
ce5e88eeYuri Skorokhodov5 years ago82export function startTunnels(projectRoot: string): Promise<void> {
242759feJiglioNero5 years ago83return getXDLPackage().then(xdl => xdl.Project.startTunnelsAsync(projectRoot));
7059d307Patricio Beltran9 years ago84}
85
ce5e88eeYuri Skorokhodov5 years ago86export function getUrl(projectRoot: string, options?: XDLPackage.IUrlOptions): Promise<string> {
242759feJiglioNero5 years ago87return getXDLPackage().then(xdl =>
88xdl.UrlUtils.constructManifestUrlAsync(projectRoot, options),
89);
7059d307Patricio Beltran9 years ago90}
91
ce5e88eeYuri Skorokhodov5 years ago92export function stopAll(projectRoot: string): Promise<void> {
242759feJiglioNero5 years ago93return getXDLPackage().then(xdl => xdl.Project.stopAsync(projectRoot));
7059d307Patricio Beltran9 years ago94}
62c4de22RedMickey6 years ago95
ce5e88eeYuri Skorokhodov5 years ago96export function startAdbReverse(projectRoot: string): Promise<boolean> {
242759feJiglioNero5 years ago97return getXDLPackage().then(xdl => xdl.Android.startAdbReverseAsync(projectRoot));
62c4de22RedMickey6 years ago98}
99
ce5e88eeYuri Skorokhodov5 years ago100export function stopAdbReverse(projectRoot: string): Promise<void> {
242759feJiglioNero5 years ago101return getXDLPackage().then(xdl => xdl.Android.stopAdbReverseAsync(projectRoot));
102}
103
104export function getMetroConfig(projectRoot: string): Promise<MetroConfigPackage.IMetroConfig> {
105return getMetroConfigPackage().then(metroConfigPackage =>
106metroConfigPackage.loadAsync(projectRoot),
107);
62c4de22RedMickey6 years ago108}