Skip to content

Commit

Permalink
Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hamlim committed May 14, 2024
1 parent 929b599 commit a961422
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 118 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Template monorepo
# One Version Monorepo

This is a template repo in GitHub for creating a fresh monorepo for managing code and documentation.
This repo contains the [`one-version`](./packages/one-version/README.md) library, a strict dependency conformance tool for monorepos.

For more details on this setup, refer to my blog post here: https://matthamlin.me/2024/february/library-docs-monorepo-template
<!--
<a href="https://hohoro.vercel.app/">Docs</a> | <a href="https://npm.im/hohoro">NPM</a> |
-->

## Getting Started:

- Use this template (see `Use this Template` button near the top right corner of the page)
- Clone the newly created repo
- Run `bun install` (if you don't have bun installed locally, refer to their [docs](https://bun.sh))
- Start writing some code!
<p align="center">
<a href="./packages/one-version/README.md">Source</a>
</p>

---

Check out the [Guidebook](./GUIDEBOOK.md) for more details on how to use this repo setup!
_Refer to the [Monorepo GUIDEBOOK.md](./GUIDEBOOK.md) for details about the repo setup and structure!_
24 changes: 19 additions & 5 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -18,9 +22,19 @@
}
],
"paths": {
"~/*": ["./*"]
}
"~/*": [
"./*"
]
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
24 changes: 19 additions & 5 deletions apps/template-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -18,9 +22,19 @@
}
],
"paths": {
"~/*": ["./*"]
}
"~/*": [
"./*"
]
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/one-version/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Unreleased:

### [0.0.1] - May 14th, 2024

- Initial release
59 changes: 59 additions & 0 deletions packages/one-version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# `one-version`

## Getting Started:

Install `one-version` from the root of your repo (even for monorepos!):

```bash
bun add one-version
```

Add a `one-version:check` script to your root `package.json`:

```json
{
"scripts": {
"one-version:check": "one-version check"
}
}
```

## Configuration:

`one-version` can be configured using a `one-version.config.(jsonc|json)` file in the root of your repo. Here's an example:

```jsonc
{
// one of: "bun", "yarn-berry", "yarn", "pnpm", "npm"
// by default it will try to detect the package manager based on the presence of a lockfile
"packageManager": "bun",
}
```

## Inspiration:

This is effectively a fork of the [wayfair/one-version](https://github.com/wayfair/one-version) project, which I had partially contributed to while I was at Wayfair. This fork is intended to be a slimmer re-write of the original project, aiming to support the same functionality (eventually), with also supporting `bun`!

This tool should be a drop-in replacement for `@wayfair/one-version`, if you run into any issues or collisions, please open an issue!

## Contributing:

This library does not have a build step currently.

### Code Quality:

#### Type Checking:

This library uses TypeScript to perform type checks, run `bun run type-check` from the root or from this workspace!

#### Linting

This library uses [BiomeJS](https://biomejs.dev/) for linting, run `bun run lint` from the root or from this workspace!

#### Tests

This library uses Node.js for running unit tests, run `bun run test` from the root or from this workspace!

### Publishing:

To publish the library, run `bun run pub` from the workspace root. This will prompt you to login to npm and publish the package.
6 changes: 6 additions & 0 deletions packages/one-version/__tests__/one-version.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import assert from "node:assert";
import { after, before, test } from "node:test";

test("stub", () => {
assert.ok(true);
});
8 changes: 8 additions & 0 deletions packages/one-version/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node
import { start } from "../one-version.mjs";

start({ rootDirectory: process.cwd(), logger: console }).catch((e) => {
console.error("Error running one-version:");
console.error(e);
process.exit(1);
});
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/one-version/one-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export async function start({ rootDirectory, logger }) {
logger.log(`Running one-version in ${rootDirectory}`);
return Promise.resolve();
}
17 changes: 6 additions & 11 deletions packages/pkg-a/package.json → packages/one-version/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"name": "pkg-a",
"name": "one-version",
"version": "0.0.1",
"module": "index.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
"bin": {
"one-version": "./bin/index.mjs"
},
"type": "module",
"devDependencies": {
Expand All @@ -18,11 +14,10 @@
"typescript": "5.4.5"
},
"scripts": {
"build": "hohoro",
"type-check": "tsc -p ./tsconfig.json",
"lint": "biome lint ./src/",
"test": "bun test",
"prepub": "bun run build && bun run type-check && bun run lint && bun run test",
"lint": "biome lint ./",
"test": "node --test",
"prepub": "bun run type-check && bun run lint && bun run test",
"pub": "npm publish --access public"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"strict": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true
}
},
"include": ["./one-version.mjs"]
}
25 changes: 0 additions & 25 deletions packages/pkg-a/.swcrc

This file was deleted.

5 changes: 0 additions & 5 deletions packages/pkg-a/CHANGELOG.md

This file was deleted.

39 changes: 0 additions & 39 deletions packages/pkg-a/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions packages/pkg-a/build.tsconfig.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/pkg-a/src/__tests__/index.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/pkg-a/src/index.ts

This file was deleted.

0 comments on commit a961422

Please sign in to comment.