p3x-tools 2025.4.121 → 2026.4.124
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 +3 -3
- package/package.json +10 -9
- package/src/command/git.js +3 -1
- package/src/git.js +72 -5
- package/src/github.js +15 -4
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
# 💣 Tools
|
|
9
|
+
# 💣 Tools v2026.4.123
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
### 🛠️ Built on NodeJs version
|
|
23
23
|
|
|
24
24
|
```txt
|
|
25
|
-
|
|
25
|
+
v24.14.1
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
|
|
@@ -392,7 +392,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
|
|
|
392
392
|
---
|
|
393
393
|
|
|
394
394
|
|
|
395
|
-
[**P3X-TOOLS**](https://corifeus.com/tools) Build
|
|
395
|
+
[**P3X-TOOLS**](https://corifeus.com/tools) Build v2026.4.123
|
|
396
396
|
|
|
397
397
|
[](https://www.npmjs.com/package/p3x-tools) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [](https://www.patrikx3.com/en/front/contact) [](https://www.facebook.com/corifeus.software)
|
|
398
398
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "p3x-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2026.4.124",
|
|
4
4
|
"corifeus": {
|
|
5
|
+
"icon": "fas fa-wrench",
|
|
5
6
|
"prefix": "p3x-",
|
|
6
7
|
"publish": true,
|
|
7
8
|
"type": "p3x",
|
|
8
9
|
"code": "Lazy",
|
|
9
|
-
"nodejs": "
|
|
10
|
+
"nodejs": "v24.14.1",
|
|
10
11
|
"opencollective": false,
|
|
11
12
|
"reponame": "tools",
|
|
12
13
|
"build": true
|
|
@@ -38,18 +39,18 @@
|
|
|
38
39
|
},
|
|
39
40
|
"homepage": "https://corifeus.com/tools",
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"corifeus-builder": "^
|
|
42
|
-
"grunt": "^1.6.
|
|
42
|
+
"corifeus-builder": "^2026.4.142",
|
|
43
|
+
"grunt": "^1.6.2"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"commander": "^
|
|
46
|
+
"commander": "^15.0.0-0",
|
|
46
47
|
"corifeus-utils": "^2025.4.123",
|
|
47
|
-
"fs-extra": "^11.3.
|
|
48
|
+
"fs-extra": "^11.3.4",
|
|
48
49
|
"github-api": "^3.4.0",
|
|
49
|
-
"globby": "^
|
|
50
|
-
"ini": "^
|
|
50
|
+
"globby": "^16.2.0",
|
|
51
|
+
"ini": "^6.0.0",
|
|
51
52
|
"mz": "^2.7.0",
|
|
52
|
-
"npm-check-updates": "^
|
|
53
|
+
"npm-check-updates": "^21.0.2",
|
|
53
54
|
"progress": "^2.0.3",
|
|
54
55
|
"readline": "^1.3.0",
|
|
55
56
|
"tmp-promise": "^3.0.3",
|
package/src/command/git.js
CHANGED
|
@@ -107,7 +107,9 @@ chmod +x ${name}/hooks/post-update`, true)
|
|
|
107
107
|
findData: findData,
|
|
108
108
|
options: options,
|
|
109
109
|
command: `git add .
|
|
110
|
-
git
|
|
110
|
+
${git.claudeCommitSnippet('r0b08x')}
|
|
111
|
+
git commit -a -F "$COMMIT_MSG_FILE" || true
|
|
112
|
+
rm -f "$COMMIT_MSG_FILE"
|
|
111
113
|
git push || true
|
|
112
114
|
${plusCommands === '' ? 'true' : plusCommands}`,
|
|
113
115
|
})
|
package/src/git.js
CHANGED
|
@@ -1,16 +1,81 @@
|
|
|
1
1
|
const utils = require('corifeus-utils');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const getMainBranch = () => {
|
|
6
|
+
try {
|
|
7
|
+
execSync('git rev-parse --verify main 2>/dev/null', { stdio: 'pipe' });
|
|
8
|
+
return 'main';
|
|
9
|
+
} catch(e) {
|
|
10
|
+
return 'master';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const claudeCommitSnippet = (fallback = 'r0b08x', diffCommand = 'git diff --cached --stat 2>/dev/null || true') => {
|
|
15
|
+
return `COMMIT_MSG_FILE=$(mktemp)
|
|
16
|
+
echo "${fallback}" > "$COMMIT_MSG_FILE"
|
|
17
|
+
P3X_CLAUDE_RC="$HOME/.p3x-claude-rc"
|
|
18
|
+
if [ -f "$P3X_CLAUDE_RC" ]; then
|
|
19
|
+
P3X_DIFF=$(${diffCommand})
|
|
20
|
+
if [ -n "$P3X_DIFF" ]; then
|
|
21
|
+
P3X_SCRIPT=$(mktemp)
|
|
22
|
+
cat > "$P3X_SCRIPT" << P3X_NODE_SCRIPT
|
|
23
|
+
(async () => {
|
|
24
|
+
try {
|
|
25
|
+
var fs = require("fs");
|
|
26
|
+
var apiKey = fs.readFileSync(process.env.HOME + "/.p3x-claude-rc", "utf8").trim();
|
|
27
|
+
var diff = process.env.P3X_DIFF_DATA;
|
|
28
|
+
var resp = await fetch("https://api.anthropic.com/v1/messages", {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: {
|
|
31
|
+
"x-api-key": apiKey,
|
|
32
|
+
"anthropic-version": "2023-06-01",
|
|
33
|
+
"content-type": "application/json"
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
model: "claude-haiku-4-5-20251001",
|
|
37
|
+
max_tokens: 300,
|
|
38
|
+
messages: [{
|
|
39
|
+
role: "user",
|
|
40
|
+
content: "Generate a git commit message for these changes. Use conventional commit style. First line is a short summary (max 72 chars), then a blank line, then bullet points describing the changes in detail. Do not use markdown code fences. Output ONLY the commit message, no extra commentary.\\n\\n" + diff
|
|
41
|
+
}]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
var data = await resp.json();
|
|
45
|
+
if (data.content && data.content[0]) process.stdout.write(data.content[0].text);
|
|
46
|
+
} catch(e) {}
|
|
47
|
+
})();
|
|
48
|
+
P3X_NODE_SCRIPT
|
|
49
|
+
P3X_MSG=$(P3X_DIFF_DATA="$P3X_DIFF" node "$P3X_SCRIPT" 2>/dev/null || true)
|
|
50
|
+
rm -f "$P3X_SCRIPT"
|
|
51
|
+
if [ -n "$P3X_MSG" ]; then
|
|
52
|
+
echo "$P3X_MSG" > "$COMMIT_MSG_FILE"
|
|
53
|
+
fi
|
|
54
|
+
fi
|
|
55
|
+
elif command -v claude >/dev/null 2>&1; then
|
|
56
|
+
P3X_DIFF=$(${diffCommand})
|
|
57
|
+
P3X_MSG=$(claude -p "Generate a git commit message for these changes. Use conventional commit style. First line is a short summary (max 72 chars), then a blank line, then bullet points describing the changes in detail. Do not use markdown code fences. Output ONLY the commit message, no extra commentary.
|
|
58
|
+
|
|
59
|
+
$P3X_DIFF" --no-session-persistence 2>/dev/null || true)
|
|
60
|
+
if [ -n "$P3X_MSG" ]; then
|
|
61
|
+
echo "$P3X_MSG" > "$COMMIT_MSG_FILE"
|
|
62
|
+
fi
|
|
63
|
+
fi`;
|
|
64
|
+
}
|
|
3
65
|
|
|
4
66
|
const truncate = async (options) => {
|
|
67
|
+
const mainBranch = getMainBranch();
|
|
5
68
|
|
|
6
69
|
const command = `git config --global credential.helper 'cache --timeout 7200'
|
|
7
70
|
git checkout --orphan temp
|
|
8
71
|
git add -A
|
|
9
|
-
|
|
10
|
-
git
|
|
11
|
-
|
|
12
|
-
git branch
|
|
13
|
-
git
|
|
72
|
+
${claudeCommitSnippet('r0b08x (truncate)')}
|
|
73
|
+
git commit -a -F "$COMMIT_MSG_FILE"
|
|
74
|
+
rm -f "$COMMIT_MSG_FILE"
|
|
75
|
+
git branch -D ${mainBranch}
|
|
76
|
+
git branch -m ${mainBranch}
|
|
77
|
+
git branch --set-upstream-to origin/${mainBranch} ${mainBranch}
|
|
78
|
+
git push -f origin ${mainBranch}`
|
|
14
79
|
|
|
15
80
|
console.log(command);
|
|
16
81
|
if (!options.dry) {
|
|
@@ -34,3 +99,5 @@ const findModules = async (root) => {
|
|
|
34
99
|
|
|
35
100
|
module.exports.findModules = findModules;
|
|
36
101
|
module.exports.truncate = truncate;
|
|
102
|
+
module.exports.getMainBranch = getMainBranch;
|
|
103
|
+
module.exports.claudeCommitSnippet = claudeCommitSnippet;
|
package/src/github.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
const GitHub = require('github-api');
|
|
2
2
|
const tmp = require('tmp-promise');
|
|
3
3
|
const utils = require('corifeus-utils');
|
|
4
|
+
const { mirrorExclude } = require('corifeus-builder').config;
|
|
4
5
|
|
|
5
6
|
const mz = require('mz');
|
|
6
7
|
const ini = require('ini');
|
|
7
8
|
const url = require('url');
|
|
8
9
|
const git = require('./git');
|
|
9
10
|
|
|
11
|
+
const mirrorExcludeFindCmds = (dir) => [
|
|
12
|
+
...mirrorExclude.files.map((f) =>
|
|
13
|
+
`find ${dir} -maxdepth 1 -iname "${f}" -exec rm -f {} +`),
|
|
14
|
+
...mirrorExclude.dirs.map((d) =>
|
|
15
|
+
`find ${dir} -maxdepth 1 -iname "${d}" -type d -exec rm -rf {} +`),
|
|
16
|
+
].join('\n');
|
|
17
|
+
|
|
10
18
|
const list = async (options) => {
|
|
11
19
|
const {only, user, exclude} = options;
|
|
12
20
|
let {disableArchived} = options
|
|
@@ -61,8 +69,8 @@ git submodule update --init --recursive --remote
|
|
|
61
69
|
const currentRepo = `${tmpDir.path}/git/${repo.name}`;
|
|
62
70
|
await utils.childProcess.exec(`
|
|
63
71
|
rm -rf ${currentRepo}/.git
|
|
64
|
-
rm -rf ${currentRepo}/secure
|
|
65
72
|
#rm -rf ${currentRepo}/package-lock.json
|
|
73
|
+
${mirrorExcludeFindCmds(currentRepo)}
|
|
66
74
|
|
|
67
75
|
mv ${tmpDir.path}/github/${repo.name}/.git ${tmpDir.path}/git/${repo.name}/
|
|
68
76
|
`, true)
|
|
@@ -95,7 +103,9 @@ git status
|
|
|
95
103
|
try {
|
|
96
104
|
await utils.childProcess.exec(`
|
|
97
105
|
cd ${tmpDir.path}/github/${repo.name}
|
|
98
|
-
|
|
106
|
+
${git.claudeCommitSnippet(`${note} ${new Date().toLocaleString()}`)}
|
|
107
|
+
git commit -a -F "$COMMIT_MSG_FILE"
|
|
108
|
+
rm -f "$COMMIT_MSG_FILE"
|
|
99
109
|
${dry ? 'true' : 'git push'}
|
|
100
110
|
`, true)
|
|
101
111
|
} catch (e) {
|
|
@@ -108,9 +118,10 @@ ${dry ? 'true' : 'git push'}
|
|
|
108
118
|
await utils.childProcess.exec(`
|
|
109
119
|
cd ${module}
|
|
110
120
|
git pull
|
|
111
|
-
git
|
|
121
|
+
MAIN_BRANCH=$(git remote show origin 2>/dev/null | sed -n 's/.*HEAD branch: //p') ; MAIN_BRANCH=\${MAIN_BRANCH:-master}
|
|
122
|
+
git checkout $MAIN_BRANCH
|
|
112
123
|
git submodule update --init --recursive --remote
|
|
113
|
-
git submodule foreach --recursive git checkout
|
|
124
|
+
git submodule foreach --recursive git checkout $MAIN_BRANCH
|
|
114
125
|
git status
|
|
115
126
|
${dry ? 'true' : 'git push'}
|
|
116
127
|
`, true)
|