Skip to content

Commit

Permalink
chore: migrate to turborepo (#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsunderhus committed Jan 3, 2024
1 parent 005eb4f commit 4c04669
Show file tree
Hide file tree
Showing 146 changed files with 17,376 additions and 47,517 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-dogs-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@floating-ui/devtools': patch
---

chore: removes repeated code between devtools & extension
12 changes: 12 additions & 0 deletions .changeset/gentle-toes-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@floating-ui/react-native': patch
'@floating-ui/react-dom': patch
'@floating-ui/devtools': patch
'@floating-ui/react': patch
'@floating-ui/utils': patch
'@floating-ui/core': patch
'@floating-ui/dom': patch
'@floating-ui/vue': patch
---

chore: exports .d.mts types, solves #2472
6 changes: 0 additions & 6 deletions .config/_global.d.ts

This file was deleted.

18 changes: 0 additions & 18 deletions .config/tsconfig.json

This file was deleted.

12 changes: 12 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ module.exports = {
'dist',
'public',
'website/out',
'out-tsc',
],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./config/tsconfig.eslint.json',
'./**/.storybook/tsconfig.stories.json',
'./**/tsconfig.lib.json',
'./**/tsconfig.test.json',
'./**/tsconfig.json',
],
},
plugins: ['@typescript-eslint', 'react-hooks', 'simple-import-sort'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
Expand All @@ -21,6 +32,7 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'simple-import-sort/imports': 'error',
Expand Down
6 changes: 2 additions & 4 deletions .github/actions/functional/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ runs:
steps:
- run: npx playwright install --with-deps chromium
shell: sh
- run: npm run build
shell: sh
- run: npm run playwright
- run: pnpm run playwright
shell: sh
- uses: actions/upload-artifact@v2
if: always()
with:
name: visual-snapshots-diff
path: test-results
path: packages/dom/test-results
5 changes: 4 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ runs:
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
uses: bahmutov/npm-install@v1
uses: pnpm/action-setup@v2
with:
version: 8
run_install: true
4 changes: 2 additions & 2 deletions .github/actions/typescript/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Performs typescript checks
runs:
using: composite
steps:
- run: npm run lint
- run: pnpm run lint
shell: sh
- run: npm run typecheck
- run: pnpm run build:api
shell: sh
14 changes: 2 additions & 12 deletions .github/actions/unit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@ description: Performs unit tests checks
runs:
using: composite
steps:
- run: npm run build
- run: pnpm run build
shell: sh
- run: npm -w packages/core test
shell: sh
- run: npm -w packages/dom test
shell: sh
- run: npm -w packages/react-dom test
shell: sh
- run: npm -w packages/react test
shell: sh
- run: npm -w packages/vue test
shell: sh
- run: npm -w packages/utils test
- run: pnpm run test
shell: sh
6 changes: 3 additions & 3 deletions .github/changeset-version.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const {execSync} = require('node:child_process');

// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
// So we also run `npm install`, which does this update.
// The standard step is only to run `changeset version` but this does not update the lock file.
// So we also run `pnpm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
execSync('npx changeset version');
execSync('npm install');
execSync('pnpm install --lockfile-only');
2 changes: 1 addition & 1 deletion .github/workflows/release-floating-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: changesets/action@v1
with:
version: node .github/changeset-version.js
publish: npm run release
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: npx playwright install --with-deps chromium
- run: npm run build
- run: npm run playwright:update
- run: pnpm run playwright:update
- uses: EndBug/add-and-commit@v7
with:
add: '.'
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ stats
.next
.parcel-cache
test-results
out
out
out-tsc
.turbo
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.19.0
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ npm install @floating-ui/core

## Contributing

This project is a monorepo written in TypeScript using npm workspaces. The
website is using Next.js SSG and Tailwind CSS for styling.
This project is a monorepo written in TypeScript using [pnpm](https://pnpm.io/)
workspaces. The website is using Next.js SSG and Tailwind CSS for styling.

- Fork and clone the repo
- Install dependencies in root directory with `npm install`
- Build initial package dist files with `npm run build`
- Install dependencies in root directory with `pnpm install`
- Build initial package dist files with `pnpm run build`

### Testing grounds

#### DOM

`npm -w packages/dom run dev` in the root will launch the `@floating-ui/dom`
development visual tests at `http://localhost:1234`. The playground uses React
to write each test route, bundled by Vite.
`pnpm run dev --filter @floating-ui/dom` in the root will launch the
`@floating-ui/dom` development visual tests at `http://localhost:1234`. The
playground uses React to write each test route, bundled by Vite.

Each route has screenshots taken of the page by Playwright to ensure all the
functionalities work as expected; this is an easy, reliable and high-level way
Expand All @@ -139,8 +139,8 @@ as much as possible.

#### React

`npm -w packages/react run dev` in the root will launch the `@floating-ui/react`
development tests at `http://localhost:1234`.
`pnpm run dev --filter @floating-ui/react` in the root will launch the
`@floating-ui/react` development tests at `http://localhost:1234`.

## Credits

Expand Down
76 changes: 76 additions & 0 deletions config/api-extractor.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"bundledPackages": [],
"newlineKind": "crlf",
"enumMemberOrder": "preserve",
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.json",
"skipLibCheck": false,
"overrideTsconfig": {
"compilerOptions": {
"moduleResolution": "Bundler",
"types": ["node", "resize-observer-browser"],
// api-extractor does not support `paths` in tsconfig.json
"paths": []
}
}
},
"apiReport": {
"enabled": false
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": true
},
"tsdocMetadata": {
"enabled": false
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
},
"ae-forgotten-export": {
"logLevel": "warning"
},
"ae-incompatible-release-tags": {
"logLevel": "warning"
},
"ae-internal-missing-underscore": {
"logLevel": "warning"
},
"ae-internal-mixed-release-tag": {
"logLevel": "warning"
},
// TODO: would be nice to ensure proper documentation for all public members
"ae-undocumented": {
"logLevel": "none"
},
"ae-unresolved-inheritdoc-reference": {
"logLevel": "warning"
},
"ae-unresolved-inheritdoc-base": {
"logLevel": "warning"
},
"ae-wrong-input-file-type": {
"logLevel": "error"
},
// TODO: would be nice to include the release tag in the error message
"ae-missing-release-tag": {
"logLevel": "none"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
}
}
}
5 changes: 5 additions & 0 deletions config/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file is used to declare global types to be used on the project.
// Those global types are declared by rollup replace plugin
// on defineRollupConfig.mts

