ui-code-health-check 0.0.1 → 0.0.2
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/README.md +16 -16
- package/dist/index.js +56 -28
- package/dist/messages.js +48 -0
- package/package.json +11 -9
- package/src/index.ts +27 -42
- package/src/messages.ts +53 -0
package/README.md
CHANGED
|
@@ -30,25 +30,19 @@ yarn add -D ui-code-health-check
|
|
|
30
30
|
After installation, you can run the health check from your project root:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
npx
|
|
33
|
+
npx ch
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Or add it as a script in your `package.json
|
|
36
|
+
Or add it as a script in your `package.json` (example):
|
|
37
37
|
|
|
38
38
|
```json
|
|
39
39
|
{
|
|
40
40
|
"scripts": {
|
|
41
|
-
"
|
|
41
|
+
"ch": "npx ch"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Then run:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm run health-check
|
|
50
|
-
```
|
|
51
|
-
|
|
52
46
|
## How It Works
|
|
53
47
|
|
|
54
48
|
The tool checks your `package.json` for the following scripts and runs them in order if they exist:
|
|
@@ -56,17 +50,23 @@ The tool checks your `package.json` for the following scripts and runs them in o
|
|
|
56
50
|
1. `lint`
|
|
57
51
|
2. `test`
|
|
58
52
|
3. `cspell`
|
|
59
|
-
4. `
|
|
53
|
+
4. `ts-ch`
|
|
60
54
|
5. `build`
|
|
61
55
|
|
|
62
56
|
If a script is missing, that step is skipped.
|
|
63
57
|
|
|
58
|
+
Then run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm run ch
|
|
62
|
+
```
|
|
63
|
+
|
|
64
64
|
## Configuration
|
|
65
65
|
|
|
66
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": "
|
|
67
|
+
- **Testing**: Add a `test` script (e.g., `"test": "vitest run"`).
|
|
68
68
|
- **Spell Checking**: Add a `cspell` script (e.g., `"cspell": "cspell '**'"`).
|
|
69
|
-
- **Type Checking**: Add a `
|
|
69
|
+
- **Type Checking**: Add a `ts-ch` script (e.g., `"ts-ch": "tsc --noEmit"`).
|
|
70
70
|
- **Build**: Add a `build` script (e.g., `"build": "tsc"` or your build tool).
|
|
71
71
|
|
|
72
72
|
## Example `package.json` Scripts
|
|
@@ -75,10 +75,10 @@ If a script is missing, that step is skipped.
|
|
|
75
75
|
{
|
|
76
76
|
"scripts": {
|
|
77
77
|
"lint": "eslint .",
|
|
78
|
-
"test": "
|
|
79
|
-
"cspell": "cspell
|
|
80
|
-
"
|
|
81
|
-
"build": "tsc"
|
|
78
|
+
"test": "vitest run",
|
|
79
|
+
"cspell": "cspell \"src/**/*.{ts,tsx,md}\" ",
|
|
80
|
+
"ts-ch": "npx tsc --noemit",
|
|
81
|
+
"build": "tsc && vite build"
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
40
|
const node_child_process_1 = require("node:child_process");
|
|
8
41
|
const node_fs_1 = require("node:fs");
|
|
42
|
+
const msg = __importStar(require("./messages"));
|
|
9
43
|
const steps = [
|
|
10
44
|
{ name: 'Lint', cmd: 'npm run lint', script: 'lint' },
|
|
11
45
|
{ name: 'Test', cmd: 'npm run test', script: 'test' },
|
|
@@ -14,53 +48,47 @@ const steps = [
|
|
|
14
48
|
{ name: 'Build', cmd: 'npm run build', script: 'build' }
|
|
15
49
|
];
|
|
16
50
|
const start = Date.now();
|
|
17
|
-
console.log(chalk_1.default.bgBlue.white.bold(
|
|
18
|
-
console.log(chalk_1.default.white.bold('
|
|
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
|
|
51
|
+
console.log(chalk_1.default.bgBlue.white.bold(msg.HEADER));
|
|
52
|
+
console.log(chalk_1.default.white.bold(msg.INFO('1.0.0', 'juandrepanther')));
|
|
23
53
|
let scripts = {};
|
|
24
54
|
try {
|
|
25
55
|
const pkg = JSON.parse((0, node_fs_1.readFileSync)('package.json', 'utf-8'));
|
|
26
56
|
scripts = pkg.scripts || {};
|
|
27
57
|
}
|
|
28
58
|
catch (_a) {
|
|
29
|
-
console.log(chalk_1.default.red(
|
|
59
|
+
console.log(chalk_1.default.red(msg.COULD_NOT_READ_PKG));
|
|
30
60
|
process.exit(1);
|
|
31
61
|
}
|
|
62
|
+
const executedSteps = [];
|
|
63
|
+
const skippedSteps = [];
|
|
32
64
|
for (const step of steps) {
|
|
33
65
|
if (!scripts[step.script]) {
|
|
34
|
-
|
|
66
|
+
skippedSteps.push(step.name);
|
|
67
|
+
console.log(chalk_1.default.yellow(msg.SKIP_STEP(step.name, step.script)));
|
|
35
68
|
continue;
|
|
36
69
|
}
|
|
37
70
|
const stepStart = Date.now();
|
|
38
71
|
try {
|
|
39
|
-
console.log(chalk_1.default.blueBright(
|
|
72
|
+
console.log(chalk_1.default.blueBright(msg.STEP_START(step.name)));
|
|
40
73
|
(0, node_child_process_1.execSync)(step.cmd, { stdio: 'inherit' });
|
|
41
74
|
const stepTime = ((Date.now() - stepStart) / 1000).toFixed(2);
|
|
42
|
-
console.log(chalk_1.default.green(
|
|
75
|
+
console.log(chalk_1.default.green(msg.STEP_SUCCESS(step.name, stepTime)));
|
|
76
|
+
executedSteps.push(step.name);
|
|
43
77
|
}
|
|
44
78
|
catch (error) {
|
|
45
|
-
console.log(chalk_1.default.red(
|
|
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')));
|
|
79
|
+
console.log(chalk_1.default.red(msg.STEP_FAIL(step.name, chalk_1.default.bold.bgBlackBright(error))));
|
|
80
|
+
console.log(chalk_1.default.yellow(msg.FAIL_HINT(chalk_1.default.bold.bgBlackBright('npm run ch'))));
|
|
61
81
|
process.exit(1);
|
|
62
82
|
}
|
|
63
83
|
}
|
|
64
84
|
const totalTime = ((Date.now() - start) / 1000).toFixed(2);
|
|
65
|
-
console.log(chalk_1.default.green(
|
|
66
|
-
console.log(chalk_1.default.bold
|
|
85
|
+
console.log(chalk_1.default.green(msg.ALL_STEPS_FINISHED(totalTime)));
|
|
86
|
+
console.log(chalk_1.default.bold(msg.STEP_SUMMARY));
|
|
87
|
+
console.log(chalk_1.default.green(msg.EXECUTED(executedSteps)));
|
|
88
|
+
console.log(chalk_1.default.yellow(msg.SKIPPED(skippedSteps)));
|
|
89
|
+
if (skippedSteps.length > 0) {
|
|
90
|
+
console.log(chalk_1.default.yellow.bold(msg.SKIP_WARNING));
|
|
91
|
+
}
|
|
92
|
+
if (executedSteps.length === steps.length) {
|
|
93
|
+
console.log(chalk_1.default.bold.green(msg.ALL_PASSED));
|
|
94
|
+
}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_PASSED = exports.SKIP_WARNING = exports.SKIPPED = exports.EXECUTED = exports.STEP_SUMMARY = exports.ALL_STEPS_FINISHED = exports.FAIL_HINT = exports.STEP_FAIL = exports.STEP_SUCCESS = exports.STEP_START = exports.SKIP_STEP = exports.COULD_NOT_READ_PKG = exports.INFO = exports.HEADER = void 0;
|
|
4
|
+
exports.HEADER = `
|
|
5
|
+
========== Starting UI Code Health Check ==========
|
|
6
|
+
`;
|
|
7
|
+
const INFO = (version, author) => `Version: ${version}
|
|
8
|
+
Developed by: ${author}
|
|
9
|
+
Date: 2026/01
|
|
10
|
+
Run: ${new Date().getFullYear()}/${String(new Date().getMonth() + 1).padStart(2, '0')}
|
|
11
|
+
`;
|
|
12
|
+
exports.INFO = INFO;
|
|
13
|
+
exports.COULD_NOT_READ_PKG = '❌ Could not read package.json.';
|
|
14
|
+
const SKIP_STEP = (stepName, script) => `⚠️ Skipping "${stepName}" — missing "${script}" script in package.json.`;
|
|
15
|
+
exports.SKIP_STEP = SKIP_STEP;
|
|
16
|
+
const STEP_START = (stepName) => `\n▶ ${stepName}...`;
|
|
17
|
+
exports.STEP_START = STEP_START;
|
|
18
|
+
const STEP_SUCCESS = (stepName, time) => `✔ ${stepName} finished in ${time}s`;
|
|
19
|
+
exports.STEP_SUCCESS = STEP_SUCCESS;
|
|
20
|
+
const STEP_FAIL = (stepName, error) => `❌ ${stepName} failed, ${error}. Please fix the issues above and try again. Before committing, make sure all checks pass.\n`;
|
|
21
|
+
exports.STEP_FAIL = STEP_FAIL;
|
|
22
|
+
const FAIL_HINT = (runCmd) => [
|
|
23
|
+
`ℹ️ lint-staged will prevent committing if any of these errors are present.`,
|
|
24
|
+
`You can run ${runCmd} to catch errors before committing.`,
|
|
25
|
+
`\nDetected errors may include:`,
|
|
26
|
+
`- Linting issues (code style, formatting, best practices)`,
|
|
27
|
+
`- Failing tests`,
|
|
28
|
+
`- Spelling mistakes`,
|
|
29
|
+
`- TypeScript type errors`,
|
|
30
|
+
`- Build errors`,
|
|
31
|
+
`\n⚠️ Note: This code health check will stop executing further commands as soon as an error is detected.`,
|
|
32
|
+
`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.`,
|
|
33
|
+
`It will not show all errors from all commands at once; you need to resolve issues step by step.`,
|
|
34
|
+
`You need to run ${runCmd} again after fixing each errors group, until all steps succeed.`,
|
|
35
|
+
`\n❗ Please resolve all reported issues to ensure a successful commit.\n`
|
|
36
|
+
].join('\n');
|
|
37
|
+
exports.FAIL_HINT = FAIL_HINT;
|
|
38
|
+
const ALL_STEPS_FINISHED = (time) => `\n🏁 All steps finished in ${time}s\n`;
|
|
39
|
+
exports.ALL_STEPS_FINISHED = ALL_STEPS_FINISHED;
|
|
40
|
+
exports.STEP_SUMMARY = 'Step summary:';
|
|
41
|
+
const EXECUTED = (steps) => `Executed: ${steps.length ? steps.join(', ') : 'None'}`;
|
|
42
|
+
exports.EXECUTED = EXECUTED;
|
|
43
|
+
const SKIPPED = (steps) => `Skipped: ${steps.length ? steps.join(', ') : 'None'}`;
|
|
44
|
+
exports.SKIPPED = SKIPPED;
|
|
45
|
+
exports.SKIP_WARNING = `
|
|
46
|
+
⚠️ Some checks were skipped. It is important to pass all checks to ensure high code quality and maintainability. Please consider adding the missing scripts to your package.json for a complete code health check.
|
|
47
|
+
`;
|
|
48
|
+
exports.ALL_PASSED = 'All checks passed! Now you can make a commit. 🚀 \n';
|
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-code-health-check",
|
|
3
|
+
"author": "juandrepanther",
|
|
4
|
+
"license": "MIT",
|
|
3
5
|
"repository": {
|
|
4
6
|
"type": "git",
|
|
5
7
|
"url": "git+https://github.com/juandrepanther/ui-code-health-check.git"
|
|
6
8
|
},
|
|
7
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.2",
|
|
8
10
|
"description": "A package to perform a series of code quality checks including linting, testing, spell checking, TypeScript checking, and building.",
|
|
9
11
|
"main": "dist/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
12
|
"bin": {
|
|
12
13
|
"ch": "dist/index.js"
|
|
13
14
|
},
|
|
14
15
|
"scripts": {
|
|
15
16
|
"lint": "eslint .",
|
|
17
|
+
"test": "echo \"Running tests...\" && exit 0",
|
|
18
|
+
"cspell": "echo \"Running cspell...\" && exit 0",
|
|
19
|
+
"ts-check": "echo \"Running TypeScript check...\" && exit 0",
|
|
16
20
|
"build": "tsc",
|
|
17
|
-
"
|
|
21
|
+
"dev": "node dist/index.js",
|
|
18
22
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
19
23
|
},
|
|
20
24
|
"dependencies": {
|
|
@@ -32,11 +36,9 @@
|
|
|
32
36
|
"keywords": [
|
|
33
37
|
"code",
|
|
34
38
|
"health",
|
|
35
|
-
"check"
|
|
36
|
-
"lint",
|
|
37
|
-
"test",
|
|
38
|
-
"typescript"
|
|
39
|
+
"check"
|
|
39
40
|
],
|
|
40
|
-
"
|
|
41
|
-
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=24.0.0"
|
|
43
|
+
}
|
|
42
44
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { execSync } from 'node:child_process'
|
|
3
3
|
import { readFileSync } from 'node:fs'
|
|
4
|
+
import * as msg from './messages'
|
|
4
5
|
|
|
5
6
|
const steps = [
|
|
6
7
|
{ name: 'Lint', cmd: 'npm run lint', script: 'lint' },
|
|
@@ -12,70 +13,54 @@ const steps = [
|
|
|
12
13
|
|
|
13
14
|
const start = Date.now()
|
|
14
15
|
|
|
15
|
-
console.log(chalk.bgBlue.white.bold(
|
|
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
|
-
)
|
|
16
|
+
console.log(chalk.bgBlue.white.bold(msg.HEADER))
|
|
17
|
+
console.log(chalk.white.bold(msg.INFO('1.0.0', 'juandrepanther')))
|
|
24
18
|
|
|
25
|
-
// Read package.json scripts
|
|
26
19
|
let scripts: Record<string, string> = {}
|
|
27
20
|
try {
|
|
28
21
|
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'))
|
|
29
22
|
scripts = pkg.scripts || {}
|
|
30
23
|
} catch {
|
|
31
|
-
console.log(chalk.red(
|
|
24
|
+
console.log(chalk.red(msg.COULD_NOT_READ_PKG))
|
|
32
25
|
process.exit(1)
|
|
33
26
|
}
|
|
34
27
|
|
|
28
|
+
const executedSteps: string[] = []
|
|
29
|
+
const skippedSteps: string[] = []
|
|
30
|
+
|
|
35
31
|
for (const step of steps) {
|
|
36
32
|
if (!scripts[step.script]) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
33
|
+
skippedSteps.push(step.name)
|
|
34
|
+
console.log(chalk.yellow(msg.SKIP_STEP(step.name, step.script)))
|
|
40
35
|
continue
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
const stepStart = Date.now()
|
|
44
39
|
|
|
45
40
|
try {
|
|
46
|
-
console.log(chalk.blueBright(
|
|
41
|
+
console.log(chalk.blueBright(msg.STEP_START(step.name)))
|
|
47
42
|
execSync(step.cmd, { stdio: 'inherit' })
|
|
48
43
|
const stepTime = ((Date.now() - stepStart) / 1000).toFixed(2)
|
|
49
|
-
console.log(chalk.green(
|
|
44
|
+
console.log(chalk.green(msg.STEP_SUCCESS(step.name, stepTime)))
|
|
45
|
+
executedSteps.push(step.name)
|
|
50
46
|
} catch (error) {
|
|
51
|
-
console.log(
|
|
52
|
-
|
|
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
|
-
)
|
|
47
|
+
console.log(chalk.red(msg.STEP_FAIL(step.name, chalk.bold.bgBlackBright(error))))
|
|
48
|
+
console.log(chalk.yellow(msg.FAIL_HINT(chalk.bold.bgBlackBright('npm run ch'))))
|
|
75
49
|
process.exit(1)
|
|
76
50
|
}
|
|
77
51
|
}
|
|
78
52
|
|
|
79
53
|
const totalTime = ((Date.now() - start) / 1000).toFixed(2)
|
|
80
|
-
console.log(chalk.green(
|
|
81
|
-
|
|
54
|
+
console.log(chalk.green(msg.ALL_STEPS_FINISHED(totalTime)))
|
|
55
|
+
|
|
56
|
+
console.log(chalk.bold(msg.STEP_SUMMARY))
|
|
57
|
+
console.log(chalk.green(msg.EXECUTED(executedSteps)))
|
|
58
|
+
console.log(chalk.yellow(msg.SKIPPED(skippedSteps)))
|
|
59
|
+
|
|
60
|
+
if (skippedSteps.length > 0) {
|
|
61
|
+
console.log(chalk.yellow.bold(msg.SKIP_WARNING))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (executedSteps.length === steps.length) {
|
|
65
|
+
console.log(chalk.bold.green(msg.ALL_PASSED))
|
|
66
|
+
}
|
package/src/messages.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const HEADER = `
|
|
2
|
+
========== Starting UI Code Health Check ==========
|
|
3
|
+
`
|
|
4
|
+
|
|
5
|
+
export const INFO = (version: string, author: string) =>
|
|
6
|
+
`Version: ${version}
|
|
7
|
+
Developed by: ${author}
|
|
8
|
+
Date: 2026/01
|
|
9
|
+
Run: ${new Date().getFullYear()}/${String(new Date().getMonth() + 1).padStart(2, '0')}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const COULD_NOT_READ_PKG = '❌ Could not read package.json.'
|
|
13
|
+
|
|
14
|
+
export const SKIP_STEP = (stepName: string, script: string) =>
|
|
15
|
+
`⚠️ Skipping "${stepName}" — missing "${script}" script in package.json.`
|
|
16
|
+
|
|
17
|
+
export const STEP_START = (stepName: string) => `\n▶ ${stepName}...`
|
|
18
|
+
|
|
19
|
+
export const STEP_SUCCESS = (stepName: string, time: string) => `✔ ${stepName} finished in ${time}s`
|
|
20
|
+
|
|
21
|
+
export const STEP_FAIL = (stepName: string, error: unknown) =>
|
|
22
|
+
`❌ ${stepName} failed, ${error}. Please fix the issues above and try again. Before committing, make sure all checks pass.\n`
|
|
23
|
+
|
|
24
|
+
export const FAIL_HINT = (runCmd: string) =>
|
|
25
|
+
[
|
|
26
|
+
`ℹ️ lint-staged will prevent committing if any of these errors are present.`,
|
|
27
|
+
`You can run ${runCmd} to catch errors before committing.`,
|
|
28
|
+
`\nDetected errors may include:`,
|
|
29
|
+
`- Linting issues (code style, formatting, best practices)`,
|
|
30
|
+
`- Failing tests`,
|
|
31
|
+
`- Spelling mistakes`,
|
|
32
|
+
`- TypeScript type errors`,
|
|
33
|
+
`- Build errors`,
|
|
34
|
+
`\n⚠️ Note: This code health check will stop executing further commands as soon as an error is detected.`,
|
|
35
|
+
`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.`,
|
|
36
|
+
`It will not show all errors from all commands at once; you need to resolve issues step by step.`,
|
|
37
|
+
`You need to run ${runCmd} again after fixing each errors group, until all steps succeed.`,
|
|
38
|
+
`\n❗ Please resolve all reported issues to ensure a successful commit.\n`
|
|
39
|
+
].join('\n')
|
|
40
|
+
|
|
41
|
+
export const ALL_STEPS_FINISHED = (time: string) => `\n🏁 All steps finished in ${time}s\n`
|
|
42
|
+
|
|
43
|
+
export const STEP_SUMMARY = 'Step summary:'
|
|
44
|
+
|
|
45
|
+
export const EXECUTED = (steps: string[]) => `Executed: ${steps.length ? steps.join(', ') : 'None'}`
|
|
46
|
+
|
|
47
|
+
export const SKIPPED = (steps: string[]) => `Skipped: ${steps.length ? steps.join(', ') : 'None'}`
|
|
48
|
+
|
|
49
|
+
export const SKIP_WARNING = `
|
|
50
|
+
⚠️ Some checks were skipped. It is important to pass all checks to ensure high code quality and maintainability. Please consider adding the missing scripts to your package.json for a complete code health check.
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
export const ALL_PASSED = 'All checks passed! Now you can make a commit. 🚀 \n'
|