@wpmoo/toolkit 0.9.14 → 0.9.15
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/dist/module-actions.js +12 -3
- package/package.json +1 -1
package/dist/module-actions.js
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { addModuleToSourceRepoInAddonsYaml, removeModuleFromSourceRepoInAddonsYaml, } from './addons-yaml.js';
|
|
4
4
|
import { readEnvironmentMetadata, replaceSourceRepos } from './environment.js';
|
|
5
5
|
import { realGit, stageAll } from './git.js';
|
|
6
|
+
import { supportedOdooVersions } from './odoo-versions.js';
|
|
6
7
|
import { pathUnderBase, validateModuleName, validateRepoPath } from './path-validation.js';
|
|
7
8
|
import { listModuleRepos, readAddonsYaml, writeAddonsYaml } from './repo-actions.js';
|
|
8
9
|
import { listSources } from './source-actions.js';
|
|
@@ -29,6 +30,13 @@ function deriveRepoSlug(repoUrl) {
|
|
|
29
30
|
function normalizeSourceType(value) {
|
|
30
31
|
return validSourceTypes.includes(value) ? value : 'private';
|
|
31
32
|
}
|
|
33
|
+
function validateSupportedOdooVersion(value) {
|
|
34
|
+
const normalized = value.trim();
|
|
35
|
+
if (supportedOdooVersions.includes(normalized)) {
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Unsupported Odoo version for generated module scaffolding: ${value}. Supported versions: ${supportedOdooVersions.join(', ')}.`);
|
|
39
|
+
}
|
|
32
40
|
function sourceRepoPath(target, sourceType, repoPath) {
|
|
33
41
|
return pathUnderBase(join(target, `odoo/custom/src/${sourceType}`), repoPath, 'repo path');
|
|
34
42
|
}
|
|
@@ -228,6 +236,7 @@ async function updateModuleRegistration(target, sourceType, repoPath, moduleName
|
|
|
228
236
|
export async function addModuleToSourceRepo(options, git = realGit) {
|
|
229
237
|
const repoPath = validateRepoPath(options.repoPath);
|
|
230
238
|
const moduleName = validateModuleName(options.moduleName);
|
|
239
|
+
const odooVersion = validateSupportedOdooVersion(options.odooVersion);
|
|
231
240
|
const sourceType = normalizeSourceType(options.sourceType);
|
|
232
241
|
const destination = modulePath(options.target, sourceType, repoPath, moduleName);
|
|
233
242
|
await mkdir(join(destination, 'models'), { recursive: true });
|
|
@@ -235,14 +244,14 @@ export async function addModuleToSourceRepo(options, git = realGit) {
|
|
|
235
244
|
await mkdir(join(destination, 'tests'), { recursive: true });
|
|
236
245
|
await mkdir(join(destination, 'views'), { recursive: true });
|
|
237
246
|
await writeIfMissing(join(destination, '__init__.py'), 'from . import models\n');
|
|
238
|
-
await writeIfMissing(join(destination, '__manifest__.py'), manifestContent(moduleName,
|
|
247
|
+
await writeIfMissing(join(destination, '__manifest__.py'), manifestContent(moduleName, odooVersion));
|
|
239
248
|
await writeIfMissing(join(destination, 'models/__init__.py'), `from . import ${moduleName}\n`);
|
|
240
249
|
await writeIfMissing(join(destination, `models/${moduleName}.py`), modelContent(moduleName));
|
|
241
250
|
await writeIfMissing(join(destination, 'tests/__init__.py'), testInitContent(moduleName));
|
|
242
251
|
await writeIfMissing(join(destination, `tests/test_${moduleName}.py`), testContent(moduleName));
|
|
243
252
|
await writeIfMissing(join(destination, 'security/ir.model.access.csv'), accessCsvContent(moduleName));
|
|
244
|
-
await writeIfMissing(join(destination, `views/${moduleName}_views.xml`), viewXmlContent(moduleName,
|
|
245
|
-
await writeIfMissing(join(destination, `views/${moduleName}_menus.xml`), menuXmlContent(moduleName,
|
|
253
|
+
await writeIfMissing(join(destination, `views/${moduleName}_views.xml`), viewXmlContent(moduleName, odooVersion));
|
|
254
|
+
await writeIfMissing(join(destination, `views/${moduleName}_menus.xml`), menuXmlContent(moduleName, odooVersion));
|
|
246
255
|
await writeIfMissing(join(destination, 'views/.gitkeep'), '');
|
|
247
256
|
if (sourceType === 'private' && (await usesAddonsYaml(options.target))) {
|
|
248
257
|
const addonsYaml = await readAddonsYaml(options.target);
|