@waron97/prbot 2.3.0 → 2.5.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/README.md +61 -0
- package/package.json +1 -1
- package/src/commands/autopr.js +2 -1
- package/src/commands/changelog.js +2 -5
- package/src/commands/commit.js +139 -90
- package/src/commands/export.js +2 -1
- package/src/commands/exportImperex.js +97 -0
- package/src/commands/exportPb.js +2 -2
- package/src/index.js +23 -1
- package/src/lib/fuzzy.js +13 -0
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ source ~/.bashrc
|
|
|
42
42
|
| `DEVOPS_PROJECT` | Azure DevOps project |
|
|
43
43
|
| `DEVOPS_REPO` | Azure DevOps repository name |
|
|
44
44
|
| `AUTOPR_TARGET_BRANCH` | Target branch for auto-created PRs (default: `15.0-dev`) |
|
|
45
|
+
| `IMPORTEXPORT_URL` | ImportExport API base URL |
|
|
45
46
|
|
|
46
47
|
## Commands
|
|
47
48
|
|
|
@@ -115,10 +116,70 @@ Options:
|
|
|
115
116
|
| `-b, --branch <name>` | Branch name (default: `autopr_<first-task-id>` or `autopr_<first-jira>`) |
|
|
116
117
|
| `-n, --name <text>` | PR title (default: Trident task name) |
|
|
117
118
|
|
|
119
|
+
### `prbot commit`
|
|
120
|
+
|
|
121
|
+
Interactive commit builder. Prompts for operation type (`[IMP]`, `[FIX]`, etc.), and a message. The destinatin module will be automatically detected. If nothing is staged, shows unstaged files and lets you select which to stage first. Previews the final commit message before confirming.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
prbot commit
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `prbot export workflow <module>`
|
|
128
|
+
|
|
129
|
+
Alias for `prbot pr <module>`. Fetches workflow XML and commits.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
prbot export workflow config_wf_contestazione
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
|
|
137
|
+
| Flag | Description |
|
|
138
|
+
| -------------------- | ------------------------------------------------------------------------- |
|
|
139
|
+
| `-b, --bump <level>` | Also bump manifest version after commit. Level: `major`, `minor`, `patch` |
|
|
140
|
+
|
|
141
|
+
### `prbot export pb`
|
|
142
|
+
|
|
143
|
+
Exports a Process Builder process from the ImportExport API and writes the ZIP to `ADDONS_PATH/.cloudbuild/pb/B2WA/processes/`. Updates the file in place if it already exists, otherwise writes to the `all/` subdirectory. Prompts to select the process via fuzzy search.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
prbot export pb
|
|
147
|
+
prbot export pb --no-commit
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
|
|
152
|
+
| Flag | Description |
|
|
153
|
+
| ------------- | ------------------------ |
|
|
154
|
+
| `--no-commit` | Skip the git commit step |
|
|
155
|
+
|
|
156
|
+
### `prbot export imperex`
|
|
157
|
+
|
|
158
|
+
Exports a single Imperex record from Odoo via RIP and writes the resulting YAML into `ADDONS_PATH/sorgenia_imperex_metadata/migrations/0.0.0/imperex/<model>/`. Prompts first for the model (from local folder names), then for the record (fetched from API). Both prompts support fuzzy search.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
prbot export imperex
|
|
162
|
+
prbot export imperex --no-commit
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Options:
|
|
166
|
+
|
|
167
|
+
| Flag | Description |
|
|
168
|
+
| ------------- | ------------------------ |
|
|
169
|
+
| `--no-commit` | Skip the git commit step |
|
|
170
|
+
|
|
118
171
|
### `prbot init`
|
|
119
172
|
|
|
120
173
|
Interactive setup: writes `~/.config/prbot/config` and installs shell completion.
|
|
121
174
|
|
|
175
|
+
### `prbot update`
|
|
176
|
+
|
|
177
|
+
Reinstalls the latest published version from npm.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
prbot update
|
|
181
|
+
```
|
|
182
|
+
|
|
122
183
|
## Tab completion
|
|
123
184
|
|
|
124
185
|
After `prbot init` and sourcing `~/.bashrc`, `<module>` arguments autocomplete from directories in `ADDONS_PATH/config/`.
|
package/package.json
CHANGED
package/src/commands/autopr.js
CHANGED
|
@@ -4,6 +4,7 @@ import search from '@inquirer/search';
|
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import fetch from 'node-fetch';
|
|
6
6
|
import { resolveAddonsPath } from '../lib/addons.js';
|
|
7
|
+
import { fuzzyMatch } from '../lib/fuzzy.js';
|
|
7
8
|
import { execGit } from '../lib/git.js';
|
|
8
9
|
import {
|
|
9
10
|
appendPrToLine,
|
|
@@ -176,7 +177,7 @@ async function selectSection(sections, candidates) {
|
|
|
176
177
|
message: 'Select changelog section:',
|
|
177
178
|
source: async (input) => {
|
|
178
179
|
if (!input) return allChoices;
|
|
179
|
-
return allChoices.filter((c) => c.value
|
|
180
|
+
return allChoices.filter((c) => fuzzyMatch(c.value, input));
|
|
180
181
|
},
|
|
181
182
|
});
|
|
182
183
|
return sections.find((s) => s.heading === selected);
|
|
@@ -3,6 +3,7 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import search from '@inquirer/search';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import { resolveAddonsPath } from '../lib/addons.js';
|
|
6
|
+
import { fuzzyMatch } from '../lib/fuzzy.js';
|
|
6
7
|
|
|
7
8
|
function buildRefString(tridents, jiras, prNumber) {
|
|
8
9
|
const refs = [];
|
|
@@ -159,11 +160,7 @@ async function changelog(prNumber, options) {
|
|
|
159
160
|
return sectionChoices;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
choice.name.toLowerCase().includes(input.toLowerCase())
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
return filtered;
|
|
163
|
+
return sectionChoices.filter((choice) => fuzzyMatch(choice.name, input));
|
|
167
164
|
},
|
|
168
165
|
});
|
|
169
166
|
|
package/src/commands/commit.js
CHANGED
|
@@ -13,133 +13,182 @@ const commitOperations = [
|
|
|
13
13
|
},
|
|
14
14
|
{ name: `📖 DOC ${chalk.gray('- Documentation changes')}`, value: '[DOC]' },
|
|
15
15
|
{ name: `🩹 FIX ${chalk.gray('- Bugfix or hotfix')}`, value: '[FIX]' },
|
|
16
|
-
{ name: `🛠️
|
|
16
|
+
{ name: `🛠️ IMP ${chalk.gray('- Improvement of existing code')}`, value: '[IMP]' },
|
|
17
17
|
{ name: `💬 I18N ${chalk.gray('- Translation changes')}`, value: '[I18N]' },
|
|
18
18
|
{ name: `📦 MIG ${chalk.gray('- Module migration')}`, value: '[MIG]' },
|
|
19
19
|
{ name: `🔄 REF ${chalk.gray('- Code refactoring')}`, value: '[REF]' },
|
|
20
20
|
{ name: `🎉 REL ${chalk.gray('- Release commit')}`, value: '[REL]' },
|
|
21
|
-
{ name: `🗑️
|
|
22
|
-
{ name: `✏️
|
|
21
|
+
{ name: `🗑️ REM ${chalk.gray('- Removing unnecessary files')}`, value: '[REM]' },
|
|
22
|
+
{ name: `✏️ REN ${chalk.gray('- Renaming files/variables/models/etc.')}`, value: '[REN]' },
|
|
23
23
|
{ name: `🔙 REV ${chalk.gray('- Revert of an existing commit')}`, value: '[REV]' },
|
|
24
24
|
{ name: `🧳 SUB ${chalk.gray('- Submodule adding/updating')}`, value: '[SUB]' },
|
|
25
|
-
{ name: `#️⃣
|
|
25
|
+
{ name: `#️⃣ VER ${chalk.gray('- Versioning')}`, value: '[VER]' },
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{ name: '📋 Module', value: 'module' },
|
|
31
|
-
{ name: '👤 Wizard', value: 'wizard' },
|
|
32
|
-
{ name: '⚙️ Symphony Process', value: 'symphony' },
|
|
33
|
-
];
|
|
28
|
+
function getModuleFromFile(file) {
|
|
29
|
+
const parts = file.split('/');
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if (parts[0] === 'config') {
|
|
32
|
+
return parts[1];
|
|
33
|
+
}
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
if (parts[0] === '.cloudbuild') {
|
|
36
|
+
const allIndex = parts.indexOf('all');
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
if (allIndex !== -1) {
|
|
39
|
+
return parts.slice(0, allIndex + 1).join('/');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return parts[0];
|
|
44
|
+
}
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
function validateSameModule(files) {
|
|
47
|
+
const modules = files.map(getModuleFromFile);
|
|
48
|
+
const currentModule = `[${modules[0]}]`;
|
|
49
|
+
|
|
50
|
+
const allSameModule = modules.every((module) => `[${module}]` === currentModule);
|
|
51
|
+
|
|
52
|
+
if (!allSameModule) {
|
|
53
|
+
console.log(chalk.red('Selected files are not of the same module'));
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return currentModule;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function getFilesToCommit(stagedChanges, unstagedChanges) {
|
|
61
|
+
if (stagedChanges.trim()) {
|
|
62
|
+
console.log(chalk.green('Staged changes:'));
|
|
63
|
+
console.log(stagedChanges);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
filesToCheck: stagedChanges.trim().split('\n'),
|
|
67
|
+
filesToStage: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const unstagedFiles = unstagedChanges.trim().split('\n');
|
|
72
|
+
|
|
73
|
+
while (true) {
|
|
44
74
|
console.log(chalk.yellow('No staged changes found.'));
|
|
45
75
|
console.log(chalk.yellow('Unstaged changes:'));
|
|
46
76
|
console.log(unstagedChanges);
|
|
47
77
|
|
|
48
|
-
|
|
78
|
+
const answers = await inquirer.prompt([
|
|
49
79
|
{
|
|
50
80
|
message: 'Select unstaged files to stage for commit:',
|
|
51
81
|
type: 'checkbox',
|
|
52
82
|
name: 'filesToStage',
|
|
53
|
-
choices:
|
|
54
|
-
.trim()
|
|
55
|
-
.split('\n')
|
|
56
|
-
.map((file) => file),
|
|
83
|
+
choices: unstagedFiles,
|
|
57
84
|
},
|
|
58
85
|
]);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
|
|
87
|
+
const currentModule = validateSameModule(answers.filesToStage);
|
|
88
|
+
|
|
89
|
+
if (currentModule) {
|
|
90
|
+
return {
|
|
91
|
+
filesToCheck: answers.filesToStage,
|
|
92
|
+
filesToStage: answers.filesToStage,
|
|
93
|
+
currentModule,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
62
96
|
}
|
|
97
|
+
}
|
|
63
98
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
async function commit() {
|
|
100
|
+
const ADDONS_PATH = resolveAddonsPath(process.env.ADDONS_PATH);
|
|
101
|
+
|
|
102
|
+
while (true) {
|
|
103
|
+
const unstagedChanges = await execGit(['diff', '--name-only'], ADDONS_PATH);
|
|
104
|
+
const stagedChanges = await execGit(['diff', '--cached', '--name-only'], ADDONS_PATH);
|
|
105
|
+
|
|
106
|
+
if (!unstagedChanges.trim() && !stagedChanges.trim()) {
|
|
107
|
+
console.log(chalk.red('No changes found to commit.'));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const {
|
|
112
|
+
filesToCheck,
|
|
113
|
+
filesToStage,
|
|
114
|
+
currentModule: selectedModule,
|
|
115
|
+
} = await getFilesToCommit(stagedChanges, unstagedChanges);
|
|
116
|
+
|
|
117
|
+
if (filesToCheck.length === 0) {
|
|
118
|
+
console.log(chalk.red('No files selected.'));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let currentModule = selectedModule || validateSameModule(filesToCheck);
|
|
123
|
+
|
|
124
|
+
if (!currentModule) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const answers = await inquirer.prompt([
|
|
129
|
+
{
|
|
130
|
+
type: 'search-list',
|
|
131
|
+
message: 'Select an operation:',
|
|
132
|
+
name: 'commitOperation',
|
|
133
|
+
choices: commitOperations,
|
|
84
134
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
135
|
+
{
|
|
136
|
+
type: 'input',
|
|
137
|
+
message: 'Please enter your message:',
|
|
138
|
+
name: 'commitMessage',
|
|
139
|
+
filter: (input) => input.trim(),
|
|
140
|
+
when(answers) {
|
|
141
|
+
return answers.commitOperation !== '[DOC]';
|
|
142
|
+
},
|
|
89
143
|
},
|
|
90
|
-
|
|
91
|
-
let value = input.trim();
|
|
144
|
+
]);
|
|
92
145
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
146
|
+
if (answers.commitOperation === '[DOC]') {
|
|
147
|
+
currentModule = '[CHANGELOG]';
|
|
148
|
+
answers.commitMessage = 'Changelog';
|
|
149
|
+
}
|
|
96
150
|
|
|
97
|
-
|
|
98
|
-
value = `${value}]`;
|
|
99
|
-
}
|
|
151
|
+
const commitMessage = `${answers.commitOperation}${currentModule} ${answers.commitMessage}`;
|
|
100
152
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
message: 'Please enter your message:',
|
|
107
|
-
name: 'commitMessage',
|
|
108
|
-
filter: (input) => input.trim(),
|
|
109
|
-
when(answers) {
|
|
110
|
-
return answers.commitOperation !== '[DOC]';
|
|
153
|
+
const finalPrompt = await inquirer.prompt([
|
|
154
|
+
{
|
|
155
|
+
type: 'confirm',
|
|
156
|
+
message: `${chalk.red(commitMessage)}\nDo you want to proceed with this commit message?`,
|
|
157
|
+
name: 'confirmCommit',
|
|
111
158
|
},
|
|
112
|
-
|
|
113
|
-
]);
|
|
159
|
+
]);
|
|
114
160
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
161
|
+
if (!finalPrompt.confirmCommit) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
119
164
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
165
|
+
if (filesToStage.length > 0) {
|
|
166
|
+
await execGit(['add', ...filesToStage], ADDONS_PATH);
|
|
167
|
+
}
|
|
123
168
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
169
|
+
await execGit(['commit', '-m', commitMessage], ADDONS_PATH);
|
|
170
|
+
console.log(chalk.green('Commit created successfully!'));
|
|
127
171
|
|
|
128
|
-
|
|
172
|
+
const remainingUnstaged = await execGit(['diff', '--name-only'], ADDONS_PATH);
|
|
173
|
+
const remainingStaged = await execGit(['diff', '--cached', '--name-only'], ADDONS_PATH);
|
|
129
174
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
name: 'confirmCommit',
|
|
135
|
-
},
|
|
136
|
-
]);
|
|
175
|
+
if (!remainingUnstaged.trim() && !remainingStaged.trim()) {
|
|
176
|
+
console.log(chalk.green('No more changes to commit.'));
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
137
179
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
180
|
+
const { continueCommit } = await inquirer.prompt([
|
|
181
|
+
{
|
|
182
|
+
type: 'confirm',
|
|
183
|
+
name: 'continueCommit',
|
|
184
|
+
message: 'Do you want to create another commit?',
|
|
185
|
+
default: true,
|
|
186
|
+
},
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
if (!continueCommit) {
|
|
190
|
+
break;
|
|
141
191
|
}
|
|
142
|
-
await execGit(['commit', '-m', commitMessage], ADDONS_PATH);
|
|
143
192
|
}
|
|
144
193
|
}
|
|
145
194
|
|
package/src/commands/export.js
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fetch from 'node-fetch';
|
|
4
|
+
import search from '@inquirer/search';
|
|
5
|
+
import { getToken } from '../lib/auth.js';
|
|
6
|
+
import { execGit } from '../lib/git.js';
|
|
7
|
+
import { resolveAddonsPath } from '../lib/addons.js';
|
|
8
|
+
import { fuzzyMatch } from '../lib/fuzzy.js';
|
|
9
|
+
|
|
10
|
+
const IMPEREX_REL = 'sorgenia_imperex_metadata/migrations/0.0.0/imperex';
|
|
11
|
+
|
|
12
|
+
async function getModels(addonsPath) {
|
|
13
|
+
const dir = path.join(addonsPath, IMPEREX_REL);
|
|
14
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
15
|
+
return entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function listRecords(model, token) {
|
|
19
|
+
const url = `${process.env.RIP_URL}/helpdesk.ticket/prbot_list_records`;
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
23
|
+
body: JSON.stringify({ model }),
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) throw new Error(await response.text());
|
|
26
|
+
return await response.json();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function exportRecord(model, id, token) {
|
|
30
|
+
const url = `${process.env.RIP_URL}/helpdesk.ticket/prbot_imperex_export`;
|
|
31
|
+
const response = await fetch(url, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
export_to: 'yaml',
|
|
36
|
+
make_zip: true,
|
|
37
|
+
manifest: {},
|
|
38
|
+
recs: { [model]: [id] },
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) throw new Error(await response.text());
|
|
42
|
+
return await response.json();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function exportImperex(opts) {
|
|
46
|
+
const token = await getToken();
|
|
47
|
+
const ADDONS_PATH = resolveAddonsPath(process.env.ADDONS_PATH);
|
|
48
|
+
|
|
49
|
+
const models = await getModels(ADDONS_PATH);
|
|
50
|
+
const modelChoices = models.map((m) => ({ name: m, value: m }));
|
|
51
|
+
const model = await search({
|
|
52
|
+
message: 'Select Imperex model:',
|
|
53
|
+
source: async (input) => {
|
|
54
|
+
if (!input) return modelChoices;
|
|
55
|
+
return modelChoices.filter((c) => fuzzyMatch(c.name, input));
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
console.log(`Fetching records for ${model}...`);
|
|
60
|
+
const records = await listRecords(model, token);
|
|
61
|
+
const recChoices = records.map((r) => ({ name: String(r.name ?? r.id), value: r.id }));
|
|
62
|
+
const recordId = await search({
|
|
63
|
+
message: 'Select record to export:',
|
|
64
|
+
source: async (input) => {
|
|
65
|
+
if (!input) return recChoices;
|
|
66
|
+
return recChoices.filter((c) => fuzzyMatch(c.name, input));
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
console.log(`Exporting record ${recordId}...`);
|
|
71
|
+
const { attachments } = await exportRecord(model, recordId, token);
|
|
72
|
+
|
|
73
|
+
const modelDir = path.join(ADDONS_PATH, IMPEREX_REL, model);
|
|
74
|
+
await fs.mkdir(modelDir, { recursive: true });
|
|
75
|
+
|
|
76
|
+
const saved = [];
|
|
77
|
+
for (const att of attachments) {
|
|
78
|
+
if (att.name === '__manifest__.yaml') continue;
|
|
79
|
+
const destPath = path.join(modelDir, path.basename(att.name));
|
|
80
|
+
await fs.writeFile(destPath, att.content, 'utf-8');
|
|
81
|
+
console.log(`Written: ${destPath}`);
|
|
82
|
+
saved.push(destPath);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (opts.commit !== false) {
|
|
86
|
+
for (const p of saved) {
|
|
87
|
+
await execGit(['add', p], ADDONS_PATH);
|
|
88
|
+
}
|
|
89
|
+
await execGit(
|
|
90
|
+
['commit', '-m', `[IMP][sorgenia_imperex_metadata] update ${model} record`],
|
|
91
|
+
ADDONS_PATH,
|
|
92
|
+
);
|
|
93
|
+
console.log('Committed.');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { exportImperex };
|
package/src/commands/exportPb.js
CHANGED
|
@@ -5,6 +5,7 @@ import search from '@inquirer/search';
|
|
|
5
5
|
import { getToken } from '../lib/auth.js';
|
|
6
6
|
import { execGit } from '../lib/git.js';
|
|
7
7
|
import { resolveAddonsPath } from '../lib/addons.js';
|
|
8
|
+
import { fuzzyMatch } from '../lib/fuzzy.js';
|
|
8
9
|
|
|
9
10
|
async function getProcessList(token) {
|
|
10
11
|
const url = `${process.env.IMPORTEXPORT_URL}/object/process_builder?addLanguageParam=true`;
|
|
@@ -112,8 +113,7 @@ async function exportPb(opts) {
|
|
|
112
113
|
message: 'Select PB process to export:',
|
|
113
114
|
source: async (input) => {
|
|
114
115
|
if (!input) return choices;
|
|
115
|
-
|
|
116
|
-
return choices.filter((c) => c.name.toLowerCase().includes(q));
|
|
116
|
+
return choices.filter((c) => fuzzyMatch(c.name, input));
|
|
117
117
|
},
|
|
118
118
|
});
|
|
119
119
|
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readdirSync, readFileSync } from 'fs';
|
|
3
|
+
import { execFile } from 'child_process';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import { program } from 'commander';
|
|
5
6
|
import { configDotenv } from 'dotenv';
|
|
@@ -7,7 +8,7 @@ import omelette from 'omelette';
|
|
|
7
8
|
import { autopr } from './commands/autopr.js';
|
|
8
9
|
import { changelog } from './commands/changelog.js';
|
|
9
10
|
import { commit } from './commands/commit.js';
|
|
10
|
-
import { exportPb, exportRip } from './commands/export.js';
|
|
11
|
+
import { exportPb, exportRip, exportImperex } from './commands/export.js';
|
|
11
12
|
import { init } from './commands/init.js';
|
|
12
13
|
import { main as prMain } from './commands/pr.js';
|
|
13
14
|
import { verbot } from './commands/ver.js';
|
|
@@ -137,4 +138,25 @@ exportCmd
|
|
|
137
138
|
});
|
|
138
139
|
});
|
|
139
140
|
|
|
141
|
+
exportCmd
|
|
142
|
+
.command('imperex')
|
|
143
|
+
.option('--no-commit')
|
|
144
|
+
.action((opts) => {
|
|
145
|
+
exportImperex(opts).catch((err) => {
|
|
146
|
+
throw err;
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
program.command('update').action(() => {
|
|
151
|
+
console.log('Updating prbot...');
|
|
152
|
+
execFile('npm', ['i', '-g', '@waron97/prbot'], (error, stdout, stderr) => {
|
|
153
|
+
if (error) {
|
|
154
|
+
console.error(stderr || error.message);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
console.log(stdout);
|
|
158
|
+
console.log('Done.');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
140
162
|
program.parse();
|
package/src/lib/fuzzy.js
ADDED