Skip to content

Commit e70d80f

Browse files
authored
build: monorepo (#43)
Fixes #35 In the long term, this monorepo structure won't be enough. We'll have to add some extra automations, but for now it's good to go, as it allows us to unblock many other tasks!! 🎉 🚀
2 parents 927ff98 + 77ac599 commit e70d80f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1770
-1170
lines changed

.github/workflows/tests.yml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,34 @@ jobs:
3333
with:
3434
node-version: ${{ matrix.node-version }}
3535
cache: 'pnpm'
36-
- name: Install dependencies
37-
run: pnpm install
38-
- name: Run Linters
36+
37+
# @beautiful-tree/types
38+
- name: (Types) Install dependencies
39+
run: pnpm --filter types install
40+
- name: (Types) Build Library
41+
run: pnpm --filter types run build
42+
- name: (Types) Run Linters
43+
if: ${{ matrix.os == 'ubuntu-22.04' }}
44+
run: pnpm --filter types run lint
45+
46+
# @beautiful-tree/algorithms
47+
- name: (Algorithms) Install dependencies
48+
run: pnpm --filter algorithms install
49+
- name: (Algorithms) Build Library
50+
run: pnpm --filter algorithms run build
51+
- name: (Algorithms) Run Linters
52+
if: ${{ matrix.os == 'ubuntu-22.04' }}
53+
run: pnpm --filter algorithms run lint
54+
- name: (Algorithms) Run Tests
55+
run: pnpm --filter algorithms run test:coverage
56+
57+
# @beautiful-tree/react
58+
- name: (React SVG) Install dependencies
59+
run: pnpm --filter react install
60+
- name: (React SVG) Build Library
61+
run: pnpm --filter react run build
62+
- name: (React SVG) Run Linters
3963
if: ${{ matrix.os == 'ubuntu-22.04' }}
40-
run: pnpm lint
41-
- name: Build Library
42-
run: pnpm build
43-
- name: Run Tests
44-
run: pnpm test:coverage
45-
- name: Publint
46-
run: pnpm publint --strict
64+
run: pnpm --filter react run lint
65+
- name: (React SVG) Run Tests
66+
run: pnpm --filter react run test:coverage

.hooks/pre-commit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
set -eu
44
set -o pipefail
55

6-
pnpm run lint
7-
pnpm publint
6+
pnpm run -r lint

.hooks/pre-push

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
set -eu
44
set -o pipefail
55

6-
pnpm run lint
7-
pnpm publint
8-
pnpm test:coverage
6+
pnpm run -r lint
7+
pnpm run -r test:coverage
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
es2020: true,
7+
},
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
ecmaVersion: 2020,
11+
sourceType: 'module',
12+
tsConfigRootDir: __dirname,
13+
project: ['./tsconfig.json'],
14+
},
15+
extends: [
16+
'@coderspirit',
17+
],
18+
ignorePatterns: [
19+
'.eslintrc.cjs',
20+
'dist/**/*',
21+
'node_modules/**/*',
22+
]
23+
}
File renamed without changes.

