Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use turborepo #1994

Merged
merged 9 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/olive-eyes-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@flopflip/adapter-utilities": patch
"@flopflip/cache": patch
"@flopflip/combine-adapters": patch
"@flopflip/cypress-plugin": patch
"@flopflip/graphql-adapter": patch
"@flopflip/http-adapter": patch
"@flopflip/launchdarkly-adapter": patch
---

Refactor to use turborepo and tsup
22 changes: 22 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

description: Shared action to install dependencies

runs:
using: composite

steps:
- name: Install pnpm
uses: pnpm/[email protected]
with:
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"

- name: Install
run: pnpm install
shell: bash
50 changes: 31 additions & 19 deletions .github/workflows/test.yml → .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test and Build
name: Quality

on:
push:
Expand All @@ -7,41 +7,53 @@ on:
pull_request:

jobs:
install:
lint:
name: Linting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/[email protected]
with:
run_install: false
- name: Setup
uses: ./.github/actions/ci

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Lint
run: pnpm lint:ci

- name: Install
run: pnpm install
check-types:
name: Type checking
runs-on: ubuntu-latest

- name: Type check
run: pnpm typecheck
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lint
run: pnpm lint:ci
- name: Setup
uses: ./.github/actions/ci

- name: TypeScript
run: pnpm check-types

testing:
name: Testing
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/ci

- name: Build
run: pnpm build

- name: Test (with coverage)
run: pnpm test:coverage
run: pnpm test:coverage --config vitest.shared.ts

- name: Test (with report)
run: pnpm test:report
run: pnpm test:report --config vitest.shared.ts

- name: Upload coverage
uses: codecov/codecov-action@v5
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ coverage
.vscode

junit.xml

