@jahia/create-module 0.0.9 → 0.5.3

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.
Files changed (77) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -3
  3. package/babel.config.cjs +2 -5
  4. package/index.js +95 -87
  5. package/node/node +0 -0
  6. package/node/npm +65 -0
  7. package/node/npm.cmd +20 -0
  8. package/node/npx +65 -0
  9. package/node/npx.cmd +20 -0
  10. package/node/yarn/dist/LICENSE +26 -0
  11. package/node/yarn/dist/README.md +60 -0
  12. package/node/yarn/dist/bin/yarn +35 -0
  13. package/node/yarn/dist/bin/yarn.cmd +2 -0
  14. package/node/yarn/dist/bin/yarn.js +31 -0
  15. package/node/yarn/dist/bin/yarnpkg +2 -0
  16. package/node/yarn/dist/bin/yarnpkg.cmd +2 -0
  17. package/node/yarn/dist/lib/cli.js +154071 -0
  18. package/node/yarn/dist/lib/v8-compile-cache.js +351 -0
  19. package/node/yarn/dist/package.json +28 -0
  20. package/node/yarn/dist/preinstall.js +60 -0
  21. package/package.json +21 -24
  22. package/pom.xml +134 -0
  23. package/sync-version.js +16 -0
  24. package/template/README.md +19 -11
  25. package/template/dotgithub/workflows/build.yml +21 -0
  26. package/template/dotgitignore +3 -9
  27. package/template/dotidea/jsLinters/eslint.xml +6 -0
  28. package/template/dotidea/prettier.xml +7 -0
  29. package/template/dotprettierignore +1 -0
  30. package/template/dotvscode/settings.json +11 -0
  31. package/template/dotyarnrc.yml +1 -0
  32. package/template/eslint.config.js +25 -0
  33. package/template/package.json +41 -43
  34. package/template/prettier.config.js +9 -0
  35. package/template/settings/README.md +3 -1
  36. package/template/settings/import.xml +5 -1
  37. package/template/settings/locales/de.json +2 -2
  38. package/template/settings/locales/en.json +3 -3
  39. package/template/settings/locales/fr.json +2 -2
  40. package/template/src/client/index.jsx +1 -5
  41. package/template/src/server/templates/page/PageHome.tsx +43 -0
  42. package/template/src/server/views/simpleContent/SimpleContentDefault.tsx +16 -0
  43. package/template/static/css/styles.css +7 -7
  44. package/template/tsconfig.json +27 -0
  45. package/template/vite.config.mjs +33 -0
  46. package/tests/create-templatesSet-project.test.js +126 -113
  47. package/.eslintrc.cjs +0 -28
  48. package/.github/ISSUE_TEMPLATE/bug.yml +0 -45
  49. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  50. package/.github/ISSUE_TEMPLATE/epic.md +0 -26
  51. package/.github/ISSUE_TEMPLATE/other.md +0 -8
  52. package/.github/ISSUE_TEMPLATE/release.md +0 -64
  53. package/.github/ISSUE_TEMPLATE/spike.md +0 -19
  54. package/.github/ISSUE_TEMPLATE/story.md +0 -27
  55. package/.github/ISSUE_TEMPLATE/support.yml +0 -40
  56. package/.github/ISSUE_TEMPLATE/tech-day.md +0 -93
  57. package/.github/dependabot.yml +0 -15
  58. package/.github/release.yml +0 -24
  59. package/.github/workflows/delivery-issue-chores.yml +0 -12
  60. package/.github/workflows/on-code-change.yml +0 -50
  61. package/.github/workflows/publish-release.yml +0 -22
  62. package/.yarn/releases/yarn-4.6.0.cjs +0 -934
  63. package/.yarnrc.yml +0 -3
  64. package/template/.babelrc +0 -9
  65. package/template/.yarn/releases/yarn-4.3.1.cjs +0 -894
  66. package/template/.yarnrc.yml +0 -3
  67. package/template/doteslintrc.cjs +0 -30
  68. package/template/dotnpmignore +0 -10
  69. package/template/src/server/components/index.js +0 -1
  70. package/template/src/server/index.js +0 -6
  71. package/template/src/server/templates/index.js +0 -1
  72. package/template/src/server/templates/page/PageHome.jsx +0 -32
  73. package/template/src/server/templates/page/index.js +0 -1
  74. package/template/src/server/views/index.js +0 -1
  75. package/template/src/server/views/simpleContent/SimpleContentDefault.jsx +0 -19
  76. package/template/src/server/views/simpleContent/index.js +0 -1
  77. package/template/webpack.config.js +0 -225
