Skip to content

Commit 6448918

Browse files
authored
Add generate:watch command move generated specs back into gitignore (#240)
* style: add pnpm-lock.yaml to prettierignore * build: create generate:watch command * refactor: capture input/output dirs in variable for openapi generate * refactor: move build dir to fern dir and add it back to gitignore * refactor: clean up code related to deprecated build dir * fix: update fern check PR GH action to generate specs first * docs: update readme and contrbuting to reflect new project structure * refactor: rename sandbox-metadata to just metadata --------- Co-authored-by: dslovinsky <dslovinsky@users.noreply.github.com>
1 parent b7ec321 commit 6448918

File tree

143 files changed

+1853
-309306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+1853
-309306
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
# Mark generated API specs as generated files
2-
build/**/*.json linguist-generated=true
3-
42
fern/dist/** linguist-generated=true

.github/actions/publish-fern/action.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ outputs:
2727
runs:
2828
using: "composite"
2929
steps:
30-
- name: Install pnpm
31-
uses: pnpm/action-setup@v4
32-
with:
33-
version: 10.9.0
34-
run_install: false
30+
- name: Setup pnpm
31+
uses: ./.github/actions/setup-pnpm
3532

36-
- name: Install Fern
33+
- name: Generate API Specs
3734
shell: bash
38-
run: pnpm install -g fern-api
35+
run: pnpm run generate
3936

4037
- name: Build custom app
4138
shell: bash
@@ -60,9 +57,9 @@ runs:
6057
FERN_TOKEN: ${{ inputs.fern-token }}
6158
run: |
6259
if [[ "${{ inputs.preview }}" == "true" ]]; then
63-
OUTPUT=$(fern generate --docs --preview 2>&1) || true
60+
OUTPUT=$(pnpm fern generate --docs --preview 2>&1) || true
6461
else
65-
OUTPUT=$(fern generate --docs --log-level debug 2>&1) || true
62+
OUTPUT=$(pnpm fern generate --docs --log-level debug 2>&1) || true
6663
fi
6764
echo "$OUTPUT"
6865
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')

.github/actions/setup-pnpm/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
uses: pnpm/action-setup@v4
99
id: pnpm-install
1010
with:
11-
version: 9
11+
version: 10.9.0
1212
run_install: false
1313

1414
- name: Get pnpm store directory

.github/workflows/gh-pages-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ jobs:
2626

2727
- name: Run build script
2828
id: build
29-
run: pnpm generate && pnpm generate:sandbox-metadata
29+
run: pnpm generate && pnpm generate:metadata
3030

3131
- name: Upload static files as artifact
3232
id: deploy-artifact
3333
uses: actions/upload-pages-artifact@v3
3434
with:
35-
path: build/
35+
path: fern/api-specs/
3636

3737
deploy:
3838
runs-on: ubuntu-latest

.github/workflows/pr-validation.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ jobs:
4545
steps:
4646
- name: Checkout repository
4747
uses: actions/checkout@v4
48+
- name: Setup pnpm
49+
uses: ./.github/actions/setup-pnpm
4850

49-
- name: Install Fern
50-
run: npm install -g fern-api
51+
- name: Generate API Specs
52+
run: pnpm run generate
5153

5254
- name: Check API is valid
53-
run: fern check
55+
run: pnpm fern check

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ node_modules/
1212
.eslintcache
1313

1414
# dotenv environment variables file
15-
.env
16-
.env.test
17-
.env*.local
15+
.env*
1816

1917
# misc
2018
.DS_Store
@@ -32,4 +30,4 @@ yarn.lock
3230
debug.log
3331

3432
# generated
35-
.sandbox-metadata.json
33+
fern/api-specs/

.lintstagedrc.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ export default {
66
"eslint --fix",
77
"prettier --write --log-level silent",
88
],
9-
"*.{yml,yaml}": ["pnpm run generate", "prettier --write --log-level silent"],
10-
"*.json": ["prettier --write --log-level silent"],
9+
"*.{yml,yaml,json}": ["prettier --write --log-level silent"],
1110
};

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
build/
21
# Prettier doesn't support MDX 3 yet
32
# https://github.com/prettier/prettier/issues/12209
43
**/*.mdx
54
**/*.md
5+
fern/api-specs/
6+
pnpm-lock.yaml

CONTRIBUTING.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Thank you for your interest in contributing to Alchemy's documentation! This gui
2727

2828
* Location: `src/openapi/`
2929
* Define APIs using YAML following the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
30-
* **Tip**: Use the [Redocly VSCode extension](https://marketplace.visualstudio.com/items?itemName=Redocly.openapi-vs-code) to enable OpenAPI spec validation with Intellisense.
30+
31+
> \[!TIP]
32+
> Use the [Redocly VSCode extension](https://marketplace.visualstudio.com/items?itemName=Redocly.openapi-vs-code) to enable OpenAPI spec validation with Intellisense.
3133
3234
**JSON-RPC APIs (OpenRPC)**
3335

@@ -37,17 +39,23 @@ Thank you for your interest in contributing to Alchemy's documentation! This gui
3739
* `alchemy/`: Alchemy-specific APIs
3840
* `chains/`: Chain-specific APIs (e.g., ethereum, polygon)
3941

42+
> \[!TIP]
43+
> Use the [YAML VSCode extension](https://marketplace.cursorapi.com/items?itemName=redhat.vscode-yaml) to get some basic OpenRPC validation with Intellisense.
44+
4045
### Account Kit Documentation
4146

42-
Account Kit documentation is maintained in the [aa-sdk repository](https://github.com/alchemyplatform/aa-sdk). See its [README](https://github.com/alchemyplatform/aa-sdk/blob/main/docs/README.md) for contribution guidelines.
47+
Account Kit documentation is maintained separately in the [aa-sdk repository](https://github.com/alchemyplatform/aa-sdk). See its [README](https://github.com/alchemyplatform/aa-sdk/blob/main/docs/README.md) for contribution guidelines.
4348

4449
## Making Changes
4550

46-
1. Make your changes
47-
2. Test locally using `pnpm dev`
48-
3. Commit your changes
49-
4. Push to your fork
50-
5. Create a pull request to the upstream
51+
If you are not an [Alchemy Employee](#alchemy-employees), you will need to create your own fork.
52+
53+
1. Fork the repo (if you haven't already)
54+
2. Make your changes
55+
3. Test locally using `pnpm dev`
56+
4. Commit your changes
57+
5. Push to your fork
58+
6. Create a pull request to the upstream
5159

5260
## Markdown Style Guide
5361

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ The latest documentation lives on https://alchemy.docs.buildwithfern.com/home
1111
├── src/
1212
│ ├── openapi/ # REST API definitions (OpenAPI)
1313
│ └── openrpc/ # JSON-RPC API definitions (OpenRPC)
14-
── fern/
15-
├── <tab>/ # Written documentation for that tab (MDX)
16-
── docs.yml # Navigation and structure config
17-
└── build/ # Generated files - Do NOT make changes here
14+
── fern/
15+
├── <tab>/ # Written documentation for that tab (MDX)
16+
── api-specs/ # Dereferenced API Specs generated from definitions (gitignored)
17+
└── docs.yml # Navigation and structure config
1818
```
1919

20+
> \[!WARNING]
21+
> Account Kit documentation is maintained separately in the [aa-sdk repository](https://github.com/alchemyplatform/aa-sdk). See its [README](https://github.com/alchemyplatform/aa-sdk/blob/main/docs/README.md) for contribution guidelines.
22+
2023
## Getting Started
2124

2225
### Prerequisites
@@ -65,7 +68,7 @@ pnpm fern login
6568
pnpm fern generate --docs --preview
6669
```
6770

68-
This will take a minute as it needs to upload a lot files to generate the preview and it will output a preview URL.
71+
This will take a few minutes as it needs to upload a lot of files to generate the preview after which it will output a preview URL.
6972

7073
### Building API Specs
7174

@@ -75,11 +78,11 @@ Production OpenAPI and OpenRPC specs are generated using scripts from their defi
7578
pnpm run generate
7679
```
7780

78-
This will generate all specs as dereferenced json files in the `build/` directory.
81+
This will generate all specs as dereferenced json files in the `fern/api-specs` directory.
7982

8083
### Validation
8184

82-
You can validate both OpenAPI and OpenRPC using scripts.
85+
You can validate both OpenAPI and OpenRPC using these commands:
8386

8487
```bash
8588
# Validate REST API specs

0 commit comments

Comments
 (0)