@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/src/config.js CHANGED
@@ -1,7 +1,7 @@
1
- import path from "path";
1
+ import path from 'path';
2
2
 
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");
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
- import { configDotenv } from "dotenv";
4
- import { readdirSync, readFileSync } from "fs";
5
- import path from "path";
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("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;
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
- configDotenv({ path: CONFIG_FILE });
44
+ configDotenv({ path: CONFIG_FILE });
46
45
  }
47
46
 
48
47
  program
49
- .command("pr <module>")
50
- .option("-b, --bump <level>")
51
- .action((module, opts) => {
52
- prMain(module)
53
- .then(() => {
54
- if (opts.bump) {
55
- return verbot(module, opts.bump);
56
- }
57
- })
58
- .catch((err) => {
59
- throw err;
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
- .command("ver <module>")
65
- .option("-b, --bump <level>")
66
- .action((module, opts) => {
67
- if (!opts.bump) {
68
- throw new Error("No bump level specified");
69
- }
70
- verbot(module, opts.bump);
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
- .command("init")
75
- .description("Create config file and install shell completion")
76
- .action(() => {
77
- init(completion);
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
- .command("changelog <pr>")
84
- .option("-t, --trident <code>", "Trident issue codes (repeatable)", collect)
85
- .option("-j, --jira <code>", "JIRA issue codes (repeatable)", collect)
86
- .option("-m, --message <text>", "Changelog entry message")
87
- .action((prNumber, opts) => {
88
- changelog(prNumber, opts).catch((err) => {
89
- throw err;
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
- .command("autopr")
95
- .option("-t, --trident <id>", "Trident task IDs (repeatable)", collect)
96
- .option("-j, --jira <code>", "JIRA issue codes (repeatable)", collect)
97
- .option("-m, --message <text>", "Changelog entry message")
98
- .option("-b, --branch <name>", "Branch name (default: autopr_<taskId>)")
99
- .option("-n, --name <text>", "PR title (default: task name from Odoo)")
100
- .action((opts) => {
101
- autopr(opts).catch((err) => {
102
- throw err;
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
- if (addonsPath.startsWith("~")) {
3
- return addonsPath.replace("~", process.env.HOME);
4
- }
5
- return addonsPath;
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 "child_process";
1
+ import { execFile } from 'child_process';
2
2
 
3
3
  function execGit(args, cwd) {
4
- return new Promise((resolve, reject) => {
5
- execFile("git", args, { cwd }, (error, stdout) => {
6
- if (error) reject(error);
7
- else resolve(stdout);
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 };