@ui5/builder 3.0.0-alpha.9 → 3.0.0-beta.1

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 (83) hide show
  1. package/.reuse/dep5 +2 -2
  2. package/CHANGELOG.md +42 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -4
  5. package/jsdoc.json +2 -2
  6. package/lib/lbt/UI5ClientConstants.js +7 -8
  7. package/lib/lbt/analyzer/ComponentAnalyzer.js +60 -22
  8. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
  9. package/lib/lbt/analyzer/JSModuleAnalyzer.js +107 -65
  10. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
  11. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
  12. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +71 -18
  13. package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
  14. package/lib/lbt/bundle/AutoSplitter.js +10 -11
  15. package/lib/lbt/bundle/Builder.js +33 -36
  16. package/lib/lbt/bundle/BundleDefinition.js +1 -5
  17. package/lib/lbt/bundle/BundleWriter.js +1 -2
  18. package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
  19. package/lib/lbt/bundle/Resolver.js +11 -12
  20. package/lib/lbt/calls/SapUiDefine.js +16 -11
  21. package/lib/lbt/graph/dependencyGraph.js +3 -4
  22. package/lib/lbt/graph/dominatorTree.js +3 -3
  23. package/lib/lbt/graph/topologicalSort.js +3 -3
  24. package/lib/lbt/resources/LibraryFileAnalyzer.js +5 -8
  25. package/lib/lbt/resources/LocatorResource.js +2 -2
  26. package/lib/lbt/resources/LocatorResourcePool.js +3 -3
  27. package/lib/lbt/resources/ModuleInfo.js +1 -2
  28. package/lib/lbt/resources/Resource.js +3 -4
  29. package/lib/lbt/resources/ResourceCollector.js +7 -8
  30. package/lib/lbt/resources/ResourceFilterList.js +38 -40
  31. package/lib/lbt/resources/ResourceInfo.js +1 -1
  32. package/lib/lbt/resources/ResourceInfoList.js +5 -3
  33. package/lib/lbt/resources/ResourcePool.js +15 -21
  34. package/lib/lbt/utils/ASTUtils.js +58 -44
  35. package/lib/lbt/utils/JSTokenizer.js +4 -4
  36. package/lib/lbt/utils/ModuleName.js +10 -20
  37. package/lib/lbt/utils/escapePropertiesFile.js +3 -3
  38. package/lib/lbt/utils/parseUtils.js +4 -10
  39. package/lib/processors/bootstrapHtmlTransformer.js +15 -7
  40. package/lib/processors/bundlers/flexChangesBundler.js +16 -8
  41. package/lib/processors/bundlers/manifestBundler.js +19 -10
  42. package/lib/processors/bundlers/moduleBundler.js +26 -15
  43. package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
  44. package/lib/processors/jsdoc/jsdocGenerator.js +31 -17
  45. package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
  46. package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +58 -2
  47. package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +306 -119
  48. package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +1 -1
  49. package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
  50. package/lib/processors/jsdoc/sdkTransformer.js +18 -11
  51. package/lib/processors/libraryLessGenerator.js +28 -16
  52. package/lib/processors/manifestCreator.js +14 -13
  53. package/lib/processors/minifier.js +22 -16
  54. package/lib/processors/nonAsciiEscaper.js +16 -6
  55. package/lib/processors/resourceListCreator.js +13 -13
  56. package/lib/processors/stringReplacer.js +13 -6
  57. package/lib/processors/themeBuilder.js +33 -24
  58. package/lib/processors/versionInfoGenerator.js +33 -23
  59. package/lib/tasks/buildThemes.js +18 -11
  60. package/lib/tasks/bundlers/generateBundle.js +23 -12
  61. package/lib/tasks/bundlers/generateComponentPreload.js +18 -10
  62. package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
  63. package/lib/tasks/bundlers/generateLibraryPreload.js +22 -12
  64. package/lib/tasks/bundlers/generateManifestBundle.js +15 -6
  65. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
  66. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +6 -6
  67. package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
  68. package/lib/tasks/generateCachebusterInfo.js +16 -8
  69. package/lib/tasks/generateLibraryManifest.js +14 -8
  70. package/lib/tasks/generateResourcesJson.js +15 -9
  71. package/lib/tasks/generateThemeDesignerResources.js +19 -9
  72. package/lib/tasks/generateVersionInfo.js +12 -5
  73. package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
  74. package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
  75. package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
  76. package/lib/tasks/minify.js +13 -6
  77. package/lib/tasks/replaceBuildtime.js +12 -5
  78. package/lib/tasks/replaceCopyright.js +12 -5
  79. package/lib/tasks/replaceVersion.js +12 -5
  80. package/lib/tasks/taskRepository.js +24 -29
  81. package/lib/tasks/transformBootstrapHtml.js +6 -5
  82. package/package.json +33 -18
  83. package/index.js +0 -173
