Skip to content

Commit

Permalink
Monorepo refactor
Browse files Browse the repository at this point in the history
* Move frontend -> apps/react-frontend
* Updated package.json and lock files
* Starlight docs starter project
* Fix CI
* Tweak readme
  • Loading branch information
NigelBreslaw authored Dec 25, 2023
1 parent 1544b01 commit 5b0b29a
Show file tree
Hide file tree
Showing 32 changed files with 4,901 additions and 475 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
timeout-minutes: 1
steps:
- uses: actions/[email protected]
- uses: oven-sh/setup-bun@v1
- uses: pnpm/[email protected]
with:
bun-version: 1.0.19
version: 8.12.1
- name: install dependencies
run: bun install
run: pnpm install --frozen-lockfile
- name: lint
run: bun run lint
run: pnpm lint
- name: format
run: bun run format:check
run: pnpm format:check
- name: build
run: bun run build
run: pnpm build
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
.astro/
*.local

# Editor directories and files
Expand All @@ -22,3 +23,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# environment variables
.env
.env.production
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ The tech choices are based on interesting new tools to learn. However the main a

## Developer environment

As of December 2023 [Bun](https://bun.sh/) is being used which limits development to Linux and MacOS with Windows support only on [WSL](https://learn.microsoft.com/en-us/windows/wsl/about). However native windows support is excpted to be added to bun any week now.
I did try to use [Bun](https://bun.sh/) which limits development to Linux and MacOS with Windows support only on [WSL](https://learn.microsoft.com/en-us/windows/wsl/about). However the monorepo and full node ecosystem support isn't quite there yet. Thus Node and [Pnpm](https://pnpm.io) are used instead. CI runs as of 25.12.2023 are ~25 seconds with PNPM and probably would be 5-8 seconds faster with Bun. I will revisit Bun later in 2024 when its compatibility and Monorepo support improves.


Bun was chosen because of it's speed. It provides a package manager and unit test framework that is super fast. However not all tools are compatible with it. For example Dependabot automatic updates are not supported. To work around this the repo also maintains a 'working' [Pnpm](https://pnpm.io) config. Currently it should not be used for dev work, but it's there as a plan B if Bun starts to breakdown as the Monorepo evolves.

## CI / DevOps
The CI is powerered by github acctions and the aims are:
1. Full CI run should only take 1 min for the entire monorepo.
2. CI costs should happily fit inside githubs free tier. That's 2000 minutes a month. But runs under 1min don't seem to count!?
2. CI costs should happily fit inside githubs free tier. That's 2000 minutes a month. However none of these minutes is currently used as runs that take under a minute don't seem to count towards this total.
3. Try and use some of the new generation of Rust based tools to keep every stage as fast as possible.

Dependabot is enabled on the repo and runs everyday. In general the number of dependencies is kept as low as possible. However the aim is to only have items updated on a weekly basis.
[Dependabot](https://github.com/dependabot) is enabled on the repo and runs everyday. In general the number of dependencies is kept as low as possible. However the aim is to only have items updated on a weekly basis.

[Sonarqube](https://sonarcloud.io/organizations/nigelbreslaw/projects) offers a free tier for public projects and runs as a quality gate on every PR.

File renamed without changes.
30 changes: 30 additions & 0 deletions apps/react-frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@gg-monorepo/react-frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"analyze": "source-map-explorer dist/**/*.js",
"build": "vite build",
"dev": "vite",
"dev:bun": "bunx --bun vite",
"format:check": "biome format ./src",
"format:write": "biome format --write ./src",
"lint": "biome lint ./src",
"preview": "vite preview",
"typecheck": "tsc"
},
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"source-map-explorer": "2.5.3"
},
"devDependencies": {
"@types/react": "18.2.45",
"@types/react-dom": "18.2.18",
"@vitejs/plugin-react-swc": "3.5.0",
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-mkcert": "1.17.1"
}
}
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/starlight/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions docs/starlight/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
54 changes: 54 additions & 0 deletions docs/starlight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Starlight Starter Kit: Basics

[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)

```
npm create astro@latest -- --template starlight
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure

Inside of your Astro + Starlight project, you'll see the following folders and files:

```
.
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ ├── docs/
│ │ └── config.ts
│ └── env.d.ts
├── astro.config.mjs
├── package.json
└── tsconfig.json
```

Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.

Images can be added to `src/assets/` and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
27 changes: 27 additions & 0 deletions docs/starlight/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
title: 'My Docs',
social: {
github: 'https://github.com/withastro/starlight',
},
sidebar: [
{
label: 'Guides',
items: [
// Each item here is one entry in the navigation menu.
{ label: 'Example Guide', link: '/guides/example/' },
],
},
{
label: 'Reference',
autogenerate: { directory: 'reference' },
},
],
}),
],
});
21 changes: 21 additions & 0 deletions docs/starlight/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@gg-monorepo/starlight",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "0.15.1",
"astro": "4.0.7",
"sharp": "0.33.1"
},
"devDependencies": {
"@astrojs/check": "0.3.4",
"typescript": "5.3.3"
}
}
1 change: 1 addition & 0 deletions docs/starlight/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/starlight/src/assets/houston.webp
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/starlight/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineCollection } from 'astro:content';
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
};
11 changes: 11 additions & 0 deletions docs/starlight/src/content/docs/guides/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Example Guide
description: A guide in my new Starlight docs site.
---

Guides lead a user through a specific task they want to accomplish, often with a sequence of steps.
Writing a good guide requires thinking about what your users are trying to do.

## Further reading

- Read [about how-to guides](https://diataxis.fr/how-to-guides/) in the Diátaxis framework
36 changes: 36 additions & 0 deletions docs/starlight/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: Welcome to Starlight
description: Get started building your docs site with Starlight.
template: splash
hero:
tagline: Congrats on setting up a new Starlight project!
image:
file: ../../assets/houston.webp
actions:
- text: Example Guide
link: /guides/example/
icon: right-arrow
variant: primary
- text: Read the Starlight docs
link: https://starlight.astro.build
icon: external
---

import { Card, CardGrid } from '@astrojs/starlight/components';

## Next steps

<CardGrid stagger>
<Card title="Update content" icon="pencil">
Edit `src/content/docs/index.mdx` to see this page change.
</Card>
<Card title="Add new content" icon="add-document">
Add Markdown or MDX files to `src/content/docs` to create new pages.
</Card>
<Card title="Configure your site" icon="setting">
Edit your `sidebar` and other config in `astro.config.mjs`.
</Card>
<Card title="Read the docs" icon="open-book">
Learn more in [the Starlight Docs](https://starlight.astro.build/).
</Card>
</CardGrid>
11 changes: 11 additions & 0 deletions docs/starlight/src/content/docs/reference/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Example Reference
description: A reference page in my new Starlight docs site.
---

Reference pages are ideal for outlining how things work in terse and clear terms.
Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what your documenting.

## Further reading

- Read [about reference](https://diataxis.fr/reference/) in the Diátaxis framework
2 changes: 2 additions & 0 deletions docs/starlight/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
3 changes: 3 additions & 0 deletions docs/starlight/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strictest"
}
30 changes: 11 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
{
"name": "web-ishtar",
"name": "@GG-monorepo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"analyze": "source-map-explorer dist/**/*.js",
"dev": "vite",
"build": "tsc && bun --bun vite build",
"lint": "biome lint ./src",
"format:check": "biome format ./src",
"format:write": "biome format --write ./src",
"preview": "vite preview"
"build": "pnpm --stream -r build",
"lint": "pnpm -r lint",
"format:check": "pnpm -r format:check",
"format:write": "pnpm -r format:write"
},
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"source-map-explorer": "2.5.3"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
"@types/react": "18.2.45",
"@types/react-dom": "18.2.18",
"@vitejs/plugin-react-swc": "3.5.0",
"typescript": "5.3.3",
"vite": "5.0.10",
"vite-plugin-mkcert": "1.17.1"
}
"@biomejs/biome": "1.4.1"
},
"workspaces": [
"apps/*",
"docs/*"
]
}
Loading

0 comments on commit 5b0b29a

Please sign in to comment.