@@ -1,6 +1,6 @@
1
1
  # $$MODULE_NAME$$
2
2
 
3
- A simple Jahia NPM module created using the NPM module starter project template
3
+ A simple Jahia Javascript module created using the Javascript module starter project template
4
4
 
5
5
  ## Configuration
6
6
 
@@ -10,22 +10,30 @@ If you don't use default configuration for the Docker container name or for Jahi
10
10
 
11
11
  You can find the documentation on how to use this module on the [Jahia Academy](https://academy.jahia.com/get-started/developers/templating) templating tutorial.
12
12
 
13
- ## Run
13
+ ## Prerequisites
14
14
 
15
- 1) Enable Corepack if needed :
15
+ Yarn is required to build the project.
16
16
 
17
- `enable corepack`
17
+ Please follow the instructions at [Node.js Downloads](https://nodejs.org/en/download) to install Node.js and Yarn. In the dropdown menus, make sure to select Yarn (the _with_) and your operating system (the _for_).
18
18
 
19
- 2) Install the dependencies :
19
+ Note: If you are using a Windows machine, you need to run your `yarn` commands in PowerShell (not cmd.exe!). It comes preinstalled on modern Windows versions. In case this is not the case on your machine, [please see Microsoft documentation](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5).
20
20
 
21
- ``yarn``
21
+ ## Development
22
22
 
23
- 3) Build and run the project :
23
+ 1. To compile and package the project:
24
24
 
25
- ``yarn watch``
25
+ ```
26
+ yarn build
27
+ ```
26
28
 
27
- ## How to upgrade yarn version to latest stable
29
+ 2. To deploy the generated package to your Jahia instance (configured in your [`.env`](.env)):
28
30
 
29
- This command will upgrade yarn to the latest stable release and update the yarn installer in .yarn/releases
31
+ ```
32
+ yarn deploy
33
+ ```
30
34
 
31
- ``yarn set version stable``
35
+ 3. Alternatively, to deploy during development using watch mode:
36
+
37
+ ```
38
+ yarn watch
39
+ ```
@@ -0,0 +1,21 @@
1
+ name: Build
2
+ on: [push]
3
+ jobs:
4
+ build-and-pack:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v4
8
+ - name: Set Node.js 22.x
9
+ uses: actions/setup-node@v4
10
+ with:
11
+ node-version: 22.x
12
+ - run: corepack enable
13
+ - name: Install dependencies
14
+ run: yarn install
15
+ - name: Bundle package
16
+ run: yarn build
17
+ - name: Upload package.tgz
18
+ uses: actions/upload-artifact@v4
19
+ with:
20
+ name: package.tgz
21
+ path: dist/package.tgz
@@ -1,5 +1,7 @@
1
1
  # Intellij
2
2
  .idea
3
+ !.idea/jsLinters/**
4
+ !.idea/prettier.xml
3
5
  *.iml
4
6
  *.ipr
5
7
 
@@ -8,14 +10,6 @@ dist
8
10
  node_modules
9
11
 
10
12
  #Yarn
11
- .yarn/*
12
- !.yarn/cache
13
- !.yarn/patches
14
- !.yarn/plugins
15
- !.yarn/releases
16
- !.yarn/sdks
17
- !.yarn/versions
13
+ .yarn
18
14
  yarn-error.log
19
15
 
20
- # generated .tgz file
21
- $$MODULE_NAME$$-*.tgz
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myConfigurationMode" value="AUTOMATIC" />
5
+ <option name="myRunOnSave" value="true" />
6
+ </component>
7
+ </project>
@@ -0,0 +1 @@
1
+ # This file inherits .gitignore, there is no need to copy its content here
@@ -0,0 +1,11 @@
1
+ {
2
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
3
+ "editor.formatOnSave": true,
4
+ "eslint.validate": [
5
+ "javascript",
6
+ "javascriptreact",
7
+ "typescript",
8
+ "typescriptreact"
9
+ ],
10
+ "eslint.run": "onSave"
11
+ }
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
@@ -0,0 +1,25 @@
1
+ // @ts-check
2
+ import { includeIgnoreFile } from "@eslint/compat";
3
+ import eslint from "@eslint/js";
4
+ import tseslint from "typescript-eslint";
5
+ import path from "node:path";
6
+ import globals from "globals";
7
+ import eslintReact from "@eslint-react/eslint-plugin";
8
+
9
+ export default tseslint.config(
10
+ {
11
+ languageOptions: {
12
+ globals: { ...globals.browser, ...globals.node },
13
+ },
14
+ },
15
+
16
+ // JS/TS recommended
17
+ eslint.configs.recommended,
18
+ { files: ["**/*.ts", "**/*.tsx"], extends: tseslint.configs.recommended },
19
+
20
+ // React
21
+ eslintReact.configs["recommended-typescript"],
22
+
23
+ // Ignore the same files as .gitignore
24
+ includeIgnoreFile(path.resolve(import.meta.dirname, ".gitignore")),
25
+ );
@@ -1,60 +1,58 @@
1
1
  {
2
2
  "name": "$$MODULE_NAME$$",
3
3
  "version": "0.1.0",
4
- "main": "index.js",
5
4
  "license": "MIT",
5
+ "type": "module",
6
+ "main": "dist/server/index.js",
7
+ "files": [
8
+ "dist/client/**/*",
9
+ "dist/server/**/*",
10
+ "settings",
11
+ "static"
12
+ ],
6
13
  "scripts": {
7
- "build:development": "webpack --mode=development && jahia-pack",
8
- "build:production": "webpack && jahia-pack",
9
- "build": "run build:production",
14
+ "build": "tsc --noEmit && vite build && run package",
10
15
  "clean": "rm -rf dist/",
11
16
  "deploy": "jahia-deploy",
12
- "watch": "webpack --mode=development --watch",
13
- "lint": "eslint --ext js,jsx .",
14
- "test": "yarn lint"
17
+ "format": "prettier --write --list-different .",
18
+ "lint": "eslint .",
19
+ "package": "mkdir -p dist && yarn pack --out dist/package.tgz",
20
+ "watch": "vite build --watch",
21
+ "watch:callback": "run package && run deploy"
22
+ },
23
+ "devDependencies": {
24
+ "@eslint-react/eslint-plugin": "^1.26.2",
25
+ "@eslint/compat": "^1.2.6",
26
+ "@eslint/js": "^9.20.0",
27
+ "@jahia/javascript-modules-library": "0.x || ^1.0.0",
28
+ "@jahia/vite-plugin": "^0.5.1",
29
+ "@types/react": "^19.0.0",
30
+ "eslint": "^9.20.1",
31
+ "eslint-plugin-cypress": "^4.1.0",
32
+ "globals": "^15.15.0",
33
+ "i18next": "^23.10.1",
34
+ "prettier": "^3.5.1",
35
+ "prettier-plugin-jsdoc": "^1.3.2",
36
+ "prettier-plugin-packagejson": "^2.5.8",
37
+ "react-i18next": "^15.4.0",
38
+ "typescript": "^5.7.3",
39
+ "typescript-eslint": "^8.24.0",
40
+ "vite": "^6.1.0"
41
+ },
42
+ "packageManager": "yarn@4.3.1",
43
+ "engines": {
44
+ "node": ">=18.0.0",
45
+ "yarn": ">=4.0.0"
15
46
  },
16
47
  "jahia": {
17
48
  "snapshot": true,
18
49
  "module-dependencies": "default",
19
50
  "module-type": "$$MODULE_TYPE$$",
20
51
  "module-type-comment": "Use templatesSet in the module type to declare a template set",
21
- "server": "main.js",
52
+ "server": "dist/server/index.js",
22
53
  "static-resources": "/icons,/images,/javascript,/locales"
23
54
  },
