Skip to content

Commit

Permalink
[BREAKING] Run 'generateThemeDesignerResources' only on framework libs
Browse files Browse the repository at this point in the history
The generateThemeDesignerResources task is currently only relevant for
framework libraries as those libraries are supported by SAP Theme Designer.

Other libraries are not expected to require the task, so it is skipped.
  • Loading branch information
matz3 committed Jan 11, 2023
1 parent 5498481 commit e4bb108
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 40 deletions.
14 changes: 8 additions & 6 deletions lib/build/definitions/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ export default function({project, taskUtil, getTask}) {
}
});

tasks.set("generateThemeDesignerResources", {
requiresDependencies: true,
options: {
version: project.getVersion()
}
});
if (project.isFrameworkProject()) {
tasks.set("generateThemeDesignerResources", {
requiresDependencies: true,
options: {
version: project.getVersion()
}
});
}

tasks.set("generateResourcesJson", {
requiresDependencies: true
Expand Down
14 changes: 8 additions & 6 deletions lib/build/definitions/themeLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ export default function({project, taskUtil, getTask}) {
}
});

tasks.set("generateThemeDesignerResources", {
requiresDependencies: true,
options: {
version: project.getVersion()
}
});
if (project.isFrameworkProject()) {
tasks.set("generateThemeDesignerResources", {
requiresDependencies: true,
options: {
version: project.getVersion()
}
});
}

tasks.set("generateResourcesJson", {requiresDependencies: true});
return tasks;
Expand Down
50 changes: 49 additions & 1 deletion test/lib/build/TaskRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function getMockProject(type) {
getCachebusterSignatureType: noop,
getCustomTasks: () => [],
hasBuildManifest: () => false,
getWorkspace: () => "workspace"
getWorkspace: () => "workspace",
isFrameworkProject: () => false
};
}

Expand Down Expand Up @@ -224,6 +225,34 @@ test("_initTasks: Project of type 'library'", async (t) => {
});
await taskRunner._initTasks();

t.deepEqual(taskRunner._taskExecutionOrder, [
"escapeNonAsciiCharacters",
"replaceCopyright",
"replaceVersion",
"replaceBuildtime",
"generateJsdoc",
"executeJsdocSdkTransformation",
"minify",
"generateLibraryManifest",
"generateComponentPreload",
"generateLibraryPreload",
"generateBundle",
"buildThemes",
"generateResourcesJson"
], "Correct standard tasks");
});

test("_initTasks: Project of type 'library' (framework project)", async (t) => {
const {graph, taskUtil, taskRepository, TaskRunner} = t.context;

const project = getMockProject("library");
project.isFrameworkProject = () => true;

const taskRunner = new TaskRunner({
project, graph, taskUtil, taskRepository, log, buildConfig
});
await taskRunner._initTasks();

t.deepEqual(taskRunner._taskExecutionOrder, [
"escapeNonAsciiCharacters",
"replaceCopyright",
Expand All @@ -249,6 +278,25 @@ test("_initTasks: Project of type 'theme-library'", async (t) => {
});
await taskRunner._initTasks();

t.deepEqual(taskRunner._taskExecutionOrder, [
"replaceCopyright",
"replaceVersion",
"buildThemes",
"generateResourcesJson"
], "Correct standard tasks");
});

test("_initTasks: Project of type 'theme-library' (framework project)", async (t) => {
const {graph, taskUtil, taskRepository, TaskRunner} = t.context;

const project = getMockProject("theme-library");
project.isFrameworkProject = () => true;

const taskRunner = new TaskRunner({
project, graph, taskUtil, taskRepository, log, buildConfig
});
await taskRunner._initTasks();

t.deepEqual(taskRunner._taskExecutionOrder, [
"replaceCopyright",
"replaceVersion",
Expand Down
37 changes: 22 additions & 15 deletions test/lib/build/definitions/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function getMockProject() {
getCachebusterSignatureType: () => "PONY",
getJsdocExcludes: () => [],
getCustomTasks: emptyarray,
isFrameworkProject: () => false
};
}

Expand Down Expand Up @@ -113,11 +114,6 @@ test("Standard build", async (t) => {
cssVariables: undefined
}
},
generateThemeDesignerResources: {
requiresDependencies: true, options: {
version: "version"
}
},
generateResourcesJson: {
requiresDependencies: true
}
Expand Down Expand Up @@ -154,6 +150,27 @@ test("Standard build", async (t) => {
"taskUtil#getBuildOption got called with correct argument");
});

test("Standard build (framework project)", (t) => {
const {project, taskUtil, getTask} = t.context;

project.isFrameworkProject = () => true;

const generateJsdocTaskStub = sinon.stub();
getTask.returns({
task: generateJsdocTaskStub
});

const tasks = library({
project, taskUtil, getTask
});

t.deepEqual(tasks.get("generateThemeDesignerResources"), {
requiresDependencies: true, options: {
version: "version"
}
});
});

test("Standard build with legacy spec version", (t) => {
const {project, taskUtil, getTask} = t.context;
project.getSpecVersion = () => {
Expand Down Expand Up @@ -224,11 +241,6 @@ test("Standard build with legacy spec version", (t) => {
cssVariables: undefined
}
},
generateThemeDesignerResources: {
requiresDependencies: true, options: {
version: "version"
}
},
generateResourcesJson: {
requiresDependencies: true
}
Expand Down Expand Up @@ -349,11 +361,6 @@ test("Custom bundles", async (t) => {
cssVariables: undefined
}
},
generateThemeDesignerResources: {
requiresDependencies: true, options: {
version: "version"
}
},
generateResourcesJson: {
requiresDependencies: true
}
Expand Down
29 changes: 17 additions & 12 deletions test/lib/build/definitions/themeLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function getMockProject() {
getBundles: emptyarray,
getCachebusterSignatureType: () => "PONY",
getCustomTasks: emptyarray,
isFrameworkProject: () => false
};
}

Expand Down Expand Up @@ -69,12 +70,6 @@ test("Standard build", (t) => {
cssVariables: undefined
}
},
generateThemeDesignerResources: {
requiresDependencies: true,
options: {
version: "version"
}
},
generateResourcesJson: {
requiresDependencies: true
}
Expand All @@ -85,6 +80,22 @@ test("Standard build", (t) => {
"taskUtil#getBuildOption got called with correct argument");
});

test("Standard build (framework project)", (t) => {
const {project, taskUtil, getTask} = t.context;

project.isFrameworkProject = () => true;

const tasks = themeLibrary({
project, taskUtil, getTask
});

t.deepEqual(tasks.get("generateThemeDesignerResources"), {
requiresDependencies: true, options: {
version: "version"
}
});
});

test("Standard build for non root project", (t) => {
const {project, taskUtil, getTask} = t.context;
taskUtil.isRootProject.returns(false);
Expand Down Expand Up @@ -115,12 +126,6 @@ test("Standard build for non root project", (t) => {
cssVariables: undefined
}
},
generateThemeDesignerResources: {
requiresDependencies: true,
options: {
version: "version"
}
},
generateResourcesJson: {
requiresDependencies: true
}
Expand Down

0 comments on commit e4bb108

Please sign in to comment.