Skip to content

Commit

Permalink
BACKLOG-23313 : rename MPM module to javascript module (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgriffon authored Jan 9, 2025
1 parent 656ed98 commit 7131fbc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ private void initialEngineCheckup() {
// check VM
String vmVendor = System.getProperty("java.vm.vendor", "Unknown");
if (!vmVendor.contains("GraalVM")) {
logger.warn("NPM Modules Engine requires GraalVM for production usage, detected {}.", vmVendor);
logger.warn("Javascript Modules Engine requires GraalVM for production usage, detected {}.", vmVendor);
return;
}

// Check if the 'js' extension is installed
try (Context context = Context.create()) {
if (!context.getEngine().getLanguages().containsKey(JS)) {
logger.error("NPM Modules Engine detected GraalVM, but the 'js' extension is not installed. You can install it by running: gu install js");
logger.error("Javascript Modules Engine detected GraalVM, but the 'js' extension is not installed. You can install it by running: gu install js");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private Properties generateInstructions(Map<String, Object> properties, Map<Stri
instructions.put("Bundle-Category", jahiaProps.getOrDefault("category", "jahia-npm-module"));
setIfPresent(properties, "description", instructions, "Bundle-Description");
String name = (String) properties.get("name");
instructions.put("Bundle-Name", name + " (npm module)");
instructions.put("Bundle-Name", name + " (javascript module)");
instructions.put("Bundle-SymbolicName", name.replace("@", "")
.replace('/', '-')
.replaceAll("[^a-zA-Z0-9\\-\\.\\s]", "_"));
Expand Down
2 changes: 1 addition & 1 deletion javascript-modules-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<artifactId>javascript-modules-engine</artifactId>
<name>Javascript Modules Engine</name>
<packaging>bundle</packaging>
<description>This is the engine allowing NPM modules to run on a Jahia server.</description>
<description>This is the engine allowing Javascript modules to run on a Jahia server.</description>

<properties>
<jahia-module-signature>MCwCFBJEmGCjTLucq4kjFZXIUdgIa5iXAhRog+SngNKsG41US2+divtyEQpSEQ==</jahia-module-signature>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {JContent, JContentPageBuilder} from '@jahia/jcontent-cypress/dist/page-object/jcontent';
import {addNode, Collapsible, getComponentBySelector, publishAndWaitJobEnding} from '@jahia/cypress';
import {addSimplePage} from '../../utils/Utils';
describe('Check that NPM module settings (UI extensions, rules, configs) are correctly deployed', () => {
describe('Check that Javascript module settings (UI extensions, rules, configs) are correctly deployed', () => {
before('Create test page and contents', () => {
addSimplePage('/sites/npmTestSite/home', 'testModuleSettings', 'testModuleSettings', 'en', 'simple', [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Check that the NPM module has been transformed properly and has the proper header values',
describe('Check that the Javascript module has been transformed properly and has the proper header values',
() => {
it('Check the transformed module headers', () => {
cy.executeGroovy('groovy/getBundleHeaders.groovy', {BUNDLE_SYMBOLIC_NAME: 'jahia-npm-module-example', BUNDLE_VERSION: '1.0.0'})
Expand All @@ -8,7 +8,7 @@ describe('Check that the NPM module has been transformed properly and has the pr
expect(result).to.contain('Bundle-Description: Jahia NPM Test module');
expect(result).to.contain('Jahia-GroupId: org.example.modules.npm');
expect(result).to.contain('Bundle-License: MIT');
expect(result).to.contain('Bundle-Name: @jahia/npm-module-example (npm module)');
expect(result).to.contain('Bundle-Name: @jahia/npm-module-example (javascript module)');
expect(result).to.contain('Bundle-SymbolicName: jahia-npm-module-example');
expect(result).to.contain('Bundle-Vendor: Jahia Solutions Group SA');
expect(result).to.contain('Bundle-Version: 1.0.0');
Expand Down
32 changes: 16 additions & 16 deletions javascript-modules-engine/tests/jahia-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<img src="https://www.jahia.com/modules/jahiacom-templates/images/jahia-3x.png" alt="Jahia logo" title="Jahia" align="right" height="60" />
</a>

NPM Plugin Module Example
Javascript Module Example
======================

<p align="center">A NPM-style modules example</p>
<p align="center">A Javascript-style modules example</p>

<p align="left">This modules provide an example of a NPM-styled module.
<p align="left">This modules provide an example of a Javascript-styled module.
It must be run inside a GraalVM environment in order to support Javascript language.
NPM modules can contain templates, definitions, filter, and other jahia extensions.
Javascript modules can contain templates, definitions, filter, and other jahia extensions.
</p>

## Table of content
Expand All @@ -31,8 +31,8 @@ NPM modules can contain templates, definitions, filter, and other jahia extensio
- [Deploying via API](#deploying-via-api)
- [Deploying via Script InstallBundle](#deploying-via-script-installbundle)
- [Deploying via Fileinstall](#deploying-via-fileinstall)
- [Activating NPM Module](#activating-npm-module)
- [Creating new NPM modules](#creating-new-npm-modules)
- [Activating Javascript Module](#activating-javascript-module)
- [Creating new Javascript modules](#creating-new-javascript-modules)
- [Views](#views)


Expand All @@ -43,7 +43,7 @@ NPM modules can contain templates, definitions, filter, and other jahia extensio

## Jahia Snapshot Environtment

In order to run npm-modules at Jahia, we need to start an environment with GraalVM running.
In order to run javascript modules at Jahia, we need to start an environment with GraalVM running.
Run the command below to start the jahia image with docker (please note that you have to be logged in to be able to pull this image)

```shell
Expand All @@ -64,15 +64,15 @@ Build the module using:
yarn build
```

Packing the module (It will generate jahia-npm-module-example-v1.0.0.tgz in the root of you project) :
Packing the module (It will generate jahia-javascript-module-example-v1.0.0.tgz in the root of you project) :
```shell
yarn pack
```

## Module deployment

NPM modules can be installed in different ways being the most indicated via Module management UI
Below are all the possible ways to install a npm module:
Javascript modules can be installed in different ways being the most indicated via Module management UI
Below are all the possible ways to install a javascript module:


### Deploying via Module management UI
Expand All @@ -89,7 +89,7 @@ In Administration - Modules
- Ensure you replace the X's in the version number of the bundle with the version number of the `.tgz` file that was created

```shell
curl -s --user root:root1234 --form bundle=@jahia-npm-module-example-vX.X.X.tgz --form start=true http://localhost:8080/modules/api/bundles
curl -s --user root:root1234 --form bundle=@jahia-javascript-module-example-vX.X.X.tgz --form start=true http://localhost:8080/modules/api/bundles
```

### Deploying via Script InstallBundle
Expand All @@ -115,17 +115,17 @@ yarn deploy
docker cp *.tgz jahia-dev:/var/jahia/modules
```

## Activating NPM Module
## Activating Javascript Module

In order to test the views and templates created we need to create a site with this npm module as in the example below:
In order to test the views and templates created we need to create a site with this javascript module as in the example below:

<img width="1518" alt="Screenshot 2021-05-18 at 09 24 09" src="https://user-images.githubusercontent.com/729255/118614476-16429c00-b7c0-11eb-9821-b582dfcf8768.png">

## NPM plugin example content
## Javascript plugin example content

NPM modules must be packaged with `npm pack` and must contain a `package.json` file, containing all package information.
Javascript modules must be packaged with `npm pack` and must contain a `package.json` file, containing all package information.
In addition to standard mandatory fields, the `package.json` file must contain a `jahia` section with a `server` entry. This entry points to the initialization script of the module, which will be responsible of registering the extensions.
You can specify the module type here (by default, it will be `module`). Our NPM example is a templates set, so it needs to define `"module-type": "templatesSet"`.
You can specify the module type here (by default, it will be `module`). Our Javascript example is a templates set, so it needs to define `"module-type": "templatesSet"`.

```json
{
Expand Down
4 changes: 2 additions & 2 deletions javascript-modules-library/typedoc-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Javascript Library for NPM Javascript Module Engine

## Introduction

You will find here all the types exposed by the javascript-modules-library library, to be used in Jahia NPM Modules
You will find here all the types exposed by the javascript-modules-library library, to be used in Jahia Javascript Modules

## Jahia Academy

You can find more documentation about NPM modules, how to get started and more on the [Jahia Academy](https://academy.jahia.com).
You can find more documentation about Javascript modules, how to get started and more on the [Jahia Academy](https://academy.jahia.com).

0 comments on commit 7131fbc

Please sign in to comment.