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

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 +59 -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 +119 -77
  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 +6 -9
  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 +2 -3
  28. package/lib/lbt/resources/Resource.js +3 -4
  29. package/lib/lbt/resources/ResourceCollector.js +8 -9
  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 +60 -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 +4 -4
  38. package/lib/lbt/utils/parseUtils.js +5 -11
  39. package/lib/processors/bootstrapHtmlTransformer.js +15 -7
  40. package/lib/processors/bundlers/flexChangesBundler.js +16 -8
  41. package/lib/processors/bundlers/moduleBundler.js +26 -15
  42. package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
  43. package/lib/processors/jsdoc/jsdocGenerator.js +37 -25
  44. package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
  45. package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +59 -2
  46. package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +310 -119
  47. package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +6 -2
  48. package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
  49. package/lib/processors/jsdoc/sdkTransformer.js +18 -11
  50. package/lib/processors/libraryLessGenerator.js +28 -16
  51. package/lib/processors/manifestCreator.js +15 -14
  52. package/lib/processors/minifier.js +22 -16
  53. package/lib/processors/nonAsciiEscaper.js +17 -7
  54. package/lib/processors/resourceListCreator.js +13 -13
  55. package/lib/processors/stringReplacer.js +13 -6
  56. package/lib/processors/themeBuilder.js +33 -24
  57. package/lib/processors/versionInfoGenerator.js +40 -30
  58. package/lib/tasks/buildThemes.js +18 -11
  59. package/lib/tasks/bundlers/generateBundle.js +23 -12
  60. package/lib/tasks/bundlers/generateComponentPreload.js +23 -12
  61. package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
  62. package/lib/tasks/bundlers/generateLibraryPreload.js +33 -17
  63. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
  64. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +7 -7
  65. package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
  66. package/lib/tasks/generateCachebusterInfo.js +17 -9
  67. package/lib/tasks/generateLibraryManifest.js +14 -8
  68. package/lib/tasks/generateResourcesJson.js +15 -9
  69. package/lib/tasks/generateThemeDesignerResources.js +19 -9
  70. package/lib/tasks/generateVersionInfo.js +12 -5
  71. package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
  72. package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
  73. package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
  74. package/lib/tasks/minify.js +13 -6
  75. package/lib/tasks/replaceBuildtime.js +12 -5
  76. package/lib/tasks/replaceCopyright.js +12 -5
  77. package/lib/tasks/replaceVersion.js +12 -5
  78. package/lib/tasks/taskRepository.js +24 -30
  79. package/lib/tasks/transformBootstrapHtml.js +6 -5
  80. package/package.json +44 -31
  81. package/index.js +0 -173
  82. package/lib/processors/bundlers/manifestBundler.js +0 -172
  83. package/lib/tasks/bundlers/generateManifestBundle.js +0 -49
@@ -1,15 +1,13 @@
1
- "use strict";
2
1
 
3
- const espree = require("espree");
4
- const {Syntax, VisitorKeys} = espree;
2
+ import {parse} from "espree";
5
3
 
6
4
  const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
7
5
 
