aws-amplify / aws-amplify/amplify-cli
SourceDir is getting ignored in the headless mode
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v16.13.1
### Amplify CLI Version
7.6.26
### What operating system are you using?
Mac
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
Only used the CLI.
### Amplify Categories
auth
### Amplify Commands
pull
### Describe the bug
I followed the Amplify headless mode documentation to create an `amplify-pull.sh` bash script to pull the app during the build time on the pipeline.
Here is the bash script:
```bash
#!/bin/bash
set -e
IFS='|'
AUTHCONFIG="{\
\"userPoolId\": \"$COGNITO_USER_POOL_ID\",\
\"webClientId\": \"$COGNITO_WEB_CLIENT_ID\",\
\"nativeClientId\": \"$COGNITO_WEB_CLIENT_ID\",\
}"
CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"profileName\":\"default\",\
\"accessKeyId\":\"$AMPLIFY_ACCESS_KEY_ID\",\
\"secretAccessKey\":\"$AMPLIFY_SECRET_KEY\",\
\"region\":\"eu-west-1\"\
}"
AMPLIFY="{\
\"projectName\":\"$AMPLIFY_PROJECT_NAME\",\
\"appId\":\"$AMPLIFY_APP_ID\",\
\"envName\":\"$AMPLIFY_ENVIRONMENT\",\
\"defaultEditor\":\"code\"\
}"
# SourceDir is defined here, and is used in the FRONTEND config (a few lines bellow this)
REACTCONFIG="{\
\"SourceDir\":\"src/aws-data\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"
amplify pull \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--categories $CATEGORIES \
--yes || true
```
### Expected behavior
I expect running the above bash script put the `aws-exports.js` in the `src/aws-data` but it ignore the path and put the `aws-exports.js` in the `src`.
I tried other values for the `SourceDir` like `aws-data`, or even tried to manually create the directory in case that the CLI was not able to make it. But none of it helped!
### Reproduction steps
1. Copy-paste the bash script above into an empty directory
2. put real values for the appId, accessKey, etc (now there are variables)
3. run `sh pull.sh` to pull the Amplify app
4. *It's expected, but does not happen:* The aws-exports.js should be in the `src/aws-data`
### GraphQL schema(s)
_No response_
### Log output
_No response_
### Additional information
_No response_
Contributor guide
Research direction
Start at the amplify pull command and reproduce the supplied bash script with a real SourceDir value. Trace how the --frontend configuration is read, then verify that aws-exports.js is generated under src/aws-data rather than src; add or run a regression check if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, bash, node.js, react, typescript
- Domain
- authentication, cli, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100