ui-code-health-check 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +7 -0
- package/README.md +88 -0
- package/dist/index.js +66 -0
- package/eslint.config.cjs +23 -0
- package/package.json +42 -0
- package/src/index.ts +81 -0
- package/tsconfig.json +14 -0
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# TESTING NEW PACKAGE, NOT FOR USE YET
|
|
2
|
+
|
|
3
|
+
# UI Code Health Check
|
|
4
|
+
|
|
5
|
+
**UI Code Health Check** is a CLI tool that helps you maintain high code quality in your TypeScript projects. It automates common checks such as linting, testing, spell checking, type checking, and building, running only the steps that are configured in your project.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Linting**: Runs ESLint to enforce code style and best practices.
|
|
10
|
+
- **Testing**: Executes your project's test suite (if defined).
|
|
11
|
+
- **Spell Checking**: Uses cspell to catch spelling mistakes (if defined).
|
|
12
|
+
- **TypeScript Checking**: Runs TypeScript type checks (if defined).
|
|
13
|
+
- **Build**: Executes your build script (if defined).
|
|
14
|
+
- **Smart Skipping**: Automatically skips any step if the corresponding script is missing in your `package.json`.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Add this package as a dev dependency:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install --save-dev ui-code-health-check
|
|
22
|
+
# or
|
|
23
|
+
pnpm add -D ui-code-health-check
|
|
24
|
+
# or
|
|
25
|
+
yarn add -D ui-code-health-check
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
After installation, you can run the health check from your project root:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx ui-code-health-check
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or add it as a script in your `package.json`:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"scripts": {
|
|
41
|
+
"health-check": "ui-code-health-check"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then run:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run health-check
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How It Works
|
|
53
|
+
|
|
54
|
+
The tool checks your `package.json` for the following scripts and runs them in order if they exist:
|
|
55
|
+
|
|
56
|
+
1. `lint`
|
|
57
|
+
2. `test`
|
|
58
|
+
3. `cspell`
|
|
59
|
+
4. `typecheck`
|
|
60
|
+
5. `build`
|
|
61
|
+
|
|
62
|
+
If a script is missing, that step is skipped.
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
- **ESLint**: Ensure you have a `lint` script in your `package.json` (e.g., `"lint": "eslint ."`).
|
|
67
|
+
- **Testing**: Add a `test` script (e.g., `"test": "jest"`).
|
|
68
|
+
- **Spell Checking**: Add a `cspell` script (e.g., `"cspell": "cspell '**'"`).
|
|
69
|
+
- **Type Checking**: Add a `typecheck` script (e.g., `"typecheck": "tsc --noEmit"`).
|
|
70
|
+
- **Build**: Add a `build` script (e.g., `"build": "tsc"` or your build tool).
|
|
71
|
+
|
|
72
|
+
## Example `package.json` Scripts
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"scripts": {
|
|
77
|
+
"lint": "eslint .",
|
|
78
|
+
"test": "jest",
|
|
79
|
+
"cspell": "cspell '**'",
|
|
80
|
+
"typecheck": "tsc --noEmit",
|
|
81
|
+
"build": "tsc"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const steps = [
|
|
10
|
+
{ name: 'Lint', cmd: 'npm run lint', script: 'lint' },
|
|
11
|
+
{ name: 'Test', cmd: 'npm run test', script: 'test' },
|
|
12
|
+
{ name: 'CSpell', cmd: 'npm run cspell', script: 'cspell' },
|
|
13
|
+
{ name: 'TypeScript Check', cmd: 'npm run ts-check', script: 'ts-check' },
|
|
14
|
+
{ name: 'Build', cmd: 'npm run build', script: 'build' }
|
|
15
|
+
];
|
|
16
|
+
const start = Date.now();
|
|
17
|
+
console.log(chalk_1.default.bgBlue.white.bold('\n========== Starting UI Code Health Check ==========\n'));
|
|
18
|
+
console.log(chalk_1.default.white.bold('Version: 1.0.0\n' +
|
|
19
|
+
'Developed by: IF | Janis Dregeris \n' +
|
|
20
|
+
'Date: 2026/01\n' +
|
|
21
|
+
`Run: ${new Date().getFullYear()}/${String(new Date().getMonth() + 1).padStart(2, '0')}\n`));
|
|
22
|
+
// Read package.json scripts
|
|
23
|
+
let scripts = {};
|
|
24
|
+
try {
|
|
25
|
+
const pkg = JSON.parse((0, node_fs_1.readFileSync)('package.json', 'utf-8'));
|
|
26
|
+
scripts = pkg.scripts || {};
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
console.log(chalk_1.default.red('❌ Could not read package.json.'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
for (const step of steps) {
|
|
33
|
+
if (!scripts[step.script]) {
|
|
34
|
+
console.log(chalk_1.default.yellow(`⚠️ Skipping "${step.name}" — missing "${step.script}" script in package.json.`));
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const stepStart = Date.now();
|
|
38
|
+
try {
|
|
39
|
+
console.log(chalk_1.default.blueBright(`\n▶ ${step.name}...`));
|
|
40
|
+
(0, node_child_process_1.execSync)(step.cmd, { stdio: 'inherit' });
|
|
41
|
+
const stepTime = ((Date.now() - stepStart) / 1000).toFixed(2);
|
|
42
|
+
console.log(chalk_1.default.green(`✔ ${step.name} finished in ${stepTime}s`));
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.log(chalk_1.default.red(`❌ ${step.name} failed, ${chalk_1.default.bold.bgBlackBright(error)}. Please fix the issues above and try again. Before committing, make sure all checks pass.\n`));
|
|
46
|
+
console.log(chalk_1.default.yellow([
|
|
47
|
+
`ℹ️ lint-staged will prevent committing if any of these errors are present.`,
|
|
48
|
+
`You can run ${chalk_1.default.bold.bgBlackBright('npm run ch')} to catch errors before committing.`,
|
|
49
|
+
`\nDetected errors may include:`,
|
|
50
|
+
`- Linting issues (code style, formatting, best practices)`,
|
|
51
|
+
`- Failing tests`,
|
|
52
|
+
`- Spelling mistakes`,
|
|
53
|
+
`- TypeScript type errors`,
|
|
54
|
+
`- Build errors`,
|
|
55
|
+
`\n⚠️ Note: This code health check will stop executing further commands as soon as an error is detected.`,
|
|
56
|
+
`If you get errors from one command, errors from subsequent commands will only appear after you fix the current errors and re-run the script.`,
|
|
57
|
+
`It will not show all errors from all commands at once; you need to resolve issues step by step.`,
|
|
58
|
+
`You need to run ${chalk_1.default.bold.bgBlackBright('npm run ch')} again after fixing each errors group, until all steps succeed.`,
|
|
59
|
+
`\n❗ Please resolve all reported issues to ensure a successful commit.\n`
|
|
60
|
+
].join('\n')));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const totalTime = ((Date.now() - start) / 1000).toFixed(2);
|
|
65
|
+
console.log(chalk_1.default.green(`\n🏁 All steps finished in ${totalTime}s\n`));
|
|
66
|
+
console.log(chalk_1.default.bold.green('All checks passed! Now you can make a commit. 🚀 \n'));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { defineConfig } = require('eslint/config')
|
|
2
|
+
const tsPlugin = require('@typescript-eslint/eslint-plugin')
|
|
3
|
+
const tsParser = require('@typescript-eslint/parser')
|
|
4
|
+
|
|
5
|
+
module.exports = defineConfig([
|
|
6
|
+
{ ignores: ['node_modules/**', 'dist/**'] },
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parser: tsParser,
|
|
11
|
+
parserOptions: {
|
|
12
|
+
project: './tsconfig.json',
|
|
13
|
+
sourceType: 'module'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
'@typescript-eslint': tsPlugin
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
...tsPlugin.configs.recommended.rules
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
])
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ui-code-health-check",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/juandrepanther/ui-code-health-check.git"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.0.0",
|
|
8
|
+
"description": "A package to perform a series of code quality checks including linting, testing, spell checking, TypeScript checking, and building.",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"ui-code-health-check": "dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"ch": "node dist/index.js",
|
|
18
|
+
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"chalk": "^4.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^25.0.3",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
26
|
+
"@typescript-eslint/parser": "^8.53.0",
|
|
27
|
+
"cspell": "^9.4.0",
|
|
28
|
+
"eslint": "^9.39.2",
|
|
29
|
+
"prettier": "^3.8.0",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"code",
|
|
34
|
+
"health",
|
|
35
|
+
"check",
|
|
36
|
+
"lint",
|
|
37
|
+
"test",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"author": "juandrepanther",
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { execSync } from 'node:child_process'
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
|
|
5
|
+
const steps = [
|
|
6
|
+
{ name: 'Lint', cmd: 'npm run lint', script: 'lint' },
|
|
7
|
+
{ name: 'Test', cmd: 'npm run test', script: 'test' },
|
|
8
|
+
{ name: 'CSpell', cmd: 'npm run cspell', script: 'cspell' },
|
|
9
|
+
{ name: 'TypeScript Check', cmd: 'npm run ts-check', script: 'ts-check' },
|
|
10
|
+
{ name: 'Build', cmd: 'npm run build', script: 'build' }
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
const start = Date.now()
|
|
14
|
+
|
|
15
|
+
console.log(chalk.bgBlue.white.bold('\n========== Starting UI Code Health Check ==========\n'))
|
|
16
|
+
console.log(
|
|
17
|
+
chalk.white.bold(
|
|
18
|
+
'Version: 1.0.0\n' +
|
|
19
|
+
'Developed by: IF | Janis Dregeris \n' +
|
|
20
|
+
'Date: 2026/01\n' +
|
|
21
|
+
`Run: ${new Date().getFullYear()}/${String(new Date().getMonth() + 1).padStart(2, '0')}\n`
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// Read package.json scripts
|
|
26
|
+
let scripts: Record<string, string> = {}
|
|
27
|
+
try {
|
|
28
|
+
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'))
|
|
29
|
+
scripts = pkg.scripts || {}
|
|
30
|
+
} catch {
|
|
31
|
+
console.log(chalk.red('❌ Could not read package.json.'))
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const step of steps) {
|
|
36
|
+
if (!scripts[step.script]) {
|
|
37
|
+
console.log(
|
|
38
|
+
chalk.yellow(`⚠️ Skipping "${step.name}" — missing "${step.script}" script in package.json.`)
|
|
39
|
+
)
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const stepStart = Date.now()
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
console.log(chalk.blueBright(`\n▶ ${step.name}...`))
|
|
47
|
+
execSync(step.cmd, { stdio: 'inherit' })
|
|
48
|
+
const stepTime = ((Date.now() - stepStart) / 1000).toFixed(2)
|
|
49
|
+
console.log(chalk.green(`✔ ${step.name} finished in ${stepTime}s`))
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log(
|
|
52
|
+
chalk.red(
|
|
53
|
+
`❌ ${step.name} failed, ${chalk.bold.bgBlackBright(error)}. Please fix the issues above and try again. Before committing, make sure all checks pass.\n`
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
console.log(
|
|
57
|
+
chalk.yellow(
|
|
58
|
+
[
|
|
59
|
+
`ℹ️ lint-staged will prevent committing if any of these errors are present.`,
|
|
60
|
+
`You can run ${chalk.bold.bgBlackBright('npm run ch')} to catch errors before committing.`,
|
|
61
|
+
`\nDetected errors may include:`,
|
|
62
|
+
`- Linting issues (code style, formatting, best practices)`,
|
|
63
|
+
`- Failing tests`,
|
|
64
|
+
`- Spelling mistakes`,
|
|
65
|
+
`- TypeScript type errors`,
|
|
66
|
+
`- Build errors`,
|
|
67
|
+
`\n⚠️ Note: This code health check will stop executing further commands as soon as an error is detected.`,
|
|
68
|
+
`If you get errors from one command, errors from subsequent commands will only appear after you fix the current errors and re-run the script.`,
|
|
69
|
+
`It will not show all errors from all commands at once; you need to resolve issues step by step.`,
|
|
70
|
+
`You need to run ${chalk.bold.bgBlackBright('npm run ch')} again after fixing each errors group, until all steps succeed.`,
|
|
71
|
+
`\n❗ Please resolve all reported issues to ensure a successful commit.\n`
|
|
72
|
+
].join('\n')
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const totalTime = ((Date.now() - start) / 1000).toFixed(2)
|
|
80
|
+
console.log(chalk.green(`\n🏁 All steps finished in ${totalTime}s\n`))
|
|
81
|
+
console.log(chalk.bold.green('All checks passed! Now you can make a commit. 🚀 \n'))
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"],
|
|
13
|
+
"exclude": ["node_modules", "**/*.spec.ts"]
|
|
14
|
+
}
|