Skip to content

Commit

Permalink
Use pnpm workspace (#28)
Browse files Browse the repository at this point in the history
* Use pnpm workspace

* Update tsconfig

* Add extension class

* Add configs

* Add configs

* Add extension class

* Add libs

* Fix util stuff

* Use pnpm build

* Use pnpm build

* Use pnpm build

* use util

* Move to extensions directory

* move extensions

* Update readme

* Update workflow

* Update workflow

* Add cache

* update lockfile

* Disable organize imports

* Move more stuff to util
  • Loading branch information
branberry authored Nov 11, 2024
1 parent 49d094a commit 8695808
Show file tree
Hide file tree
Showing 169 changed files with 37,198 additions and 189,633 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run lint
node-version: 22
cache: "pnpm"

- run: pnpm i
- run: pnpm lint
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.9.0
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,40 @@

This repository contains the integrations/extensions that are used for documentation site builds.

## Project setup

This project uses PNPM to manage dependencies. To install you can run the following the command:

`npm install -g pnpm`

For additional installation methods, follow [this link](https://pnpm.io/installation).

Once installed, dependencies can be installed at the root level of the project by using `pnpm install`.

## Project structure

The project is configured as a monorepo using [PNPM Workspaces](https://pnpm.io/workspaces). This allows us to install dependencies with one command, and to easily share dependencies between individual extensions.

```
- extensions/
- git-changed-files
- snooty-cache
- ...
- libs/
- util/
```

The extensions, unsurprisingly, live under the `extensions/` directory. The libs directory contains projects that are shared. Currently, there is a single project called `util` which contains the custom extension class used in the extension projects. To import a project into another one such as the `util` project in one of the extensions, go to the `package.json` of the extension, and add `"util": "workspace:*"` as a dependency (in this case, as a `devDependency`), and then run `pnpm install`. You can then import files from that project like so:

```ts
import { Extension } from "util/extensions";
```

If you make changes to the `util` project, the changes will only be reflected on subsequent builds of that project. You can run `pnpm build:util` at the root directory of the repository to rebuild those changes.

## linting/formatting with Biome

To install the linter, run `npm ci` at the root level of the project. From there, you can install the Biome Extension for VS Code to display linting errors.
To install the linter, run `pnpm i` at the root level of the project. From there, you can install the Biome Extension for VS Code to display linting errors.

For auto-formatting on save, add this configuration to your `settings.json`:

Expand Down
4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": ["*/.ntli/*"]
"ignore": ["*/.ntli/*", "*/build/*", "*.json"]
},
"formatter": {
"enabled": true,
Expand All @@ -16,7 +16,7 @@
"formatWithErrors": true
},
"organizeImports": {
"enabled": true
"enabled": false
},
"linter": {
"enabled": true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[build]
command = "netlify-extension build"
command = "pnpm build"
publish = ".ntli/site/static"

[dev]
command = "netlify-extension dev"

[functions]
directory = "src/endpoints"

[dev]
command = "netlify-extension dev"

[[plugins]]
package = "@netlify/netlify-plugin-netlify-extension"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "src/index.ts",
"type": "module",
"scripts": {
"build": "netlify-extension build",
"build": "pnpm --filter util build && netlify-extension build -a",
"dev": "netlify-extension dev --open",
"test": "vitest"
},
Expand All @@ -16,6 +16,9 @@
"devDependencies": {
"@netlify/build": "^29.50.2",
"@netlify/netlify-plugin-netlify-extension": "^1.0.3",
"@tsconfig/node18": "^18.2.4",
"@tsconfig/recommended": "^1.0.8",
"util": "workspace:*",
"@types/node": "^20.14.9",
"execa": "^6.1.0",
"netlify-cli": "^17.36.4",
Expand Down
Loading

0 comments on commit 8695808

Please sign in to comment.