Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeveric committed Dec 1, 2023
0 parents commit 03f6e09
Show file tree
Hide file tree
Showing 34 changed files with 5,028 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 @@
coverage/
dist/
node_modules/
private/
83 changes: 83 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"root": true,
"extends": ["@webdeveric/eslint-config-ts", "plugin:import/recommended", "plugin:import/typescript", "prettier"],
"env": {
"browser": false,
"es6": true,
"node": true
},
"parserOptions": {
"project": ["./tsconfig.json"],
"ecmaFeatures": {
"jsx": false
}
},
"settings": {
"import/extensions": [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json"],
"import/resolver": {
"typescript": {
"project": "./tsconfig.json"
},
"node": {
"extensions": [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"]
}
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".mts", ".cts"]
}
},
"rules": {
"import/first": "error",
"import/no-absolute-path": "error",
"import/no-cycle": "error",
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["./build.mjs", "./vitest.config.mts", "**/*.test.ts"]
}
],
"import/no-relative-packages": "error",
"import/no-self-import": "error",
"import/no-unresolved": "error",
"import/no-useless-path-segments": [
"error",
{
"noUselessIndex": false
}
],
"import/order": [
"error",
{
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"groups": ["builtin", "external", "internal", "parent", ["sibling", "index"], "type"],
"newlines-between": "always",
"pathGroups": [
{
"pattern": "@{src,commands}/**",
"group": "internal",
"position": "after"
}
]
}
],
"sort-imports": "off"
},
"overrides": [
{
"files": ["./*.mjs", "./*.mts"],
"parserOptions": {
"project": ["./tsconfig.project-files.json"]
}
},
{
"files": ["**/*.test.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": ["off"]
}
}
]
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @webdeveric
34 changes: 34 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Node.js CI

on: [push]

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

jobs:
ci:
name: Continuous Integration
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Installing dependencies
run: pnpm install
- name: Linting
run: pnpm lint
- name: Type checking
run: pnpm typecheck
- name: Testing
run: pnpm coverage
- name: Building
run: pnpm build
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
npm-debug.log
coverage/
dist/
node_modules/
private/
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
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
auto-install-peers=true
enable-pre-post-scripts=true
# strict-peer-dependencies=false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode/
coverage/
dist/
private/
package-lock.json
LICENSE
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"eamodio.gitlens"
]
}
34 changes: 34 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"eslint.alwaysShowStatus": true,
"eslint.format.enable": true,
"eslint.validate": [
"javascript",
"typescript"
],
"eslint.lintTask.enable": true,
"eslint.packageManager": "npm",
"editor.bracketPairColorization.enabled": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"javascript.format.semicolons": "insert",
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.format.semicolons": "insert",
"typescript.updateImportsOnFileMove.enabled": "always",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.suggest.completeJSDocs": true,
"javascript.suggest.jsdoc.generateReturns": true,
"typescript.suggest.completeJSDocs": false,
"typescript.suggest.jsdoc.generateReturns": false
}
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) 2023 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.
55 changes: 55 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env -S node --experimental-json-modules --no-warnings

import { comment } from '@webdeveric/utils/comment';
import { build } from 'esbuild';
import { clean } from 'esbuild-plugin-clean';
import { environmentPlugin } from 'esbuild-plugin-environment';
import { nodeExternals } from 'esbuild-plugin-node-externals';

import pkg from './package.json' assert { type: 'json' };

try {
const results = await build({
entryPoints: ['./src/cli.ts'],
outdir: './dist',
platform: 'node',
bundle: true,
format: 'esm',
outExtension: {
'.js': '.mjs',
},
target: `node${process.versions.node}`,
minify: process.env.NODE_ENV === 'production',
banner: {
js: comment(
`
@file ${pkg.name}
@version ${pkg.version}
@license ${pkg.license}
@copyright ${pkg.author.name} ${new Date().getFullYear()}
@see {@link ${pkg.homepage}}
`,
{
type: 'legal',
},
),
},
plugins: [
clean({
patterns: ['./dist/*'],
}),
nodeExternals(),
environmentPlugin(['npm_package_engines_node']),
],
});

const errors = [...results.warnings, ...results.errors];

if (errors.length) {
throw new AggregateError(errors, 'Build error and warnings');
}
} catch (error) {
console.error(error);

process.exitCode ||= 1;
}
22 changes: 22 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2",
"words": [
"CODEOWNERS",
"corepack",
"nvmrc",
"outdir",
"Positionals",
"predemo",
"typecheck",
"unstub",
"vitest",
"webdeveric"
],
"ignorePaths": ["node_modules/**", ".vscode/*.json", "./private", "pnpm-lock.yaml", ".github/CODEOWNERS"],
"languageSettings": [
{
"languageId": "commit-msg",
"ignoreRegExpList": ["/^#.*/gm"]
}
]
}
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 { relative } from 'node:path';
import { cwd } from 'node:process';

/**
* @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.
];
},
};
Loading

0 comments on commit 03f6e09

Please sign in to comment.