@@ -1,15 +1,27 @@
1
- const spawn = require("child_process").spawn;
2
- const fs = require("graceful-fs");
3
- const path = require("path");
4
- const {promisify} = require("util");
1
+ import {spawn} from "node:child_process";
2
+ import fs from "graceful-fs";
3
+ import path from "node:path";
4
+ import {promisify} from "node:util";
5
5
  const writeFile = promisify(fs.writeFile);
6
- const {resourceFactory} = require("@ui5/fs");
6
+ import {createAdapter} from "@ui5/fs/resourceFactory";
7
+ import {createRequire} from "node:module";
8
+ import {fileURLToPath} from "node:url";
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ const require = createRequire(import.meta.url);
12
+
13
+ /**
14
+ * @public
15
+ * @module @ui5/builder/processors/jsdoc/jsdocGenerator
16
+ */
7
17
 
8
18
  /**
9
19
  * JSDoc generator
10
20
  *
11
21
  * @public
12
- * @alias module:@ui5/builder.processors.jsdocGenerator
22
+ * @function default
23
+ * @static
24
+ *
13
25
  * @param {object} parameters Parameters
14
26
  * @param {string} parameters.sourcePath Path of the source files to be processed
15
27
  * @param {string} parameters.targetPath Path to write any output files
@@ -19,9 +31,9 @@ const {resourceFactory} = require("@ui5/fs");
19
31
  * @param {string} parameters.options.namespace Namespace to build (e.g. <code>some/project/name</code>)
20
32
  * @param {string} parameters.options.version Project version
21
33
  * @param {Array} [parameters.options.variants=["apijson"]] JSDoc variants to be built
22
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with newly created resources
34
+ * @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with newly created resources
23
35
  */
