@waron97/prbot 2.1.0 → 2.3.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 -263
- package/src/commands/changelog.js +154 -150
- package/src/commands/commit.js +146 -0
- package/src/commands/export.js +7 -0
- package/src/commands/exportPb.js +156 -0
- package/src/commands/init.js +144 -136
- package/src/commands/pr.js +81 -107
- package/src/commands/ver.js +54 -64
- package/src/config.js +4 -4
- package/src/index.js +112 -78
- package/src/lib/addons.js +4 -4
- package/src/lib/auth.js +25 -0
- package/src/lib/git.js +6 -6
package/src/commands/init.js
CHANGED
|
@@ -1,147 +1,155 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import path from
|
|
3
|
-
import inquirer from
|
|
4
|
-
import { CONFIG_DIR, CONFIG_FILE
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { COMPLETION_SCRIPT, CONFIG_DIR, CONFIG_FILE } from '../config.js';
|
|
5
5
|
|
|
6
6
|
async function init(completion) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
8
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const existing = existsSync(CONFIG_FILE)
|
|
12
|
+
? Object.fromEntries(
|
|
13
|
+
readFileSync(CONFIG_FILE, 'utf-8')
|
|
14
|
+
.split('\n')
|
|
15
|
+
.flatMap((line) => {
|
|
16
|
+
const m = line.match(/^([A-Z_]+)=(.*)$/);
|
|
17
|
+
return m ? [[m[1], m[2]]] : [];
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
: {};
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
22
|
+
const answers = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: 'input',
|
|
25
|
+
name: 'ADDONS_PATH',
|
|
26
|
+
message: 'Addons path:',
|
|
27
|
+
default: existing.ADDONS_PATH ?? '~/codebase/sorgenia/addons',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'input',
|
|
31
|
+
name: 'KC_URL',
|
|
32
|
+
message: 'Keycloak URL:',
|
|
33
|
+
default: existing.KC_URL ?? '',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'input',
|
|
37
|
+
name: 'KC_USER',
|
|
38
|
+
message: 'Keycloak user:',
|
|
39
|
+
default: existing.KC_USER ?? '',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'password',
|
|
43
|
+
name: 'KC_PASSWORD',
|
|
44
|
+
message: `Keycloak password${existing.KC_PASSWORD ? ' (leave blank to keep existing)' : ''}:`,
|
|
45
|
+
mask: '*',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'input',
|
|
49
|
+
name: 'KC_ID',
|
|
50
|
+
message: 'Keycloak client ID:',
|
|
51
|
+
default: existing.KC_ID ?? '',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'input',
|
|
55
|
+
name: 'KC_SECRET',
|
|
56
|
+
message: 'Keycloak client secret:',
|
|
57
|
+
default: existing.KC_SECRET ?? '',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'input',
|
|
61
|
+
name: 'RIP_URL',
|
|
62
|
+
message: 'RIP URL:',
|
|
63
|
+
default: existing.RIP_URL ?? '',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'input',
|
|
67
|
+
name: 'TRIDENT_URL',
|
|
68
|
+
message: 'Trident URL:',
|
|
69
|
+
default: existing.TRIDENT_URL ?? '',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'input',
|
|
73
|
+
name: 'TRIDENT_UID',
|
|
74
|
+
message: 'Trident UID:',
|
|
75
|
+
default: existing.TRIDENT_UID ?? '',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'input',
|
|
79
|
+
name: 'TRIDENT_TOKEN',
|
|
80
|
+
message: 'Trident token:',
|
|
81
|
+
default: existing.TRIDENT_TOKEN ?? '',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'input',
|
|
85
|
+
name: 'DEVOPS_TOKEN',
|
|
86
|
+
message: 'DevOps token:',
|
|
87
|
+
default: existing.DEVOPS_TOKEN ?? '',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: 'input',
|
|
91
|
+
name: 'DEVOPS_ORG',
|
|
92
|
+
message: 'DevOps org:',
|
|
93
|
+
default: existing.DEVOPS_ORG ?? '',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'input',
|
|
97
|
+
name: 'DEVOPS_PROJECT',
|
|
98
|
+
message: 'DevOps project:',
|
|
99
|
+
default: existing.DEVOPS_PROJECT ?? '',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'input',
|
|
103
|
+
name: 'DEVOPS_REPO',
|
|
104
|
+
message: 'DevOps repo:',
|
|
105
|
+
default: existing.DEVOPS_REPO ?? '',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'input',
|
|
109
|
+
name: 'TRIDENT_DB',
|
|
110
|
+
message: 'Trident DB name:',
|
|
111
|
+
default: existing.TRIDENT_DB ?? 'trident-agora',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: 'input',
|
|
115
|
+
name: 'AUTOPR_TARGET_BRANCH',
|
|
116
|
+
message: 'AutoPR target branch:',
|
|
117
|
+
default: existing.AUTOPR_TARGET_BRANCH ?? '15.0-dev',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'input',
|
|
121
|
+
name: 'IMPORTEXPORT_URL',
|
|
122
|
+
message: 'ImportExport URL:',
|
|
123
|
+
default:
|
|
124
|
+
existing.IMPORTEXPORT_URL ??
|
|
125
|
+
'https://sorgenia-test-02.symple.cloud/api/importexport/v1/',
|
|
126
|
+
},
|
|
127
|
+
]);
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
if (!answers.KC_PASSWORD && existing.KC_PASSWORD) {
|
|
130
|
+
answers.KC_PASSWORD = existing.KC_PASSWORD;
|
|
131
|
+
}
|
|
124
132
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
writeFileSync(
|
|
134
|
+
CONFIG_FILE,
|
|
135
|
+
Object.entries(answers)
|
|
136
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
137
|
+
.join('\n') + '\n'
|
|
138
|
+
);
|
|
139
|
+
console.log(`Config written to ${CONFIG_FILE}`);
|
|
132
140
|
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
writeFileSync(COMPLETION_SCRIPT, completion.generateCompletionCode());
|
|
142
|
+
console.log(`Completion script written to ${COMPLETION_SCRIPT}`);
|
|
135
143
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const rcFile = path.join(process.env.HOME || '', '.bashrc');
|
|
145
|
+
const sourceLine = `source ${COMPLETION_SCRIPT}`;
|
|
146
|
+
const rcContent = existsSync(rcFile) ? readFileSync(rcFile, 'utf-8') : '';
|
|
147
|
+
if (!rcContent.includes(sourceLine)) {
|
|
148
|
+
appendFileSync(rcFile, `\n# prbot completion\n${sourceLine}\n`);
|
|
149
|
+
console.log(`Registered completion in ${rcFile} — run: source ~/.bashrc`);
|
|
150
|
+
} else {
|
|
151
|
+
console.log('Completion already registered in ~/.bashrc');
|
|
152
|
+
}
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
export { init };
|
package/src/commands/pr.js
CHANGED
|
@@ -1,124 +1,98 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from
|
|
3
|
-
import path from
|
|
4
|
-
import
|
|
5
|
-
import { resolveAddonsPath } from
|
|
6
|
-
|
|
7
|
-
async function getToken() {
|
|
8
|
-
const url = process.env.KC_URL;
|
|
9
|
-
const payload = new URLSearchParams();
|
|
10
|
-
|
|
11
|
-
payload.append("username", process.env.KC_USER);
|
|
12
|
-
payload.append("password", process.env.KC_PASSWORD);
|
|
13
|
-
payload.append("client_id", process.env.KC_ID);
|
|
14
|
-
payload.append("client_secret", process.env.KC_SECRET);
|
|
15
|
-
payload.append("grant_type", "password");
|
|
16
|
-
|
|
17
|
-
const response = await fetch(url, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
headers: {
|
|
20
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
21
|
-
},
|
|
22
|
-
body: payload.toString(),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const json = await response.json();
|
|
26
|
-
return json.access_token;
|
|
27
|
-
}
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
import { resolveAddonsPath } from '../lib/addons.js';
|
|
6
|
+
import { getToken } from '../lib/auth.js';
|
|
28
7
|
|
|
29
8
|
async function getFiles(module_name, token) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
const url = `${process.env.RIP_URL}/ir.model/xml_prbot`;
|
|
10
|
+
const body = JSON.stringify({ module_name });
|
|
11
|
+
const headers = {
|
|
12
|
+
Authorization: `Bearer ${token}`,
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const response = await fetch(url, { method: 'POST', body, headers });
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(await response.text());
|
|
19
|
+
}
|
|
20
|
+
return await response.json();
|
|
42
21
|
}
|
|
43
22
|
|
|
44
23
|
async function main(module_name) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
24
|
+
const token = await getToken();
|
|
25
|
+
const files = await getFiles(module_name, token);
|
|
26
|
+
|
|
27
|
+
let ADDONS_PATH = resolveAddonsPath(process.env.ADDONS_PATH);
|
|
28
|
+
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
const buffer = Buffer.from(file.data, 'base64');
|
|
31
|
+
let content = buffer.toString();
|
|
32
|
+
const lines = content.split('\n');
|
|
33
|
+
|
|
34
|
+
const odooCloseIndex = lines.findIndex((l) => l.trim() === '</odoo>');
|
|
35
|
+
if (odooCloseIndex !== -1 && odooCloseIndex < lines.length - 1) {
|
|
36
|
+
const footer = lines.slice(odooCloseIndex + 1).join('\n');
|
|
37
|
+
const skippedMatch = footer.match(/Skipped records:\s*(\d+)/);
|
|
38
|
+
if (skippedMatch && parseInt(skippedMatch[1]) > 0) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`[${file.name}] Export contains skipped records:\n${footer.trim()}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const duplicatedMatch = footer.match(/Duplicated records:\s*(\d+)/);
|
|
44
|
+
if (duplicatedMatch && parseInt(duplicatedMatch[1]) > 0) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`[${file.name}] Export contains duplicated records:\n${footer.trim()}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (lines.length > 2) {
|
|
52
|
+
lines.splice(-2);
|
|
53
|
+
}
|
|
54
|
+
content = lines.join('\n');
|
|
55
|
+
content = content.replace(
|
|
56
|
+
/<field name="bpmn_diagram"><!\[CDATA\[[\s\S]*?\]\]><\/field>/g,
|
|
57
|
+
''
|
|
62
58
|
);
|
|
63
|
-
}
|
|
64
|
-
const duplicatedMatch = footer.match(/Duplicated records:\s*(\d+)/);
|
|
65
|
-
if (duplicatedMatch && parseInt(duplicatedMatch[1]) > 0) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`[${file.name}] Export contains duplicated records:\n${footer.trim()}`,
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"",
|
|
79
|
-
);
|
|
60
|
+
let destPath;
|
|
61
|
+
if (file.name.includes('Relazioni mancanti')) {
|
|
62
|
+
destPath = `${ADDONS_PATH}/config/${module_name}/data/workflow_missing_relations.xml`;
|
|
63
|
+
} else {
|
|
64
|
+
destPath = `${ADDONS_PATH}/config/${module_name}/data/workflow_configuration.xml`;
|
|
65
|
+
}
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} else {
|
|
85
|
-
destPath = `${ADDONS_PATH}/config/${module_name}/data/workflow_configuration.xml`;
|
|
67
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
68
|
+
await fs.writeFile(destPath, content);
|
|
69
|
+
console.log(`Processed: ${file.name} -> ${destPath}`);
|
|
86
70
|
}
|
|
87
71
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
const workflowDir = path.join(ADDONS_PATH, 'config', module_name, 'data');
|
|
73
|
+
const filesToAdd = [
|
|
74
|
+
path.join(workflowDir, 'workflow_missing_relations.xml'),
|
|
75
|
+
path.join(workflowDir, 'workflow_configuration.xml'),
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
for (const filePath of filesToAdd) {
|
|
79
|
+
await new Promise((resolve, reject) => {
|
|
80
|
+
execFile('git', ['add', filePath], { cwd: ADDONS_PATH }, (error) => {
|
|
81
|
+
if (error) reject(error);
|
|
82
|
+
else resolve();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
98
86
|
|
|
99
|
-
|
|
87
|
+
const commitMessage = `[IMP][${module_name}] Update workflow`;
|
|
100
88
|
await new Promise((resolve, reject) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
execFile('git', ['commit', '-m', commitMessage], { cwd: ADDONS_PATH }, (error) => {
|
|
90
|
+
if (error) reject(error);
|
|
91
|
+
else resolve();
|
|
92
|
+
});
|
|
105
93
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const commitMessage = `[IMP][${module_name}] Update workflow`;
|
|
109
|
-
await new Promise((resolve, reject) => {
|
|
110
|
-
execFile(
|
|
111
|
-
"git",
|
|
112
|
-
["commit", "-m", commitMessage],
|
|
113
|
-
{ cwd: ADDONS_PATH },
|
|
114
|
-
(error) => {
|
|
115
|
-
if (error) reject(error);
|
|
116
|
-
else resolve();
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
94
|
|
|
121
|
-
|
|
95
|
+
console.log(`Committed with message: ${commitMessage}`);
|
|
122
96
|
}
|
|
123
97
|
|
|
124
98
|
export { main };
|
package/src/commands/ver.js
CHANGED
|
@@ -1,83 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { resolveAddonsPath } from
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { resolveAddonsPath } from '../lib/addons.js';
|
|
5
5
|
|
|
6
6
|
async function verbot(module_name, level) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!['major', 'minor', 'patch'].includes(level)) {
|
|
8
|
+
throw new Error('Level must be one of major, minor, patch');
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
let ADDONS_PATH = resolveAddonsPath(process.env.ADDONS_PATH);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
await fs.access(manifestPath);
|
|
16
|
-
} catch {
|
|
17
|
-
manifestPath = path.join(
|
|
18
|
-
ADDONS_PATH,
|
|
19
|
-
"config",
|
|
20
|
-
module_name,
|
|
21
|
-
"__manifest__.py",
|
|
22
|
-
);
|
|
13
|
+
let manifestPath = path.join(ADDONS_PATH, module_name, '__manifest__.py');
|
|
23
14
|
try {
|
|
24
|
-
|
|
15
|
+
await fs.access(manifestPath);
|
|
25
16
|
} catch {
|
|
26
|
-
|
|
17
|
+
manifestPath = path.join(ADDONS_PATH, 'config', module_name, '__manifest__.py');
|
|
18
|
+
try {
|
|
19
|
+
await fs.access(manifestPath);
|
|
20
|
+
} catch {
|
|
21
|
+
throw new Error(`__manifest__.py not found for module ${module_name}`);
|
|
22
|
+
}
|
|
27
23
|
}
|
|
28
|
-
}
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
26
|
+
const versionMatch = content.match(/"version":\s*"(15\.0\.\d+\.\d+\.\d+)"/);
|
|
27
|
+
if (!versionMatch) {
|
|
28
|
+
throw new Error('Version not found in manifest');
|
|
29
|
+
}
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
const currentVersion = versionMatch[1];
|
|
32
|
+
const parts = currentVersion.split('.');
|
|
33
|
+
const base = `${parts[0]}.${parts[1]}`;
|
|
34
|
+
const major = parseInt(parts[2]);
|
|
35
|
+
const minor = parseInt(parts[3]);
|
|
36
|
+
const patch = parseInt(parts[4]);
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
let newVersion;
|
|
39
|
+
if (level === 'patch') {
|
|
40
|
+
newVersion = `${base}.${major}.${minor}.${patch + 1}`;
|
|
41
|
+
} else if (level === 'minor') {
|
|
42
|
+
newVersion = `${base}.${major}.${minor + 1}.0`;
|
|
43
|
+
} else if (level === 'major') {
|
|
44
|
+
newVersion = `${base}.${major + 1}.0.0`;
|
|
45
|
+
}
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
const newContent = content.replace(
|
|
48
|
+
`"version": "${currentVersion}"`,
|
|
49
|
+
`"version": "${newVersion}"`
|
|
50
|
+
);
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
await fs.writeFile(manifestPath, newContent);
|
|
53
|
+
console.log(`Updated version: ${currentVersion} -> ${newVersion}`);
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
await new Promise((resolve, reject) => {
|
|
56
|
+
execFile('git', ['add', manifestPath], { cwd: ADDONS_PATH }, (error) => {
|
|
57
|
+
if (error) reject(error);
|
|
58
|
+
else resolve();
|
|
59
|
+
});
|
|
64
60
|
});
|
|
65
|
-
});
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (error) reject(error);
|
|
75
|
-
else resolve();
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
});
|
|
62
|
+
const commitMessage = `[VER][${module_name}] Bump`;
|
|
63
|
+
await new Promise((resolve, reject) => {
|
|
64
|
+
execFile('git', ['commit', '-m', commitMessage], { cwd: ADDONS_PATH }, (error) => {
|
|
65
|
+
if (error) reject(error);
|
|
66
|
+
else resolve();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
79
69
|
|
|
80
|
-
|
|
70
|
+
console.log(`Committed with message: ${commitMessage}`);
|
|
81
71
|
}
|
|
82
72
|
|
|
83
73
|
export { verbot };
|
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 };
|