Skip to content

Commit

Permalink
Merge branch 'main' into @bycedric/eas-cli/deploy-project-url-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric authored Sep 14, 2024
2 parents ec436f4 + d7dfef0 commit 60ffe75
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes

- Avoid merging `expo.extra` plugin-generated data with `expo.extra.eas.projectId` in `eas init`. ([#2554](https://github.com/expo/eas-cli/pull/2554) by [@byCedric](https://github.com/byCedric)))
- Restore "export not found" error and hide recent export timestamps. ([#2566](https://github.com/expo/eas-cli/pull/2566) by [@byCedric](https://github.com/byCedric)))

### 🧹 Chores

Expand All @@ -39,6 +40,7 @@ This is the log of notable changes to EAS CLI and related packages.
- Share similar table/json output in both `worker` and `worker:alias` command outputs. ([#2563](https://github.com/expo/eas-cli/pull/2563) by [@byCedric](https://github.com/byCedric)))
- Polish the project URL prompt when setting up new projects. ([#2564](https://github.com/expo/eas-cli/pull/2564) by [@byCedric](https://github.com/byCedric)))
- Always assume `static` exports in `eas deploy` and add modified time. ([#2565](https://github.com/expo/eas-cli/pull/2565) by [@byCedric](https://github.com/byCedric)))
- Update the `eas worker --help` `--environment` description. ([#2567](https://github.com/expo/eas-cli/pull/2567) by [@byCedric](https://github.com/byCedric)))
- Remove the cursor space after selecting project dev domain. ([#2568](https://github.com/expo/eas-cli/pull/2568) by [@byCedric](https://github.com/byCedric)))

## [12.3.0](https://github.com/expo/eas-cli/releases/tag/v12.3.0) - 2024-09-09
Expand Down
14 changes: 5 additions & 9 deletions packages/eas-cli/src/commands/worker/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ export default class WorkerAlias extends EasCommand {
static override flags = {
prod: Flags.boolean({
aliases: ['production'],
description: 'Promote an existing deployment to production',
description: 'Promote an existing deployment to production.',
default: false,
}),
alias: Flags.string({
description: 'Custom alias to assign to the existing deployment',
description: 'Custom alias to assign to the existing deployment.',
helpValue: 'name',
required: false,
}),
id: Flags.string({
description: 'Unique identifier of an existing deployment',
description: 'Unique identifier of an existing deployment.',
helpValue: 'xyz123',
required: false,
}),
Expand All @@ -66,19 +66,15 @@ export default class WorkerAlias extends EasCommand {
};

override async runAsync(): Promise<void> {
// NOTE(cedric): `Log.warn` uses `console.log`, which is incorrect when running with `--json`
// eslint-disable-next-line no-console
console.warn(
chalk.yellow('EAS Worker Deployments are in beta and subject to breaking changes.')
);

const { flags: rawFlags } = await this.parse(WorkerAlias);
const flags = this.sanitizeFlags(rawFlags);

if (flags.json) {
enableJsonOutput();
}

Log.warn('EAS Worker Deployments are in beta and subject to breaking changes.');

const {
getDynamicPrivateProjectConfigAsync,
loggedIn: { graphqlClient },
Expand Down
62 changes: 42 additions & 20 deletions packages/eas-cli/src/commands/worker/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,27 @@ export default class WorkerDeploy extends EasCommand {
static override flags = {
prod: Flags.boolean({
aliases: ['production'],
description: 'Create a new production deployment',
description: 'Create a new production deployment.',
default: false,
}),
alias: Flags.string({
description: 'Custom alias to assign to the new deployment',
description: 'Custom alias to assign to the new deployment.',
helpValue: 'name',
}),
id: Flags.string({
description: 'Custom unique identifier for the new deployment',
description: 'Custom unique identifier for the new deployment.',
helpValue: 'xyz123',
}),
'export-dir': Flags.string({
description: 'Directory where the Expo project was exported',
description: 'Directory where the Expo project was exported.',
helpValue: 'dir',
default: 'dist',
}),
// TODO(@kitten): Allow deployment identifier to be specified
environment: {
...EASEnvironmentFlag.environment,
description: 'Deploy with EAS Environment Variables matching the specified environment.',
},
...EasNonInteractiveAndJsonFlags,
...EASEnvironmentFlag,
};

static override contextDefinition = {
Expand All @@ -93,19 +95,15 @@ export default class WorkerDeploy extends EasCommand {
};

async runAsync(): Promise<void> {
// NOTE(cedric): `Log.warn` uses `console.log`, which is incorrect when running with `--json`
// eslint-disable-next-line no-console
console.warn(
chalk.yellow('EAS Worker Deployments are in beta and subject to breaking changes.')
);

const { flags: rawFlags } = await this.parse(WorkerDeploy);
const flags = this.sanitizeFlags(rawFlags);

if (flags.json) {
enableJsonOutput();
}

Log.warn('EAS Worker Deployments are in beta and subject to breaking changes.');

const {
getDynamicPrivateProjectConfigAsync,
loggedIn: { graphqlClient },
Expand Down Expand Up @@ -360,29 +358,53 @@ async function resolveExportedProjectAsync(
flags: DeployFlags,
projectDir: string
): Promise<
| { type: 'static'; modifiedAt: Date; path: string }
| { type: 'server'; modifiedAt: Date; path: string; serverPath: string; clientPath: string }
| { type: 'static'; modifiedAt: Date | null; path: string }
| {
type: 'server';
modifiedAt: Date | null;
path: string;
serverPath: string;
clientPath: string;
}
> {
const exportPath = path.join(projectDir, flags.exportDir);
const serverPath = path.join(exportPath, 'server');
const clientPath = path.join(exportPath, 'client');

const [hasServerPath, hasClientPath, modifiedAt] = await Promise.all([
const [hasServerPath, hasClientPath, exportStat] = await Promise.all([
isDirectory(serverPath),
isDirectory(clientPath),
fs.promises.stat(exportPath).then(stat => stat.mtime),
fs.promises.stat(exportPath).catch(() => null),
]);

if (!exportStat?.isDirectory()) {
throw new Error(
`No "${flags.exportDir}/" folder found. Prepare your project for deployment with "npx expo export --platform web"`
);
}

if (hasServerPath && hasClientPath) {
return { type: 'server', path: exportPath, modifiedAt, serverPath, clientPath };
return {
type: 'server',
path: exportPath,
modifiedAt: exportStat.mtime,
serverPath,
clientPath,
};
}

return { type: 'static', path: exportPath, modifiedAt };
return { type: 'static', path: exportPath, modifiedAt: exportStat.mtime };
}

function logExportedProjectInfo(
project: Awaited<ReturnType<typeof resolveExportedProjectAsync>>
): void {
const modifiedAgo = formatTimeAgo(project.modifiedAt);
Log.log(chalk`{dim > Project export: ${project.type} - created ${modifiedAgo}}`);
let modifiedAgo = '';

// Only show the timestamp for exports older than 1 minute
if (project.modifiedAt && Date.now() - project.modifiedAt.getTime() > 60_000) {
modifiedAgo = ` - exported ${formatTimeAgo(project.modifiedAt)}`;
}

Log.log(chalk`{dim > Project export: ${project.type}${modifiedAgo}}`);
}

0 comments on commit 60ffe75

Please sign in to comment.