Skip to content

Commit

Permalink
[FIX] TaskUtil: Provide framework configuration getters to custom tas…
Browse files Browse the repository at this point in the history
…ks (#580)
  • Loading branch information
RandomByte authored Feb 16, 2023
1 parent 1163821 commit 6a40927
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
6 changes: 5 additions & 1 deletion lib/build/helpers/TaskUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ class TaskUtil {
* @property {Function} getSourcePath Get the local File System path of the project's source directory
* @property {Function} getCustomConfiguration Get the project Custom Configuration
* @property {Function} isFrameworkProject Check whether the project is a UI5-Framework project
* @property {Function} getFrameworkName Get the project's framework name configuration
* @property {Function} getFrameworkVersion Get the project's framework version configuration
* @property {Function} getFrameworkDependencies Get the project's framework dependencies configuration
*/

/**
Expand Down Expand Up @@ -312,7 +315,8 @@ class TaskUtil {
bindFunctions(project, baseProjectInterface, [
"getType", "getName", "getVersion", "getNamespace",
"getRootReader", "getReader", "getRootPath", "getSourcePath",
"getCustomConfiguration", "isFrameworkProject"
"getCustomConfiguration", "isFrameworkProject", "getFrameworkName",
"getFrameworkVersion", "getFrameworkDependencies"
]);
return baseProjectInterface;
};
Expand Down
30 changes: 21 additions & 9 deletions lib/specifications/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,42 @@ class Project extends Specification {
}

/**
* Get the project's frameworkName configuration
* Get the project's framework name configuration
*
* @private
* @returns {string} FrameworkName configuration
* @public
* @returns {string} Framework name configuration, either <code>OpenUI5</code> or <code>SAPUI5</code>
*/
getFrameworkName() {
return this._config.framework?.name;
}

/**
* Get the project's frameworkVersion configuration
* Get the project's framework version configuration
*
* @private
* @returns {string} FrameworkVersion configuration
* @public
* @returns {string} Framework version configuration, e.g <code>1.110.0</code>
*/
getFrameworkVersion() {
return this._config.framework?.version;
}


/**
* Get the project's frameworkDependencies configuration
* Framework dependency entry of the project configuration.
* Also see [Framework Configuration: Dependencies]{@link https://sap.github.io/ui5-tooling/stable/pages/Configuration/#dependencies}
*
* @private
* @returns {object[]} FrameworkDependencies configuration
* @public
* @typedef {object} @ui5/project/specifications/Project~FrameworkDependency
* @property {string} name Name of the framework library. For example <code>sap.ui.core</code>
* @property {boolean} development Whether the dependency is meant for development purposes only
* @property {boolean} optional Whether the dependency should be treated as optional
*/

/**
* Get the project's framework dependencies configuration
*
* @public
* @returns {@ui5/project/specifications/Project~FrameworkDependency[]} Framework dependencies configuration
*/
getFrameworkDependencies() {
return this._config.framework?.libraries || [];
Expand Down
13 changes: 12 additions & 1 deletion test/lib/build/helpers/TaskUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ test("getInterface: specVersion 3.0", (t) => {
getSourcePath: () => "sourcePath",
getCustomConfiguration: () => "customConfiguration",
isFrameworkProject: () => "isFrameworkProject",
getFrameworkVersion: () => "frameworkVersion",
getFrameworkName: () => "frameworkName",
getFrameworkDependencies: () => ["frameworkDependencies"],
hasBuildManifest: () => "hasBuildManifest", // Should not be exposed
getFrameworkVersion: () => "frameworkVersion", // Should not be exposed
});
const getDependenciesStub = sinon.stub().returns(["dep a", "dep b"]);

Expand Down Expand Up @@ -462,6 +464,9 @@ test("getInterface: specVersion 3.0", (t) => {
"getSourcePath",
"getCustomConfiguration",
"isFrameworkProject",
"getFrameworkName",
"getFrameworkVersion",
"getFrameworkDependencies",
], "Correct methods are provided");

t.is(interfacedProject.getType(), "type", "getType function is bound correctly");
Expand All @@ -476,6 +481,12 @@ test("getInterface: specVersion 3.0", (t) => {
"getCustomConfiguration function is bound correctly");
t.is(interfacedProject.isFrameworkProject(), "isFrameworkProject",
"isFrameworkProject function is bound correctly");
t.is(interfacedProject.getFrameworkVersion(), "frameworkVersion",
"getFrameworkVersion function is bound correctly");
t.is(interfacedProject.getFrameworkName(), "frameworkName",
"getFrameworkName function is bound correctly");
t.deepEqual(interfacedProject.getFrameworkDependencies(), ["frameworkDependencies"],
"getFrameworkDependencies function is bound correctly");

// getDependencies
t.deepEqual(interfacedTaskUtil.getDependencies("pony"), ["dep a", "dep b"],
Expand Down

0 comments on commit 6a40927

Please sign in to comment.