24
55
  "dependencies": {
25
- "graphql": "^16.7.1",
26
- "i18next": "^23.10.1",
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0",
29
- "react-i18next": "^14.1.0"
30
- },
31
- "devDependencies": {
32
- "@babel/cli": "^7.16.0",
33
- "@babel/core": "^7.16.0",
34
- "@babel/preset-env": "^7.16.4",
35
- "@babel/preset-react": "^7.16.0",
36
- "@jahia/eslint-config": "^2.1.2",
37
- "@jahia/scripts": "^1.3.7",
38
- "babel-loader": "^8.2.3",
39
- "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
40
- "clean-webpack-plugin": "^4.0.0",
41
- "copy-webpack-plugin": "^10.0.0",
42
- "dotenv-cli": "^4.0.0",
43
- "eslint": "^8.43.0",
44
- "eslint-plugin-jest": "latest",
45
- "eslint-plugin-react": "latest",
46
- "eslint-plugin-react-hooks": "latest",
47
- "extra-watch-webpack-plugin": "^1.0.3",
48
- "styled-jsx": "^5.1.2",
49
- "terser-webpack-plugin": "^5.3.10",
50
- "typescript": "^5.3.3",
51
- "webpack": "^5.64.4",
52
- "webpack-cli": "^4.9.1",
53
- "webpack-shell-plugin-next": "^2.3.1"
54
- },
55
- "engines": {
56
- "node": ">=18.0.0",
57
- "yarn": ">=4.0.0"
58
- },
59
- "packageManager": "yarn@4.3.1"
56
+ "modern-normalize": "^3.0.1"
57
+ }
60
58
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @type {import("prettier").Config}
3
+ * @see https://prettier.io/docs/en/configuration.html
4
+ */
5
+ export default {
6
+ quoteProps: "consistent",
7
+ printWidth: 100,
8
+ plugins: ["prettier-plugin-jsdoc", "prettier-plugin-packagejson"],
9
+ };
@@ -1,6 +1,7 @@
1
1
  # Directory Structure
2
2
 
3
- In this directory, you can directly put:
3
+ In this directory, you can directly put:
4
+
4
5
  - **Rule files** (`*.drl`, `*.dsl`)
5
6
  - **URL rewrite XML files**
6
7
  - **import.xml** file
@@ -10,6 +11,7 @@ In this directory, you can directly put:
10
11
  ## Configurations Directory
11
12
 
12
13
  In the `configurations` directory, you can put:
14
+
13
15
  - **OSGi configuration files** (`*.cfg`, `*.yml`)
14
16
 
15
17
  ## Content Editor Forms Directory
@@ -3,7 +3,11 @@
3
3
  <modules jcr:primaryType="jnt:modules">
4
4
  <$$MODULE_NAME$$>
5
5
  <home j:isHomePage="true" j:templateName="home" jcr:primaryType="jnt:page">
6
+ <j:translation_en jcr:language="en"
7
+ jcr:mixinTypes="mix:title"
8
+ jcr:primaryType="jnt:translation"
9
+ jcr:title="Home"/>
6
10
  </home>
7
11
  </$$MODULE_NAME$$>
8
12
  </modules>
9
- </content>
13
+ </content>
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "greeting": "Hallo !",
3
- "welcomeTitle" : "Willkommen bei Jahia!",
3
+ "welcomeTitle": "Willkommen bei Jahia!",
4
4
  "homeTitle": "Startvorlage"
5
- }
5
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "greeting": "Hello !",
3
- "welcomeTitle" : "Welcome to Jahia !",
2
+ "greeting": "Hello !",
3
+ "welcomeTitle": "Welcome to Jahia !",
4
4
  "homeTitle": "Home Template"
5
- }
5
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "greeting": "Salut !",
3
- "welcomeTitle" : "Bienvenue chez Jahia !",
3
+ "welcomeTitle": "Bienvenue chez Jahia !",
4
4
  "homeTitle": "Template Accueil"
