@jahia/create-module 0.5.3 → 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.
Files changed (79) hide show
  1. package/index.js +88 -150
  2. package/package.json +11 -19
  3. package/template/README.md +1 -1
  4. package/template/{dotenv → dot/env} +1 -1
  5. package/template/dot/github/workflows/build.yml +18 -0
  6. package/template/dot/node-version +1 -0
  7. package/template/dot/vscode/extensions.json +3 -0
  8. package/template/dot/vscode/settings.json +8 -0
  9. package/template/dot/yarnrc.yml +1 -0
  10. package/template/package.json +20 -20
  11. package/template/prettier.config.js +0 -1
  12. package/template/settings/content-types-icons/$MODULE_HelloCard.png +0 -0
  13. package/template/settings/content-types-icons/$MODULE_HelloWorld.png +0 -0
  14. package/template/settings/content-types-icons/$MODULE_LanguageSwitcher.png +0 -0
  15. package/template/settings/content-types-icons/$MODULE_component.png +0 -0
  16. package/template/settings/definitions.cnd +2 -7
  17. package/template/settings/import.xml +103 -11
  18. package/template/settings/locales/en.json +10 -3
  19. package/template/settings/locales/fr.json +10 -3
  20. package/template/settings/resources/$MODULE.properties +15 -0
  21. package/template/settings/resources/$MODULE_fr.properties +15 -0
  22. package/template/src/components/HelloCard/component.module.css +14 -0
  23. package/template/src/components/HelloCard/default.server.tsx +18 -0
  24. package/template/src/components/HelloCard/definition.cnd +3 -0
  25. package/template/src/components/HelloWorld/Celebrate.client.tsx +30 -0
  26. package/template/src/components/HelloWorld/component.module.css +105 -0
  27. package/template/src/components/HelloWorld/default.server.tsx +85 -0
  28. package/template/src/components/HelloWorld/definition.cnd +3 -0
  29. package/template/src/components/LanguageSwitcher/component.module.css +5 -0
  30. package/template/src/components/LanguageSwitcher/default.server.tsx +45 -0
  31. package/template/src/components/LanguageSwitcher/definition.cnd +1 -0
  32. package/template/src/pages/Layout.tsx +24 -0
  33. package/template/src/pages/basic.server.tsx +16 -0
  34. package/template/src/pages/global.css +11 -0
  35. package/template/src/types.d.ts +1 -0
  36. package/template/static/arrows/bottom.svg +1 -0
  37. package/template/static/arrows/left.svg +1 -0
  38. package/template/static/illustrations/code.svg +1 -0
  39. package/template/static/illustrations/coffee.svg +1 -0
  40. package/template/static/illustrations/interface.svg +1 -0
  41. package/template/static/illustrations/read.svg +1 -0
  42. package/template/static/illustrations/write.svg +1 -0
  43. package/template/tsconfig.json +11 -19
  44. package/template/vite.config.mjs +6 -10
  45. package/babel.config.cjs +0 -3
  46. package/node/node +0 -0
  47. package/node/npm +0 -65
  48. package/node/npm.cmd +0 -20
  49. package/node/npx +0 -65
  50. package/node/npx.cmd +0 -20
  51. package/node/yarn/dist/LICENSE +0 -26
  52. package/node/yarn/dist/README.md +0 -60
  53. package/node/yarn/dist/bin/yarn +0 -35
  54. package/node/yarn/dist/bin/yarn.cmd +0 -2
  55. package/node/yarn/dist/bin/yarn.js +0 -31
  56. package/node/yarn/dist/bin/yarnpkg +0 -2
  57. package/node/yarn/dist/bin/yarnpkg.cmd +0 -2
  58. package/node/yarn/dist/lib/cli.js +0 -154071
  59. package/node/yarn/dist/lib/v8-compile-cache.js +0 -351
  60. package/node/yarn/dist/package.json +0 -28
  61. package/node/yarn/dist/preinstall.js +0 -60
  62. package/pom.xml +0 -134
  63. package/sync-version.js +0 -16
  64. package/template/dotgithub/workflows/build.yml +0 -21
  65. package/template/dotidea/jsLinters/eslint.xml +0 -6
  66. package/template/dotvscode/settings.json +0 -11
  67. package/template/dotyarnrc.yml +0 -1
  68. package/template/settings/content-types-icons/MODULE_NAMESPACE_simpleContent.png +0 -0
  69. package/template/settings/locales/de.json +0 -5
  70. package/template/settings/resources/MODULE_NAME.properties +0 -3
  71. package/template/settings/resources/MODULE_NAME_fr.properties +0 -3
  72. package/template/src/client/index.jsx +0 -1
  73. package/template/src/server/templates/page/PageHome.tsx +0 -43
  74. package/template/src/server/views/simpleContent/SimpleContentDefault.tsx +0 -16
  75. package/template/static/css/styles.css +0 -8
  76. package/tests/create-templatesSet-project.test.js +0 -136
  77. /package/template/{dotgitignore → dot/gitignore} +0 -0
  78. /package/template/{dotidea → dot/idea}/prettier.xml +0 -0
  79. /package/template/{dotprettierignore → dot/prettierignore} +0 -0
