microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
transitive-dependency-serialize-javascript

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/commands/configEASBuild.ts

74lines · modeblame

ee2a3185Ezio 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 { 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({
14messageFormat: nls.MessageFormat.bundle,
15bundleFormat: nls.BundleFormat.standalone,
16})();
17const localize = nls.loadMessageBundle();
18const logger = OutputChannelLogger.getMainChannel();
19
20export class ConfigEASBuild extends ReactNativeCommand {
21nodeModulesRoot: string;
22codeName = "createExpoEASBuildConfigFile";
23label = "Config Expo app with EAS build";
24error = ErrorHelper.getInternalError(InternalErrorCode.FailedToConfigEASBuild);
25
26async baseFn(): Promise<void> {
27assert(this.project);
9c71977dEzio Li2 years ago28const projectRootPath = this.project.getPackager().getProjectPath();
29const expoHelper = this.project.getExponentHelper();
30logger.info(localize("CheckExpoEnvironment", "Checking Expo project environment."));
ee2a3185Ezio Li3 years ago31const isExpo = await expoHelper.isExpoManagedApp(true);
32
33if (isExpo) {
34const fs = new FileSystem();
35const exists = await fs.exists(`${projectRootPath}/eas.json`);
36if (exists) {
37logger.info(
38localize(
39"FoundEASJsonFile",
40"There is an eas.json file already existing in your app root.",
41),
42);
43} else {
44logger.info(
45localize("ConfigEASBuildInProgress", "Creating EAS build config file."),
46);
47
48try {
49await new CommandExecutor(this.nodeModulesRoot, projectRootPath).execute(
50"eas build:configure --platform all",
51);
52
53logger.info(
54localize(
55"ConfigEASBuildSuccessfully",
56"Create EAS build config file successfully.",
57),
58);
59} catch {
60logger.error(
61localize(
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 {
69throw new Error(
70localize("NotExpoApplication", "The current app is not an Expo application."),
71);
72}
73}
74}