-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
769f201
commit 652d0cd
Showing
10 changed files
with
160 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const resourceFactory = require("@ui5/fs").resourceFactory; | ||
const createIndex = require("./lib/create-api-index"); | ||
|
||
/** | ||
* Compiles API index resources from all <code>api.json</code> resources available in the given test resources directory | ||
* as created by the [sdkTransformer]{@link module:@ui5/builder.processors.sdkTransformer} processor. | ||
* The resulting index resources (e.g. <code>api-index.json</code>, <code>api-index-deprecated.json</code>, | ||
* <code>api-index-experimental.json</code> and <code>api-index-since.json</code>) are mainly to be used in the SDK. | ||
* | ||
* @public | ||
* @alias module:@ui5/builder.processors.apiIndexGenerator | ||
* @param {Object} parameters Parameters | ||
* @param {string} parameters.versionInfoFile Path to <code>sap-ui-version.json</code> resource | ||
* @param {string} parameters.unpackedTestresourcesRoot Path to <code>/test-resources</code> root directory in the | ||
* given fs | ||
* @param {string} parameters.targetFile Path to create the generated API index JSON resource for | ||
* @param {string} parameters.targetFileDeprecated Path to create the generated API index "deprecated" JSON resource for | ||
* @param {string} parameters.targetFileExperimental Path to create the generated API index "experimental" JSON | ||
* resource for | ||
* @param {string} parameters.targetFileSince Path to create the generated API index "since" JSON resource for | ||
* @param {fs|module:@ui5/fs.fsInterface} parameters.fs Node fs or | ||
* custom [fs interface]{@link module:resources/module:@ui5/fs.fsInterface} to use | ||
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with created resources <code>api-index.json</code>, | ||
* <code>api-index-deprecated.json</code>, <code>api-index-experimental.json</code> and | ||
* <code>api-index-since.json</code> (names depend on the supplied paths) | ||
*/ | ||
const apiIndexGenerator = async function({ | ||
versionInfoFile, unpackedTestresourcesRoot, targetFile, targetFileDeprecated, targetFileExperimental, | ||
targetFileSince, fs | ||
}) { | ||
if (!versionInfoFile || !unpackedTestresourcesRoot || !targetFile || !targetFileDeprecated || | ||
!targetFileExperimental || !targetFileSince || !fs) { | ||
throw new Error("[apiIndexGenerator]: One or more mandatory parameters not provided"); | ||
} | ||
|
||
const resourceMap = await createIndex(versionInfoFile, unpackedTestresourcesRoot, targetFile, | ||
targetFileDeprecated, targetFileExperimental, targetFileSince, { | ||
fs, | ||
returnOutputFiles: true | ||
}); | ||
|
||
return Object.keys(resourceMap).map((resPath) => { | ||
return resourceFactory.createResource({ | ||
path: resPath, | ||
string: resourceMap[resPath] | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = apiIndexGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const ui5Fs = require("@ui5/fs"); | ||
const ReaderCollectionPrioritized = ui5Fs.ReaderCollectionPrioritized; | ||
const fsInterface = ui5Fs.fsInterface; | ||
const apiIndexGenerator = require("../../processors/jsdoc/apiIndexGenerator"); | ||
|
||
/** | ||
* Compiles an api-index.json resource from all available api.json resources as created by the | ||
* [executeJsdocSdkTransformation]{@link module:@ui5/builder.tasks.executeJsdocSdkTransformation} task. | ||
* The resulting api-index.json resource is mainly to be used in the SDK. | ||
* | ||
* @public | ||
* @alias module:@ui5/builder.tasks.generateApiIndex | ||
* @param {Object} parameters Parameters | ||
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files | ||
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files | ||
* @param {Object} parameters.options Options | ||
* @param {string} parameters.options.projectName Project name | ||
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written | ||
*/ | ||
module.exports = async function({workspace, dependencies, options}) { | ||
if (!options || !options.projectName) { | ||
throw new Error("[generateApiIndex]: One or more mandatory options not provided"); | ||
} | ||
const combo = new ReaderCollectionPrioritized({ | ||
name: `generateApiIndex - workspace + dependencies: ${options.projectName}`, | ||
readers: [workspace, dependencies] | ||
}); | ||
|
||
const versionInfoFile = "/resources/sap-ui-version.json"; | ||
const unpackedTestresourcesRoot = "/test-resources"; | ||
const targetFile = "/docs/api/api-index.json"; | ||
const targetFileDeprecated = "/docs/api/api-index-deprecated.json"; | ||
const targetFileExperimental = "/docs/api/api-index-experimental.json"; | ||
const targetFileSince = "/docs/api/api-index-since.json"; | ||
|
||
const createdResources = await apiIndexGenerator({ | ||
versionInfoFile, | ||
unpackedTestresourcesRoot, | ||
targetFile, | ||
targetFileDeprecated, | ||
targetFileExperimental, | ||
targetFileSince, | ||
fs: fsInterface(combo), | ||
}); | ||
|
||
await Promise.all(createdResources.map((resource) => { | ||
return workspace.write(resource); | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters