Files
eas-cli/packages/create-eas-build-function/src/resolveProjectRoot.ts
Stanisław Chmiela 789cf62bd6 [chore] Add eas-build packages (#3290)
## Consolidate eas-build packages into eas-cli monorepo

This PR completes the migration of packages from the `eas-build` repository into `eas-cli`, consolidating all EAS Build tooling into a single monorepo.

### Background

Previously, the EAS Build libraries lived in a separate `expo/eas-build` repository. This made development and releases more complex, requiring coordination between two repos. By consolidating into `eas-cli`, we can:

- Develop and test changes across CLI and build tools in a single PR
- Simplify the release process
- Reduce dependency version drift between packages

### Migrated Packages

The following packages have been moved from `eas-build`:

| Package | npm Name | License |
|---------|----------|---------|
| `build-tools` | `@expo/build-tools` | BUSL-1.1 |
| `eas-build-job` | `@expo/eas-build-job` | MIT |
| `steps` | `@expo/steps` | BUSL-1.1 |
| `logger` | `@expo/logger` | BUSL-1.1 |
| `downloader` | `@expo/downloader` | BUSL-1.1 |
| `turtle-spawn` | `@expo/turtle-spawn` | BUSL-1.1 |
| `template-file` | `@expo/template-file` | BUSL-1.1 |
| `local-build-plugin` | `eas-cli-local-build-plugin` | BUSL-1.1 |
| `create-eas-build-function` | `create-eas-build-function` | MIT |

### Changes

**Package Configuration:**
- Updated `repository` and `bugs` URLs in all migrated package.json files to point to `expo/eas-cli`
- Updated README repository links
- Aligned dependency versions across `eas-cli`, `eas-json`, and `worker` to use workspace packages

**Documentation:**
- Expanded `CLAUDE.md` with comprehensive documentation covering all packages, architectural patterns, and development workflows
- Added `AGENTS.md` for AI agent guidance

**Licensing:**
- Added `LICENSE-BUSL` for BUSL-1.1 licensed packages
- Added `LICENSE-eas-build-job` for MIT licensed packages

**Build Infrastructure:**
- Added `.gitignore` entries for build artifacts: `dist`, `*.tsbuildinfo` (needed for `tsconfig.json` and `tsconfig.build.json`), vim swap files
- Added `bin/eas-cli-local-build-plugin` symlink for local build testing

**Dependency Cleanup:**
- Removed stale npm registry entries from `yarn.lock` - workspace packages now resolve locally

### Testing

- [x] `yarn install` completes successfully
- [x] `yarn build` builds all packages
- [x] `yarn test` passes
- [x] Worker builds and runs correctly against workspace packages

### Follow-up

After this PR is merged:
- Archive or deprecate the `expo/eas-build` repository
- Update any CI/CD pipelines that referenced the old repo
- Update internal documentation pointing to eas-build
2026-02-03 14:30:15 +01:00

108 lines
2.9 KiB
JavaScript

#!/usr/bin/env node
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import prompts from 'prompts';
import { Log } from './log';
import { formatSelfCommand } from './resolvePackageManager';
import { getConflictsForDirectory } from './utils/dir';
export function assertFolderEmpty(projectRoot: string, folderName: string): void {
const conflicts = getConflictsForDirectory(projectRoot);
if (conflicts.length) {
Log.log(chalk`The directory {cyan ${folderName}} has files that might be overwritten:`);
Log.log();
for (const file of conflicts) {
Log.log(` ${file}`);
}
Log.log();
Log.exit('Try using a new directory name, or moving these files.\n');
}
}
const FORBIDDEN_NAMES = [
'react-native',
'react',
'react-dom',
'react-native-web',
'expo',
'expo-router',
];
export function assertValidName(folderName: string): void {
const validation = validateName(folderName);
if (typeof validation === 'string') {
Log.exit(chalk`{red Cannot create an app named {bold "${folderName}"}. ${validation}}`, 1);
}
const isForbidden = isFolderNameForbidden(folderName);
if (isForbidden) {
Log.exit(
chalk`{red Cannot create an app named {bold "${folderName}"} because it would conflict with a dependency of the same name.}`,
1
);
}
}
export async function resolveProjectRootAsync(input: string): Promise<string> {
let name = input?.trim();
if (!name) {
const { answer } = await prompts({
type: 'text',
name: 'answer',
message: 'What is your EAS Build function named?',
initial: 'my-function',
validate: name => {
const validation = validateName(path.basename(path.resolve(name)));
if (typeof validation === 'string') {
return 'Invalid project name: ' + validation;
}
return true;
},
});
if (typeof answer === 'string') {
name = answer.trim();
}
}
if (!name) {
const selfCmd = formatSelfCommand();
Log.log();
Log.log('Please choose your app name:');
Log.log(chalk` {dim $} {cyan ${selfCmd} <name>}`);
Log.log();
Log.log(`For more info, run:`);
Log.log(chalk` {dim $} {cyan ${selfCmd} --help}`);
Log.log();
Log.exit('');
}
const projectRoot = path.resolve(name);
const folderName = path.basename(projectRoot);
assertValidName(folderName);
await fs.promises.mkdir(projectRoot, { recursive: true });
assertFolderEmpty(projectRoot, folderName);
return projectRoot;
}
function validateName(name?: string): string | true {
if (typeof name !== 'string' || name === '') {
return 'The project name can not be empty.';
}
if (!/^[a-z0-9@.\-_]+$/i.test(name)) {
return 'The project name can only contain URL-friendly characters.';
}
return true;
}
function isFolderNameForbidden(folderName: string): boolean {
return FORBIDDEN_NAMES.includes(folderName);
}