Skip to content

Commit

Permalink
[INTERNAL] TaskUtil: Update JSDoc
Browse files Browse the repository at this point in the history
State lowest supported specVersion per function
  • Loading branch information
RandomByte committed Aug 11, 2020
1 parent 998b22a commit 7821e51
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
45 changes: 34 additions & 11 deletions lib/tasks/TaskUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Convenience functions for UI5 Builder tasks.
* An instance of this class is passed to every standard UI5 Builder task that requires it.
*
* Custom tasks that define a specification version >= 2.2 will receive an interface
* Custom tasks that define a Specification Version >= 2.2 will receive an interface
* to an instance of this class when called.
* The set of available functions on that interface depends on the specification
* version defined for the extension.
Expand All @@ -12,7 +12,9 @@
*/
class TaskUtil {
/**
* Standard Build Tags. See UI5 Tooling RFC 0008 for details.
* Standard Build Tags. See UI5 Tooling
* [RFC 0008]{@link https://github.com/SAP/ui5-tooling/blob/master/rfcs/0008-resource-tagging-during-build.md}
* for details.
*
* @public
* @typedef {object} module:@ui5/builder.tasks.TaskUtil~StandardBuildTags
Expand All @@ -21,12 +23,12 @@ class TaskUtil {
*/

/**
* Constructor
* Since <code>@ui5/builder.builder.ProjectBuildContext</code> is a private class, TaskUtil must not be
* instantiated by modules other than @ui5/builder itself.
*
* @param {object} parameters
* @param {module:@ui5/builder.builder.ProjectBuildContext} parameters.projectBuildContext ProjectBuildContext
* @public
* @hideconstructor
*/
constructor({projectBuildContext}) {
this._projectBuildContext = projectBuildContext;
Expand All @@ -43,6 +45,10 @@ class TaskUtil {
* resource instance. For two resource instances with the same path, the same tag value is returned.
* If the path of a resource is changed, any tag information previously stored for that resource is lost.
*
* </br></br>
* This method is only available to custom task extensions defining
* <b>Specification Version 2.2 and above</b>.
*
* @param {module:@ui5/fs.Resource} resource Resource the tag should be stored for
* @param {string} tag Name of the tag.
* Currently only the [STANDARD_TAGS]{@link module:@ui5/builder.tasks.TaskUtil#STANDARD_TAGS} are allowed
Expand All @@ -56,9 +62,13 @@ class TaskUtil {
/**
* Retrieves the value for a stored tag. If no value is stored, <code>undefined</code> is returned.
*
* </br></br>
* This method is only available to custom task extensions defining
* <b>Specification Version 2.2 and above</b>.
*
* @param {module:@ui5/fs.Resource} resource Resource the tag should be retrieved for
* @param {string} tag Name of the tag
* @returns {string|boolean|integer} Tag value for the given resource.
* @returns {string|boolean|integer|undefined} Tag value for the given resource.
* <code>undefined</code> if no value is available
* @public
*/
Expand All @@ -70,6 +80,10 @@ class TaskUtil {
* Clears the value of a tag stored for the given resource's path.
* It's like the tag was never set for that resource.
*
* </br></br>
* This method is only available to custom task extensions defining
* <b>Specification Version 2.2 and above</b>.
*
* @param {module:@ui5/fs.Resource} resource Resource the tag should be cleared for
* @param {string} tag Tag
* @public
Expand All @@ -81,16 +95,25 @@ class TaskUtil {
/**
* Check whether the project currently being build is the root project.
*
* @returns {boolean} True if the currently built project is the root project
* </br></br>
* This method is only available to custom task extensions defining
* <b>Specification Version 2.2 and above</b>.
*
* @returns {boolean} <code>true</code> if the currently built project is the root project
* @public
*/
isRootProject() {
return this._projectBuildContext.isRootProject();
}

/**
* Register a function that must be executed once the build is finished. This can be used to for example
* Register a function that must be executed once the build is finished. This can be used to, for example,
* cleanup files temporarily created on the file system. If the callback returns a Promise, it will be waited for.
* It will also be executed in cases where the build has failed or has been aborted.
*
* </br></br>
* This method is only available to custom task extensions defining
* <b>Specification Version 2.2 and above</b>.
*
* @param {Function} callback Callback to register. If it returns a Promise, it will be waited for
* @public
Expand All @@ -101,10 +124,10 @@ class TaskUtil {

/**
* Get an interface to an instance of this class that only provides those functions
* that are supported by the given custom middleware extension specification version.
* that are supported by the given custom task extension Specification Version.
*
* @param {string} specVersion Specification Version of custom middleware extension
* @returns {object} An object with bound instance methods supported by the given specification version
* @param {string} specVersion Specification Version of custom task extension
* @returns {object} An object with bound instance methods supported by the given Specification Version
*/
getInterface(specVersion) {
if (["0.1", "1.0", "1.1", "2.0", "2.1"].includes(specVersion)) {
Expand All @@ -123,7 +146,7 @@ class TaskUtil {
case "2.2":
return baseInterface;
default:
throw new Error(`TaskUtil: Unknown or unsupported specification version ${specVersion}`);
throw new Error(`TaskUtil: Unknown or unsupported Specification Version ${specVersion}`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/types/AbstractBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class AbstractBuilder {
{Object} parameters Parameters
{module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
{module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
{Object} taskUtil Specification Version dependent interface to a
{Object} parameters.taskUtil Specification Version dependent interface to a
[TaskUtil]{@link module:@ui5/builder.tasks.TaskUtil} instance
{Object} parameters.options Options
{string} parameters.options.projectName Project name
Expand Down
4 changes: 2 additions & 2 deletions test/lib/tasks/TaskUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test("getInterface: specVersion undefined", async (t) => {
taskUtil.getInterface();
});

t.is(err.message, "TaskUtil: Unknown or unsupported specification version undefined",
t.is(err.message, "TaskUtil: Unknown or unsupported Specification Version undefined",
"Throw with correct error message");
});

Expand All @@ -171,6 +171,6 @@ test("getInterface: specVersion unknown", async (t) => {
taskUtil.getInterface("1.5");
});

t.is(err.message, "TaskUtil: Unknown or unsupported specification version 1.5",
t.is(err.message, "TaskUtil: Unknown or unsupported Specification Version 1.5",
"Throw with correct error message");
});

0 comments on commit 7821e51

Please sign in to comment.