Skip to content

Commit b3b03a0

Browse files
authored
chore: optimize local testing of amplify-dev (#146)
* chore: optimize local testing of amplify-dev * fix: rm space * chore: update contribution * fix: remove underline * fix: minor fix * chore: update pretty-quick dependency * fix: address cr * fix: add anchor point
1 parent 8fbd99a commit b3b03a0

File tree

2 files changed

+64
-17
lines changed

2 files changed

+64
-17
lines changed

CONTRIBUTING.md

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,52 @@ Thank you for your interest in contributing to our project! 💛
44

55
Whether it's a bug report, new feature, correction, or additional documentation, we greatly value feedback and contributions from our community. Please read through these guidelines carefully before submitting a PR or issue and let us know if it's not up-to-date (or even better, submit a PR with your proposed corrections 😉).
66

7-
# Development Process
7+
## Getting Started
88

99
Our work is done directly on Github and PR's are sent to the GitHub repo by core team members and contributors. Everyone undergoes the same review process to get their changes into the repo.
1010

11-
# Setting up for local development
11+
This section should get you running with **Amplify Codegen**.
1212

13-
This section should get you running with **Amplify Codegen**. You will need the latest version of [nodejs](https://nodejs.org/en/) on your system and developing locally also requires `yarn` workspaces. You can install it [here](https://classic.yarnpkg.com/en/docs/install#mac-stable).
13+
### Setting up for local development
1414

15-
Start by, [Forking](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) the main branch of [amplify-codegen](https://github.com/aws-amplify/amplify-codegen).
15+
1. You will need the latest version of [nodejs](https://nodejs.org/en/) on your system and developing locally also requires `yarn` workspaces. You can install it [here](https://classic.yarnpkg.com/en/docs/install#mac-stable).
1616

17-
```
17+
2. Start by [Forking](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) the main branch of [amplify-codegen](https://github.com/aws-amplify/amplify-codegen).
18+
19+
```sh
1820
$ git clone [email protected]:[username]/amplify-codegen.git
21+
```
22+
23+
> NOTE: Make sure to always [sync your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork) with _main_ branch of amplify-codegen
24+
25+
3. Move into your project folder
26+
27+
```sh
1928
$ cd amplify-codegen
29+
```
30+
31+
4. Run `setup-dev` script to installs dependencies and perform initial configuration. This command will also link a `amplify-dev` binary for your local testing.
2032

21-
$ yarn run setup-dev
33+
```sh
34+
$ yarn setup-dev
2235
```
2336

24-
# Bugs
37+
> NOTE: The `amplify-dev` binary is built based on the latest amplify cli from npm registry and your local codegen packages. All your local changes from codegen can be reflected (typescript files need to be build by `tsc`). In addition, if you are a developer of cli repo, you can run the same command to override the `amplify-dev` binary.
38+
39+
### Architecture of the codebase
40+
41+
Amplify Codegen is a monorepo built with [Yarn Workspaces](https://yarnpkg.com/features/workspaces) and [Lerna](https://github.com/lerna/lerna). All packages live within the `packages/` directory in the root. Each category inside packages has its own `src/` and `package.json`.
42+
43+
### Steps towards contribution
44+
45+
- Make changes to required file.
46+
- Write unit tests
47+
- Run `yarn build` to compile your changes
48+
- [Run test suite](#tests)
49+
- Test in sample app using [amplify-dev](#tests)
50+
- Submit a PR
51+
52+
## Bugs
2553

2654
Bug reports and feature suggestions are always welcome. Good bug reports are extremely helpful, so thanks in advance!
2755

@@ -40,20 +68,20 @@ Guidelines for bug reports:
4068
- Format any code snippets using [Markdown](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) syntax
4169
- If you're not using the latest version of the CLI, see if the issue still persists after upgrading - this helps to isolate regressions!
4270

43-
# Pull Requests
44-
71+
## Pull Requests
4572

4673
Pull requests are welcome!
4774

48-
You should open an issue to discuss your pull request, unless it's a trivial change. It's best to ensure that your proposed change would be accepted so that you don't waste your own time. If you would like to implement support for a significant feature that is not yet available, please talk to us beforehand to avoid any duplication of effort.
75+
You should open an issue to discuss your pull request, unless it's a trivial change. It's best to ensure that your proposed change would be accepted so that you don't waste your own time. If you would like to implement support for a significant feature that is not yet available, please talk to us beforehand to avoid any duplication of effort.
4976

5077
Pull requests should generally be opened against **master**.
5178

52-
Only include ***src*** files in your PR. Don't include any build files i.e. dist/. These will be built upon publish to npm and when a release is created on GitHub.
79+
Don't include any build files i.e. `dist/`, `lib/`. These will be built upon publish to npm and when a release is created on GitHub.
5380

5481
Before submitting PR make sure to run `yarn` on the root of monorepo to ensure that commit lint and husky are installed.
5582

5683
Make sure you follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) commit message structure. You can automatically generate conventional commit message by running `yarn commit` in the root of the amplify mono repo. This will run through series of question shown below
84+
5785
```
5886
? Select the type of change that you're committing: <type of commit (if its a feature, bug fix etc.,>
5987
? What is the scope of this change (e.g. component or file name)? <package name if change is only in one package>
@@ -67,7 +95,25 @@ Make sure you follow [conventional commits](https://www.conventionalcommits.org/
6795

6896
## Tests
6997

70-
Please ensure that your change still passes unit tests, and ideally integration/UI tests. Use `yarn run test-ci` to run the test suite like it would in our CI environment. It's OK if you're still working on tests at the time that you submit, but be prepared to be asked about them. Wherever possible, pull requests should contain tests as appropriate. Bugfixes should contain tests that exercise the corrected behavior (i.e., the test should fail without the bugfix and pass with it), and new features should be accompanied by tests exercising the feature.
98+
Please ensure that your change still passes unit tests, and ideally integration/UI tests. It's OK if you're still working on tests at the time that you submit, but be prepared to be asked about them. Wherever possible, pull requests should contain tests as appropriate. Bugfixes should contain tests that exercise the corrected behavior (i.e., the test should fail without the bugfix and pass with it), and new features should be accompanied by tests exercising the feature.
99+
100+
To run the test suite:
101+
102+
```sh
103+
# Unit tests
104+
$ yarn test
105+
106+
# Tests in CI environment
107+
$ yarn test-ci
108+
```
109+
110+
To test in a sample application with `amplify-dev`:
111+
112+
```sh
113+
$ cd <your-test-frontend-project>
114+
$ amplify-dev init
115+
$ amplify-dev codegen <subcommand>
116+
```
71117

72118
## Code Style
73119

@@ -92,7 +138,6 @@ For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of
92138

93139
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.
94140

95-
96141
## Licensing
97142

98143
AWS Amplify Codegen is [Apache 2.0](LICENSE)-licensed. Contributions you submit will be released under that license.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"verdaccio-publish": "yarn verdaccio-clean && yarn publish-to-verdaccio",
2323
"verdaccio-disconnect": "source .circleci/local_publish_helpers.sh && unsetNpmRegistryUrl",
2424
"verdaccio-stop": "kill -9 $(lsof -n -t -iTCP:4873 -sTCP:LISTEN)",
25-
"setup-dev": "yarn && lerna run build",
25+
"setup-dev": "(yarn && lerna run build) && (yarn hoist-cli && yarn rm-dev-link && yarn link-dev)",
26+
"hoist-cli": "rm -rf node_modules/amplify-cli && mkdir node_modules/amplify-cli && cp -r node_modules/@aws-amplify/cli/ node_modules/amplify-cli",
27+
"link-dev": "cd node_modules/amplify-cli && ln -s \"$(pwd)/bin/amplify\" \"$(yarn global bin)/amplify-dev\" && cd -",
28+
"rm-dev-link": "rm -f \"$(yarn global bin)/amplify-dev\"",
2629
"commit": "git-cz",
2730
"coverage": "codecov || exit 0"
2831
},
@@ -84,13 +87,12 @@
8487
"lnk": "1.1.0",
8588
"prettier": "^1.19.1",
8689
"prettier-eslint": "^9.0.1",
87-
"pretty-quick": "^2.0.1",
90+
"pretty-quick": "^3.1.0",
8891
"rimraf": "^3.0.0",
8992
"ts-jest": "^25.5.0",
9093
"ts-node": "^8.10.1",
9194
"typescript": "^3.8.3",
92-
"amplify-cli-core": "^1.17.2",
93-
"graphql-transformer-core": "^6.26.2"
95+
"@aws-amplify/cli": "^4.46.1"
9496
},
9597
"config": {
9698
"commitizen": {

0 commit comments

Comments
 (0)