@wpmoo/odoo 0.8.32 → 0.8.34
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 +26 -1
- package/dist/args.js +10 -1
- package/dist/cli.js +6 -0
- package/dist/daily-actions.js +123 -0
- package/dist/help.js +11 -0
- package/package.json +14 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
[](https://github.com/wpmoo-org/wpmoo-odoo/actions/workflows/ci.yml) [](LICENSE)
|
|
5
|
+
[](https://github.com/wpmoo-org/wpmoo-odoo/actions/workflows/ci.yml) [](LICENSE) [](https://www.buymeacoffee.com/cangir)
|
|
6
6
|
|
|
7
7
|
WPMoo Odoo lifecycle tooling for development, staging, and production workflows.
|
|
8
8
|
|
|
@@ -177,6 +177,22 @@ Refresh generated environment files without deleting module source code:
|
|
|
177
177
|
npx @wpmoo/odoo reset
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
Run daily local development actions from a generated environment root:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx @wpmoo/odoo logs odoo
|
|
184
|
+
npx @wpmoo/odoo restart
|
|
185
|
+
npx @wpmoo/odoo shell
|
|
186
|
+
npx @wpmoo/odoo psql devel
|
|
187
|
+
npx @wpmoo/odoo install sale devel
|
|
188
|
+
npx @wpmoo/odoo update sale devel
|
|
189
|
+
npx @wpmoo/odoo test sale --db devel --mode update --tags /sale
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Daily actions require `.wpmoo/odoo.json` in the current directory and delegate to
|
|
193
|
+
fixed scripts under `./scripts`; they do not search parent directories or accept
|
|
194
|
+
arbitrary script names.
|
|
195
|
+
|
|
180
196
|
## Defaults
|
|
181
197
|
|
|
182
198
|
Each source repo can contain one or many Odoo modules. For example:
|
|
@@ -227,3 +243,12 @@ tool-owned development guideline files.
|
|
|
227
243
|
`--create-missing-repos` is provided, or through the interactive wizard.
|
|
228
244
|
- Legacy `--org`, `--community-repo`, and `--pro-repo` flags are still accepted
|
|
229
245
|
when no `--source-repo-url` flags are provided.
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
## Support
|
|
249
|
+
|
|
250
|
+
If this project helps you, you can support the work here:
|
|
251
|
+
|
|
252
|
+
<a href="https://www.buymeacoffee.com/cangir">
|
|
253
|
+
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me a Coffee" width="250">
|
|
254
|
+
</a>
|
package/dist/args.js
CHANGED
|
@@ -2,9 +2,18 @@ import { basename, resolve } from 'node:path';
|
|
|
2
2
|
import { supportedOdooVersions } from './odoo-versions.js';
|
|
3
3
|
import { defaultAgentSkillsTemplateUrl, defaultComposeTemplateUrl } from './external-templates.js';
|
|
4
4
|
import { defaultCommunityAddons, defaultProAddons } from './templates.js';
|
|
5
|
+
import { dailyActionCommands } from './daily-actions.js';
|
|
5
6
|
import { validateAddonName, validateRepoPath } from './path-validation.js';
|
|
6
7
|
import { inferGitHubOwner, inferRepoPath, normalizeRepositoryUrl } from './repo-url.js';
|
|
7
|
-
const commandNames = new Set([
|
|
8
|
+
const commandNames = new Set([
|
|
9
|
+
'create',
|
|
10
|
+
'add-repo',
|
|
11
|
+
'remove-repo',
|
|
12
|
+
'add-module',
|
|
13
|
+
'remove-module',
|
|
14
|
+
'reset',
|
|
15
|
+
...dailyActionCommands,
|
|
16
|
+
]);
|
|
8
17
|
const internalFlags = new Set(['--no-update-check']);
|
|
9
18
|
export function isUpdateCheckFlag(arg) {
|
|
10
19
|
return internalFlags.has(arg);
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { commandFromArgs, defaultTargetForProduct, isHelpRequested, isVersionReq
|
|
|
5
5
|
import { detectDevelopmentEnvironment } from './environment.js';
|
|
6
6
|
import { commandOdooVersion } from './environment-version.js';
|
|
7
7
|
import { defaultAgentSkillsTemplateUrl } from './external-templates.js';
|
|
8
|
+
import { isDailyActionCommand, runDailyAction } from './daily-actions.js';
|
|
8
9
|
import { getOriginUrl, realGit } from './git.js';
|
|
9
10
|
import { renderHelp } from './help.js';
|
|
10
11
|
import { addModuleToSourceRepo, listModulesInSourceRepo, removeModuleFromSourceRepo, } from './module-actions.js';
|
|
@@ -675,6 +676,11 @@ async function main() {
|
|
|
675
676
|
outro(`Safe reset refreshed generated environment files in ${options.target}.`);
|
|
676
677
|
return;
|
|
677
678
|
}
|
|
679
|
+
if (isDailyActionCommand(route.command)) {
|
|
680
|
+
console.log(renderBanner());
|
|
681
|
+
await runDailyAction(route.command, route.argv);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
678
684
|
const options = optionsFromArgs(route.argv);
|
|
679
685
|
if (options) {
|
|
680
686
|
console.log(renderBanner());
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { access } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { markerPath } from './environment.js';
|
|
5
|
+
export const dailyActionCommands = ['logs', 'restart', 'shell', 'psql', 'install', 'update', 'test'];
|
|
6
|
+
const dailyActionCommandSet = new Set(dailyActionCommands);
|
|
7
|
+
const scripts = {
|
|
8
|
+
logs: 'logs.sh',
|
|
9
|
+
restart: 'restart.sh',
|
|
10
|
+
shell: 'shell.sh',
|
|
11
|
+
psql: 'psql.sh',
|
|
12
|
+
install: 'install.sh',
|
|
13
|
+
update: 'update.sh',
|
|
14
|
+
test: 'test.sh',
|
|
15
|
+
};
|
|
16
|
+
export function isDailyActionCommand(command) {
|
|
17
|
+
return dailyActionCommandSet.has(command);
|
|
18
|
+
}
|
|
19
|
+
function usage(command) {
|
|
20
|
+
if (command === 'logs')
|
|
21
|
+
return 'Usage: wpmoo logs [service]';
|
|
22
|
+
if (command === 'restart')
|
|
23
|
+
return 'Usage: wpmoo restart';
|
|
24
|
+
if (command === 'shell')
|
|
25
|
+
return 'Usage: wpmoo shell';
|
|
26
|
+
if (command === 'psql')
|
|
27
|
+
return 'Usage: wpmoo psql [db]';
|
|
28
|
+
if (command === 'install')
|
|
29
|
+
return 'Usage: wpmoo install <module[,module]> [db]';
|
|
30
|
+
if (command === 'update')
|
|
31
|
+
return 'Usage: wpmoo update <module[,module]> [db]';
|
|
32
|
+
return 'Usage: wpmoo test <module[,module]> [--db <db>] [--mode init|update] [--tags <tags>]';
|
|
33
|
+
}
|
|
34
|
+
function ensureNoArgs(command, argv) {
|
|
35
|
+
if (argv.length > 0)
|
|
36
|
+
throw new Error(usage(command));
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
function optionalSingleArg(command, argv, fallback) {
|
|
40
|
+
if (argv.length > 1)
|
|
41
|
+
throw new Error(usage(command));
|
|
42
|
+
return [argv[0] ?? fallback];
|
|
43
|
+
}
|
|
44
|
+
function moduleArgs(command, argv) {
|
|
45
|
+
const [modules, db, ...rest] = argv;
|
|
46
|
+
if (!modules || modules.startsWith('-') || rest.length > 0)
|
|
47
|
+
throw new Error(usage(command));
|
|
48
|
+
return db ? [modules, db] : [modules];
|
|
49
|
+
}
|
|
50
|
+
function testArgs(argv) {
|
|
51
|
+
const [modules, ...rest] = argv;
|
|
52
|
+
if (!modules || modules.startsWith('-'))
|
|
53
|
+
throw new Error(usage('test'));
|
|
54
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
55
|
+
const option = rest[index];
|
|
56
|
+
if (!['--db', '--mode', '--tags'].includes(option))
|
|
57
|
+
throw new Error(`Unknown option for wpmoo test: ${option}`);
|
|
58
|
+
const value = rest[index + 1];
|
|
59
|
+
if (!value || value.startsWith('--'))
|
|
60
|
+
throw new Error(`Missing value for ${option}`);
|
|
61
|
+
if (option === '--mode' && value !== 'init' && value !== 'update') {
|
|
62
|
+
throw new Error('Invalid value for --mode: expected init or update');
|
|
63
|
+
}
|
|
64
|
+
index += 1;
|
|
65
|
+
}
|
|
66
|
+
return argv;
|
|
67
|
+
}
|
|
68
|
+
function scriptArgs(command, argv) {
|
|
69
|
+
if (command === 'logs')
|
|
70
|
+
return optionalSingleArg(command, argv, 'odoo');
|
|
71
|
+
if (command === 'restart')
|
|
72
|
+
return ensureNoArgs(command, argv);
|
|
73
|
+
if (command === 'shell')
|
|
74
|
+
return ensureNoArgs(command, argv);
|
|
75
|
+
if (command === 'psql')
|
|
76
|
+
return optionalSingleArg(command, argv, 'postgres');
|
|
77
|
+
if (command === 'install' || command === 'update')
|
|
78
|
+
return moduleArgs(command, argv);
|
|
79
|
+
return testArgs(argv);
|
|
80
|
+
}
|
|
81
|
+
async function assertEnvironmentRoot(cwd) {
|
|
82
|
+
try {
|
|
83
|
+
await access(join(cwd, markerPath));
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
throw new Error('Daily actions must be run from a WPMoo Odoo environment root containing .wpmoo/odoo.json.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function assertScriptExists(cwd, script) {
|
|
90
|
+
const scriptPath = join(cwd, 'scripts', script);
|
|
91
|
+
try {
|
|
92
|
+
await access(scriptPath);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new Error(`Missing daily action script: scripts/${script}`);
|
|
96
|
+
}
|
|
97
|
+
return scriptPath;
|
|
98
|
+
}
|
|
99
|
+
export async function dailyActionPlan(command, argv, cwd = process.cwd()) {
|
|
100
|
+
await assertEnvironmentRoot(cwd);
|
|
101
|
+
const scriptPath = await assertScriptExists(cwd, scripts[command]);
|
|
102
|
+
return {
|
|
103
|
+
cwd,
|
|
104
|
+
scriptPath,
|
|
105
|
+
args: scriptArgs(command, argv),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function spawnDailyAction(plan) {
|
|
109
|
+
const child = spawn(plan.scriptPath, plan.args, {
|
|
110
|
+
cwd: plan.cwd,
|
|
111
|
+
stdio: 'inherit',
|
|
112
|
+
});
|
|
113
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
114
|
+
child.on('error', reject);
|
|
115
|
+
child.on('close', resolve);
|
|
116
|
+
});
|
|
117
|
+
if (exitCode !== 0) {
|
|
118
|
+
throw new Error(`Daily action script exited with code ${exitCode ?? 'unknown'}: ${plan.scriptPath}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export async function runDailyAction(command, argv, cwd = process.cwd(), runner = spawnDailyAction) {
|
|
122
|
+
await runner(await dailyActionPlan(command, argv, cwd));
|
|
123
|
+
}
|
package/dist/help.js
CHANGED
|
@@ -11,6 +11,13 @@ Usage:
|
|
|
11
11
|
npx @wpmoo/odoo add-module --repo <source-repo> --module <module-name>
|
|
12
12
|
npx @wpmoo/odoo remove-module --repo <source-repo> --module <module-name>
|
|
13
13
|
npx @wpmoo/odoo reset
|
|
14
|
+
npx @wpmoo/odoo logs [service]
|
|
15
|
+
npx @wpmoo/odoo restart
|
|
16
|
+
npx @wpmoo/odoo shell
|
|
17
|
+
npx @wpmoo/odoo psql [db]
|
|
18
|
+
npx @wpmoo/odoo install <module[,module]> [db]
|
|
19
|
+
npx @wpmoo/odoo update <module[,module]> [db]
|
|
20
|
+
npx @wpmoo/odoo test <module[,module]> [--db <db>] [--mode init|update] [--tags <tags>]
|
|
14
21
|
|
|
15
22
|
Options:
|
|
16
23
|
--product <slug> Product slug, for example my_odoo_module.
|
|
@@ -45,6 +52,10 @@ Options:
|
|
|
45
52
|
--version, -v Show the package version.
|
|
46
53
|
--help, -h Show this help.
|
|
47
54
|
|
|
55
|
+
Daily actions:
|
|
56
|
+
Daily actions must be run from a generated environment root containing .wpmoo/odoo.json.
|
|
57
|
+
They delegate to the fixed scripts copied from the compose resource under ./scripts.
|
|
58
|
+
|
|
48
59
|
Example:
|
|
49
60
|
npx @wpmoo/odoo create \\
|
|
50
61
|
--product odoo_sample_module \\
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wpmoo/odoo",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.34",
|
|
4
4
|
"description": "WPMoo Odoo lifecycle tooling for development, staging, and production workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
"url": "https://github.com/wpmoo-org/wpmoo-odoo/issues"
|
|
13
13
|
},
|
|
14
14
|
"readmeFilename": "README.md",
|
|
15
|
+
"fundingUrl": "https://buymeacoffee.com/cangir",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"odoo",
|
|
18
|
+
"odoo development",
|
|
19
|
+
"odoo cli",
|
|
20
|
+
"odoo lifecycle",
|
|
21
|
+
"odoo dev workflow",
|
|
22
|
+
"odoo staging workflow",
|
|
23
|
+
"odoo production workflow",
|
|
24
|
+
"odoo docker",
|
|
25
|
+
"odoo docker compose",
|
|
26
|
+
"odoo skills"
|
|
27
|
+
],
|
|
15
28
|
"bin": {
|
|
16
29
|
"wpmoo": "dist/cli.js"
|
|
17
30
|
},
|