24
- const jsdocGenerator = async function(
36
+ export default async function jsdocGenerator(
25
37
  {sourcePath, targetPath, tmpPath, options: {projectName, namespace, version, variants}} = {}
26
38
  ) {
27
39
  if (!sourcePath || !targetPath || !tmpPath || !projectName || !namespace || !version) {
@@ -48,7 +60,7 @@ const jsdocGenerator = async function(
48
60
  configPath
49
61
  });
50
62
 
51
- const fsTarget = resourceFactory.createAdapter({
63
+ const fsTarget = createAdapter({
52
64
  fsBasePath: targetPath,
53
65
  virBasePath: "/"
54
66
  });
@@ -58,7 +70,7 @@ const jsdocGenerator = async function(
58
70
  fsTarget.byPath(`/test-resources/${namespace}/designtime/api.json`)
59
71
  // fsTarget.byPath(`/libraries/${options.projectName}.js`)
60
72
  ]).then((res) => res.filter(($)=>$));
61
- };
73
+ }
62
74
 
63
75
 
64
76
  /**
@@ -82,8 +94,11 @@ async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName,
82
94
 
83
95
  // Resolve path to this script to get the path to the JSDoc extensions folder
84
96
  const jsdocPath = path.normalize(__dirname);
85
- const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.js").replace(backslashRegex, "\\\\");
86
- const templatePath = path.join(jsdocPath, "lib", "ui5", "template").replace(backslashRegex, "\\\\");
97
+ const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.cjs").replace(backslashRegex, "\\\\");
98
+ // Using export via package.json to allow loading the CJS template.
99
+ // jsdoc appends /publish to the provided path but doesn't allow to
100
+ // add the .cjs extension, so loading won't work otherwise.
101
+ const templatePath = "@ui5/builder/internal/jsdoc/template";
87
102
  const destinationPath = path.normalize(tmpPath).replace(backslashRegex, "\\\\");
88
103
  const jsapiFilePath = path.join(targetPath, "libraries", projectName + ".js").replace(backslashRegex, "\\\\");
89
104
  const apiJsonFolderPath = path.join(tmpPath, "dependency-apis").replace(backslashRegex, "\\\\");
@@ -157,7 +172,7 @@ async function buildJsdoc({sourcePath, configPath}) {
157
172
  ];
158
173
  return new Promise((resolve, reject) => {
159
174
  const child = spawn("node", args, {
160
- stdio: ["ignore", "ignore", process.stderr]
175
+ stdio: ["ignore", "ignore", "inherit"]
161
176
  });
162
177
  child.on("close", function(code) {
163
178
  if (code === 0 || code === 1) {
@@ -169,7 +184,6 @@ async function buildJsdoc({sourcePath, configPath}) {
169
184
  });
170
185
  }
171
186
 
172
- module.exports = jsdocGenerator;
173
- module.exports._generateJsdocConfig = generateJsdocConfig;
174
- module.exports._writeJsdocConfig = writeJsdocConfig;
175
- module.exports._buildJsdoc = buildJsdoc;
187
+ jsdocGenerator._generateJsdocConfig = generateJsdocConfig;
188
+ jsdocGenerator._writeJsdocConfig = writeJsdocConfig;
189
+ jsdocGenerator._buildJsdoc = buildJsdoc;
@@ -25,6 +25,11 @@ const log = (function() {
25
25
  }
26
26
  }());
27
27
 
28
+ function replaceLastPathSegment(p, replacement) {
29
+ // Note: path.join also correctly normalizes any POSIX paths on Windows
30
+ return path.join(path.dirname(p), replacement);
31
+ }
32
+
28
33
  /*
29
34
  * Transforms the api.json as created by the JSDoc build into a pre-processed api.json file suitable for the SDK.
30
35
  *
@@ -698,7 +703,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
698
703
  oMethod.returnValue.types.forEach(oType => {
699
704
 
700
705
  // Link Enabled
701
- if (!isBuiltInType(oType.value)) {
706
+ if (!isBuiltInType(oType.value) && possibleUI5Symbol(oType.value)) {
702
707
  oType.href = "api/" + oType.value.replace("[]", "");
703
708
  oType.linkEnabled = true;
704
709
  }
@@ -981,6 +986,57 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
981
986
  // Normalize path to resolve relative path
982
987
  sPath = path.normalize(sPath);
983
988
 
989
+ const {sources} = options;
990
+ let {librarySrcDir, libraryTestDir} = options;
991
+
992
+ // Using path.join to normalize POSIX paths to Windows paths on Windows
993
+ librarySrcDir = path.join(librarySrcDir);
994
+ libraryTestDir = path.join(libraryTestDir);
995
+
996
+ if (Array.isArray(sources) && typeof librarySrcDir === "string" && typeof libraryTestDir === "string") {
997
+ /**
998
+ * Calculate prefix to check
999
+ *
1000
+ * Example 1:
1001
+ * - sSource: /path/to/project/src
1002
+ * - sLibrarySrcDir: src
1003
+ *
1004
+ * Prefix: /path/to/project/test-resources
1005
+ *
1006
+ * Example 2:
1007
+ * - sSource: /path/to/project/src/main/js
1008
+ * - sLibrarySrcDir: src/main/js
1009
+ *
1010
+ * Prefix: /path/to/project/src/main/test-resources
1011
+ */
1012
+ const librarySrcDirWithTestResources = replaceLastPathSegment(librarySrcDir, "test-resources");
1013
+
1014
+ for (const sourcePath of sources) {
1015
+ /**
1016
+ * Replace prefix with file system path
1017
+ *
1018
+ * Example 1:
1019
+ * - sPath: /path/to/project/test-resources/sap/test/demokit/docuindex.json
1020
+ *
1021
+ * New sPath: /path/to/project/test/sap/test/demokit/docuindex.json
1022
+ *
1023
+ * Example 2:
1024
+ * - sPath: /path/to/project/src/main/test-resources/sap/test/demokit/docuindex.json
1025
+ *
1026
+ * New sPath: /path/to/project/src/main/test/sap/test/demokit/docuindex.json
1027
+ */
1028
+ if (!sourcePath.endsWith(librarySrcDir)) {
1029
+ continue;
1030
+ }
1031
+ const libraryDir = sourcePath.substring(0, sourcePath.lastIndexOf(librarySrcDir) - 1);
1032
+ const prefix = path.join(libraryDir, librarySrcDirWithTestResources);
1033
+ if (sPath.startsWith(prefix)) {
1034
+ sPath = path.join(libraryDir, libraryTestDir, sPath.substring(prefix.length));
1035
+ break;
1036
+ }
1037
+ }
1038
+ }
1039
+
984
1040
  fs.readFile(sPath, 'utf8', (oError, oFileData) => {
985
1041
  if (!oError) {
986
1042
  oFileData = JSON.parse(oFileData);
@@ -991,7 +1047,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
991
1047
  });
992
1048
  }
993
1049
  }
994
- // We aways resolve as this data is not mandatory
1050
+ // We always resolve as this data is not mandatory
995
1051
  oResolve(oChainObject);
996
1052
  });
997
1053