@waron97/prbot 3.0.0 → 3.0.2

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 CHANGED
@@ -190,3 +190,82 @@ Reinstalls the latest published version from npm.
190
190
  prbot update
191
191
  ```
192
192
 
193
+ ---
194
+
195
+ ## agrippa
196
+
197
+ Syncs Odoo workflow phase Python code and MFA records between the local filesystem and the RIP API. Tracks changes via checksums and detects conflicts before overwriting.
198
+
199
+ Credentials are inherited from the global prbot config (`~/.config/prbot/config`). Override per-workspace in `agrippa.yaml`.
200
+
201
+ ### `agrippa init`
202
+
203
+ Creates `agrippa.yaml` in the current directory. Always writes `pyproject.toml` with the standard ruff builtins. Optionally writes `pyrightconfig.json` and copies type stubs into `typings/`.
204
+
205
+ ```bash
206
+ agrippa init
207
+ ```
208
+
209
+ ### `agrippa clone`
210
+
211
+ Clones all `from_code` phases for a selected workflow, or a single MFA, into the workspace. Writes files to disk and registers them in `agrippa.yaml`.
212
+
213
+ ```bash
214
+ agrippa clone
215
+ agrippa clone --phase
216
+ agrippa clone --mfa
217
+ agrippa clone --phase --id 123 --path my-workflow/
218
+ ```
219
+
220
+ Options:
221
+
222
+ | Flag | Description |
223
+ | --------------- | -------------------------------------------------------- |
224
+ | `--phase` | Clone a phase (select a workflow) |
225
+ | `--mfa` | Clone an MFA record |
226
+ | `--id <id>` | Skip selection, clone by ID |
227
+ | `--path <path>` | Destination path (base dir for phases, file path for MFA)|
228
+
229
+ ### `agrippa pull`
230
+
231
+ Fetches remote code for all tracked entries and shows what changed. Classifies each as `fast-forward` (safe overwrite) or `conflict` (local edits would be lost). Lets you select which to pull.
232
+
233
+ After pulling, also checks tracked workflows for newly added `from_code` phases and auto-clones any not yet present locally.
234
+
235
+ ```bash
236
+ agrippa pull
237
+ ```
238
+
239
+ ### `agrippa push`
240
+
241
+ Pushes local file changes back to RIP. Backs up current remote code to `.backup/<timestamp>/` before overwriting. Same conflict detection as pull, with the concern inverted.
242
+
243
+ ```bash
244
+ agrippa push
245
+ ```
246
+
247
+ ### `agrippa diff [path]`
248
+
249
+ Shows a diff between local files and remote code. Optionally filter to a specific file path.
250
+
251
+ ```bash
252
+ agrippa diff
253
+ agrippa diff my-workflow/some-phase.py
254
+ ```
255
+
256
+ ### `agrippa init-phase`
257
+
258
+ Selects a workflow and any phase, then pushes a default code scaffold to that phase on RIP. Sets `set_result_automatically` to `from_code`, generates result variable constants from the phase's allowed results, and creates the corresponding `result.code.configurator` records.
259
+
260
+ ```bash
261
+ agrippa init-phase
262
+ ```
263
+
264
+ ### `agrippa repair`
265
+
266
+ Removes entries from `agrippa.yaml` whose local files no longer exist on disk.
267
+
268
+ ```bash
269
+ agrippa repair
270
+ ```
271
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waron97/prbot",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@ function escapeXml(str) {
55
55
  function generateXml(templates) {
56
56
  const records = templates
57
57
  .map((t) => {
58
- const id = toXmlId(t.name);
58
+ const id = `mail_template_${toXmlId(t.template_code)}`;
59
59
  const modelRef = Object.values(t.model_id)[0];
60
60
  return ` <record id="${id}" model="mail.template">
61
61
  <field name="name">${escapeXml(t.name)}</field>
@@ -93,28 +93,41 @@ async function exportEmailTemplates(opts) {
93
93
  const token = await getToken();
94
94
 
95
95
  const moduleChoices = await getModuleChoices();
96
- const module = await search({
97
- message: 'Select module:',
98
- source: async (input) => {
99
- if (!input) return moduleChoices;
100
- return moduleChoices.filter((c) => fuzzyMatch(c.name, input));
101
- },
102
- });
96
+ const moduleMatch = opts.module ? moduleChoices.find((c) => c.name === opts.module) : null;
97
+ const module = moduleMatch
98
+ ? moduleMatch.value
99
+ : await search({
100
+ message: 'Select module:',
101
+ source: async (input) => {
102
+ if (!input) return moduleChoices;
103
+ return moduleChoices.filter((c) => fuzzyMatch(c.name, input));
104
+ },
105
+ });
103
106
 
104
107
  console.log('Fetching workflows...');
105
108
  const workflows = await getWorkflows(token);
106
109
  const choices = workflows.map((w) => ({ name: w.name, value: w.id }));
107
110
 
108
- const workflowId = await search({
109
- message: 'Select workflow:',
110
- source: async (input) => {
111
- if (!input) return choices;
112
- return choices.filter((c) => fuzzyMatch(c.name, input));
113
- },
114
- });
111
+ const workflowMatch = opts.workflow
112
+ ? workflows.find((w) => w.name === opts.workflow || String(w.id) === opts.workflow)
113
+ : null;
114
+ const workflowId = workflowMatch
115
+ ? workflowMatch.id
116
+ : await search({
117
+ message: 'Select workflow:',
118
+ source: async (input) => {
119
+ if (!input) return choices;
120
+ return choices.filter((c) => fuzzyMatch(c.name, input));
121
+ },
122
+ });
115
123
 
116
124
  console.log(`Fetching email templates for workflow ${workflowId}...`);
117
- const templates = await getEmailTemplates(workflowId, token);
125
+ const excludes = opts.exclude ?? [];
126
+ const templates = (await getEmailTemplates(workflowId, token))
127
+ .filter((t) => t.template_code)
128
+ .filter((t) => {
129
+ return !excludes.some((ex) => ex === String(t.id) || ex === t.name || ex === t.template_code);
130
+ });
118
131
 
119
132
  if (!templates.length) {
120
133
  console.log('No email templates found for this workflow.');
@@ -125,7 +138,7 @@ async function exportEmailTemplates(opts) {
125
138
  const dataDir = path.join(ADDONS_PATH, 'config', module, 'data');
126
139
  await fs.mkdir(dataDir, { recursive: true });
127
140
 
128
- const outPath = path.join(dataDir, 'mail_templates.xml');
141
+ const outPath = path.join(dataDir, 'mail_template.xml');
129
142
  await fs.writeFile(outPath, generateXml(templates), 'utf-8');
130
143
  console.log(`Written: ${outPath}`);
131
144
 
package/src/index.js CHANGED
@@ -112,6 +112,9 @@ exportCmd
112
112
  exportCmd
113
113
  .command('email-templates')
114
114
  .option('--no-commit')
115
+ .option('-e, --exclude <value...>', 'exclude templates matching id, name, or template_code')
116
+ .option('-m, --module <name>', 'module directory name (skip prompt)')
117
+ .option('-w, --workflow <value>', 'workflow name or id (skip prompt)')
115
118
  .action((opts) => {
116
119
  exportEmailTemplates(opts).catch((err) => {
117
120
  throw err;