@jahia/create-module 0.0.10 → 0.5.4
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/LICENSE +1 -1
- package/README.md +3 -2
- package/index.js +82 -130
- package/package.json +26 -37
- package/template/README.md +19 -11
- package/template/{dotenv → dot/env} +1 -1
- package/template/dot/github/workflows/build.yml +18 -0
- package/template/dot/gitignore +15 -0
- package/template/dot/idea/prettier.xml +7 -0
- package/template/dot/node-version +1 -0
- package/template/dot/prettierignore +1 -0
- package/template/dot/vscode/extensions.json +3 -0
- package/template/dot/vscode/settings.json +8 -0
- package/template/dot/yarnrc.yml +1 -0
- package/template/eslint.config.js +25 -0
- package/template/package.json +45 -48
- package/template/prettier.config.js +8 -0
- package/template/settings/README.md +3 -1
- package/template/settings/content-types-icons/$MODULE_HelloCard.png +0 -0
- package/template/settings/content-types-icons/$MODULE_HelloWorld.png +0 -0
- package/template/settings/content-types-icons/$MODULE_LanguageSwitcher.png +0 -0
- package/template/settings/content-types-icons/$MODULE_component.png +0 -0
- package/template/settings/definitions.cnd +2 -7
- package/template/settings/import.xml +104 -8
- package/template/settings/locales/en.json +11 -4
- package/template/settings/locales/fr.json +11 -4
- package/template/settings/resources/$MODULE.properties +15 -0
- package/template/settings/resources/$MODULE_fr.properties +15 -0
- package/template/src/components/HelloCard/component.module.css +14 -0
- package/template/src/components/HelloCard/default.server.tsx +18 -0
- package/template/src/components/HelloCard/definition.cnd +3 -0
- package/template/src/components/HelloWorld/Celebrate.client.tsx +30 -0
- package/template/src/components/HelloWorld/component.module.css +105 -0
- package/template/src/components/HelloWorld/default.server.tsx +85 -0
- package/template/src/components/HelloWorld/definition.cnd +3 -0
- package/template/src/components/LanguageSwitcher/component.module.css +5 -0
- package/template/src/components/LanguageSwitcher/default.server.tsx +45 -0
- package/template/src/components/LanguageSwitcher/definition.cnd +1 -0
- package/template/src/pages/Layout.tsx +24 -0
- package/template/src/pages/basic.server.tsx +16 -0
- package/template/src/pages/global.css +11 -0
- package/template/src/types.d.ts +1 -0
- package/template/static/arrows/bottom.svg +1 -0
- package/template/static/arrows/left.svg +1 -0
- package/template/static/illustrations/code.svg +1 -0
- package/template/static/illustrations/coffee.svg +1 -0
- package/template/static/illustrations/interface.svg +1 -0
- package/template/static/illustrations/read.svg +1 -0
- package/template/static/illustrations/write.svg +1 -0
- package/template/tsconfig.json +19 -0
- package/template/vite.config.mjs +29 -0
- package/.eslintrc.cjs +0 -28
- package/.github/ISSUE_TEMPLATE/bug.yml +0 -45
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/epic.md +0 -26
- package/.github/ISSUE_TEMPLATE/other.md +0 -8
- package/.github/ISSUE_TEMPLATE/release.md +0 -74
- package/.github/ISSUE_TEMPLATE/spike.md +0 -19
- package/.github/ISSUE_TEMPLATE/story.md +0 -27
- package/.github/ISSUE_TEMPLATE/support.yml +0 -40
- package/.github/ISSUE_TEMPLATE/tech-day.md +0 -93
- package/.github/dependabot.yml +0 -15
- package/.github/release.yml +0 -24
- package/.github/workflows/delivery-issue-chores.yml +0 -12
- package/.github/workflows/on-code-change.yml +0 -50
- package/.github/workflows/publish-release.yml +0 -22
- package/.yarn/releases/yarn-4.6.0.cjs +0 -934
- package/.yarnrc.yml +0 -3
- package/babel.config.cjs +0 -6
- package/template/.babelrc +0 -9
- package/template/.yarn/releases/yarn-4.3.1.cjs +0 -894
- package/template/.yarnrc.yml +0 -3
- package/template/doteslintrc.cjs +0 -30
- package/template/dotgitignore +0 -21
- package/template/dotnpmignore +0 -10
- package/template/settings/content-types-icons/MODULE_NAMESPACE_simpleContent.png +0 -0
- package/template/settings/locales/de.json +0 -5
- package/template/settings/resources/MODULE_NAME.properties +0 -3
- package/template/settings/resources/MODULE_NAME_fr.properties +0 -3
- package/template/src/client/index.jsx +0 -5
- package/template/src/server/components/index.js +0 -1
- package/template/src/server/index.js +0 -6
- package/template/src/server/templates/index.js +0 -1
- package/template/src/server/templates/page/PageHome.jsx +0 -32
- package/template/src/server/templates/page/index.js +0 -1
- package/template/src/server/views/index.js +0 -1
- package/template/src/server/views/simpleContent/SimpleContentDefault.jsx +0 -19
- package/template/src/server/views/simpleContent/index.js +0 -1
- package/template/static/css/styles.css +0 -8
- package/template/webpack.config.js +0 -225
- package/tests/create-templatesSet-project.test.js +0 -124
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025 Jahia Forge - Code Repository
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# Javascript Module template create-module project
|
|
2
2
|
|
|
3
|
-
This project provides
|
|
3
|
+
This project provides a Javascript module starter project template to quickly get up and running to create Jahia Javascript modules
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
npx @jahia/create-module@latest project-name [module-type] [namespace-definitions]
|
|
8
8
|
|
|
9
|
-
where
|
|
9
|
+
where
|
|
10
|
+
|
|
10
11
|
- `project-name` (mandatory) can be anything you want to call your project
|
|
11
12
|
- `module-type` (optional) Can be one of:
|
|
12
13
|
- `templatesSet`: A collection of templates and components. A template set is required when creating a website.
|
package/index.js
CHANGED
|
@@ -1,144 +1,96 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import camelCase from "camelcase";
|
|
7
|
+
import { styleText } from "node:util";
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
try {
|
|
10
|
+
console.log(styleText("bgBlueBright", " Jahia JavaScript Module Creator "), "\n");
|
|
11
|
+
|
|
12
|
+
const nodeVersion = Number(process.versions.node.split(".")[0]);
|
|
13
|
+
|
|
14
|
+
if (nodeVersion < 22) {
|
|
15
|
+
console.warn(
|
|
16
|
+
`You are using ${styleText("redBright", `Node.js ${process.versions.node}`)} which is not officially supported.
|
|
17
|
+
Please upgrade to ${styleText("greenBright", "Node.js 22 or later")} if you encounter any issues.
|
|
18
|
+
Upgrade guide: ${styleText("underline", "https://nodejs.org/en/download")}
|
|
19
|
+
`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const name = process.argv[2];
|
|
4
24
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {replaceInFileSync} from 'replace-in-file';
|
|
9
|
-
import camelCase from 'camelcase';
|
|
25
|
+
if (!name) {
|
|
26
|
+
console.error(
|
|
27
|
+
`No module name provided.
|
|
10
28
|
|
|
11
|
-
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
29
|
+
Usage: npm init @jahia/module ${styleText("blueBright", "<module-name>")}
|
|
13
30
|
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line no-unused-vars
|
|
16
|
-
const [nodeCommand, npxCommand, projectName, moduleType = 'module', namespace = camelCase(projectName || '')] = process.argv;
|
|
31
|
+
It will create a new module at this location with the provided name:
|
|
17
32
|
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
${path.join(process.cwd(), styleText("blueBright", "<module-name>"))}`,
|
|
34
|
+
);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
// Module name and output directory
|
|
39
|
+
const module = camelCase(name);
|
|
40
|
+
const output = path.join(process.cwd(), name);
|
|
22
41
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- \x1B[3mmodule\x1B[0m sStandard Jahia module. This is the default value.
|
|
28
|
-
- \x1B[3msystem\x1B[0m Critical module for the whole platform .
|
|
29
|
-
- \x1B[1mnamespace-definitions\x1B[0m (optional) The namespace used for content definitions. Default is the project name in camel case.
|
|
42
|
+
console.log(`Creating a new Jahia module project...
|
|
43
|
+
|
|
44
|
+
Module name: ${styleText("blueBright", module)}
|
|
45
|
+
Path: ${styleText("blueBright", output)}
|
|
30
46
|
`);
|
|
31
|
-
process.exit(9);
|
|
32
|
-
}
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Create a project directory with the project name.
|
|
38
|
-
const currentDir = process.cwd();
|
|
39
|
-
const projectDir = path.resolve(currentDir, projectName);
|
|
40
|
-
fs.mkdirSync(projectDir, {recursive: true});
|
|
41
|
-
|
|
42
|
-
console.log(`Creating a new Jahia module project \x1B[1m${projectName}\x1B[0m of type \x1B[1m${moduleType}\x1B[0m and definitions namespace \x1B[1m${namespace}\x1B[0m`);
|
|
43
|
-
|
|
44
|
-
// A common approach to building a starter template is to
|
|
45
|
-
// create a `template` folder which will house the template
|
|
46
|
-
// and the files we want to create.
|
|
47
|
-
const templateDir = path.resolve(__dirname, 'template');
|
|
48
|
-
const isTemplatesSet = moduleType === 'templatesSet';
|
|
49
|
-
fs.cpSync(templateDir, projectDir, {
|
|
50
|
-
recursive: true,
|
|
51
|
-
filter: src => {
|
|
52
|
-
// The file template-thumbnail.png is only used for the type templatesSet
|
|
53
|
-
return (isTemplatesSet || src !== path.join(templateDir, 'settings', 'template-thumbnail.png'));
|
|
54
|
-
}
|
|
55
|
-
});
|
|
48
|
+
/** Renames the `dot` directory to dotfiles and dotdirs. */
|
|
49
|
+
const renameDot = (/** @type {string} */ name) =>
|
|
50
|
+
name.startsWith(`dot${path.sep}`) ? `.${name.slice(4)}` : name;
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const targetFiles = `${projectDir}/**`;
|
|
52
|
+
/** Replaces `$MODULE` with the actual module name. */
|
|
53
|
+
const templatify = (/** @type {string} */ str) => str.replaceAll("$MODULE", module);
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
55
|
+
// Copy the template to the output directory
|
|
56
|
+
const input = fileURLToPath(new URL("template/", import.meta.url));
|
|
57
|
+
for (const entry of fs.readdirSync(input, { recursive: true, withFileTypes: true })) {
|
|
58
|
+
if (entry.isDirectory()) continue;
|
|
59
|
+
|
|
60
|
+
const from = path.join(entry.parentPath, entry.name);
|
|
61
|
+
const to = path.join(output, templatify(renameDot(path.relative(input, from))));
|
|
62
|
+
|
|
63
|
+
// Ensure the parent directory exists
|
|
64
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
65
|
+
|
|
66
|
+
// Binary files are copied as is, text files are templated
|
|
67
|
+
if (entry.name.endsWith(".png")) {
|
|
68
|
+
fs.copyFileSync(from, to);
|
|
69
|
+
} else {
|
|
70
|
+
const contents = fs.readFileSync(from, "utf-8");
|
|
71
|
+
fs.writeFileSync(to, templatify(contents));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(`${styleText("greenBright", "Successfully created a new Jahia module project!")}
|
|
76
|
+
|
|
77
|
+
Next steps:
|
|
78
|
+
${styleText("magentaBright", `cd ${name}`)}
|
|
79
|
+
${styleText("magentaBright", "yarn")} ${styleText("dim", "# Install dependencies")}
|
|
80
|
+
${styleText("magentaBright", 'git init && git add . && git commit -m "chore: create module"')} ${styleText(
|
|
81
|
+
"dim",
|
|
82
|
+
"# Commit all files",
|
|
83
|
+
)}
|
|
84
|
+
${styleText("magentaBright", "code .")} ${styleText("dim", "# Open the project in VSCode")}
|
|
85
|
+
${styleText("magentaBright", "yarn dev")} ${styleText("dim", "# Start the development server")}
|
|
86
|
+
`);
|
|
79
87
|
} catch (error) {
|
|
80
|
-
|
|
88
|
+
console.error(
|
|
89
|
+
`${styleText("bgRedBright", "Something went wrong")}
|
|
90
|
+
|
|
91
|
+
If you believe this is a bug, please report it at:
|
|
92
|
+
${styleText("underline", "https://github.com/Jahia/javascript-modules/issues")}
|
|
93
|
+
`,
|
|
94
|
+
error,
|
|
95
|
+
);
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
// It is good practice to have dotfiles stored in the
|
|
84
|
-
// template without the dot (so they do not get picked
|
|
85
|
-
// up by the starter template repository). We can rename
|
|
86
|
-
// the dotfiles after we have copied them over to the
|
|
87
|
-
// new project directory.
|
|
88
|
-
fs.renameSync(
|
|
89
|
-
path.join(projectDir, 'dotgitignore'),
|
|
90
|
-
path.join(projectDir, '.gitignore')
|
|
91
|
-
);
|
|
92
|
-
fs.renameSync(
|
|
93
|
-
path.join(projectDir, 'dotnpmignore'),
|
|
94
|
-
path.join(projectDir, '.npmignore')
|
|
95
|
-
);
|
|
96
|
-
fs.renameSync(
|
|
97
|
-
path.join(projectDir, 'dotenv'),
|
|
98
|
-
path.join(projectDir, '.env')
|
|
99
|
-
);
|
|
100
|
-
fs.renameSync(
|
|
101
|
-
path.join(projectDir, 'doteslintrc.cjs'),
|
|
102
|
-
path.join(projectDir, '.eslintrc.cjs')
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
// Rename the resource file to use the project name
|
|
106
|
-
fs.renameSync(
|
|
107
|
-
path.join(projectDir, 'settings', 'resources', 'MODULE_NAME.properties'),
|
|
108
|
-
path.join(projectDir, 'settings', 'resources', projectName + '.properties')
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
fs.renameSync(
|
|
112
|
-
path.join(projectDir, 'settings', 'resources', 'MODULE_NAME_fr.properties'),
|
|
113
|
-
path.join(projectDir, 'settings', 'resources', projectName + '_fr.properties')
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
fs.renameSync(
|
|
117
|
-
path.join(projectDir, 'settings', 'content-types-icons', 'MODULE_NAMESPACE_simpleContent.png'),
|
|
118
|
-
path.join(projectDir, 'settings', 'content-types-icons', namespace + '_simpleContent.png')
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// Create empty directories for static resources and configurations
|
|
122
|
-
fs.mkdirSync(path.join(projectDir, 'static', 'css'), {recursive: true});
|
|
123
|
-
fs.mkdirSync(path.join(projectDir, 'static', 'images'), {recursive: true});
|
|
124
|
-
fs.mkdirSync(path.join(projectDir, 'static', 'javascript'), {recursive: true});
|
|
125
|
-
fs.mkdirSync(path.join(projectDir, 'settings', 'configurations'), {recursive: true});
|
|
126
|
-
fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms'), {recursive: true});
|
|
127
|
-
fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'forms'), {recursive: true});
|
|
128
|
-
fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'fieldsets'), {recursive: true});
|
|
129
|
-
|
|
130
|
-
// Add an empty yarn.lock in case any parent folder is using yarn
|
|
131
|
-
fs.writeFileSync(path.join(projectDir, 'yarn.lock'), '', 'utf8');
|
|
132
|
-
|
|
133
|
-
console.log(`Created \x1B[1m${projectName}\x1B[0m at \x1B[1m${projectDir}\x1B[0m`);
|
|
134
|
-
console.log('Success! Your new project is ready.');
|
|
135
|
-
console.log('You can now change into your project and launch "yarn" to install everything to get started.');
|
|
136
|
-
console.log('---');
|
|
137
|
-
console.log('Available project scripts will then be :');
|
|
138
|
-
console.log(' - yarn build : build the project');
|
|
139
|
-
console.log(' - yarn deploy : deploy the project. Make sure you have updated the .env file to match your setup if needed.');
|
|
140
|
-
console.log(' - yarn watch : will build and watch for file modifications, and deploy automatically when changes are detected. Use CTRL+C to stop watching.');
|
|
141
|
-
console.log(' - yarn lint : use to check that your code follows the recommended syntax guidelines. Append --fix to automatically fix most problems.');
|
|
142
|
-
console.log(' - yarn test : to test your project. By default only performs yarn lint but you are encouraged to add your own testing system here.');
|
|
143
|
-
console.log('---');
|
|
144
|
-
console.log('You can also check the documentation available here for more details: https://academy.jahia.com/get-started/developers/templating');
|
package/package.json
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jahia/create-module",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"template"
|
|
6
|
+
],
|
|
7
|
+
"homepage": "https://github.com/Jahia/javascript-modules/javascript-create-module",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/Jahia/javascript-modules/issues"
|
|
10
|
+
},
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com
|
|
13
|
+
"url": "git+https://github.com:Jahia/javascript-modules.git",
|
|
14
|
+
"directory": "javascript-create-module"
|
|
10
15
|
},
|
|
11
|
-
"
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Jahia <support@jahia.com>",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"bin": "./index.js",
|
|
20
|
+
"files": [
|
|
12
21
|
"template"
|
|
13
22
|
],
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "yarn pack --out dist/package.tgz && publint",
|
|
25
|
+
"lint": "yarn run --top-level lint",
|
|
26
|
+
"playground-to-template": "rm -rf template && node ./playground-to-template.js",
|
|
27
|
+
"template-to-playground": "rm -rf playground && create-module playground",
|
|
28
|
+
"test": "node --test"
|
|
17
29
|
},
|
|
18
|
-
"homepage": "https://github.com/Jahia/npm-create-module#readme",
|
|
19
30
|
"dependencies": {
|
|
20
|
-
"camelcase": "^8.0.0"
|
|
21
|
-
"path": "^0.12.7",
|
|
22
|
-
"replace-in-file": "^8.2.0",
|
|
23
|
-
"semver": "^7.5.4",
|
|
24
|
-
"url": "^0.11.1"
|
|
31
|
+
"camelcase": "^8.0.0"
|
|
25
32
|
},
|
|
26
33
|
"devDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"@jahia/scripts": "^1.3.7",
|
|
29
|
-
"eslint": "^8.43.0",
|
|
30
|
-
"eslint-plugin-jest": "latest",
|
|
31
|
-
"eslint-plugin-react": "latest",
|
|
32
|
-
"eslint-plugin-react-hooks": "latest",
|
|
33
|
-
"jest": "^29.7.0",
|
|
34
|
-
"jest-each": "^29.7.0",
|
|
35
|
-
"tar": "^7.4.3"
|
|
36
|
-
},
|
|
37
|
-
"scripts": {
|
|
38
|
-
"lint": "eslint .",
|
|
39
|
-
"posttest": "yarn lint",
|
|
40
|
-
"test": "jest tests/"
|
|
34
|
+
"publint": "^0.3.6"
|
|
41
35
|
},
|
|
42
36
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"jest": {
|
|
47
|
-
"testTimeout": 60000
|
|
48
|
-
},
|
|
49
|
-
"packageManager": "yarn@4.6.0"
|
|
50
|
-
}
|
|
37
|
+
"node": ">=22.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/template/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Jahia Javascript Module
|
|
2
2
|
|
|
3
3
|
A simple Jahia Javascript module created using the Javascript module starter project template
|
|
4
4
|
|
|
@@ -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
|
-
##
|
|
13
|
+
## Prerequisites
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Yarn is required to build the project.
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Development
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
1. To compile and package the project:
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
```
|
|
26
|
+
yarn build
|
|
27
|
+
```
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
2. To deploy the generated package to your Jahia instance (configured in your [`.env`](.env)):
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
```
|
|
32
|
+
yarn deploy
|
|
33
|
+
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
3. Alternatively, to deploy during development using watch mode:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
yarn watch
|
|
39
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Build and upload the package on every push
|
|
2
|
+
name: Build
|
|
3
|
+
|
|
4
|
+
on: push
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build-and-upload:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v4
|
|
11
|
+
- uses: actions/setup-node@v4
|
|
12
|
+
- run: corepack enable
|
|
13
|
+
- run: yarn install
|
|
14
|
+
- run: yarn build
|
|
15
|
+
- uses: actions/upload-artifact@v4
|
|
16
|
+
with:
|
|
17
|
+
name: package.tgz
|
|
18
|
+
path: dist/package.tgz
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v22
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This file inherits .gitignore, there is no need to copy its content here
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
3
|
+
"editor.formatOnSave": true,
|
|
4
|
+
"i18n-ally.extract.keygenStrategy": "random",
|
|
5
|
+
"i18n-ally.keystyle": "flat",
|
|
6
|
+
"i18n-ally.localesPaths": ["settings/locales"],
|
|
7
|
+
"typescript.tsdk": "node_modules/typescript/lib"
|
|
8
|
+
}
|
|
@@ -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
|
+
);
|
package/template/package.json
CHANGED
|
@@ -1,61 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"
|
|
5
|
-
"
|
|
2
|
+
"name": "$MODULE",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src/**/*.cnd",
|
|
8
|
+
"settings",
|
|
9
|
+
"static"
|
|
10
|
+
],
|
|
6
11
|
"scripts": {
|
|
7
|
-
"build
|
|
8
|
-
"build:production": "webpack && jahia-pack",
|
|
9
|
-
"build": "run build:production",
|
|
12
|
+
"build": "tsc --noEmit && vite build && run package",
|
|
10
13
|
"clean": "rm -rf dist/",
|
|
11
14
|
"deploy": "jahia-deploy",
|
|
12
|
-
"
|
|
13
|
-
"lint": "eslint
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"module-dependencies": "default",
|
|
19
|
-
"module-type": "$$MODULE_TYPE$$",
|
|
20
|
-
"module-type-comment": "Use templatesSet in the module type to declare a template set",
|
|
21
|
-
"server": "main.js",
|
|
22
|
-
"static-resources": "/icons,/images,/javascript,/locales"
|
|
15
|
+
"format": "prettier --write --list-different .",
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"package": "yarn pack --out dist/package.tgz",
|
|
18
|
+
"dev": "vite build --watch",
|
|
19
|
+
"watch": "run dev",
|
|
20
|
+
"watch:callback": "run package && run deploy"
|
|
23
21
|
},
|
|
24
22
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"react": "^18.2.0",
|
|
29
|
-
"react-dom": "^18.2.0",
|
|
30
|
-
"react-i18next": "^14.1.0"
|
|
23
|
+
"canvas-confetti": "^1.9.3",
|
|
24
|
+
"clsx": "^2.1.1",
|
|
25
|
+
"modern-normalize": "^3.0.1"
|
|
31
26
|
},
|
|
32
27
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@jahia/
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"eslint
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"terser-webpack-plugin": "^5.3.10",
|
|
51
|
-
"typescript": "^5.3.3",
|
|
52
|
-
"webpack": "^5.64.4",
|
|
53
|
-
"webpack-cli": "^4.9.1",
|
|
54
|
-
"webpack-shell-plugin-next": "^2.3.1"
|
|
28
|
+
"@eslint-react/eslint-plugin": "^1.26.2",
|
|
29
|
+
"@eslint/compat": "^1.2.6",
|
|
30
|
+
"@eslint/js": "^9.20.0",
|
|
31
|
+
"@jahia/javascript-modules-library": "latest",
|
|
32
|
+
"@jahia/vite-plugin": "latest",
|
|
33
|
+
"@types/canvas-confetti": "^1.9.0",
|
|
34
|
+
"@types/react": "^19.0.0",
|
|
35
|
+
"eslint": "^9.20.1",
|
|
36
|
+
"eslint-plugin-cypress": "^4.1.0",
|
|
37
|
+
"globals": "^15.15.0",
|
|
38
|
+
"i18next": "^23.10.1",
|
|
39
|
+
"prettier": "^3.5.1",
|
|
40
|
+
"react-i18next": "^15.4.0",
|
|
41
|
+
"typescript": "^5.7.3",
|
|
42
|
+
"typescript-eslint": "^8.24.0",
|
|
43
|
+
"typescript-plugin-css-modules": "^5.1.0",
|
|
44
|
+
"vite": "^6.1.0"
|
|
55
45
|
},
|
|
46
|
+
"packageManager": "yarn@4.7.0",
|
|
56
47
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
48
|
+
"node": ">=22.0.0",
|
|
58
49
|
"yarn": ">=4.0.0"
|
|
59
50
|
},
|
|
60
|
-
"
|
|
51
|
+
"jahia": {
|
|
52
|
+
"snapshot": true,
|
|
53
|
+
"module-dependencies": "default",
|
|
54
|
+
"module-type": "templatesSet",
|
|
55
|
+
"server": "dist/server/index.js",
|
|
56
|
+
"static-resources": "/dist,/locales,/images,/icons"
|
|
57
|
+
}
|
|
61
58
|
}
|
|
@@ -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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
<jnt = 'http://www.jahia.org/jahia/nt/1.0'>
|
|
2
2
|
<jmix = 'http://www.jahia.org/jahia/mix/1.0'>
|
|
3
|
-
|
|
4
|
-
<$$MODULE_NAMESPACE$$mix = 'http://www.acme.org/$$MODULE_NAME$$/mix/1.0'>
|
|
3
|
+
<$MODULE = 'https://example.com/$MODULE/1.0'>
|
|
5
4
|
|
|
6
5
|
// Defining the content types is similar to defining a data model: once deployed, you cannot change the type of a property.
|
|
7
6
|
// If you need to do changes during the development phase, it is possible to remove the definitions from the tools:
|
|
8
7
|
// http://localhost:8080/cms/login?redirect=/modules/tools/definitionsBrowser.jsp however that will remove content created with this type.
|
|
9
8
|
// Learn more about content types definitions here: https://academy.jahia.com/developer/content-types"
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
// This mixin creates a category to regroup types in the content type selector UI. Apply it to any definition you want
|
|
13
11
|
// to see in this category.
|
|
14
|
-
[
|
|
15
|
-
|
|
16
|
-
[$$MODULE_NAMESPACE$$:simpleContent] > jnt:content, $$MODULE_NAMESPACE$$mix:$$MODULE_NAMESPACE$$Components
|
|
17
|
-
- title (string) = 'Hello world !' i18n
|
|
12
|
+
[$MODULE:component] > jmix:droppableContent, jmix:accessControllableContent mixin
|