@beautiful-tree/algorithms/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Beautiful-Tree Algorithms
2+
3+
## Other members of the family
4+
5+
This is the "core" of the BeautifulTree library. If you are looking for
6+
for integration with other technologies such as React or Vue, check the
7+
[main README.md](https://github.com/Coder-Spirit/beautiful-tree?tab=readme-ov-file#beautiful-tree)
8+
file of the project's repository.
9+
10+
## Install
11+
12+
```bash
13+
# With NPM
14+
npm install @beautiful-tree/algorithms
15+
16+
# With Yarn
17+
yarn add @beautiful-tree/algorithms
18+
19+
# With PNPM
20+
pnpm add @beautiful-tree/algorithms
21+
```
22+
23+
## Basic Usage
24+
25+
TODO: Document algorithms library
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "@beautiful-tree/algorithms",
3+
"version": "0.2.0",
4+
"private": false,
5+
"author": "Andres Correa Casablanca <castarco@coderspirit.xyz>",
6+
"license": "MIT",
7+
"main": "./dist/main.big.cjs",
8+
"module": "./dist/main.big.mjs",
9+
"types": "./dist/main.d.cts",
10+
"exports": {
11+
".": {
12+
"import": {
13+
"types": "./dist/main.d.mts",
14+
"default": "./dist/main.big.mjs"
15+
},
16+
"require": {
17+
"types": "./dist/main.d.cts",
18+
"default": "./dist/main.big.cjs"
19+
},
20+
"browser": "./dist/main.big.iife.js",
21+
"default": "./dist/main.big.umd.js"
22+
},
23+
"./min": {
24+
"import": {
25+
"types": "./dist/main.d.mts",
26+
"default": "./dist/main.min.mjs"
27+
},
28+
"require": {
29+
"types": "./dist/main.d.cts",
30+
"default": "./dist/main.min.cjs"
31+
},
32+
"browser": "./dist/main.min.iife.js",
33+
"default": "./dist/main.min.umd.js"
34+
}
35+
},
36+
"files": [
37+
"dist"
38+
],
39+
"scripts": {
40+
"build": "rm -rf dist && rollup --config rollup.config.prod.mjs",
41+
"build-storybook": "storybook build",
42+
"lint": "tsc && eslint . --ext ts,mts,tsx --report-unused-disable-directives --max-warnings 0 && publint",
43+
"lint:eslint": "eslint . --ext ts,mts,tsx --report-unused-disable-directives --max-warnings 0",
44+
"lint:publint": "publint",
45+
"lint:tsc": "tsc",
46+
"test": "vitest run",
47+
"test:coverage": "vitest run --coverage",
48+
"test:watch": "vitest",
49+
"prepublishOnly": "pnpm run build"
50+
},
51+
"devDependencies": {
52+
"@arethetypeswrong/cli": "^0.10.2",
53+
"@beautiful-tree/types": "workspace:0.2.0",
54+
"@coderspirit/eslint-config": "^1.2.1",
55+
"@rollup/plugin-terser": "^0.4.3",
56+
"@rollup/plugin-typescript": "^11.1.3",
57+
"@types/node": "^20.6.1",
58+
"@typescript-eslint/parser": "^6.7.0",
59+
"@vitest/coverage-v8": "^0.34.4",
60+
"eslint": "^8.49.0",
61+
"prettier": "^3.0.3",
62+
"publint": "^0.2.2",
63+
"rollup": "^3.29.1",
64+
"rollup-plugin-dts": "^5.3.1",
65+
"tslib": "^2.6.2",
66+
"typescript": "^5.2.2",
67+
"vitest": "^0.34.4"
68+
}
69+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { defineConfig } from 'rollup'
2+
import dts from 'rollup-plugin-dts'
3+
import pluginTs from '@rollup/plugin-typescript'
4+
import terser from '@rollup/plugin-terser'
5+
6+
const name = 'BeautifulTreeAlgos'
7+
const input = 'src/main.ts'
8+
9+
export default defineConfig([
10+
{
11+
input,
12+
output: [
13+
{
14+
file: 'dist/main.big.cjs',
15+
format: 'cjs',
16+
sourcemap: true,
17+
},
18+
{
19+
file: 'dist/main.big.mjs',
20+
format: 'es',
21+
sourcemap: true,
22+
},
23+
{
24+
name,
25+
file: 'dist/main.big.iife.js',
26+
format: 'iife',
27+
sourcemap: true,
28+
},
29+
{
30+
name,
31+
file: 'dist/main.big.umd.js',
32+
format: 'umd',
33+
sourcemap: true,
34+
},
35+
],
36+
plugins: [pluginTs()],
37+
},
38+
{
39+
input,
40+
output: [
41+
{
42+
file: 'dist/main.min.cjs',
43+
format: 'cjs',
44+
sourcemap: true,
45+
},
46+
{
47+
file: 'dist/main.min.mjs',
48+
format: 'es',
49+
sourcemap: true,
50+
},
51+
{
52+
name,
53+
file: 'dist/main.min.iife.js',
54+
format: 'iife',
55+
sourcemap: true,
56+
},
57+
{
58+
name,
59+
file: 'dist/main.min.umd.js',
60+
format: 'umd',
61+
sourcemap: true,
62+
},
63+
],
64+
plugins: [pluginTs(), terser()],
65+
},
66+
{
67+
input,
68+
output: [
69+
{ format: 'cjs', file: 'dist/main.d.cts' },
70+
{ format: 'es', file: 'dist/main.d.mts' },
71+
],
72+
plugins: [dts({ respectExternal: true })],
73+
},
74+
])

src/layouts.ts renamed to @beautiful-tree/algorithms/src/layouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Tree, TreeChild, TreeWithLayout } from './types'
1+
import type { Tree, TreeChild, TreeWithLayout } from '@beautiful-tree/types'
22

