Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .prettierignore

This file was deleted.

9 changes: 9 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"plugins": [
"https://github.com/speakeasy-api/dprint-plugin-java/releases/download/v0.5.0/dprint_plugin_java.wasm",
"https://plugins.dprint.dev/typescript-0.95.15.wasm",
"https://plugins.dprint.dev/json-0.21.1.wasm"
],
"excludes": ["**/.yarn/releases/**", ".github/**", "**/fixtures/expected"],
"java": { "formatJavadoc": true }
}
14 changes: 5 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// @ts-check
import { defineConfig } from "eslint/config";
import eslintReact from "@eslint-react/eslint-plugin";
import { includeIgnoreFile } from "@eslint/compat";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import path from "node:path";
import globals from "globals";
import eslintReact from "@eslint-react/eslint-plugin";
import pluginCypress from "eslint-plugin-cypress";
import { defineConfig } from "eslint/config";
import globals from "globals";
import path from "node:path";
import tseslint from "typescript-eslint";

export default defineConfig(
{
languageOptions: {
globals: { ...globals.browser, ...globals.jest, ...globals.node },
},
},

// JS/TS recommended
eslint.configs.recommended,
{ files: ["**/*.ts", "**/*.tsx"], extends: tseslint.configs.recommended },

// React
eslintReact.configs["recommended-typescript"],
{
Expand All @@ -27,7 +25,6 @@ export default defineConfig(
"@eslint-react/dom/no-dangerously-set-innerhtml": "off",
},
},

// Cypress
pluginCypress.configs.recommended,
{
Expand All @@ -37,7 +34,6 @@ export default defineConfig(
"@typescript-eslint/no-unused-expressions": "off",
},
},

// Ignore the same files as .gitignore
includeIgnoreFile(path.resolve(import.meta.dirname, ".gitignore")),
{ ignores: ["**/fixtures/expected/**"] },
Expand Down
2 changes: 1 addition & 1 deletion jahia-test-module/javascript/head-script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
console.log("Executing head script...");
document.addEventListener("DOMContentLoaded", function () {
document.addEventListener("DOMContentLoaded", function() {
var newDiv = document.createElement("div");
newDiv.id = "testHeadElement";
document.body.appendChild(newDiv);
Expand Down
2 changes: 1 addition & 1 deletion jahia-test-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "tsc --noEmit && vite build && run pack",
"clean": "rm -rf dist/",
"deploy": "jahia-deploy",
"format": "prettier --write --list-different .",
"format": "dprint fmt",
"pack": "yarn pack --out dist/package.tgz"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default function SampleRenderInBrowserReact({ path }: { path: string }) {
Able to display current node path: <span data-testid="path">{path}</span>
</p>
<p>
And refreshing date every 2 sec:{" "}
<span data-testid="date">{currentDate.toLocaleString()}</span>
And refreshing date every 2 sec: <span data-testid="date">{currentDate.toLocaleString()}</span>
</p>
<p>
Countdown: <span data-testid="counter">{counter}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jahiaComponent(
displayName: "Default event template",
componentType: "template",
},

(_, { currentResource }) => {
return (
<html lang="en">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AddResources, Render, Area, jahiaComponent } from "@jahia/javascript-modules-library";
import { AddResources, Area, jahiaComponent, Render } from "@jahia/javascript-modules-library";
import { footer, header, login } from "./pageComponents";

jahiaComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jahiaComponent(
/>
</div>

<h2>Non editable area </h2>
<h2>Non editable area</h2>
<div data-testid="nonEditableArea">
<AbsoluteArea name="nonEditable" parent={currentNode} readOnly />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jahiaComponent(
<Area name={"basicArea/subLevel"} />
</div>

<h2>Non editable area </h2>
<h2>Non editable area</h2>
<div data-testid="nonEditableArea">
<Area name="nonEditable" readOnly />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jahiaComponent(
<p data-testid="allConfigPIDs">allConfigPIDs={server.config.getConfigPids()}</p>

<h3>OSGi Config Complex Values</h3>
{Object.keys(complexObject).map(function (key) {
{Object.keys(complexObject).map(function(key) {
return (
<div data-testid={`complexObject_${key}`} key={key}>
{key}: {complexObject[key]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jahiaComponent(
},
(_, { currentNode }) => {
const result = useGQLQuery({
query:
"query ($path:String!) { jcr { nodeByPath(path:$path) { name, properties { name, value } } } }",
query: "query ($path:String!) { jcr { nodeByPath(path:$path) { name, properties { name, value } } } }",
variables: { path: currentNode.getPath() },
});
const resultFromDocument = useGQLQuery({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const PrintChildren = ({
<>
<h2>${title}</h2>
<div data-testid={`getChildNodes_${testid}`}>
{children &&
children.map(function (child, i) {
{children
&& children.map(function(child, i) {
return (
<div data-testid={`getChildNodes_${testid}_${i + 1}`} key={child.getPath()}>
{child.getPath()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jahiaComponent(
richText = false,
) => {
return (
values &&
values.map(function (value, i) {
values
&& values.map(function(value, i) {
if (richText) {
return (
<div
Expand All @@ -100,8 +100,8 @@ jahiaComponent(
};
const printMultiValuedRefsProp = (selector: string, values: JCRNodeWrapper[]) => {
return (
values &&
values.map(function (value, i) {
values
&& values.map(function(value, i) {
return (
<div key={value.getPath()} data-testid={`${selector}_${i + 1}`}>
{value.getPath()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const PrintQueryResults = ({
<>
<h2>${title}</h2>
<div data-testid={`getNodesByJCRQuery_${testid}`}>
{nodes &&
nodes.map(function (node, i) {
{nodes
&& nodes.map(function(node, i) {
return (
<div data-testid={`getNodesByJCRQuery_${testid}_${i + 1}`} key={node.getPath()}>
{node.getPath()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Island, jahiaComponent } from "@jahia/javascript-modules-library";
import SampleHydrateInBrowserReact from "$client/components/SampleHydrateInBrowserReact";
import SampleRenderInBrowserReact from "$client/components/SampleRenderInBrowserReact";
import { Island, jahiaComponent } from "@jahia/javascript-modules-library";

jahiaComponent(
{
Expand All @@ -11,7 +11,7 @@ jahiaComponent(
(_, { currentResource }) => {
return (
<>
<h2>Just a normal view, that is using a client side react component: </h2>
<h2>Just a normal view, that is using a client side react component:</h2>
<Island
component={SampleHydrateInBrowserReact}
props={{ initialValue: 9, set: new Set(["a", "b", "c"]) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jahiaComponent(
<div data-testid="react-render-editable-default">
<h3>Render generates editable items by default</h3>
<div className="childs">
{allChildren &&
allChildren.map(function (child) {
{allChildren
&& allChildren.map(function(child) {
return <Render path={child.getPath()} key={child.getIdentifier()} />;
})}
</div>
</div>
<div data-testid="react-render-editable">
<h3>Render generates editable items when precised true</h3>
<div className="childs">
{allChildren &&
allChildren.map(function (child) {
{allChildren
&& allChildren.map(function(child) {
return <Render path={child.getPath()} key={child.getIdentifier()} />;
})}
</div>
</div>
<div data-testid="react-render-not-editable">
<h3>Render generates non editable items when precised false</h3>
<div className="childs">
{allChildren &&
allChildren.map(function (child) {
{allChildren
&& allChildren.map(function(child) {
return <Render path={child.getPath()} readOnly key={child.getIdentifier()} />;
})}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// <reference types="vite/client" />
import {
jahiaComponent,
server,
buildEndpointUrl,
buildModuleFileUrl,
buildNodeUrl,
jahiaComponent,
server,
} from "@jahia/javascript-modules-library";
import goat from "./goat.png";

Expand Down
2 changes: 1 addition & 1 deletion jahia-test-module/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { defineConfig } from "vite";
import jahia from "@jahia/vite-plugin";
import path from "node:path";
import { defineConfig } from "vite";

export default defineConfig({
resolve: {
Expand Down
18 changes: 12 additions & 6 deletions javascript-create-module/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { styleText } from "node:util";
import pkg from "./package.json" with { type: "json" };

/** Renames the `dot` directory to dotfiles and dotdirs. */
const renameDot = (/** @type {string} */ name) =>
name.startsWith(`dot${path.sep}`) ? `.${name.slice(4)}` : name;
const renameDot = (/** @type {string} */ name) => name.startsWith(`dot${path.sep}`) ? `.${name.slice(4)}` : name;

try {
prompts.intro("Jahia JavaScript Module Creator");
Expand All @@ -31,8 +30,9 @@ Upgrade guide: ${styleText("underline", "https://nodejs.org/en/download")}
initialValue: process.argv[2],
validate(value) {
if (!/^[a-z]/.test(value)) return "Module name must start with a lowercase letter.";
if (!/^[a-z0-9-]+$/.test(value))
if (!/^[a-z0-9-]+$/.test(value)) {
return "Module name can only contain lowercase letters, numbers, and hyphens.";
}
},
});

Expand Down Expand Up @@ -116,9 +116,15 @@ Upgrade guide: ${styleText("underline", "https://nodejs.org/en/download")}

Run the following commands to get started:
${styleText("dim", "1.")} ${styleText("greenBright", `cd ${output}`)}
${styleText("dim", "2.")} ${styleText("cyanBright", "yarn install")} ${styleText("dim", "# Install dependencies")}
${styleText("dim", "3.")} ${styleText("blueBright", "docker compose up --wait")} ${styleText("dim", "# Start Jahia in Docker")}
${styleText("dim", "4.")} ${styleText("magentaBright", "yarn dev")} ${styleText("dim", "# Start the dev mode")}
${styleText("dim", "2.")} ${styleText("cyanBright", "yarn install")} ${
styleText("dim", "# Install dependencies")
}
${styleText("dim", "3.")} ${styleText("blueBright", "docker compose up --wait")} ${
styleText("dim", "# Start Jahia in Docker")
}
${styleText("dim", "4.")} ${styleText("magentaBright", "yarn dev")} ${
styleText("dim", "# Start the dev mode")
}

The ${styleText("underline", "README.md")} file contains a reminder of all commands.
`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import clsx from "clsx";
import { useEffect, useState } from "react";
import classes from "./styles.module.css";
import { useTranslation } from "react-i18next";
import classes from "./styles.module.css";

export default function () {
export default function() {
const [confetti, setConfetti] = useState<typeof import("canvas-confetti")>();

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Island,
RenderChildren,
buildModuleFileUrl,
jahiaComponent,
} from "@jahia/javascript-modules-library";
import { buildModuleFileUrl, Island, jahiaComponent, RenderChildren } from "@jahia/javascript-modules-library";
import { Trans, useTranslation } from "react-i18next";
import down from "./arrows/down.svg";
import left from "./arrows/left.svg";
Expand Down
11 changes: 4 additions & 7 deletions javascript-create-module/templates/module/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
// @ts-check
import { defineConfig } from "eslint/config";
import eslintReact from "@eslint-react/eslint-plugin";
import { includeIgnoreFile } from "@eslint/compat";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import path from "node:path";
import { defineConfig } from "eslint/config";
import globals from "globals";
import eslintReact from "@eslint-react/eslint-plugin";
import path from "node:path";
import tseslint from "typescript-eslint";

export default defineConfig(
{
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
},

// JS/TS recommended
eslint.configs.recommended,
{ files: ["**/*.ts", "**/*.tsx"], extends: tseslint.configs.recommended },

// React
eslintReact.configs["recommended-typescript"],

// Ignore the same files as .gitignore
includeIgnoreFile(path.resolve(import.meta.dirname, ".gitignore")),
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "vite";
import jahia from "@jahia/vite-plugin";
import { spawnSync } from "node:child_process";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
AddResources,
buildModuleFileUrl,
useServerContext,
} from "@jahia/javascript-modules-library";
import { AddResources, buildModuleFileUrl, useServerContext } from "@jahia/javascript-modules-library";
import type { ReactNode } from "react";

import "modern-normalize/modern-normalize.css";
Expand Down
Loading
Loading