Is it possible to inspect what files are getting transferred to EAS? In my app.config.js I am switching between different .env files based on which mode is used (preview or production).
It looks like this:
import * as dotenv from 'dotenv'
import fs from 'fs'
const envPath = process.env.APP_ENV
? `.env.${process.env.APP_ENV}`
: '.env.development'
if (!fs.existsSync(envPath)) {
throw new Error(
`No ${envPath} file found. Please create one within the root directory of this project.`
)
}
dotenv.config({ path: envPath })
export default ({ config }) => {
return {
...config,
extra: {
API_KEY: process.env.API_KEY,
// And more...
}
}
}
When publishing or building it finds the .env.preview file, but on EAS build I get the following:
I don’t really know what to do and why it can’t find my .env.preview file.
If file is gitignored it won’t be uploaded to eas
# How projects are uploaded to EAS Build
When you run `eas build`, we need to get your source code from your development machine to one of our macOS or Linux build workers. In order to do this, EAS CLI will collect and compress project files into a single archive, and then upload that archive to private cloud storage that is accessible only to the build worker. By default, EAS CLI will produce the archive by copying all files starting from the root of the git repository with the exception of `.git`, `node_modules`, and all files matched by rules from `.gitignore` (or `.easignore` if it exists).
> `.easignore` supports [the same path patterns as `.gitignore` files](http://git-scm.com/docs/gitignore), but it can only be located in the root of your git repository and, if it is present, none of the existing `.gitignore` files will be respected by EAS CLI.
## What files are included in the archive?
You likely do not want to upload your `node_modules` directory, or maybe you have a `.env` file that is ignored by source control. EAS CLI always respects `.gitignore` files, but depending on your configuration there might be certain edge cases where EAS behavior is not 100% compliant with git.
You can run `eas build:inspect --platform [ios|android] --stage archive --output ~/target/output/path --profile production` and inspect the output directory (in this case `~/target/output/path`) to see which files are included.
#### EAS CLI
By default, or if you set the `EAS_NO_VCS` environment variable, EAS CLI will use its own packaging algorithm that approximates `git clone --depth 1 ...` and allows you to build with a dirty git working tree. The following limitations apply when using this approach:
- If you have multiple `.gitignore` files, they are applied in isolation starting from the root, so if you have an ignore rule like `test/example` in the parent directory and `!example/example1` in the `test` directory then the entire `example` directory will still be ignored.
- The `node_modules` directory is ignored by default.
- Even if you are using `git-crypt`, all the files are uploaded as they are in your project directory. This means all sensitive files could be uploaded to EAS Build in a non-encrypted state.
- The `.git` directory is not uploaded to EAS Build. So if you are using any tools that depend on the state of the Git repository, this might result in unexpected behavior (e.g. sentry reads the commit hash when uploading the source maps).
- The content of the submodules will be included as they are in your working directory.
This file has been truncated. show original
Hey wkozyra,
Thank you again for the quick answer. Your document helped me to debug further and the .env files aren’t gitignored, but with eas build inspect I can see the files are indeed in the archive.
So the problem should be in finding the file on the server. I have updated the pathname, going to trigger a new build to test it.
It worked! I was using the fs module wrong:
import * as dotenv from 'dotenv'
import fs from 'fs'
import path from 'path'
const envPath = process.env.APP_ENV
? `.env.${process.env.APP_ENV}`
: '.env.development'
const filePath = path.join(__dirname, envPath)
if (!fs.existsSync(filePath)) {
throw new Error(
`No ${envPath} file found. Please create one within the root directory of this project.`
)
}
dotenv.config({ path: envPath })
export default ({ config }) => {
return {
...config,
extra: {
API_KEY: process.env.API_KEY,
// and more
}
}
}
Marking this as answer because the eas build:inspect helped me tracking my issue.
system
Closed
August 18, 2022, 9:45am
6
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.