8
- function parseJS(code, userOptions = {}) {
6
+ export function parseJS(code, userOptions = {}) {
9
7
  // allowed options and their defaults
10
8
  const options = {
11
9
  comment: false,
12
- ecmaVersion: 2021, // NOTE: Adopt JSModuleAnalyzer.js to allow new Syntax when upgrading to newer ECMA versions
10
+ ecmaVersion: 2022, // NOTE: Adopt JSModuleAnalyzer.js to allow new Syntax when upgrading to newer ECMA versions
13
11
  range: false,
14
12
  sourceType: "script",
15
13
  };
@@ -22,11 +20,7 @@ function parseJS(code, userOptions = {}) {
22
20
  options[name] = value;
23
21
  }
24
22
 
25
- return espree.parse(code, options);
23
+ return parse(code, options);
26
24
  }
27
25
 
28
- module.exports = {
29
- parseJS,
30
- Syntax,
31
- VisitorKeys
32
- };
26
+ export {Syntax, VisitorKeys} from "espree";
@@ -1,17 +1,25 @@
1
- const log = require("@ui5/logger").getLogger("builder:processors:bootstrapHtmlTransformer");
2
- const cheerio = require("cheerio");
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:processors:bootstrapHtmlTransformer");
3
+ import cheerio from "cheerio";
4
+
5
+ /**
6
+ * @module @ui5/builder/processors/bootstrapHtmlTransformer
7
+ */
3
8
 
4
9
  /**
5
10
  * Transforms the UI5 bootstrap of a HTML resource files.
6
11
  *
7
- * @module builder/processors/bootstrapHtmlTransformer
12
+ * @public
13
+ * @function default
14
+ * @static
15
+ *
8
16
  * @param {object} parameters Parameters
9
- * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed
17
+ * @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
10
18
  * @param {object} parameters.options Options
11
19
  * @param {string} parameters.options.src Bootstrap "src" that should be used
12
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with the cloned resources
20
+ * @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the cloned resources
13
21
  */
14
- module.exports = function({resources, options: {src}}) {
22
+ export default function({resources, options: {src}}) {
15
23
  async function processResource(resource) {
16
24
  const content = await resource.getString();
17
25
  const $ = cheerio.load(content);
@@ -30,4 +38,4 @@ module.exports = function({resources, options: {src}}) {
30
38
  }
31
39
 
32
40
  return Promise.all(resources.map(processResource));
33
- };
41
+ }
@@ -1,20 +1,28 @@
1
- const log = require("@ui5/logger").getLogger("builder:processors:bundlers:flexChangesBundler");
2
- const resourceFactory = require("@ui5/fs").resourceFactory;
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:processors:bundlers:flexChangesBundler");
3
+ import {createResource} from "@ui5/fs/resourceFactory";
4
+
5
+ /**
6
+ * @public
7
+ * @module @ui5/builder/processors/bundlers/flexChangesBundler
8
+ */
3
9
 
4
10
  /**
5
11
  * Bundles all supplied changes.
6
12
  *
7
13
  * @public
8
- * @alias module:@ui5/builder.processors.flexChangesBundler
14
+ * @function default
15
+ * @static
16
+ *
9
17
  * @param {object} parameters Parameters
10
- * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed
18
+ * @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
11
19
  * @param {object} parameters.options Options
12
20
  * @param {string} parameters.options.pathPrefix Prefix for bundle path
13
21
  * @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.73 than
14
22
  * create flexibility-bundle.json
15
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with flex changes bundle resources
23
+ * @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with flex changes bundle resources
16
24
  */
17
- module.exports = function({resources, options: {pathPrefix, hasFlexBundleVersion}}) {
25
+ export default function({resources, options: {pathPrefix, hasFlexBundleVersion}}) {
18
26
  let bundleName = "changes-bundle.json";
19
27
 
20
28
  function sortByTimeStamp(a, b) {
@@ -101,11 +109,11 @@ module.exports = function({resources, options: {pathPrefix, hasFlexBundleVersion
101
109
  const result = [];
102
110
  if (nNumberOfChanges > 0) {
103
111
  changesContent = sortAndStringifyInFlexFormat(changesContent);
104
- result.push(resourceFactory.createResource({
112
+ result.push(createResource({
105
113
  path: `${pathPrefix}/changes/${bundleName}`,
106
114
  string: changesContent
107
115
  }));
108
116
  }
109
117
  return result;
110
118
  });
111
- };
119
+ }
@@ -1,7 +1,13 @@
1
- const BundleBuilder = require("../../lbt/bundle/Builder");
2
- const LocatorResourcePool = require("../../lbt/resources/LocatorResourcePool");
3
- const EvoResource = require("@ui5/fs").Resource;
4
- const log = require("@ui5/logger").getLogger("builder:processors:bundlers:moduleBundler");
1
+ import BundleBuilder from "../../lbt/bundle/Builder.js";
2
+ import LocatorResourcePool from "../../lbt/resources/LocatorResourcePool.js";
3
+ import EvoResource from "@ui5/fs/Resource";
4
+ import logger from "@ui5/logger";
5
+ const log = logger.getLogger("builder:processors:bundlers:moduleBundler");
6
+
7
+ /**
8
+ * @public
9
+ * @module @ui5/builder/processors/bundlers/moduleBundler
10
+ */
5
11
 
6
12
  /**
7
13
  * A ModuleBundleDefinitionSection specifies the embedding mode (either 'provided', 'raw', 'preload', 'require'
@@ -80,7 +86,7 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
80
86
  * @property {string} name The module bundle name
81
87
  * @property {string[]} [defaultFileTypes=[".js", ".control.xml", ".fragment.html", ".fragment.json", ".fragment.xml", ".view.html", ".view.json", ".view.xml"]]
82
88
  * List of default file types to be included in the bundle
83
- * @property {ModuleBundleDefinitionSection[]} sections List of module bundle definition sections.
89
+ * @property {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinitionSection[]} sections List of module bundle definition sections.
84
90
  */
85
91
  /* eslint-enable max-len */
86
92
 
@@ -106,27 +112,32 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
106
112
  *
107
113
  * @public
108
114
  * @typedef {object} ModuleBundlerResult
109
- * @property {module:@ui5/fs.Resource} bundle Bundle resource
110
- * @property {module:@ui5/fs.Resource} sourceMap Source Map
111
- * @memberof module:@ui5/builder.processors
115
+ * @property {@ui5/fs/Resource} bundle Bundle resource
116
+ * @property {@ui5/fs/Resource} sourceMap Source Map
112
117
  */
113
118
 
119
+ /* eslint-disable max-len */
114
120
  /**
115
121
  * Legacy module bundler.
116
122
  *
117
123
  * @public
118
- * @alias module:@ui5/builder.processors.moduleBundler
124
+ * @function default
125
+ * @static
126
+ *
119
127
  * @param {object} parameters Parameters
120
- * @param {module:@ui5/fs.Resource[]} parameters.resources Resources
128
+ * @param {@ui5/fs/Resource[]} parameters.resources Resources
121
129
  * @param {object} parameters.options Options
122
130
  * @param {object} [parameters.options.moduleNameMapping]
123
131
  Optional mapping of resource paths to module name in order to overwrite the default determination
124
- * @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
125
- * @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
126
- * @returns {Promise<module:@ui5/builder.processors.ModuleBundlerResult[]>}
132
+ * @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition} parameters.options.bundleDefinition Module
133
+ bundle definition
134
+ * @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleOptions} [parameters.options.bundleOptions] Module
135
+ bundle options
136
+ * @returns {Promise<module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundlerResult[]>}
127
137
  * Promise resolving with module bundle resources
128
138
  */
129
- module.exports = function({resources, options: {bundleDefinition, bundleOptions, moduleNameMapping}}) {
139
+ /* eslint-enable max-len */
140
+ export default function({resources, options: {bundleDefinition, bundleOptions, moduleNameMapping}}) {
130
141
  // Apply defaults without modifying the passed object
131
142
  bundleOptions = Object.assign({}, {
132
143
  optimize: true,
@@ -177,4 +188,4 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions,
177
188
  }
178
189
  }));
179
190
  });
180
- };
191
+ }
@@ -1,14 +1,21 @@
1
- const resourceFactory = require("@ui5/fs").resourceFactory;
2
- const createIndex = require("./lib/createIndexFiles");
1
+ import {createResource} from "@ui5/fs/resourceFactory";
2
+ import createIndex from "./lib/createIndexFiles.cjs";
3
+
4
+ /**
5
+ * @public
6
+ * @module @ui5/builder/processors/jsdoc/apiIndexGenerator
7
+ */
3
8
 
4
9
  /**
5
10
  * Compiles API index resources from all <code>api.json</code> resources available in the given test resources directory
6
- * as created by the [sdkTransformer]{@link module:@ui5/builder.processors.sdkTransformer} processor.
11
+ * as created by the [sdkTransformer]{@link @ui5/builder/processors/sdkTransformer} processor.
7
12
  * The resulting index resources (e.g. <code>api-index.json</code>, <code>api-index-deprecated.json</code>,
8
13
  * <code>api-index-experimental.json</code> and <code>api-index-since.json</code>) are mainly to be used in the SDK.
9
14
  *
10
15
  * @public
11
- * @alias module:@ui5/builder.processors.apiIndexGenerator
16
+ * @function default
17
+ * @static
18
+ *
12
19
  * @param {object} parameters Parameters
13
20
  * @param {string} parameters.versionInfoPath Path to <code>sap-ui-version.json</code> resource
14
21
  * @param {string} parameters.testResourcesRootPath Path to <code>/test-resources</code> root directory in the
@@ -19,9 +26,9 @@ const createIndex = require("./lib/createIndexFiles");
19
26
  * @param {string} parameters.targetApiIndexExperimentalPath Path to create the generated API index "experimental" JSON
20
27
  * resource for
21
28
  * @param {string} parameters.targetApiIndexSincePath Path to create the generated API index "since" JSON resource for
22
- * @param {fs|module:@ui5/fs.fsInterface} parameters.fs Node fs or
23
- * custom [fs interface]{@link module:resources/module:@ui5/fs.fsInterface} to use
24
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with created resources <code>api-index.json</code>,
29
+ * @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or
30
+ * custom [fs interface]{@link module:@ui5/fs/fsInterface} to use
31
+ * @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with created resources <code>api-index.json</code>,
25
32
  * <code>api-index-deprecated.json</code>, <code>api-index-experimental.json</code> and
26
33
  * <code>api-index-since.json</code> (names depend on the supplied paths)
27
34
  */
@@ -41,11 +48,11 @@ const apiIndexGenerator = async function({
41
48
  });
42
49
 
43
50
  return Object.keys(resourceMap).map((resPath) => {
44
- return resourceFactory.createResource({
51
+ return createResource({
45
52
  path: resPath,
46
53
  string: resourceMap[resPath]
47
54
  });
48
55
  });
49
56
  };
50
57
 
51
- module.exports = apiIndexGenerator;
58
+ export default apiIndexGenerator;
@@ -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, "\\\\");
@@ -155,21 +170,18 @@ async function buildJsdoc({sourcePath, configPath}) {
155
170
  "--verbose",
156
171
  sourcePath
157
172
  ];
158
- return new Promise((resolve, reject) => {
173
+ const exitCode = await new Promise((resolve /* , reject */) => {
159
174
  const child = spawn("node", args, {
160
- stdio: ["ignore", "ignore", process.stderr]
161
- });
162
- child.on("close", function(code) {
163
- if (code === 0 || code === 1) {
164
- resolve();
165
- } else {
166
- reject(new Error(`JSDoc child process closed with code ${code}`));
167
- }
175
+ stdio: ["ignore", "ignore", "inherit"]
168
176
  });
177
+ child.on("close", resolve);
169
178
  });
179
+
180
+ if (exitCode !== 0) {
181
+ throw new Error(`JSDoc reported an error, check the log for issues (exit code: ${exitCode})`);
182
+ }
170
183
  }
171
184
 
172
- module.exports = jsdocGenerator;
173
- module.exports._generateJsdocConfig = generateJsdocConfig;
174
- module.exports._writeJsdocConfig = writeJsdocConfig;
175
- module.exports._buildJsdoc = buildJsdoc;
185
+ jsdocGenerator._generateJsdocConfig = generateJsdocConfig;
186
+ jsdocGenerator._writeJsdocConfig = writeJsdocConfig;
187
+ 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,58 @@ 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
+ if (Array.isArray(sources) && typeof librarySrcDir === "string" && typeof libraryTestDir === "string") {
993
+
994
+ // Using path.join to normalize POSIX paths to Windows paths on Windows
995
+ librarySrcDir = path.join(librarySrcDir);
996
+ libraryTestDir = path.join(libraryTestDir);
997
+
998
+ /**
999
+ * Calculate prefix to check
1000
+ *
1001
+ * Example 1:
1002
+ * - sSource: /path/to/project/src
1003
+ * - sLibrarySrcDir: src
1004
+ *
1005
+ * Prefix: /path/to/project/test-resources
1006
+ *
1007
+ * Example 2:
1008
+ * - sSource: /path/to/project/src/main/js
1009
+ * - sLibrarySrcDir: src/main/js
1010
+ *
1011
+ * Prefix: /path/to/project/src/main/test-resources
1012
+ */
1013
+ const librarySrcDirWithTestResources = replaceLastPathSegment(librarySrcDir, "test-resources");
1014
+
1015
+ for (const sourcePath of sources) {
1016
+ /**
1017
+ * Replace prefix with file system path
1018
+ *
1019
+ * Example 1:
1020
+ * - sPath: /path/to/project/test-resources/sap/test/demokit/docuindex.json
1021
+ *
1022
+ * New sPath: /path/to/project/test/sap/test/demokit/docuindex.json
1023
+ *
1024
+ * Example 2:
1025
+ * - sPath: /path/to/project/src/main/test-resources/sap/test/demokit/docuindex.json
1026
+ *
1027
+ * New sPath: /path/to/project/src/main/test/sap/test/demokit/docuindex.json
1028
+ */
1029
+ if (!sourcePath.endsWith(librarySrcDir)) {
1030
+ continue;
1031
+ }
1032
+ const libraryDir = sourcePath.substring(0, sourcePath.lastIndexOf(librarySrcDir) - 1);
1033
+ const prefix = path.join(libraryDir, librarySrcDirWithTestResources);
1034
+ if (sPath.startsWith(prefix)) {
1035
+ sPath = path.join(libraryDir, libraryTestDir, sPath.substring(prefix.length));
1036
+ break;
1037
+ }
1038
+ }
1039
+ }
1040
+
984
1041
  fs.readFile(sPath, 'utf8', (oError, oFileData) => {
985
1042
  if (!oError) {
986
1043
  oFileData = JSON.parse(oFileData);
@@ -991,7 +1048,7 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
991
1048
  });
992
1049
  }
993
1050
  }
994
- // We aways resolve as this data is not mandatory
1051
+ // We always resolve as this data is not mandatory
995
1052
  oResolve(oChainObject);
996
1053
  });
997
1054