@@ -1,43 +0,0 @@
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
- );
@@ -1,16 +0,0 @@
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 +0,0 @@
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
- }
@@ -1,136 +0,0 @@
1
- import { execSync } from "child_process";
2
- import fs from "fs";
3
- import os from "os";
4
- import path from "path";
5
- import * as tar from "tar";
6
- import { test, before, after } from "node:test";
7
- import assert from "assert";
8
- import { fileURLToPath } from "url";
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
-
13
- let tempFolder;
14
-
15
- before(() => {
16
- // Create a temporary directory
17
- tempFolder = fs.mkdtempSync(os.tmpdir());
18
- console.log("Using temp folder ", tempFolder);
19
- });
20
-
21
- after(() => {
22
- // Remove the temporary directory
23
- fs.rmSync(tempFolder, { recursive: true, force: true });
24
- console.log(`Temp folder ${tempFolder} removed.`);
25
- });
26
-
27
- const testCases = [
28
- ["test-project", "testProject", "templatesSet"],
29
- ["otherSampleProject", "otherSampleProject", "module"],
30
- ["foo", "foo", ""],
31
- ];
32
-
33
- testCases.forEach(([projectName, projectNameSanitized, moduleType]) => {
34
- test(`Project creation using archetype ('${projectName}'/'${projectNameSanitized}' with moduleType '${moduleType}')`, async () => {
35
- // Create a temporary directory
36
- const tempDir = fs.mkdtempSync(path.join(tempFolder, projectNameSanitized));
37
- console.log("tempDir", tempDir);
38
-
39
- const parentFolder = path.dirname(__dirname);
40
- const indexFile = path.join(parentFolder, "index.js");
41
- const isTemplatesSet = moduleType === "templatesSet";
42
-
43
- // Create a new test-project from within the temp directory
44
- process.chdir(tempDir);
45
- console.log(execSync(`node ${indexFile} ${projectName} ${moduleType}`).toString());
46
- const projectPath = path.join(tempDir, projectName);
47
- assert(fs.existsSync(projectPath), true);
48
-
49
- // TODO check the replacement of the markers in the files
50
-
51
- // Validate the generated project structure
52
- const expectedFiles = [
53
- // Make sure the dot files have been renamed
54
- ".env",
55
- ".gitignore",
56
- ".prettierignore",
57
- ".yarnrc.yml",
58
- ".github/workflows/build.yml",
59
- ".idea/jsLinters/eslint.xml",
60
- ".idea/prettier.xml",
61
- ".vscode/settings.json",
62
- "eslint.config.js",
63
- // Make sure the renaming with MODULE_NAME is correct
64
- `settings/resources/${projectName}.properties`,
65
- `settings/resources/${projectName}_fr.properties`,
66
- `settings/content-types-icons/${projectNameSanitized}_simpleContent.png`,
67
- // Make sure the static and config folders exist
68
- "static/css",
69
- "static/images",
70
- "static/javascript",
71
- "settings/configurations",
72
- "settings/content-editor-forms/forms",
73
- "settings/content-editor-forms/fieldsets",
74
- "yarn.lock",
75
- ];
76
- if (moduleType === "templatesSet") {
77
- // This file should only exist for templates set
78
- expectedFiles.push("settings/template-thumbnail.png");
79
- }
80
-
81
- expectedFiles.forEach((file) => {
82
- console.log(`Testing that ${file} exists...`);
83
- assert(fs.existsSync(path.join(projectPath, file)), true);
84
- });
85
-
86
- // Install & build the project
87
- process.chdir(projectPath);
88
- // YARN_ENABLE_IMMUTABLE_INSTALLS=false is used as the yarn.lock file gets updated
89
- // Without this flag, the following error is encountered: "The lockfile would have been created by this install, which is explicitly forbidden."
90
- console.log(execSync("YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install").toString());
91
- console.log(execSync("yarn build").toString());
92
-
93
- // Make sure the tgz file is created in the dist/ folder
94
- const tgzFilePath = path.join(projectPath, "dist", "package.tgz");
95
- assert(fs.existsSync(tgzFilePath), true);
96
-
97
- // Check the contents of the tgz file
98
- const expectedFilesInArchive = [
99
- "dist/client/index.jsx.js",
100
- "dist/server/index.js",
101
- `settings/content-types-icons/${projectNameSanitized}_simpleContent.png`,
102
- "settings/locales/de.json",
103
- "settings/locales/en.json",
104
- "settings/locales/fr.json",
105
- `settings/resources/${projectName}.properties`,
106
- `settings/resources/${projectName}_fr.properties`,
107
- "settings/definitions.cnd",
108
- "settings/import.xml",
109
- "settings/README.md",
110
- isTemplatesSet && "settings/template-thumbnail.png",
111
- "static/css/styles.css",
112
- "package.json",
113
- "README.md",
114
- ].filter(Boolean);
115
-
116
- const entries = [];
117
- await tar
118
- .list({
119
- file: tgzFilePath,
120
- onReadEntry: (entry) => {
121
- entries.push(entry.path);
122
- },
123
- })
124
- .then(() => {
125
- expectedFilesInArchive.forEach((file) => {
126
- console.log(`Testing that ${file} exists in the archive...`);
127
- assert(entries.includes(`package/${file}`), true);
128
- });
129
- assert(entries.length, expectedFilesInArchive.length);
130
- });
131
-
132
- // Make sure the package.json contains the dependency @jahia/javascript-modules-library
133
- const packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, "package.json"), "utf8"));
134
- assert(packageJson.devDependencies["@jahia/javascript-modules-library"], true);
135
- });
136
- });
File without changes
File without changes