- ⚡️ Gatsby 5
- ⚛️ React 18
- ⛑ TypeScript
- 🐐 Tests — Vitest and Testing Library out of the box
- 📏 ESLint — To find and fix problems in your code
- 💖 Prettier — Code Formatter for consistent style
- 🐶 Husky — For running scripts before committing
- 🚓 Commitlint — To make sure your commit messages follow the convention
- 🖌 Renovate — To keep your dependencies up to date (needs to be set up)
- 🚫 lint-staged — Run ESLint and Prettier against staged Git files (under development)
- 👷 PR Workflow — Run Type Check & Linters on Pull Requests
- ⚙️ EditorConfig - Consistent coding styles across editors and IDEs
- 🗂 Path Mapping — Import components or images using the
@
prefix
The best way to start is to clone this repo:
git clone https://github.com/usds/gastby-uswds-ts-starter.git your-project-name
To start the project locally:
- Git clone the starter repo (above) in a terminal
- run
cd your-project-name
- If you don't have node 18, install and verify that
node -v
return 18.x. You can usenvm
orasdf
- run
nvm use 18
- Ensure that
pnpm
andgatsby-cli
are globally installed:
$ npm list -g --depth=0
/Users/username/.nvm/versions/node/v18.12.1/lib
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
- run
pnpm install
- run
pnpm clean && pnpm start
Open http://localhost:8000
with your browser to see the result.
- Node.js >= 18
- pnpm 7
__helpers__
— Helpers files for testing configuration.__mocks__
— Mocks for testing..github
— GitHub configuration including the CI workflow..husky
— Husky configuration and hooks.src
— Application source code, including pages, components, styles.
pnpm start
— Starts the application in development mode athttp://localhost:8000
.pnpm build
— Compile your application and make it ready for deployment.pnpm serve
— Serve the production build of your sitepnpm clean
— Wipe out the cache (.cache
folder).pnpm type-check
— Validate code using TypeScript compiler.pnpm lint
— Runs ESLint for all files in thesrc
directory.pnpm format
— Runs Prettier for all files in thesrc
directory.pnpm test
— Run tests with Vitest.pnpm test:watch
— Run tests on watch mode.
TypeScript are pre-configured with custom path mappings. To import components or files, use the @
prefix.
import { Button } from '@/components/Button';
// To import images or other files from the static folder
import avatar from '@/static/avatar.png';
- works with trusswork components
- can use USWDS tokens as mixins in sass modules (at component level)
- works with i18n using format.js (react-intl)
- has a generator script to quickly create components
pnmp run type-check
pnmp run lint
pnmp run format
pnmp run test
pnmp run intl:extract
The steps involved with creating i18n content is as follows:
- Use
react-intl
as demonstrated in various pages and/or components. - When new content is added, run
pnpm intl:extract
. This will update the json object inlang/en-US-extract.json
. - Run
pnpm intl:createEnJson
. This will modify the extracted JSON file into an AST that the library expects and remove console errors. - Translate the
en-US.json
file to anes-MX.json
. Each key from theen-US.json
file should have a spanish value ines-MX.json
.
Currently this repo is using Github actions (see .github/workflows in the root directory) for deployment to AWS with the support of Geoplatform.
The Github actions currently expect an S3 bucket to exist. When setting up the S3 on AWS, you can specify the name and the region. Each action requires this name and region to be set as environment variables:
- AWS_BUCKET_NAME
- AWS_REGION
These actions will
- creates a staging link (see deploy-staging.yml) as a comment in every PR made against
main
that passes all checks (type-check, linting, testing, format, commit messages) - update the production folder on AWS
- remove any artifacts of the PR when the PR is closed (see close-pr.yml)
In order for these actions to work as is, the following secrets need to be added in your repo:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- STAGE_SITE_URL
The AWS_ACCESS_KEY_ID and the AWS_SECRET_ACCESS_KEY will allow for programmatic (via CLI) access to your AWS resources. See the programmatic access section on here.
The STAGE_SITE_URL should point to the name of your S3 bucket or CDN.
This project is licensed under the MIT License - see the LICENSE.md file for more information.