Skip to content

Commit

Permalink
Convert to monorepo (pixijs#364)
Browse files Browse the repository at this point in the history
* remove docz related stuff

* move code into separate packages with appropriate tooling

* add nx config and ensure all package scripts run from repo root

* move shared deps to root package.json

* fix husky

* move TYPES to separate package for easier sharing

* add global eslint configuration dynamically pulling in patterns from packages

* ignore eslintcache

* switch yarn commands to npm

Co-authored-by: Alex Prokop <[email protected]>
  • Loading branch information
baseten and Alex Prokop authored Jan 17, 2023
1 parent 5f05cae commit 58457b2
Show file tree
Hide file tree
Showing 156 changed files with 28,751 additions and 14,685 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- v{{ checksum "_cache_version" }}-dependencies-{{ checksum "package.json" }}
- v{{ checksum "_cache_version" }}-dependencies-

- run: yarn install
- run: npm install

- save_cache:
paths:
- node_modules
key: v{{ checksum "_cache_version" }}-dependencies-{{ checksum "package.json" }}

- run: yarn test --ci --silent
- run: npm test --ci --silent
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[{*.js,*.ts,*.mjs}]
quote_type = single

[{*.json,.github/workflows/*.yml,*.md}]

[{*.json,*.yml,*.md}]
indent_size = 2
16 changes: 0 additions & 16 deletions .eslintignore

This file was deleted.

86 changes: 44 additions & 42 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
// In this monorepo linting is set up per workspace following the example from turborepo:
// https://turbo.build/repo/docs/handbook/linting
// Setting up the configs as modules works really nicely for parallelization and to handle includes/excludes, which can get
// super messy globally, but it doesn't play nicely with husky at all, which expects to be able to lint globally. It also
// doesn't easily allow us to lint the scripts and shared folders along with random root js files. This config exists to
// handle these problems and dynamically shepherds the package specific includes/excludes into a single global config.
// TODO: can we fix/improve this somehow?

const { existsSync, readdirSync } = require('fs');
const { join } = require('path');

const ignorePatterns = [];

try
{
const packages = readdirSync('packages');

for (const folder of packages)
{
const packagePath = join('packages', folder);
const eslintPath = join(packagePath, '.eslintrc.js');

if (existsSync(eslintPath))
{
// eslint-disable-next-line global-require
const packageLintConfig = require(`./${eslintPath}`);
const packagePatternToGlobalPattern = (packagePattern) => join('/', packagePath, packagePattern);

ignorePatterns.push(...packageLintConfig.ignorePatterns.map(packagePatternToGlobalPattern));
}
}
}
catch (err)
{
console.error('Error reading ignorePatterns from packages', err);
}

module.exports = {
extends: ['@pixi/eslint-config'],
root: true,
extends: ['pixi-react'],
parserOptions: {
project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'],
project: ['tsconfig.eslint.json'],
tsconfigRootDir: __dirname
},
settings: {
jsdoc: {
mode: 'typescript',
tagNamePreference: {
method: 'method',
function: 'function',
extends: 'extends',
typeParam: 'typeParam',
api: 'api'
}
}
},
rules: {
'no-empty-function': 0,
'no-prototype-builtins': 0,
'spaced-comment': [1, 'always', { markers: ['/'] }],
'@typescript-eslint/triple-slash-reference': [1, { path: 'always' }],
'@typescript-eslint/consistent-type-imports': [1, { disallowTypeAnnotations: false }],
'@typescript-eslint/no-parameter-properties': 1,
'@typescript-eslint/type-annotation-spacing': 1,
},
overrides: [
{
files: ['test/**'],
rules: {
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/dot-notation': [
0,
{
allowPrivateClassPropertyAccess: true,
allowProtectedClassPropertyAccess: true,
allowIndexSignaturePropertyAccess: true
}
],
'dot-notation': 0
},
env: {
jest: true,
}
}
ignorePatterns: [
...ignorePatterns,
'dist',
'node_modules'
]
};
12 changes: 3 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
node_modules/
lib/
dist/
animated/react-pixi*
legacy/react-pixi*
examples/
.docz/
.yarn-error.log
docs/
.idea
node_modules/
**/dist/
.eslintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
5 changes: 0 additions & 5 deletions animated/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions animated/module.js

This file was deleted.

7 changes: 0 additions & 7 deletions animated/package.json

This file was deleted.

File renamed without changes.
Binary file removed config/docz/public/favicon.ico
Binary file not shown.
25 changes: 0 additions & 25 deletions docz-rp-animated.js

This file was deleted.

28 changes: 0 additions & 28 deletions docz-rp.js

This file was deleted.

11 changes: 0 additions & 11 deletions doczrc.js

This file was deleted.

23 changes: 0 additions & 23 deletions gatsby-node.js

This file was deleted.

8 changes: 0 additions & 8 deletions index.js

This file was deleted.

5 changes: 0 additions & 5 deletions legacy/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions legacy/module.js

This file was deleted.

7 changes: 0 additions & 7 deletions legacy/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions module.js

This file was deleted.

39 changes: 39 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"extends": "nx/presets/npm.json",
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": [
"build",
"lint",
"test"
],
"accessToken": "ZjQ3OWVmMTAtMTBlYS00YmJkLTk1ZjMtNmM5MWQ0YWFhYzY4fHJlYWQtd3JpdGU=",
"scan": true
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
},
"test": {
"dependsOn": ["^build"]
}
},
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"{projectRoot}/dist"
]
},
"targets": {
"build": {
"inputs": [
"default"
]
}
}
}
Loading

0 comments on commit 58457b2

Please sign in to comment.