5
- }
5
+ }
@@ -1,5 +1 @@
1
- // PublicPath is used to make webpack able to download the chunks and assets from the correct location
2
- // Since JS can be aggregated by Jahia on live, the path of the original file is lost
3
- // Also the context of the server should be handled properly
4
- // eslint-disable-next-line camelcase, no-undef
5
- __webpack_public_path__ = `${window.__APPSHELL_INIT_DATA__.moduleBaseUrl}/$$MODULE_NAME$$/javascript/client/`;
1
+ // define your client components in this folder (configured in vite.config.mjs: client.input.dir)
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import {
3
+ AddResources,
4
+ Area,
5
+ jahiaComponent,
6
+ useUrlBuilder,
7
+ } from "@jahia/javascript-modules-library";
8
+ import { useTranslation } from "react-i18next";
9
+ import "modern-normalize/modern-normalize.css";
10
+
11
+ jahiaComponent(
12
+ {
13
+ nodeType: "jnt:page",
14
+ name: "home",
15
+ displayName: "Home page",
16
+ componentType: "template",
17
+ },
18
+
19
+ (_, { currentResource }) => {
20
+ const { t } = useTranslation();
21
+ const { buildStaticUrl } = useUrlBuilder();
22
+ const lang = currentResource.getLocale().getLanguage();
23
+ return (
24
+ <html lang={lang}>
25
+ <head>
26
+ <AddResources
27
+ type="css"
28
+ resources={buildStaticUrl({ assetPath: "../dist/server/index.css" })}
29
+ />
30
+ <AddResources type="css" resources={buildStaticUrl({ assetPath: "css/styles.css" })} />
31
+ <title>Home</title>
32
+ </head>
33
+ <body>
34
+ <main>
35
+ {/* Using i18next defined in locales */}
36
+ <h1>{t("homeTitle")}</h1>
37
+ <Area name="pagecontent" />
38
+ </main>
39
+ </body>
40
+ </html>
41
+ );
42
+ },
43
+ );
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { jahiaComponent } from "@jahia/javascript-modules-library";
3
+
4
+ jahiaComponent(
5
+ {
6
+ name: "default",
7
+ nodeType: "$$MODULE_NAMESPACE$$:simpleContent",
8
+ displayName: "Simple Content (default)",
9
+ componentType: "view",
10
+ },
11
+ ({ title }) => (
12
+ <div>
13
+ <h2>{title}</h2>
14
+ </div>
15
+ ),
16
+ );
@@ -1,8 +1,8 @@
1
1
  body {
2
- font-family: 'Helvetica Neue', Arial, sans-serif;
3
- margin: 0;
4
- padding: 40px;
5
- background-color: #f5f5f5;
6
- color: #333;
7
- line-height: 1.6;
8
- }
2
+ font-family: "Helvetica Neue", Arial, sans-serif;
3
+ margin: 0;
4
+ padding: 40px;
5
+ background-color: #f5f5f5;
6
+ color: #333;
7
+ line-height: 1.6;
8
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "allowJs": true,
6
+ "checkJs": true,
7
+ "moduleResolution": "bundler",
8
+ "jsx": "preserve",
9
+ "esModuleInterop": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "noImplicitAny": true,
14
+ "allowSyntheticDefaultImports": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "lib": ["esnext", "dom"],
18
+ "declaration": true,
19
+ "declarationDir": "dist",
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "*": ["target/types/*"]
23
+ }
24
+ },
25
+ "include": ["src/**/*.js", "src/**/*.mjs", "src/**/*.ts", "src/**/*.tsx", "src/**/*.jsx"],
26
+ "exclude": ["node_modules"]
27
+ }
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from "vite";
2
+ import jahia from "@jahia/vite-plugin";
3
+ import path from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+
6
+ export default defineConfig({
7
+ resolve: {
8
+ alias: { $client: path.resolve("./src/client") },
9
+ },
10
+ plugins: [
11
+ jahia({
12
+ client: {
13
+ input: {
14
+ dir: "./src/client/",
15
+ glob: "**/*.{jsx,tsx}",
16
+ },
17
+ output: "./dist/client/",
18
+ },
19
+ server: {
20
+ // You can use a glob pattern to match multiple files
21
+ input: "./src/server/**/*.{jsx,tsx}",
22
+ output: {
23
+ dir: "./dist/server",
24
+ fileName: "index", // Will produce index.js and index.css
25
+ },
26
+ },
27
+ // This function is called every time a build succeeds in watch mode
28
+ watchCallback() {
29
+ spawnSync("yarn", ["watch:callback"], { stdio: "inherit" });
30
+ },
31
+ }),
32
+ ],
33
+ });