Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeveric committed Apr 26, 2023
0 parents commit a8bb7f8
Show file tree
Hide file tree
Showing 26 changed files with 4,253 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
examples/
fixtures/
private/
dist/
38 changes: 38 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"root": true,
"extends": ["@webdeveric/eslint-config-ts", "plugin:import/recommended", "plugin:import/typescript", "prettier"],
"env": {
"browser": false,
"es6": true,
"node": true
},
"settings": {
"import/extensions": [".ts", ".mts", ".cts", ".js", ".json"],
"import/resolver": {
"typescript": {
"project": "./tsconfig.json"
},
"node": {
"extensions": [".js", ".ts", ".mts", ".cts"]
}
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".mts", ".cts"]
}
},
"rules": {},
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["./tsconfig.json"]
}
},
{
"files": ["./*.{js,cjs,mjs,mts}"],
"parserOptions": {
"project": ["./tsconfig.project-files.json"]
}
}
]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
29 changes: 29 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Node.js CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm build
- run: pnpm coverage
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
coverage/
private/
dist/
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no cspell -- --no-summary --no-progress --language-id commit-msg $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no lint-staged -- --config "$(dirname "$0")/../lint-staged.config.mjs"
14 changes: 14 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

origin="${1:-origin}"

numberOfTsFiles=$(git diff --stat --cached ${origin}/master --name-only | grep -E "(\.tsx?|tsconfig\.json)$" | wc -l)

if [ "$numberOfTsFiles" = "0" ]; then
echo "No TypeScript files found. Skipping typecheck."

exit 0
fi

npm run typecheck
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"esbenp.prettier-vscode"
]
}
34 changes: 34 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.validate": ["javascript", "typescript"],
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.packageManager": "npm",
"editor.bracketPairColorization.enabled": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"javascript.format.semicolons": "insert",
"javascript.preferences.quoteStyle": "single",
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.format.semicolons": "insert",
"typescript.preferences.quoteStyle": "single",
"typescript.updateImportsOnFileMove.enabled": "always",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"**/*.min.{cjs,mjs,js}": "plaintext"
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Eric King

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2",
"language": "en",
"words": [
"entrypoints",
"env",
"esbuild",
"escaperegexp",
"npmrc",
"pnpm",
"postbuild",
"preinstall",
"typecheck",
"unstub",
"vitest",
"webdeveric"
],
"flagWords": [],
"ignorePaths": ["pnpm-lock.yaml", "package-lock.json", "node_modules", ".vscode"],
"languageSettings": [
{
"languageId": "commit-msg",
"ignoreRegExpList": ["/^#.*/gm"]
}
]
}
1 change: 1 addition & 0 deletions fixtures/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello, World!');
27 changes: 27 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { cwd } from 'node:process';
import { relative } from 'node:path';

/**
* @type {(filenames: string[]) => string[]>}
*/
const relativeFilenames = filenames => {
const root = cwd();

return filenames.map(file => relative(root, file));
};

/**
* @type {Record<string, string | (filenames: string[]) => string | string[] | Promise<string | string[]>}
*/
export default {
'*.{js,cjs,mjs,ts,cts,mts}': ['eslint --fix', 'prettier --write'],
'*.{json,md}': 'prettier --write',
'*': filenames => {
const files = relativeFilenames(filenames);

return [
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
];
},
};
90 changes: 90 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"name": "esbuild-plugin-modify-entrypoints",
"version": "0.0.0",
"description": "esbuild plugin to modify entrypoint contents",
"license": "MIT",
"author": {
"email": "eric@webdeveric.com",
"name": "Eric King",
"url": "http://webdeveric.com/"
},
"keywords": [
"esbuild",
"plugin",
"modify",
"entrypoints"
],
"repository": {
"type": "git",
"url": "https://github.com/webdeveric/esbuild-plugin-modify-entrypoints.git"
},
"bugs": {
"url": "https://github.com/webdeveric/esbuild-plugin-modify-entrypoints/issues"
},
"homepage": "https://github.com/webdeveric/esbuild-plugin-modify-entrypoints",
"type": "module",
"packageManager": "pnpm@8.3.1",
"engines": {
"node": ">=16.0.0"
},
"exports": {
".": {
"types": "./dist/types/plugin.d.ts",
"require": "./dist/cjs/plugin.js",
"import": "./dist/mjs/plugin.js"
},
"./*": {
"types": "./dist/types/*.d.ts",
"require": "./dist/cjs/*.js",
"import": "./dist/mjs/*.js"
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"lint": "eslint --fix ./*{js,cjs,mjs,mts} ./src",
"clean": "rimraf ./dist/",
"prebuild": "npm run clean",
"build:cjs": "tsc -p ./tsconfig.cjs.json",
"build:mjs": "tsc -p ./tsconfig.mjs.json",
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
"postbuild:mjs": "echo '{\"type\":\"module\"}' > ./dist/mjs/package.json",
"build": "npm run build:cjs && npm run build:mjs",
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.project-files.json",
"spellcheck": "cspell --no-progress './{.github,src,test}/**/*.{ts,js,json}' './*.{md,js}' './package.json'",
"format": "prettier --write ./*.{js,json,md} ./src/ ./test/ --no-error-on-unmatched-pattern",
"test": "vitest -c vitest.config.mts",
"coverage": "vitest run -c vitest.config.mts --coverage",
"prepack": "npm run build",
"prepublishOnly": "npm run typecheck && npm run spellcheck && npm run lint && npm run coverage",
"prepare": "husky install"
},
"prettier": "@webdeveric/prettier-config",
"peerDependencies": {
"esbuild": ">=0.15"
},
"dependencies": {
"@types/lodash.escaperegexp": "^4.1.7",
"lodash.escaperegexp": "^4.1.2"
},
"devDependencies": {
"@types/node": "^18.16.1",
"@vitest/coverage-c8": "^0.30.1",
"@webdeveric/eslint-config-ts": "^0.6.0",
"@webdeveric/prettier-config": "^0.2.0",
"cspell": "^6.31.1",
"esbuild": "^0.17.18",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"typescript": "^5.0.4",
"vitest": "^0.30.1"
}
}

0 comments on commit a8bb7f8

Please sign in to comment.