microsoft/vscode-react-native

Public

mirrored fromhttps://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/openEASProject.ts

68lines · 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 { ExponentHelper } from "../exponent/exponentHelper";
11import { ReactNativeCommand } from "./util/reactNativeCommand";
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 OpenEASProject extends ReactNativeCommand {
21 nodeModulesRoot: string;
22 codeName = "openEASProjectInWebPage";
23 label = "Open the eas project in a web page";
24 error = ErrorHelper.getInternalError(InternalErrorCode.FailedToOpenProjectPage);
25
26 async baseFn(): Promise<void> {
27 assert(this.project);
28 const projectRootPath = this.project.getWorkspaceFolder().uri.fsPath;
29 const expoHelper = new ExponentHelper(projectRootPath, projectRootPath);
30 const isExpo = await expoHelper.isExpoManagedApp(true);
31
32 if (isExpo) {
33 try {
34 let id = null;
35 await expoHelper.getExpoEasProjectId().then(result => {
36 id = result;
37 });
38 let owner = null;
39 await expoHelper.getExpoEasProjectOwner().then(result => {
40 owner = result;
41 });
42 let name = null;
43 await expoHelper.getExpoEasProjectName().then(result => {
44 name = result;
45 });
46 if (id == null || owner == null) {
47 const error = localize(
48 "ExpoProjectNotLinkToEAS",
49 "Your app not link to EAS project. Please run 'eas init' firstly to bind your app to EAS project.",
50 );
51 void vscode.window.showErrorMessage(error);
52 logger.error(error);
53 } else if (name != null) {
54 // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
55 const url = `https://expo.dev/accounts/${owner}/projects/${name}`;
56 await vscode.env.openExternal(vscode.Uri.parse(url));
57 }
58 } catch {
59 logger.error(
60 localize(
61 "NoExistingEASProject",
62 "Unable to find existing EAS project. Please run 'eas init' firstly to bind your app to EAS project.",
63 ),
64 );
65 }
66 }
67 }
68}
69