Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a framework to reuse some build files across multiple open-source projects #6

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
},
});
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
const config = require("./.eslintrc.base.js")(__dirname);
config.rules["import/no-extraneous-dependencies"] = "error";
config.rules["lodash/import-scope"] = ["error", "method"];
module.exports = config;
module.exports = require("./.eslintrc.base.js")(__dirname, {
"import/no-extraneous-dependencies": "error",
"lodash/import-scope": ["error", "method"],
});
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
dist

# Common in both .gitignore and .npmignore
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock
pnpm-lock.yaml
.DS_Store
*.log
*.tmp
Expand Down
9 changes: 5 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
__tests__
dist/__tests__
dist/**/__tests__
dist/tsconfig.tsbuildinfo
.npmrc
tsconfig.tsbuildinfo
.github

# Common in both .gitignore and .npmignore
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock
pnpm-lock.yaml
.DS_Store
*.log
*.tmp
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 @@ -24,13 +24,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": {
"abort-controller": "^3.0.0",
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: ".",
};
22 changes: 0 additions & 22 deletions typedoc.json

This file was deleted.