@waron97/prbot 2.0.0 → 2.2.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/.claude/settings.local.json +9 -3
- package/.prettierrc.mjs +11 -0
- package/README.md +30 -30
- package/eslint.config.mjs +16 -0
- package/index.js +327 -344
- package/package.json +33 -32
- package/src/commands/autopr.js +238 -259
- package/src/commands/changelog.js +154 -150
- package/src/commands/commit.js +146 -0
- package/src/commands/init.js +137 -134
- package/src/commands/pr.js +101 -106
- package/src/commands/ver.js +54 -64
- package/src/config.js +4 -4
- package/src/index.js +83 -78
- package/src/lib/addons.js +4 -4
- package/src/lib/git.js +6 -6
package/src/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import path from
|
|
1
|
+
import path from 'path';
|
|
2
2
|
|
|
3
|
-
const CONFIG_DIR = path.join(process.env.HOME ||
|
|
4
|
-
const CONFIG_FILE = path.join(CONFIG_DIR,
|
|
5
|
-
const COMPLETION_SCRIPT = path.join(CONFIG_DIR,
|
|
3
|
+
const CONFIG_DIR = path.join(process.env.HOME || '', '.config', 'prbot');
|
|
4
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config');
|
|
5
|
+
const COMPLETION_SCRIPT = path.join(CONFIG_DIR, 'completion.sh');
|
|
6
6
|
|
|
7
7
|
export { CONFIG_DIR, CONFIG_FILE, COMPLETION_SCRIPT };
|
package/src/index.js
CHANGED
|
@@ -1,106 +1,111 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readdirSync, readFileSync } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import { configDotenv } from 'dotenv';
|
|
6
|
+
import omelette from 'omelette';
|
|
7
|
+
import { autopr } from './commands/autopr.js';
|
|
8
|
+
import { changelog } from './commands/changelog.js';
|
|
9
|
+
import { commit } from './commands/commit.js';
|
|
10
|
+
import { init } from './commands/init.js';
|
|
11
|
+
import { main as prMain } from './commands/pr.js';
|
|
12
|
+
import { verbot } from './commands/ver.js';
|
|
13
|
+
import { CONFIG_FILE } from './config.js';
|
|
2
14
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { program } from "commander";
|
|
7
|
-
import omelette from "omelette";
|
|
8
|
-
import { CONFIG_FILE, COMPLETION_SCRIPT } from "./config.js";
|
|
9
|
-
import { main as prMain } from "./commands/pr.js";
|
|
10
|
-
import { verbot } from "./commands/ver.js";
|
|
11
|
-
import { init } from "./commands/init.js";
|
|
12
|
-
import { changelog } from "./commands/changelog.js";
|
|
13
|
-
import { autopr } from "./commands/autopr.js";
|
|
14
|
-
|
|
15
|
-
const completion = omelette("prbot <command> <module>");
|
|
16
|
-
completion.on("command", ({ reply }) => {
|
|
17
|
-
reply(["pr", "ver", "init", "changelog", "autopr"]);
|
|
15
|
+
const completion = omelette('prbot <command> <module>');
|
|
16
|
+
completion.on('command', ({ reply }) => {
|
|
17
|
+
reply(['pr', 'ver', 'init', 'changelog', 'autopr', 'commit']);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
completion.on(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
completion.on('module', ({ before, reply }) => {
|
|
21
|
+
if (['init', 'changelog', 'autopr'].includes(before)) {
|
|
22
|
+
reply([]);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const raw = readFileSync(CONFIG_FILE, 'utf-8');
|
|
27
|
+
const match = raw.match(/^ADDONS_PATH=(.+)$/m);
|
|
28
|
+
if (!match) {
|
|
29
|
+
reply([]);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const addonsPath = match[1].trim().replace(/^~/, process.env.HOME || '');
|
|
33
|
+
reply(readdirSync(path.join(addonsPath, 'config')));
|
|
34
|
+
} catch {
|
|
35
|
+
reply([]);
|
|
31
36
|
}
|
|
32
|
-
const addonsPath = match[1].trim().replace(/^~/, process.env.HOME || "");
|
|
33
|
-
reply(readdirSync(path.join(addonsPath, "config")));
|
|
34
|
-
} catch {
|
|
35
|
-
reply([]);
|
|
36
|
-
}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
completion.init();
|
|
40
40
|
|
|
41
|
-
const isCompletionMode =
|
|
42
|
-
process.argv.includes("--compbash") || process.argv.includes("--compzsh");
|
|
41
|
+
const isCompletionMode = process.argv.includes('--compbash') || process.argv.includes('--compzsh');
|
|
43
42
|
|
|
44
43
|
if (!isCompletionMode) {
|
|
45
|
-
|
|
44
|
+
configDotenv({ path: CONFIG_FILE });
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
program
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
.command('pr <module>')
|
|
49
|
+
.option('-b, --bump <level>')
|
|
50
|
+
.action((module, opts) => {
|
|
51
|
+
prMain(module)
|
|
52
|
+
.then(() => {
|
|
53
|
+
if (opts.bump) {
|
|
54
|
+
return verbot(module, opts.bump);
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
throw err;
|
|
59
|
+
});
|
|
60
|
+
});
|
|
62
61
|
|
|
63
62
|
program
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
.command('ver <module>')
|
|
64
|
+
.option('-b, --bump <level>')
|
|
65
|
+
.action((module, opts) => {
|
|
66
|
+
if (!opts.bump) {
|
|
67
|
+
throw new Error('No bump level specified');
|
|
68
|
+
}
|
|
69
|
+
verbot(module, opts.bump);
|
|
70
|
+
});
|
|
72
71
|
|
|
73
72
|
program
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
.command('init')
|
|
74
|
+
.description('Create config file and install shell completion')
|
|
75
|
+
.action(() => {
|
|
76
|
+
init(completion);
|
|
77
|
+
});
|
|
79
78
|
|
|
80
79
|
const collect = (val, prev) => [...(prev ?? []), val];
|
|
81
80
|
|
|
82
81
|
program
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
.command('changelog <pr>')
|
|
83
|
+
.option('-t, --trident <code>', 'Trident issue codes (repeatable)', collect)
|
|
84
|
+
.option('-j, --jira <code>', 'JIRA issue codes (repeatable)', collect)
|
|
85
|
+
.option('-m, --message <text>', 'Changelog entry message')
|
|
86
|
+
.action((prNumber, opts) => {
|
|
87
|
+
changelog(prNumber, opts).catch((err) => {
|
|
88
|
+
throw err;
|
|
89
|
+
});
|
|
90
90
|
});
|
|
91
|
-
});
|
|
92
91
|
|
|
93
92
|
program
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
.command('autopr')
|
|
94
|
+
.option('-t, --trident <id>', 'Trident task IDs (repeatable)', collect)
|
|
95
|
+
.option('-j, --jira <code>', 'JIRA issue codes (repeatable)', collect)
|
|
96
|
+
.option('-m, --message <text>', 'Changelog entry message')
|
|
97
|
+
.option('-b, --branch <name>', 'Branch name (default: autopr_<taskId>)')
|
|
98
|
+
.option('-n, --name <text>', 'PR title (default: task name from Odoo)')
|
|
99
|
+
.action((opts) => {
|
|
100
|
+
autopr(opts).catch((err) => {
|
|
101
|
+
throw err;
|
|
102
|
+
});
|
|
103
103
|
});
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
program.command('commit').action((opts) => {
|
|
106
|
+
commit(opts).catch((err) => {
|
|
107
|
+
throw err;
|
|
108
|
+
});
|
|
109
|
+
});
|
|
105
110
|
|
|
106
111
|
program.parse();
|
package/src/lib/addons.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function resolveAddonsPath(addonsPath) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
if (addonsPath.startsWith('~')) {
|
|
3
|
+
return addonsPath.replace('~', process.env.HOME);
|
|
4
|
+
}
|
|
5
|
+
return addonsPath;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export { resolveAddonsPath };
|
package/src/lib/git.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { execFile } from
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
2
|
|
|
3
3
|
function execGit(args, cwd) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
execFile('git', args, { cwd }, (error, stdout) => {
|
|
6
|
+
if (error) reject(error);
|
|
7
|
+
else resolve(stdout);
|
|
8
|
+
});
|
|
8
9
|
});
|
|
9
|
-
});
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { execGit };
|