@digitoimistodude/code-quality-checks 2.1.3 → 2.1.4
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/bin/setup.js +3 -0
- package/index.js +29 -4
- package/package.json +6 -1
package/bin/setup.js
ADDED
package/index.js
CHANGED
|
@@ -3,18 +3,43 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exports the path to husky hooks for direct reference.
|
|
5
5
|
*
|
|
6
|
-
* Usage in your project's .
|
|
7
|
-
*
|
|
6
|
+
* Usage in your project's package.json:
|
|
7
|
+
* "prepare": "dude-code-quality-setup"
|
|
8
8
|
*
|
|
9
9
|
* Or import the path:
|
|
10
10
|
* const { huskyPath } = require('@digitoimistodude/code-quality-checks');
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const path = require('path');
|
|
14
|
+
const { execSync } = require('child_process');
|
|
15
|
+
|
|
16
|
+
const huskyPath = path.join(__dirname, '.husky');
|
|
17
|
+
const huskyInternalPath = path.join(__dirname, '.husky', '_');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Setup husky with absolute path to hooks
|
|
21
|
+
* This ensures hooks work from anywhere in the git repository
|
|
22
|
+
*/
|
|
23
|
+
function setup() {
|
|
24
|
+
try {
|
|
25
|
+
// Get the git root directory
|
|
26
|
+
const gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
|
|
27
|
+
|
|
28
|
+
// Set core.hooksPath to absolute path
|
|
29
|
+
execSync(`git config core.hooksPath "${huskyInternalPath}"`, { cwd: gitRoot });
|
|
30
|
+
|
|
31
|
+
console.log(`✅ Husky hooks configured at: ${huskyInternalPath}`);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('❌ Failed to setup husky hooks:', error.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
14
37
|
|
|
15
38
|
module.exports = {
|
|
16
|
-
huskyPath
|
|
39
|
+
huskyPath,
|
|
40
|
+
huskyInternalPath,
|
|
17
41
|
preCommitPath: path.join(__dirname, '.husky', 'pre-commit'),
|
|
18
42
|
preCommitConfigPath: path.join(__dirname, '.husky', 'pre-commit-config'),
|
|
19
|
-
commitMsgPath: path.join(__dirname, '.husky', 'commit-msg')
|
|
43
|
+
commitMsgPath: path.join(__dirname, '.husky', 'commit-msg'),
|
|
44
|
+
setup
|
|
20
45
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitoimistodude/code-quality-checks",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Code quality definitions and Husky pre-commit hooks for Dude WordPress projects",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node bin/setup.js"
|
|
8
|
+
},
|
|
6
9
|
"files": [
|
|
7
10
|
".husky/pre-commit",
|
|
8
11
|
".husky/pre-commit-config",
|
|
9
12
|
".husky/commit-msg",
|
|
13
|
+
".husky/_",
|
|
14
|
+
"bin",
|
|
10
15
|
"index.js"
|
|
11
16
|
],
|
|
12
17
|
"repository": {
|