microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dev/v-zhenyuan/update-parameters

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/commands/configEASBuild.ts

74lines · 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 assert = require("assert");
5import * as nls from "vscode-nls";
6import { OutputChannelLogger } from "../log/OutputChannelLogger";
7import { ErrorHelper } from "../../common/error/errorHelper";
8import { InternalErrorCode } from "../../common/error/internalErrorCode";
9import { CommandExecutor } from "../../common/commandExecutor";
10import { FileSystem } from "../../common/node/fileSystem";
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 ConfigEASBuild extends ReactNativeCommand {
21 nodeModulesRoot!: string;
22 codeName = "createExpoEASBuildConfigFile";
23 label = "Config Expo app with EAS build";
24 error = ErrorHelper.getInternalError(InternalErrorCode.FailedToConfigEASBuild);
25
26 async baseFn(): Promise<void> {
27 assert(this.project);
28 const projectRootPath = this.project.getPackager().getProjectPath();
29 const expoHelper = this.project.getExponentHelper();
30 logger.info(localize("CheckExpoEnvironment", "Checking Expo project environment."));
31 const isExpo = await expoHelper.isExpoManagedApp(true);
32
33 if (isExpo) {
34 const fs = new FileSystem();
35 const exists = await fs.exists(`${projectRootPath}/eas.json`);
36 if (exists) {
37 logger.info(
38 localize(
39 "FoundEASJsonFile",
40 "There is an eas.json file already existing in your app root.",
41 ),
42 );
43 } else {
44 logger.info(
45 localize("ConfigEASBuildInProgress", "Creating EAS build config file."),
46 );
47
48 try {
49 await new CommandExecutor(this.nodeModulesRoot, projectRootPath).execute(
50 "eas build:configure --platform all",
51 );
52
53 logger.info(
54 localize(
55 "ConfigEASBuildSuccessfully",
56 "Create EAS build config file successfully.",
57 ),
58 );
59 } catch {
60 logger.error(
61 localize(
62 "NoExistingEASProject",
63 "Unable to find existing EAS project. Please run 'eas init' firstly to bind your app to EAS project.",
64 ),
65 );
66 }
67 }
68 } else {
69 throw new Error(
70 localize("NotExpoApplication", "The current app is not an Expo application."),
71 );
72 }
73 }
74}
75