diff --git a/.eslintrc.base.js b/.eslintrc.base.js index 5d45f7a..9684533 100644 --- a/.eslintrc.base.js +++ b/.eslintrc.base.js @@ -1,5 +1,5 @@ "use strict"; -module.exports = (projectRoot) => ({ +module.exports = (projectRoot, extraRules = {}) => ({ root: true, // fix possible "Plugin %s was conflicted between %s.json and %s.json" errors env: { jest: true, @@ -430,5 +430,6 @@ module.exports = (projectRoot) => ({ ], quotes: ["error", "double", { avoidEscape: true }], + ...extraRules, }, }); diff --git a/.eslintrc.js b/.eslintrc.js index f242838..afae8f8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,9 @@ "use strict"; -const config = require("./.eslintrc.base.js")(__dirname); -config.rules["import/no-extraneous-dependencies"] = "error"; -config.rules["@typescript-eslint/explicit-function-return-type"] = [ - "error", - { allowExpressions: true }, -]; -config.rules["lodash/import-scope"] = ["error", "method"]; -module.exports = config; +module.exports = require("./.eslintrc.base.js")(__dirname, { + "import/no-extraneous-dependencies": "error", + "@typescript-eslint/explicit-function-return-type": [ + "error", + { allowExpressions: true }, + ], + "lodash/import-scope": ["error", "method"], +}); diff --git a/.gitignore b/.gitignore index d73b8ab..6314675 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ dist +# Common in both .gitignore and .npmignore node_modules package-lock.json yarn.lock diff --git a/.npmignore b/.npmignore index 14484a5..7ec72e7 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,9 @@ -__tests__ +dist/__tests__ +dist/**/__tests__ +dist/tsconfig.tsbuildinfo .npmrc -tsconfig.tsbuildinfo -.github +# Common in both .gitignore and .npmignore node_modules package-lock.json yarn.lock diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..69c81d9 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "mhutchie.git-graph", + "trentrand.git-rebase-shortcuts" + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..7076e3d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,20 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "git grok: push local commits as individual PRs", + "detail": "Install git-grok first: https://github.com/dimikot/git-grok", + "type": "shell", + "command": "git grok", + "problemMatcher": [], + "hide": false + }, + { + "label": "git rebase --interactive", + "detail": "Opens a UI for interactive rebase (install \"Git rebase shortcuts\" extension).", + "type": "shell", + "command": "GIT_EDITOR=\"code --wait\" git rebase -i", + "problemMatcher": [] + } + ] +} diff --git a/internal/clean.sh b/internal/clean.sh new file mode 100644 index 0000000..f82a4a1 --- /dev/null +++ b/internal/clean.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log diff --git a/internal/deploy.sh b/internal/deploy.sh new file mode 100644 index 0000000..7b12dc6 --- /dev/null +++ b/internal/deploy.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +npm run build +npm run lint +npm run test +npm publish --access=public diff --git a/internal/docs.sh b/internal/docs.sh new file mode 100644 index 0000000..ea628f6 --- /dev/null +++ b/internal/docs.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +rm -rf docs +typedoc --plugin typedoc-plugin-markdown --plugin typedoc-plugin-merge-modules +sed -i '' -E 's#packages/[^/]+/##g' $(find docs -type f -name '*.md') diff --git a/internal/lint.sh b/internal/lint.sh new file mode 100644 index 0000000..8815fd6 --- /dev/null +++ b/internal/lint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +eslint . --ext .ts --cache --cache-location dist/.eslintcache diff --git a/jest.config.js b/jest.config.js index 822985a..c0ea465 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,7 +4,9 @@ module.exports = { testMatch: ["**/*.test.ts"], clearMocks: true, restoreMocks: true, - ...(process.env.IN_JEST_PROJECT ? {} : { forceExit: true }), + ...(process.env.IN_JEST_PROJECT + ? {} + : { forceExit: true, testTimeout: 30000, forceExit: true }), transform: { "\\.ts$": "ts-jest", }, diff --git a/package.json b/package.json index 56abd5c..1fe9d6a 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "scripts": { "build": "tsc", "dev": "tsc --watch --preserveWatchOutput", - "lint": "eslint . --ext .ts --cache --cache-location dist/.eslintcache", + "lint": "bash internal/lint.sh", "test": "jest", - "docs": "rm -rf docs && typedoc --plugin typedoc-plugin-markdown --plugin typedoc-plugin-merge-modules && sed -i '' -E 's#packages/[^/]+/##g' $(find docs -type f -name '*.md')", - "clean": "rm -rf dist node_modules yarn.lock package-lock.json pnpm-lock.yaml *.log", + "docs": "bash internal/docs.sh", + "clean": "bash internal/clean.sh", "copy-package-to-public-dir": "copy-package-to-public-dir.sh", "backport-package-from-public-dir": "backport-package-from-public-dir.sh", - "deploy": "npm run build && npm run lint && npm run test && npm publish --access=public" + "deploy": "bash internal/deploy.sh" }, "dependencies": { "lodash": "^4.17.21", diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..783953d --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,31 @@ +{ + "include": ["src/**/*"], + "compilerOptions": { + "allowJs": true, + "declaration": true, + "declarationMap": true, + "disableReferencedProjectLoad": true, + "disableSourceOfProjectReferenceRedirect": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "incremental": true, + "lib": ["ES2019"], + "module": "Node16", + "noEmitOnError": true, + "noErrorTruncation": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, + "outDir": "dist", + "pretty": true, + "removeComments": false, + "resolveJsonModule": true, + "rootDir": "src", + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "target": "ES2019", + "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", + "types": ["node", "jest"] + } +} diff --git a/tsconfig.json b/tsconfig.json index 783953d..8342ac4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,31 +1,4 @@ { - "include": ["src/**/*"], - "compilerOptions": { - "allowJs": true, - "declaration": true, - "declarationMap": true, - "disableReferencedProjectLoad": true, - "disableSourceOfProjectReferenceRedirect": true, - "esModuleInterop": true, - "experimentalDecorators": true, - "incremental": true, - "lib": ["ES2019"], - "module": "Node16", - "noEmitOnError": true, - "noErrorTruncation": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noPropertyAccessFromIndexSignature": true, - "outDir": "dist", - "pretty": true, - "removeComments": false, - "resolveJsonModule": true, - "rootDir": "src", - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "target": "ES2019", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", - "types": ["node", "jest"] - } + "extends": "./tsconfig.base.json", + "include": ["src/**/*"] } diff --git a/typedoc.config.js b/typedoc.config.js new file mode 100644 index 0000000..bc744b8 --- /dev/null +++ b/typedoc.config.js @@ -0,0 +1,20 @@ +"use strict"; +const { basename } = require("path"); + +module.exports = { + entryPoints: ["src"], + exclude: ["**/internal/**", "**/__tests__/**", "**/node_modules/**"], + entryPointStrategy: "expand", + mergeModulesMergeMode: "project", + sort: ["source-order"], + out: "docs", + logLevel: "Warn", + hideGenerator: true, + excludeInternal: true, + excludePrivate: true, + categorizeByGroup: true, + hideInPageTOC: true, + gitRevision: "master", + sourceLinkTemplate: `https://github.com/clickup/${basename(__dirname)}/blob/master/{path}#L{line}`, + basePath: ".", +}; diff --git a/typedoc.json b/typedoc.json deleted file mode 100644 index 7058348..0000000 --- a/typedoc.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "entryPoints": ["src"], - "exclude": ["**/internal/**", "**/__tests__/**", "**/node_modules/**"], - "entryPointStrategy": "expand", - "mergeModulesMergeMode": "project", - "sort": ["source-order"], - "out": "docs", - "logLevel": "Warn", - "hideGenerator": true, - "excludeInternal": true, - "excludePrivate": true, - "categorizeByGroup": true, - "hideInPageTOC": true, - "gitRevision": "master", - "sourceLinkTemplate": "https://github.com/clickup/magination/blob/master/{path}#L{line}", - "basePath": "." -}