diff --git a/README.md b/README.md index ff34444..38a7674 100644 --- a/README.md +++ b/README.md @@ -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 + -## 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! +
+ Source +
--- -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!_ diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index 8606067..bd90251 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -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" + ] } diff --git a/apps/template-app/tsconfig.json b/apps/template-app/tsconfig.json index 8606067..bd90251 100644 --- a/apps/template-app/tsconfig.json +++ b/apps/template-app/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -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" + ] } diff --git a/bun.lockb b/bun.lockb index d85bc67..54bc05d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/one-version/CHANGELOG.md b/packages/one-version/CHANGELOG.md new file mode 100644 index 0000000..1f72f53 --- /dev/null +++ b/packages/one-version/CHANGELOG.md @@ -0,0 +1,5 @@ +### Unreleased: + +### [0.0.1] - May 14th, 2024 + +- Initial release diff --git a/packages/one-version/README.md b/packages/one-version/README.md new file mode 100644 index 0000000..c3a1d94 --- /dev/null +++ b/packages/one-version/README.md @@ -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. diff --git a/packages/one-version/__tests__/one-version.test.mjs b/packages/one-version/__tests__/one-version.test.mjs new file mode 100644 index 0000000..28afce7 --- /dev/null +++ b/packages/one-version/__tests__/one-version.test.mjs @@ -0,0 +1,6 @@ +import assert from "node:assert"; +import { after, before, test } from "node:test"; + +test("stub", () => { + assert.ok(true); +}); diff --git a/packages/one-version/bin/index.mjs b/packages/one-version/bin/index.mjs new file mode 100644 index 0000000..37f2c97 --- /dev/null +++ b/packages/one-version/bin/index.mjs @@ -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); +}); diff --git a/packages/pkg-a/biome.jsonc b/packages/one-version/biome.jsonc similarity index 100% rename from packages/pkg-a/biome.jsonc rename to packages/one-version/biome.jsonc diff --git a/packages/one-version/one-version.mjs b/packages/one-version/one-version.mjs new file mode 100644 index 0000000..70db470 --- /dev/null +++ b/packages/one-version/one-version.mjs @@ -0,0 +1,4 @@ +export async function start({ rootDirectory, logger }) { + logger.log(`Running one-version in ${rootDirectory}`); + return Promise.resolve(); +} diff --git a/packages/pkg-a/package.json b/packages/one-version/package.json similarity index 52% rename from packages/pkg-a/package.json rename to packages/one-version/package.json index 9da7160..1eaaffd 100644 --- a/packages/pkg-a/package.json +++ b/packages/one-version/package.json @@ -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": { @@ -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" } } diff --git a/packages/pkg-a/tsconfig.json b/packages/one-version/tsconfig.json similarity index 92% rename from packages/pkg-a/tsconfig.json rename to packages/one-version/tsconfig.json index 59116c2..7733731 100644 --- a/packages/pkg-a/tsconfig.json +++ b/packages/one-version/tsconfig.json @@ -19,5 +19,6 @@ "strict": true, "noFallthroughCasesInSwitch": true, "forceConsistentCasingInFileNames": true - } + }, + "include": ["./one-version.mjs"] } diff --git a/packages/pkg-a/.swcrc b/packages/pkg-a/.swcrc deleted file mode 100644 index 6fe78e4..0000000 --- a/packages/pkg-a/.swcrc +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/swcrc", - "jsc": { - "parser": { - "syntax": "ecmascript", - "jsx": false, - "dynamicImport": false, - "privateMethod": false, - "functionBind": false, - "exportDefaultFrom": false, - "exportNamespaceFrom": false, - "decorators": false, - "decoratorsBeforeExport": false, - "topLevelAwait": false, - "importMeta": false - }, - "transform": null, - "target": "es5", - "loose": false, - "externalHelpers": false, - // Requires v1.2.50 or upper and requires target to be es2016 or upper. - "keepClassNames": false - }, - "minify": false -} diff --git a/packages/pkg-a/CHANGELOG.md b/packages/pkg-a/CHANGELOG.md deleted file mode 100644 index e8b5ca1..0000000 --- a/packages/pkg-a/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -### Unreleased: - -### [0.0.1] - March 3rd, 2024 - -- Build the library using SWC and TypeScript diff --git a/packages/pkg-a/README.md b/packages/pkg-a/README.md deleted file mode 100644 index 1117d8d..0000000 --- a/packages/pkg-a/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# `pkg-a` - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run ./src/index.ts -``` - -## Building: - -This library uses [`swc`](https://swc.rs/) and [`TypeScript`](https://www.typescriptlang.org/docs/) to build the source code and generate types. - -To build the library, run `bun run build` from the root, or from this workspace! - -## 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 Bun 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. - -> Note: In the future, we will automate this process using GitHub Actions. And also add in tooling to manage releases / changelogs! diff --git a/packages/pkg-a/build.tsconfig.json b/packages/pkg-a/build.tsconfig.json deleted file mode 100644 index c4d0196..0000000 --- a/packages/pkg-a/build.tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "extends": "./tsconfig.json", - "compilerOptions": { - "emitDeclarationOnly": true, - "declaration": true, - "noEmit": false, - "rootDir": "./src", - "outDir": "./dist" - } -} diff --git a/packages/pkg-a/src/__tests__/index.test.ts b/packages/pkg-a/src/__tests__/index.test.ts deleted file mode 100644 index 2df36ea..0000000 --- a/packages/pkg-a/src/__tests__/index.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { expect, test } from "bun:test"; - -test("pkg-a", () => { - expect("pkg-a").toBe("pkg-a"); -}); diff --git a/packages/pkg-a/src/index.ts b/packages/pkg-a/src/index.ts deleted file mode 100644 index 2a5e4b8..0000000 --- a/packages/pkg-a/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello via Bun!");