@techninja/clearstack 0.3.6 → 0.3.7
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/lib/check.js +32 -15
- package/package.json +1 -1
package/lib/check.js
CHANGED
|
@@ -10,6 +10,13 @@ import { checkFileLines, runCmd, countFiles } from './spec-utils.js';
|
|
|
10
10
|
|
|
11
11
|
export { checkFileLines, runCmd, countFiles, findFiles, elapsed } from './spec-utils.js';
|
|
12
12
|
|
|
13
|
+
/** Detect the project's package manager runner (npx, pnpm exec, yarn). */
|
|
14
|
+
function detectRunner(projectDir) {
|
|
15
|
+
if (existsSync(resolve(projectDir, 'pnpm-lock.yaml'))) return 'pnpm exec';
|
|
16
|
+
if (existsSync(resolve(projectDir, 'yarn.lock'))) return 'yarn';
|
|
17
|
+
return 'npx';
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/** @param {string} src */
|
|
14
21
|
function parseEnv(src) {
|
|
15
22
|
const env = {};
|
|
@@ -36,15 +43,24 @@ export function loadConfig(projectDir) {
|
|
|
36
43
|
};
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
46
|
+
/**
|
|
47
|
+
* Build check commands for the detected package manager.
|
|
48
|
+
* @param {string} runner
|
|
49
|
+
*/
|
|
50
|
+
function buildCmds(runner) {
|
|
51
|
+
const audit = runner === 'pnpm exec' ? 'pnpm audit --prod' : 'npm audit --omit=dev';
|
|
52
|
+
return {
|
|
53
|
+
lint: `${runner} eslint --config .configs/eslint.config.js . --fix`,
|
|
54
|
+
stylelint: `${runner} stylelint --config .configs/.stylelintrc.json "src/**/*.css" --fix`,
|
|
55
|
+
prettier: `${runner} prettier --config .configs/.prettierrc --write src scripts`,
|
|
56
|
+
mdlint: `${runner} markdownlint-cli2 --config .configs/.markdownlint.jsonc --fix "docs/**/*.md" "*.md"`,
|
|
57
|
+
types: `${runner} tsc --project .configs/jsconfig.json`,
|
|
58
|
+
audit,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @deprecated Use buildCmds() instead — kept for backward compat. */
|
|
63
|
+
export const CMDS = buildCmds('npx');
|
|
48
64
|
|
|
49
65
|
/**
|
|
50
66
|
* Run the full spec compliance check (used by clearstack CLI).
|
|
@@ -53,6 +69,7 @@ export const CMDS = {
|
|
|
53
69
|
*/
|
|
54
70
|
export async function check(projectDir, scope) {
|
|
55
71
|
const cfg = loadConfig(projectDir);
|
|
72
|
+
const cmds = buildCmds(detectRunner(projectDir));
|
|
56
73
|
|
|
57
74
|
if (scope === 'code') {
|
|
58
75
|
if (!checkFileLines(projectDir, cfg.codeExt, cfg.codeMax, cfg.ignore, `Code (max ${cfg.codeMax} lines)`))
|
|
@@ -73,12 +90,12 @@ export async function check(projectDir, scope) {
|
|
|
73
90
|
const results = [
|
|
74
91
|
checkFileLines(projectDir, cfg.codeExt, cfg.codeMax, cfg.ignore, `Code (max ${cfg.codeMax} lines)`),
|
|
75
92
|
checkFileLines(projectDir, cfg.docsExt, cfg.docsMax, cfg.ignore, `Docs (max ${cfg.docsMax} lines)`),
|
|
76
|
-
runCmd('ESLint',
|
|
77
|
-
runCmd('Stylelint',
|
|
78
|
-
runCmd('Prettier',
|
|
79
|
-
runCmd('Markdown',
|
|
80
|
-
runCmd('JSDoc types',
|
|
81
|
-
runCmd('Security audit',
|
|
93
|
+
runCmd('ESLint', cmds.lint, projectDir, `${jsFiles} files`),
|
|
94
|
+
runCmd('Stylelint', cmds.stylelint, projectDir, `${cssFiles} files`),
|
|
95
|
+
runCmd('Prettier', cmds.prettier, projectDir, `${jsFiles} files`),
|
|
96
|
+
runCmd('Markdown', cmds.mdlint, projectDir, `${mdFiles} files`),
|
|
97
|
+
runCmd('JSDoc types', cmds.types, projectDir, `${jsFiles} files`),
|
|
98
|
+
runCmd('Security audit', cmds.audit, projectDir),
|
|
82
99
|
];
|
|
83
100
|
|
|
84
101
|
const passed = results.filter(Boolean).length;
|