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

68lines · modeblame

57fee98eEzio 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 { ExponentHelper } from "../exponent/exponentHelper";
11import { ReactNativeCommand } from "./util/reactNativeCommand";
12
13nls.config({
14messageFormat: nls.MessageFormat.bundle,
15bundleFormat: nls.BundleFormat.standalone,
16})();
17const localize = nls.loadMessageBundle();
18const logger = OutputChannelLogger.getMainChannel();
19
20export class OpenEASProject extends ReactNativeCommand {
21nodeModulesRoot: string;
22codeName = "openEASProjectInWebPage";
23label = "Open the eas project in a web page";
24error = ErrorHelper.getInternalError(InternalErrorCode.FailedToOpenProjectPage);
25
26async baseFn(): Promise<void> {
27assert(this.project);
28const projectRootPath = this.project.getWorkspaceFolder().uri.fsPath;
29const expoHelper = new ExponentHelper(projectRootPath, projectRootPath);
30const isExpo = await expoHelper.isExpoManagedApp(true);
31
32if (isExpo) {
33try {
34let id = null;
35await expoHelper.getExpoEasProjectId().then(result => {
36id = result;
37});
38let owner = null;
39await expoHelper.getExpoEasProjectOwner().then(result => {
40owner = result;
41});
42let name = null;
43await expoHelper.getExpoEasProjectName().then(result => {
44name = result;
45});
46if (id == null || owner == null) {
47const 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);
51void vscode.window.showErrorMessage(error);
52logger.error(error);
53} else if (name != null) {
54// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
55const url = `https://expo.dev/accounts/${owner}/projects/${name}`;
56await vscode.env.openExternal(vscode.Uri.parse(url));
57}
58} catch {
59logger.error(
60localize(
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}