Skip to content

Commit d974737

Browse files
feat: support for custom module name (#525)
1 parent 1bd2ae5 commit d974737

6 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎jahia-test-module/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"yarn": ">=4.0.0"
3535
},
3636
"jahia": {
37+
"name": "JS Modules Engine Test Module",
3738
"maven": {
3839
"groupId": "org.jahia.test",
3940
"distributionManagement": {

‎javascript-create-module/templates/hello-world/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"node": ">=22.0.0"
4949
},
5050
"jahia": {
51+
"name": "$MODULE",
5152
"snapshot": true,
5253
"module-dependencies": "default",
5354
"module-type": "templatesSet",

‎javascript-create-module/templates/module/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"node": ">=22.0.0"
4343
},
4444
"jahia": {
45+
"name": "$MODULE",
4546
"snapshot": true,
4647
"module-dependencies": "default",
4748
"module-type": "module",

‎javascript-create-module/templates/template-set/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"node": ">=22.0.0"
4646
},
4747
"jahia": {
48+
"name": "$MODULE",
4849
"snapshot": true,
4950
"module-dependencies": "default",
5051
"module-type": "templatesSet",

‎javascript-modules-engine-java/src/main/java/org/jahia/modules/javascript/modules/engine/jshandler/JavascriptProtocolConnection.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ private Properties generateInstructions(Map<String, Object> properties, Map<Stri
190190
// First let's setup Bundle headers
191191
instructions.put("Bundle-Category", jahiaProps.getOrDefault("category", "jahia-javascript-module"));
192192
setIfPresent(properties, "description", instructions, "Bundle-Description");
193-
String name = (String) properties.get("name");
193+
String name = StringUtils.defaultString((String) jahiaProps.get("name"), (String) properties.get("name"));
194194
instructions.put("Bundle-Name", name + " (javascript module)");
195-
instructions.put("Bundle-SymbolicName", name.replace("@", "")
196-
.replace('/', '-')
197-
.replaceAll("[^a-zA-Z0-9\\-\\.\\s]", "_"));
195+
instructions.put("Bundle-SymbolicName",
196+
((String) properties.get("name")).replace("@", "").replace('/', '-').replaceAll("[^a-zA-Z0-9\\-\\.\\s]", "_"));
198197
setIfPresent(properties, "author", instructions, "Bundle-Vendor");
199198
instructions.put("Bundle-Version", getBundleVersion(properties, jahiaProps));
200199
instructions.put("Implementation-Version", getImplementationVersion(properties, jahiaProps));

‎javascript-modules-engine/tests/cypress/e2e/module/moduleTransformationTest.cy.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@ describe("Check that the Javascript module has been transformed properly and has
55
}).then((result) => {
66
console.log(result);
77
expect(result).to.contain("Bundle-Category: jahia-javascript-module");
8-
expect(result).to.contain("Bundle-Description: Test module for Javascript Module Engine");
8+
expect(result).to.contain(
9+
"Bundle-Description: Test module for Javascript Module Engine"
10+
);
911
expect(result).to.contain("Jahia-GroupId: org.jahia.test");
1012
expect(result).to.contain("Bundle-License: MIT");
1113
expect(result).to.contain(
12-
"Bundle-Name: javascript-modules-engine-test-module (javascript module)",
14+
"Bundle-Name: JS Modules Engine Test Module (javascript module)"
15+
);
16+
expect(result).to.contain(
17+
"Bundle-SymbolicName: javascript-modules-engine-test-module"
1318
);
14-
expect(result).to.contain("Bundle-SymbolicName: javascript-modules-engine-test-module");
1519
expect(result).to.contain("Bundle-Vendor: Jahia Solutions Group SA");
1620
expect(result).to.contain("Bundle-Version: ");
1721
// TODO to enable once javascript-modules-engine >= 0.4.0 is included in jahia-pack
1822
// expect(result).to.contain('Jahia-Depends: default,legacy-default-components,javascript-modules-engine')
1923
expect(result).to.contain("Jahia-Module-Type: templatesSet");
20-
expect(result).to.contain("Jahia-javascript-InitScript: dist/server/index.js");
24+
expect(result).to.contain(
25+
"Jahia-javascript-InitScript: dist/server/index.js"
26+
);
2127
expect(result).to.contain("Jahia-Required-Version: 8.2.0.0-SNAPSHOT");
2228
expect(result).to.contain(
23-
"Jahia-Static-Resources: /css,/javascript,/icons,/dist/client,/static",
29+
"Jahia-Static-Resources: /css,/javascript,/icons,/dist/client,/static"
2430
);
2531
});
2632
});

0 commit comments

Comments
 (0)