Skip to content

Commit

Permalink
Add a framework to reuse some build files across multiple open-source…
Browse files Browse the repository at this point in the history
… projects (#5)


## PRs in the Stack
- ➡ #5

(The stack is managed by
[git-grok](https://github.com/dimikot/git-grok).)
  • Loading branch information
dimikot authored Jan 14, 2024
2 parents 842d96e + a17ea37 commit dc7642b
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.base.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -430,5 +430,6 @@ module.exports = (projectRoot) => ({
],

quotes: ["error", "double", { avoidEscape: true }],
...extraRules,
},
});
16 changes: 8 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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"],
});
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist

# Common in both .gitignore and .npmignore
node_modules
package-lock.json
yarn.lock
Expand Down
7 changes: 4 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"trentrand.git-rebase-shortcuts"
]
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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": []
}
]
}
4 changes: 4 additions & 0 deletions internal/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log
7 changes: 7 additions & 0 deletions internal/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

npm run build
npm run lint
npm run test
npm publish --access=public
6 changes: 6 additions & 0 deletions internal/docs.sh
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 4 additions & 0 deletions internal/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

eslint . --ext .ts --cache --cache-location dist/.eslintcache
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 31 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
31 changes: 2 additions & 29 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
20 changes: 20 additions & 0 deletions typedoc.config.js
Original file line number Diff line number Diff line change
@@ -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: ".",
};
17 changes: 0 additions & 17 deletions typedoc.json

This file was deleted.

0 comments on commit dc7642b

Please sign in to comment.