Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Jun 30, 2022
1 parent 9edf6ee commit f1db181
Show file tree
Hide file tree
Showing 69 changed files with 442 additions and 925 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15
lts/gallium
44 changes: 44 additions & 0 deletions config/cache.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-disable lines-around-directive,strict */
/**
* Convenience script to harmonize cache directories across various
* tooling such as eslint and jest.
*
* Recently more & more tools like babel-loader tend to cache in
* node_modules/.cache (@link https://github.com/avajs/find-cache-dir)
* It's possible too.
*/
// @ts-check
'use strict';

const { resolve } = require('path');

const globalCachePath = resolve(`${__dirname}/../.cache`);

/**
* @param {string} packageName
* @returns string
*/
function sanitize(packageName) {
return packageName.replace('/', '.').replace(/[^a-z0-9.@_-]+/gi, '-');
}

/**
* @param {string} packageName
* @returns string
*/
function getEslintCachePath(packageName) {
return `${globalCachePath}/${sanitize(packageName)}/eslint`;
}

/**
* @param {string} packageName
* @returns string
*/
function getJestCachePath(packageName) {
return `${globalCachePath}/${sanitize(packageName)}/jest`;
}

module.exports = {
getJestCachePath,
getEslintCachePath,
};
26 changes: 26 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/* eslint-disable import/extensions */
const { pathsToModuleNameMapper } = require('ts-jest');
const appRoot = require('app-root-path');

const { getJestCachePath } = require(`${appRoot}/config/cache.config`);

const packageJson = require(`${process.cwd()}/package.json`);
const {
compilerOptions: baseTsConfig,
} = require(`${process.cwd()}/tsconfig.json`);

// Take the paths from tsconfig automatically from base tsconfig.json
// @link https://kulshekhar.github.io/ts-jest/docs/paths-mapping
const getTsConfigBasePaths = () => {
return baseTsConfig.paths
? pathsToModuleNameMapper(baseTsConfig.paths, {
prefix: '<rootDir>/',
})
: {};
};

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
displayName: `${packageJson.name}:unit`,
cacheDirectory: getJestCachePath(packageJson.name),
// TODO
collectCoverageFrom: [
'packages/**/src/**/*.{ts,tsx}',
Expand All @@ -12,13 +36,15 @@ module.exports = {
],
globals: {
'ts-jest': {
diagnostics: true,
tsconfig: '<rootDir>/config/tsconfig.test.json',
},
},
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/scripts/styleMock.js',
...getTsConfigBasePaths(),
// '^@udecode/plate-ui-dnd$': '<rootDir>/packages/dnd/src',
'^@udecode/plate-core$': '<rootDir>/packages/core/src',
// '^@udecode/plate-basic-elements$':
Expand Down
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "plate",
"private": true,
"version": "0.0.0",
"license": "MIT",
"scripts": {
"check:install": "yarn dlx @yarnpkg/doctor@4.0.0-rc.10 packages",
"clean:global-cache": "rimraf .cache",
"docs:build": "cd docs && yarn && yarn build",
"docs:start": "cd docs && yarn && yarn start",
"g:build": "yarn workspaces foreach -ptv --no-private run build ",
"g:build-changed": "yarn workspaces foreach -ptv --no-private --since=origin/main run build",
"g:build": "yarn workspaces foreach -ptv --no-private run p:build ",
"g:build-changed": "yarn workspaces foreach -ptv --no-private --since=origin/main run p:build",
"g:changeset": "changeset",
"g:clean": "yarn clean:global-cache && rimraf dist && yarn workspaces foreach -ptv run clean",
"g:clean": "yarn clean:global-cache && rimraf dist && yarn workspaces foreach -ptv run p:clean",
"g:codegen": "yarn plop --plopfile ./config/plopfile.js",
"g:cti": "yarn workspaces foreach -ptv --no-private run cti",
"g:cti:clean": "yarn workspaces foreach -p --no-private run cti clean ./src",
"g:cti": "yarn workspaces foreach -ptv --no-private run p:cti",
"g:cti:clean": "yarn workspaces foreach -p --no-private run p:cti clean ./src",
"g:dev": "yarn workspace examples-next dev",
"g:lint": "yarn workspaces foreach -ptv --no-private run p:lint --color",
"g:lint-changed": "yarn workspaces foreach -ptv --no-private --since=origin/main --recursive run p:lint --color",
Expand All @@ -27,10 +29,16 @@
"g:test:covwa": "yarn g:test:cov --watchAll",
"g:test:w": "yarn g:test --watch",
"g:test:wa": "yarn g:test --watchAll",
"g:typecheck": "yarn workspaces foreach -ptv run typecheck",
"g:typecheck-changed": "yarn workspaces foreach -ptv --from '@udecode/plate*' --since=origin/main --recursive run typecheck",
"g:typecheck": "yarn workspaces foreach -ptv run p:typecheck",
"g:typecheck-changed": "yarn workspaces foreach -ptv --from '@udecode/plate*' --since=origin/main --recursive run p:typecheck",
"p:build": "cd $INIT_CWD && yarn p:clean && tsc && yarn p:rollup",
"p:build:w": "cd $INIT_CWD && yarn p:rollup -w",
"p:clean": "cd $INIT_CWD && rimraf dist",
"p:cti": "cd $INIT_CWD && && sh ${PROJECT_CWD}/scripts/cti.sh",
"p:lint": "cd $INIT_CWD && eslint src --ext .ts,.tsx --cache --cache-location ${PROJECT_CWD}/.cache/eslint/core-lib.eslintcache --color",
"p:rollup": "cd $INIT_CWD && rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"p:test": "cd $INIT_CWD && jest --config=${PROJECT_CWD}/jest.config.js --passWithNoTests $INIT_CWD ",
"p:typecheck": "cd $INIT_CWD && tsc --noEmit --emitDeclarationOnly false",
"postinstall": "patch-package",
"nuke:node_modules": "rimraf '**/node_modules'",
"typedoc": "npx typedoc --tsconfig packages/plate/tsconfig.json --options config/typedoc.json"
Expand Down Expand Up @@ -82,6 +90,7 @@
"@types/validator": "^13.7.2",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"app-root-path": "^3.0.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.5",
Expand Down
9 changes: 0 additions & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@radix-ui/react-slot": "^0.1.2",
Expand Down
9 changes: 0 additions & 9 deletions packages/decorators/find-replace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/autoformat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/break/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/combobox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0",
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/node-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/normalizers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/reset-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/select/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/trailing-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
7 changes: 0 additions & 7 deletions packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh below",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-alignment": "13.6.0",
Expand Down
9 changes: 0 additions & 9 deletions packages/nodes/alignment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/nodes/basic-elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-block-quote": "13.6.0",
Expand Down
9 changes: 0 additions & 9 deletions packages/nodes/basic-marks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
9 changes: 0 additions & 9 deletions packages/nodes/block-quote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
"files": [
"dist"
],
"scripts": {
"build": "yarn clean && tsc && yarn rollup",
"build:w": "yarn rollup -w",
"clean": "rimraf dist",
"cti": "sh ${PROJECT_CWD}/scripts/cti.sh",
"rollup": "rollup -c=${PROJECT_CWD}/config/rollup.config.js",
"test": "jest",
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
},
"types": "dist/index.d.ts",
"dependencies": {
"@udecode/plate-core": "13.6.0"
Expand Down
Loading

0 comments on commit f1db181

Please sign in to comment.