declare const __DEV__: boolean;
28 changes: 28 additions & 0 deletions config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "config",
"private": true,
"type": "module",
"version": "0.0.0",
"scripts": {
"build": "tsc -b",
"clean": "rimraf dist",
"postinstall": "pnpm run build"
},
"files": [
"dist",
"tsconfig.base.json",
"api-extractor.base.json"
],
"bin": {
"build-api": "./scripts/build-api.mjs",
"compat-exports": "./scripts/compat-exports.mjs"
},
"main": "dist/src/index.mjs",
"module": "dist/src/index.mjs",
"types": "dist/src/index.d.mts",
"devDependencies": {
"glob": "^10.3.10",
"minimist": "^1.2.8",
"zx": "^7.2.3"
}
}
70 changes: 70 additions & 0 deletions config/scripts/build-api.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env node

//@ts-check
import {glob} from 'glob';
import minimist from 'minimist';
import {$, chalk, echo, fs} from 'zx';

/**
* @template {string} Keys
* @typedef {{[K in Keys]: string | string[]} & { _: never[]; }} ParseArgs<Keys>
*/

const args = /** @type {ParseArgs<'tsc'| 'aec'>} */ (
minimist(process.argv.slice(2), {
default: {
tsc: './tsconfig.json',
aec: './api-extractor.json',
},
})
);

const tscPaths = await glob(args.tsc);
const aecPaths = await glob(args.aec);

echo(
chalk.cyan(
`TS Configuration${tscPaths.length > 1 ? 's' : ''}: ${chalk.greenBright(
tscPaths.join(', '),
)}`,
),
);
echo(
chalk.cyan(
`API Extractor configuration${
aecPaths.length > 1 ? 's' : ''
}: ${chalk.greenBright(aecPaths.join(chalk.gray(', ')))}`,
),
);

echo('');

echo(chalk.cyan(`Running tsc (${chalk.greenBright(tscPaths.join(', '))})`));
await Promise.all(tscPaths.map((tscPath) => $`npx tsc -b ${tscPath}`));

echo(
chalk.cyan(
`Running API Extractor (${chalk.greenBright(aecPaths.join(', '))})`,
),
);
await Promise.all(
aecPaths.map(async (aecPath) => {
await $`npx api-extractor run --local --verbose -c ${aecPath}`;
const configFile = await fs.readJson(aecPath);
if (configFile.dtsRollup?.untrimmedFilePath) {
const path = configFile.dtsRollup.untrimmedFilePath.replace(
'<projectFolder>',
configFile.projectFolder ?? '.',
);
const mdtsPath = path.replace(/\.d\.ts$/, '.d.mts');
echo(
chalk.cyan(
`Copying ${chalk.greenBright(path)} into ${chalk.greenBright(
mdtsPath,
)}`,
),
);
await fs.copyFile(path, mdtsPath);
}
}),
);

0 comments on commit 4c04669

Please sign in to comment.