33
export interface WrappedTreeWithLayout {
44
readonly tree: Readonly<TreeWithLayout>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type { WrappedTreeWithLayout } from './layouts'
2+
export { computeNaiveLayout, computeSmartLayout } from './layouts'
3+
export { edgesIterator, postOrderIterator } from './traversal'

src/tests/traversal.test.ts renamed to @beautiful-tree/algorithms/src/tests/traversal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'vitest'
22
import { edgesIterator, postOrderIterator } from '../traversal'
3-
import type { TreeWithLayout } from '../types'
3+
import type { TreeWithLayout } from '@beautiful-tree/types'
44

55
describe('postOrderIterator', () => {
66
const testTree = {

src/traversal.ts renamed to @beautiful-tree/algorithms/src/traversal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Edge, Tree, TreeWithLayout } from './types'
1+
import type { Edge, Tree, TreeWithLayout } from '@beautiful-tree/types'
22

33
export function* postOrderIterator<T extends Tree | TreeWithLayout = Tree>(
44
tree: Readonly<T>,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": "./src",
5+
},
6+
"exclude": [
7+
"coverage/**/*",
8+
"dist/**/*",
9+
"node_modules/**/*",
10+
]
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// eslint-disable-next-line import/no-unresolved
2+
import { defineConfig } from 'vitest/config'
3+
4+
export default defineConfig({
5+
test: {
6+
coverage: {
7+
provider: 'v8',
8+
include: ['src/*.ts'],
9+
exclude: ['src/**/*.test.ts'],
10+
// thresholdAutoUpdate: true,
11+
branches: 93.54,
12+
lines: 93.4,
13+
functions: 90.9,
14+
statements: 93.4,
15+
},
16+
},
17+
})

.eslintrc.cjs renamed to @beautiful-tree/react/.eslintrc.cjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ module.exports = {
88
},
99
parser: '@typescript-eslint/parser',
1010
parserOptions: {
11-
ecmaVersion: 2020,
11+
ecmaVersion: 2020,
1212
sourceType: 'module',
13-
tsConfigRootDir: __dirname,
14-
project: ['./tsconfig.json'],
15-
},
13+
tsConfigRootDir: __dirname,
14+
project: ['./tsconfig.json'],
15+
},
1616
plugins: [
1717
'react-refresh',
1818
],
@@ -24,10 +24,10 @@ module.exports = {
2424
'plugin:storybook/recommended',
2525
],
2626
settings: {
27-
react: {
28-
version: 'detect'
29-
},
30-
},
27+
react: {
28+
version: 'detect'
29+
},
30+
},
3131
ignorePatterns: [
3232
'.eslintrc.cjs',
3333
'dist/**/*',

@beautiful-tree/react/.prettierrc.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from '@coderspirit/eslint-config/prettier'
2+
3+
export default config
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)