Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Source @expo/env dotenv vars for worker deployments #2545

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is the log of notable changes to EAS CLI and related packages.

- Make error message for invalid CFBundleShortVersionString more descriptive and actionable. Improve CFBundleShortVersionString validation regex. ([#2542](https://github.com/expo/eas-cli/pull/2542) by [@szdziedzic](https://github.com/szdziedzic))
- Add missing `--non-interactive` argument to `worker:deploy` command. ([#2544](https://github.com/expo/eas-cli/pull/2544) by [@kitten](https://github.com/kitten))
- Source `@expo/env` dotenv files for worker deployments. ([#2545](https://github.com/expo/eas-cli/pull/2545) by [@kitten](https://github.com/kitten))

## [12.3.0](https://github.com/expo/eas-cli/releases/tag/v12.3.0) - 2024-09-09

Expand Down
1 change: 1 addition & 0 deletions packages/eas-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@expo/config-types": "50.0.0",
"@expo/eas-build-job": "1.0.133",
"@expo/eas-json": "12.0.0",
"@expo/env": "^0.3.0",
"@expo/json-file": "8.2.37",
"@expo/logger": "1.0.117",
"@expo/multipart-body-parser": "1.1.0",
Expand Down
21 changes: 11 additions & 10 deletions packages/eas-cli/src/commands/worker/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,12 @@
);
}

async function* emitWorkerTarballAsync(
assetMap: WorkerAssets.AssetMap
): AsyncGenerator<WorkerAssets.FileEntry> {
yield ['assets.json', JSON.stringify(assetMap)];

// TODO: Create manifest from user configuration
const manifest = { env: {} };
yield ['manifest.json', JSON.stringify(manifest)];

async function* emitWorkerTarballAsync(params: {
assetMap: WorkerAssets.AssetMap,

Check warning on line 95 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Replace `,` with `;`
manifest: WorkerAssets.Manifest,

Check warning on line 96 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Replace `,` with `;`
}): AsyncGenerator<WorkerAssets.FileEntry> {
yield ['assets.json', JSON.stringify(params.assetMap)];
yield ['manifest.json', JSON.stringify(params.manifest)];
if (distServerPath) {
const workerFiles = WorkerAssets.listWorkerFilesAsync(distServerPath);
for await (const workerFile of workerFiles) {
Expand Down Expand Up @@ -195,7 +192,11 @@
let tarPath: string;
try {
assetMap = await WorkerAssets.createAssetMapAsync(distClientPath);
tarPath = await WorkerAssets.packFilesIterableAsync(emitWorkerTarballAsync(assetMap));
const manifest = await WorkerAssets.createManifestAsync(projectDir);
tarPath = await WorkerAssets.packFilesIterableAsync(emitWorkerTarballAsync({

Check warning on line 196 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Insert `⏎········`
assetMap,

Check warning on line 197 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Insert `··`
manifest,

Check warning on line 198 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Insert `··`
}));

Check warning on line 199 in packages/eas-cli/src/commands/worker/deploy.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Replace `})` with `··})⏎······`
} catch (error: any) {
progress.fail('Failed to prepare worker upload');
throw error;
Expand Down
13 changes: 13 additions & 0 deletions packages/eas-cli/src/worker/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import path from 'node:path';
import { pipeline } from 'node:stream/promises';
import { pack } from 'tar-stream';
import { get as getEnv } from '@expo/env';

Check warning on line 8 in packages/eas-cli/src/worker/assets.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

`@expo/env` import should occur before import of `minizlib`

/** Returns whether a file or folder is ignored */
function isIgnoredName(name: string): boolean {
Expand Down Expand Up @@ -87,6 +88,18 @@
return map;
}

export interface Manifest {
env: Record<string, string | undefined>;
}

/** Creates a manifest configuration sent up for deployment */
export async function createManifestAsync(

Check warning on line 96 in packages/eas-cli/src/worker/assets.ts

View workflow job for this annotation

GitHub Actions / Test with Node 22

Replace `⏎··projectDir:·string⏎` with `projectDir:·string`
projectDir: string
): Promise<Manifest> {
const { env } = getEnv(projectDir);
return { env };
}

interface WorkerFileEntry {
normalizedPath: string;
path: string;
Expand Down
23 changes: 23 additions & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading