Skip to content

Commit

Permalink
[ENG-10464][eas-cli] throw error if custom build config is gitignored (
Browse files Browse the repository at this point in the history
…#2123)

* [eas-cli] throw error if custom build config is gitignored

* update CHANGELOG.md
  • Loading branch information
szdziedzic authored Nov 22, 2023
1 parent 5b46476 commit 8c8b354
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🧹 Chores

- Throw error if custom build config is gitignored. ([#2123](https://github.com/expo/eas-cli/pull/2123) by [@szdziedzic](https://github.com/szdziedzic))

## [5.9.1](https://github.com/expo/eas-cli/releases/tag/v5.9.1) - 2023-11-20

### 🐛 Bug fixes
Expand Down
6 changes: 5 additions & 1 deletion packages/eas-cli/src/build/runBuildAndSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ export async function runBuildAndSubmitAsync(
{};
for (const buildProfile of buildProfiles) {
validateBuildProfileVersionSettings(buildProfile, easJsonCliConfig);
const maybeMetadata = await validateCustomBuildConfigAsync(projectDir, buildProfile.profile);
const maybeMetadata = await validateCustomBuildConfigAsync({
projectDir,
profile: buildProfile.profile,
vcsClient,
});
if (maybeMetadata) {
customBuildConfigMetadataByPlatform[toAppPlatform(buildProfile.platform)] = maybeMetadata;
}
Expand Down
22 changes: 18 additions & 4 deletions packages/eas-cli/src/project/customBuildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import chalk from 'chalk';
import fs from 'fs-extra';
import path from 'path';

import { Client } from '../vcs/vcs';

export interface CustomBuildConfigMetadata {
workflowName?: string;
}

export async function validateCustomBuildConfigAsync(
projectDir: string,
profile: BuildProfile<Platform>
): Promise<CustomBuildConfigMetadata | undefined> {
export async function validateCustomBuildConfigAsync({
profile,
projectDir,
vcsClient,
}: {
projectDir: string;
profile: BuildProfile<Platform>;
vcsClient: Client;
}): Promise<CustomBuildConfigMetadata | undefined> {
if (!profile.config) {
return undefined;
}
Expand All @@ -24,6 +31,13 @@ export async function validateCustomBuildConfigAsync(
`Custom build configuration file ${chalk.bold(relativeConfigPath)} does not exist.`
);
}
if (await vcsClient.isFileIgnoredAsync(relativeConfigPath)) {
throw new Error(
`Custom build configuration file ${chalk.bold(
relativeConfigPath
)} is ignored by your version control system. Remove it from the ignore list to successfully create custom build.`
);
}

try {
const config = await readAndValidateBuildConfigAsync(configPath, {
Expand Down

0 comments on commit 8c8b354

Please sign in to comment.