@jahia/create-module 0.0.2 → 0.0.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.
- package/.github/workflows/lint.yml +5 -3
- package/.github/workflows/publish-release.yml +2 -2
- package/.yarn/releases/yarn-4.4.0.cjs +925 -0
- package/.yarnrc.yml +3 -0
- package/handlebars/.yarn/releases/yarn-4.3.1.cjs +894 -0
- package/handlebars/.yarnrc.yml +3 -0
- package/handlebars/README.md +20 -0
- package/handlebars/dotgitignore +9 -6
- package/handlebars/package.json +11 -10
- package/handlebars/webpack.config.js +19 -1
- package/jsx/.yarn/releases/yarn-4.3.1.cjs +894 -0
- package/jsx/.yarnrc.yml +3 -0
- package/jsx/README.md +20 -0
- package/jsx/definitions.cnd +6 -0
- package/jsx/dotenv +1 -1
- package/jsx/dotgitignore +9 -6
- package/jsx/locales/de.json +2 -1
- package/jsx/locales/en.json +2 -1
- package/jsx/locales/fr.json +2 -1
- package/jsx/package.json +15 -15
- package/jsx/src/server/templates/page/PageHome.jsx +11 -8
- package/jsx/src/server/views/hello/HelloDefault.jsx +7 -6
- package/jsx/webpack.config.js +46 -23
- package/package.json +4 -4
package/jsx/.yarnrc.yml
ADDED
package/jsx/README.md
CHANGED
|
@@ -9,3 +9,23 @@ If you don't use default configuration for the Docker container name or for Jahi
|
|
|
9
9
|
## Documentation
|
|
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
|
+
|
|
13
|
+
## Run
|
|
14
|
+
|
|
15
|
+
1) Enable Corepack if needed :
|
|
16
|
+
|
|
17
|
+
`enable corepack`
|
|
18
|
+
|
|
19
|
+
2) Install the dependencies :
|
|
20
|
+
|
|
21
|
+
``yarn``
|
|
22
|
+
|
|
23
|
+
3) Build and run the project :
|
|
24
|
+
|
|
25
|
+
``yarn watch``
|
|
26
|
+
|
|
27
|
+
## How to upgrade yarn version to latest stable
|
|
28
|
+
|
|
29
|
+
This command will upgrade yarn to the latest stable release and update the yarn installer in .yarn/releases
|
|
30
|
+
|
|
31
|
+
``yarn set version stable``
|
package/jsx/definitions.cnd
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
<$$MODULE_NAMESPACE$$ = 'http://www.acme.org/$$MODULE_NAME$$/nt/1.0'>
|
|
4
4
|
<$$MODULE_NAMESPACE$$mix = 'http://www.acme.org/$$MODULE_NAME$$/mix/1.0'>
|
|
5
5
|
|
|
6
|
+
// Defining the content types is similar to defining a data model: once deployed, you cannot change the type of a property.
|
|
7
|
+
// If you need to do changes during the development phase, it is possible to remove the definitions from the tools:
|
|
8
|
+
// http://localhost:8080/cms/login?redirect=/modules/tools/definitionsBrowser.jsp however that will remove content created with this type.
|
|
9
|
+
// Learn more about content types definitions here: https://academy.jahia.com/developer/content-types"
|
|
10
|
+
|
|
11
|
+
|
|
6
12
|
// This mixin creates a category to regroup types in the content type selector UI. Apply it to any definition you want
|
|
7
13
|
// to see in this category.
|
|
8
14
|
[$$MODULE_NAMESPACE$$mix:$$MODULE_NAMESPACE$$Components] > jmix:droppableContent, jmix:accessControllableContent mixin
|
package/jsx/dotenv
CHANGED
package/jsx/dotgitignore
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
dist
|
|
8
8
|
node_modules
|
|
9
9
|
|
|
10
|
-
#
|
|
11
|
-
.yarn
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
#Yarn
|
|
11
|
+
.yarn/*
|
|
12
|
+
!.yarn/cache
|
|
13
|
+
!.yarn/patches
|
|
14
|
+
!.yarn/plugins
|
|
15
|
+
!.yarn/releases
|
|
16
|
+
!.yarn/sdks
|
|
17
|
+
!.yarn/versions
|
|
18
|
+
yarn-error.log
|
package/jsx/locales/de.json
CHANGED
package/jsx/locales/en.json
CHANGED
package/jsx/locales/fr.json
CHANGED
package/jsx/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "$$MODULE_NAME$$",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "webpack --mode=development",
|
|
8
|
-
"build:production": "webpack --mode=production",
|
|
9
|
-
"deploy": "jahia-deploy
|
|
10
|
-
"watch": "
|
|
7
|
+
"build": "webpack --mode=development && jahia-pack",
|
|
8
|
+
"build:production": "webpack --mode=production && jahia-pack",
|
|
9
|
+
"deploy": "jahia-deploy",
|
|
10
|
+
"watch": "webpack --mode=development --watch",
|
|
11
11
|
"lint": "eslint .",
|
|
12
|
-
"test": "yarn lint"
|
|
13
|
-
"postinstall": "yarn dlx @yarnpkg/sdks vscode"
|
|
12
|
+
"test": "yarn lint"
|
|
14
13
|
},
|
|
15
14
|
"jahia": {
|
|
16
15
|
"module-dependencies": "default",
|
|
17
|
-
"module-type": "
|
|
16
|
+
"module-type": "",
|
|
17
|
+
"module-type-comment": "Use templatesSet in the module type to declare a template set",
|
|
18
18
|
"server": "dist/main.js",
|
|
19
19
|
"static-resources": "/css,/images,/javascript,/locales"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@jahia/data-helper": "1.0.4",
|
|
24
|
-
"@jahia/js-server-core": "^0.0.7",
|
|
22
|
+
"@jahia/js-server-core": "^0.0.13",
|
|
25
23
|
"graphql": "^16.7.1",
|
|
24
|
+
"i18next": "^23.10.1",
|
|
26
25
|
"react": "^18.2.0",
|
|
27
|
-
"react-dom": "^18.2.0"
|
|
26
|
+
"react-dom": "^18.2.0",
|
|
27
|
+
"react-i18next": "^14.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/cli": "^7.16.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"webpack-shell-plugin-next": "^2.3.1"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"node": ">=
|
|
53
|
-
"yarn": ">=
|
|
52
|
+
"node": ">=18.0.0",
|
|
53
|
+
"yarn": ">=4.0.0"
|
|
54
54
|
},
|
|
55
|
-
"packageManager": "yarn@4.1
|
|
55
|
+
"packageManager": "yarn@4.3.1"
|
|
56
56
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {Area, AddResources} from '@jahia/js-server-core';
|
|
2
|
+
import {Area, AddResources, defineJahiaComponent} from '@jahia/js-server-core';
|
|
3
|
+
import {useTranslation} from 'react-i18next';
|
|
3
4
|
|
|
4
5
|
export const PageHome = () => {
|
|
6
|
+
const {t} = useTranslation();
|
|
5
7
|
return (<>
|
|
6
8
|
<head>
|
|
7
9
|
<AddResources type='css' resources='styles.css' />
|
|
8
10
|
<title>Home</title>
|
|
9
11
|
</head>
|
|
10
12
|
<body>
|
|
11
|
-
|
|
13
|
+
{/* Using i18next defined in locales */}
|
|
14
|
+
<h1>{t('homeTitle')}</h1>
|
|
12
15
|
<main>
|
|
13
16
|
<Area name="pagecontent" />
|
|
14
17
|
</main>
|
|
@@ -16,9 +19,9 @@ export const PageHome = () => {
|
|
|
16
19
|
</>);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
PageHome.jahiaComponent = {
|
|
20
|
-
nodeType: 'jnt:page',
|
|
21
|
-
name: 'home',
|
|
22
|
-
displayName: 'Home page',
|
|
23
|
-
componentType: 'template'
|
|
24
|
-
}
|
|
22
|
+
PageHome.jahiaComponent = defineJahiaComponent({
|
|
23
|
+
nodeType: 'jnt:page',
|
|
24
|
+
name: 'home',
|
|
25
|
+
displayName: 'Home page',
|
|
26
|
+
componentType: 'template'
|
|
27
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {useServerContext, getNodeProps, defineJahiaComponent} from '@jahia/js-server-core'
|
|
3
3
|
|
|
4
4
|
export const HelloDefault = () => {
|
|
5
5
|
const { currentNode } = useServerContext();
|
|
@@ -11,8 +11,9 @@ export const HelloDefault = () => {
|
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
HelloDefault.jahiaComponent = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
HelloDefault.jahiaComponent = defineJahiaComponent({
|
|
15
|
+
name: 'default',
|
|
16
|
+
nodeType: '$$MODULE_NAMESPACE$$:hello',
|
|
17
|
+
displayName: 'Hello (default)',
|
|
18
|
+
componentType: 'view'
|
|
19
|
+
});
|
package/jsx/webpack.config.js
CHANGED
|
@@ -18,9 +18,13 @@ fs.readdirSync(componentsDir).forEach(file => {
|
|
|
18
18
|
});
|
|
19
19
|
const moduleName = '$$MODULE_NAME$$';
|
|
20
20
|
|
|
21
|
-
module.exports = env => {
|
|
21
|
+
module.exports = (env, mode) => {
|
|
22
22
|
let configs = [
|
|
23
|
+
// Config for jahia's client-side components (HydrateInBrowser or RenderInBrowser)
|
|
24
|
+
// This config can be removed if the module doesn't contain client-side components
|
|
25
|
+
// More info here : https://academy.jahia.com/documentation/jahia/jahia-8/developer/javascript-module-development/client-side-javascript
|
|
23
26
|
{
|
|
27
|
+
name: 'client',
|
|
24
28
|
entry: {
|
|
25
29
|
[moduleName]: path.resolve(__dirname, './src/client/index')
|
|
26
30
|
},
|
|
@@ -52,6 +56,7 @@ module.exports = env => {
|
|
|
52
56
|
]
|
|
53
57
|
},
|
|
54
58
|
plugins: [
|
|
59
|
+
// This plugin allows a build to provide or consume modules with other independent builds at runtime.
|
|
55
60
|
new ModuleFederationPlugin({
|
|
56
61
|
name: moduleName,
|
|
57
62
|
library: {type: 'assign', name: `window.appShell = (typeof appShell === "undefined" ? {} : appShell); window.appShell['${moduleName}']`},
|
|
@@ -70,7 +75,10 @@ module.exports = env => {
|
|
|
70
75
|
devtool: 'inline-source-map',
|
|
71
76
|
mode: 'development'
|
|
72
77
|
},
|
|
78
|
+
// Config for jahia's server-side components (using SSR) and source code
|
|
79
|
+
// Those components have access to jahia's custom types and functions (https://academy.jahia.com/documentation/jahia/jahia-8/developer/javascript-module-development/javascript-modules-reference-documentation)
|
|
73
80
|
{
|
|
81
|
+
name: 'server',
|
|
74
82
|
entry: {
|
|
75
83
|
main: path.resolve(__dirname, 'src/server')
|
|
76
84
|
},
|
|
@@ -78,8 +86,11 @@ module.exports = env => {
|
|
|
78
86
|
path: path.resolve(__dirname, 'dist')
|
|
79
87
|
},
|
|
80
88
|
externals: {
|
|
89
|
+
// Those libraries are supplied to webpack at runtime (by the npm-module-engine project), and are not packaged in the output bundle
|
|
81
90
|
'@jahia/js-server-core': 'jsServerCoreLibraryBuilder.getLibrary()',
|
|
82
91
|
react: 'jsServerCoreLibraryBuilder.getSharedLibrary(\'react\')',
|
|
92
|
+
'react-i18next': 'jsServerCoreLibraryBuilder.getSharedLibrary(\'react-i18next\')',
|
|
93
|
+
i18next: 'jsServerCoreLibraryBuilder.getSharedLibrary(\'i18next\')',
|
|
83
94
|
'styled-jsx/style': 'jsServerCoreLibraryBuilder.getSharedLibrary(\'styled-jsx\')'
|
|
84
95
|
},
|
|
85
96
|
resolve: {
|
|
@@ -122,13 +133,31 @@ module.exports = env => {
|
|
|
122
133
|
}
|
|
123
134
|
]
|
|
124
135
|
},
|
|
136
|
+
devtool: 'inline-source-map',
|
|
137
|
+
mode: 'development'
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
// In case of watch we add a final config that will do automatic shell commands to trigger the pack and deploy scripts
|
|
142
|
+
// Also an additional sleep is added to avoid watch triggering too much in a short time
|
|
143
|
+
// (Feel free to adjust the sleep time according to your needs)
|
|
144
|
+
if (mode.watch) {
|
|
145
|
+
configs.push({
|
|
146
|
+
name: 'watch',
|
|
147
|
+
mode: 'development',
|
|
148
|
+
dependencies: ['client', 'server'], // Wait for all webpack configs to be done
|
|
149
|
+
entry: {},
|
|
150
|
+
output: {},
|
|
125
151
|
plugins: [
|
|
126
152
|
new ExtraWatchWebpackPlugin({
|
|
153
|
+
// This is an extra list of files to watch for changes,
|
|
154
|
+
// It should include all files that are not already part of any webpack build
|
|
155
|
+
// Also do not watch for webpack generated files places, it can cause infinite loops of watch triggers
|
|
156
|
+
// for example, if your css is generated by webpack compiling scss, then:
|
|
157
|
+
// - do not add extra watch for 'css/**/*' -> it's the output of webpack scss build
|
|
158
|
+
// - do not add extra watch for 'src/scss/**/*' either, as it's already watched by webpack related config.
|
|
127
159
|
files: [
|
|
128
|
-
'src/server/**/*',
|
|
129
160
|
'images/**/*',
|
|
130
|
-
'css/**/*',
|
|
131
|
-
'javascript/**/*',
|
|
132
161
|
'locales/**/*.json',
|
|
133
162
|
'resources/**/*.properties',
|
|
134
163
|
'settings/**/*',
|
|
@@ -136,26 +165,20 @@ module.exports = env => {
|
|
|
136
165
|
'import.xml',
|
|
137
166
|
'package.json'
|
|
138
167
|
]
|
|
168
|
+
}),
|
|
169
|
+
new WebpackShellPluginNext({
|
|
170
|
+
onAfterDone: {
|
|
171
|
+
scripts: [
|
|
172
|
+
'yarn jahia-pack',
|
|
173
|
+
'yarn jahia-deploy',
|
|
174
|
+
'sleep 5' // Sleep for 5 seconds, can be adjusted
|
|
175
|
+
],
|
|
176
|
+
blocking: true,
|
|
177
|
+
parallel: false
|
|
178
|
+
}
|
|
139
179
|
})
|
|
140
|
-
]
|
|
141
|
-
|
|
142
|
-
mode: 'development'
|
|
143
|
-
}
|
|
144
|
-
];
|
|
145
|
-
|
|
146
|
-
const webpackShellPlugin = new WebpackShellPluginNext({
|
|
147
|
-
onAfterDone: {
|
|
148
|
-
scripts: ['yarn jahia-deploy pack']
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
if (env.deploy) {
|
|
153
|
-
let config = configs[configs.length - 1];
|
|
154
|
-
if (!config.plugins) {
|
|
155
|
-
config.plugins = [];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
config.plugins.push(webpackShellPlugin);
|
|
180
|
+
]
|
|
181
|
+
});
|
|
159
182
|
}
|
|
160
183
|
|
|
161
184
|
return configs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jahia/create-module",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"version": "git add README.md"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
44
|
-
"yarn": ">=
|
|
43
|
+
"node": ">=18.0.0",
|
|
44
|
+
"yarn": ">=4.0.0"
|
|
45
45
|
},
|
|
46
|
-
"packageManager": "yarn@4.
|
|
46
|
+
"packageManager": "yarn@4.4.0"
|
|
47
47
|
}
|