.turbo
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tools]
node = "22"
node = "22.13.0"
60 changes: 26 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"name": "flopflip",
"description": "Monorepository for flipflop and its projects e.g. react-redux, react and the wrapper",
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "husky install && preconstruct dev && manypkg check && check-node-version --package --print",
"reinstall": "manypkg exec rm -rf node_modules && rm -rf node_modules pnpm-lock.yaml && pnpm install",
"auth": "npm_config_registry=https://registry.npmjs.org npm whoami",
"lint": "biome lint",
"typecheck": "tsc --project tsconfig.json --noEmit && tsc --project packages/cypress-plugin/tsconfig.json --noEmit",
"format": "biome format --write",
"fix:biome": "biome lint --write",
"biome:check": "biome check --write",
"lint:ci": "biome ci",
"test:coverage": "pnpm test -- --coverage",
"test": "vitest run",
"test:report": "vitest --reporter=junit --outputFile=junit.xml",
"build": "preconstruct build",
"build:watch": "preconstruct watch",
"changeset": "changeset",
"build": "turbo build",
"changeset:version-and-format": "changeset version && pnpm format && pnpm install --no-frozen-lockfile",
"changeset": "changeset",
"check-types": "turbo check-types",
"clean": "manypkg exec rm -rf dist && manypkg exec rm -rf .turbo && rm -rf .turbo",
"fix:biome": "biome lint --write",
"format": "biome format --write",
"lint:ci": "biome ci",
"lint": "biome lint",
"postinstall": "husky install && manypkg check && check-node-version --package --print",
"postpublish": "pinst --enable",
"preinstall": "npx only-allow pnpm",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
"reinstall": "manypkg exec rm -rf node_modules && rm -rf node_modules pnpm-lock.yaml && pnpm install",
"test:coverage": "vitest run --coverage",
"test:report": "vitest run --reporter=junit --outputFile=junit.xml",
"test": "turbo test"
},
"author": "Tobias Deekens <[email protected]>",
"engines": {
Expand All @@ -43,14 +43,6 @@
"store-enhancer"
],
"packageManager": "[email protected]",
"preconstruct": {
"packages": [
"demo",
"packages/*",
"!packages/test-utils",
"!demo"
]
},
"pnpm": {
"overrides": {
"@types/react": "18.3.18",
Expand All @@ -63,43 +55,43 @@
"bundlewatch": {
"files": [
{
"path": "./packages/launchdarkly-adapter/dist/flopflip-launchdarkly-adapter.esm.js",
"path": "./packages/launchdarkly-adapter/dist/index.js",
"maxSize": "5Kb"
},
{
"path": "./packages/localstorage-adapter/dist/flopflip-localstorage-adapter.esm.js",
"path": "./packages/localstorage-adapter/dist/index.js",
"maxSize": "3KB"
},
{
"path": "./packages/localstorage-cache/dist/flopflip-localstorage-cache.esm.js",
"path": "./packages/localstorage-cache/dist/index.js",
"maxSize": "1KB"
},
{
"path": "./packages/memory-adapter/dist/flopflip-memory-adapter.esm.js",
"path": "./packages/memory-adapter/dist/index.js",
"maxSize": "3KB"
},
{
"path": "./packages/graphql-adapter/dist/flopflip-graphql-adapter.esm.js",
"path": "./packages/graphql-adapter/dist/index.js",
"maxSize": "4KB"
},
{
"path": "./packages/splitio-adapter/dist/flopflip-splitio-adapter.esm.js",
"path": "./packages/splitio-adapter/dist/index.js",
"maxSize": "3.5Kb"
},
{
"path": "./packages/combine-adapters/dist/flopflip-combine-adapters.esm.js",
"path": "./packages/combine-adapters/dist/index.js",
"maxSize": "3.0Kb"
},
{
"path": "./packages/react/dist/flopflip-react.esm.js",
"path": "./packages/react/dist/index.js",
"maxSize": "6Kb"
},
{
"path": "./packages/react-broadcast/dist/flopflip-react-broadcast.browser.esm.js",
"path": "./packages/react-broadcast/dist/index.js",
"maxSize": "3Kb"
},
{
"path": "./packages/react-redux/dist/flopflip-react-redux.browser.esm.js",
"path": "./packages/react-redux/dist/index.js",
"maxSize": "4Kb"
}
]
Expand Down Expand Up @@ -132,7 +124,6 @@
"@commitlint/cli": "19.7.1",
"@commitlint/config-conventional": "19.7.1",
"@manypkg/cli": "0.23.0",
"@preconstruct/cli": "2.8.10",
"@testing-library/jest-dom": "6.6.3",
"@types/jest": "29.5.14",
"@types/lodash": "4.17.15",
Expand All @@ -156,6 +147,7 @@
"rimraf": "6.0.1",
"ts-node": "10.9.2",
"tslib": "2.8.1",
"turbo": "2.4.1",
"typescript": "5.7.3",
"vite": "6.1.0",
"vitest": "3.0.5",
Expand Down
28 changes: 26 additions & 2 deletions packages/adapter-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@
"name": "@flopflip/adapter-utilities",
"version": "14.0.2",
"description": "Adapter utilities for flipflop",
"main": "dist/flopflip-adapter-utilities.cjs.js",
"module": "dist/flopflip-adapter-utilities.esm.js",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"typesVersions": {
"*": {
".": [
"dist/*.d.ts",
"dist/*.d.cts"
]
}
},
"scripts": {
"build": "rimraf dist && tsup",
"check-types": "tsc --noEmit",
"test": "vitest --run",
"test:watch": "vitest",
"dev": "tsup --watch --clean=false"
},
"files": [
"readme.md",
"dist/**"
Expand Down Expand Up @@ -34,6 +56,8 @@
"lodash": "4.17.21"
},
"devDependencies": {
"@flopflip/tsconfig": "workspace:*",
"tsup": "8.3.6",
"typescript": "5.7.3"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-utilities/src/normalize-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { normalizeFlag as defaultNormalizeFlag } from './normalize-flag';

const normalizeFlags = (
rawFlags: TFlags,
normalizeFlag: typeof defaultNormalizeFlag = defaultNormalizeFlag
normalizer: typeof defaultNormalizeFlag = defaultNormalizeFlag
): Record<string, TFlagVariation> =>
Object.entries(rawFlags || {}).reduce<TFlags>(
(normalizedFlags: TFlags, [flagName, flagValue]) => {
const [normalizedFlagName, normalizedFlagValue]: TFlag = normalizeFlag(
const [normalizedFlagName, normalizedFlagValue]: TFlag = normalizer(
flagName,
flagValue
);
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-utilities/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.json"
"extends": "@flopflip/tsconfig/base.json",
"exclude": ["**/dist/*", "**/vitest.config.ts"]
}
13 changes: 13 additions & 0 deletions packages/adapter-utilities/tsup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
splitting: true,
sourcemap: true,
minify: false,
clean: false,
skipNodeModulesBundle: true,
dts: true,
external: ['node_modules'],
});
11 changes: 11 additions & 0 deletions packages/adapter-utilities/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineProject, mergeConfig } from 'vitest/config';
import configShared from '../../vitest.shared.ts';

export default mergeConfig(
configShared,
defineProject({
test: {
environment: 'jsdom',
},
})
);
30 changes: 28 additions & 2 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@
"name": "@flopflip/cache",
"version": "14.0.2",
"description": "Caching for flipflop adapters",
"main": "dist/flopflip-cache.cjs.js",
"module": "dist/flopflip-cache.esm.js",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.js",
"typesVersions": {
"*": {
".": [
"dist/*.d.ts",
"dist/*.d.cts"
]
}
},
"scripts": {
"build": "rimraf dist && tsup",
"check-types": "tsc --noEmit",
"test": "vitest --run",
"test:watch": "vitest",
"dev": "tsup --watch --clean=false"
},
"files": [
"readme.md",
"dist/**"
Expand Down Expand Up @@ -32,5 +54,9 @@
"@flopflip/localstorage-cache": "workspace:*",
"@flopflip/sessionstorage-cache": "workspace:*",
"@flopflip/types": "workspace:*"
},
"devDependencies": {
"@flopflip/tsconfig": "workspace:*",
"tsup": "8.3.6"
}
}
3 changes: 2 additions & 1 deletion packages/cache/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "../../tsconfig.json"
"extends": "@flopflip/tsconfig/base.json",
"exclude": ["**/dist/*", "**/vitest.config.ts"]
}
13 changes: 13 additions & 0 deletions packages/cache/tsup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
splitting: true,
sourcemap: true,
minify: false,
clean: false,
skipNodeModulesBundle: true,
dts: true,
external: ['node_modules'],
});
Loading