Skip to content

Commit

Permalink
[INTERNAL] AbstractReader: Remove obsolete filter and flatten methods
Browse files Browse the repository at this point in the history
They have been moved to resourceFactory in
#438

All known consumers have been updated accordingly.
  • Loading branch information
RandomByte committed Nov 30, 2022
1 parent fab0090 commit ee9cfb8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
40 changes: 0 additions & 40 deletions lib/AbstractReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,46 +82,6 @@ class AbstractReader {
});
}

/**
* Create a [Filter-Reader]{@link @ui5/fs/readers/Filter} from the current reader.
*
* @public
* @param {@ui5/fs/readers/Filter~callback} callback
* Filter function. Will be called for every resource passed through this reader.
* @returns {Promise<@ui5/fs/readers/Filter>} Promise resolving with filter instance
*/
async filter(callback) {
console.warn("DEPRECATED CALL TO AbstractReader#filter - THIS FUNCTION WILL BE REMOVED IN THE NEXT RELEASE");
const {default: Filter} = await import("./readers/Filter.js");
return new Filter({
reader: this,
callback
});
}

/**
* Create a [Link-Reader]{@link @ui5/fs/readers/Link} where all requests are prefixed with
* <code>/resources/<namespace></code>.
*
* This simulates "flat" resource access, which is for example common for projects of type
* "application".
*
* @public
* @param {string} namespace Project namespace
* @returns {Promise<@ui5/fs/readers/Link>} Promise resolving with reader instance
*/
async flatten(namespace) {
console.warn("DEPRECATED CALL TO AbstractReader#flatten - THIS FUNCTION WILL BE REMOVED IN THE NEXT RELEASE");
const {default: Link} = await import("./readers/Link.js");
return new Link({
reader: this,
pathMapping: {
linkPath: `/`,
targetPath: `/resources/${namespace}/`
}
});
}

/**
* Locates resources by one or more glob patterns.
*
Expand Down
30 changes: 0 additions & 30 deletions test/lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,6 @@ test("Get resource from application.a (/index.html) and write it to /dest/ using
});
});

test("Legacy: Filter resources", async (t) => {
const source = createAdapter({
fsBasePath: "./test/fixtures/application.a/webapp",
virBasePath: "/app/"
});
const filteredSource = await source.filter((resource) => {
return resource.getPath().endsWith(".js");
});
const sourceResources = await source.byGlob("**");
t.is(sourceResources.length, 2, "Found two resources in source");

const resources = await filteredSource.byGlob("**");

t.is(resources.length, 1, "Found exactly one resource via filter");
t.is(resources[0].getPath(), "/app/test.js", "Found correct resource");
});

test("Legacy: Flatten resources", async (t) => {
const source = createAdapter({
fsBasePath: "./test/fixtures/application.a/webapp",
virBasePath: "/resources/app/"
});
const transformedSource = await source.flatten("app");

const resources = await transformedSource.byGlob("**/*.js");
t.is(resources.length, 1, "Found one resource via transformer");
t.is(resources[0].getPath(), "/test.js", "Found correct resource");
});


test("Filter resources", async (t) => {
const source = createAdapter({
fsBasePath: "./test/fixtures/application.a/webapp",
Expand Down

0 comments on commit ee9cfb8

Please sign in to comment.