How to use the @ui5/fs.ReaderCollectionPrioritized function in @ui5/fs

To help you get started, we’ve selected a few @ui5/fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / ui5-builder / lib / tasks / generateLibraryManifest.js View on Github external
module.exports = function({workspace, dependencies, options}) {
	const combo = new ReaderCollectionPrioritized({
		name: `libraryManifestGenerator - prioritize workspace over dependencies: ${options.projectName}`,
		readers: [workspace, dependencies]
	});
	// Note:
	// *.library files are needed to identify libraries
	// *.json files are needed to avoid overwriting them
	// *.js files are needed to identify nested components
	// *.less, *.css, *.theming and *.theme files are needed to identify supported themes
	// *.properties to identify existence of i18n bundles (e.g. messagebundle.properties)
	return combo.byGlob("/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
		// Find all libraries and create a manifest.json file
		return workspace.byGlob("/resources/**/.library").then((libraryIndicatorResources) => {
			if (libraryIndicatorResources.length < 1) {
				// No library found - nothing to do
				log.verbose(`Could not find a ".library" file for project ${options.projectName}. Skipping library manifest generation.`);
				return;
github SAP / ui5-builder / lib / tasks / bundlers / generateLibraryPreload.js View on Github external
module.exports = function({workspace, dependencies, options}) {
	const combo = new ReaderCollectionPrioritized({
		name: `libraryBundler - prioritize workspace over dependencies: ${options.projectName}`,
		readers: [workspace, dependencies]
	});

	return combo.byGlob("/**/*.{js,json,xml,html,properties,library}").then((resources) => {
		// Find all libraries and create a library-preload.js bundle

		let p;

		// Create sap-ui-core.js
		// TODO: move to config of actual core project
		if (options.projectName === "sap.ui.core") {
			// Filter out sap-ui-core.js from further uglification/replacement processors
			//	to prevent them from overwriting it
			resources = resources.filter((resource) => {
				return resource.getPath() !== "/resources/sap-ui-core.js";
github SAP / ui5-builder / lib / tasks / buildThemes.js View on Github external
module.exports = function({workspace, dependencies, options}) {
	const combo = new ReaderCollectionPrioritized({
		name: `theme - prioritize workspace over dependencies: ${options.projectName}`,
		readers: [workspace, dependencies]
	});

	const promises = [workspace.byGlob(options.inputPattern)];
	if (options.librariesPattern) {
		// If a librariesPattern is given
		//	we will use it to reduce the set of libraries a theme will be built for
		promises.push(combo.byGlob(options.librariesPattern));
	}

	const compress = options.compress === undefined ? true : options.compress;

	return Promise.all(promises).then(([allResources, availableLibraries]) => {
		if (!availableLibraries || availableLibraries.length === 0) {
			// Try to build all themes
github SAP / ui5-builder / lib / tasks / bundlers / generateComponentPreload.js View on Github external
module.exports = function({workspace, dependencies, options}) {
	const combo = new ReaderCollectionPrioritized({
		name: `generateComponentPreload - prioritize workspace over dependencies: ${options.projectName}`,
		readers: [workspace, dependencies]
	});

	return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}")
		.then(async (resources) => {
			let namespaces = [];
			if (options.paths) {
				namespaces = await Promise.all(options.paths.map(async (componentPath) => {
					const components = await combo.byGlob("/resources/" + componentPath);
					return components.map((component) => {
						return path.dirname(component.getPath()).replace(/^\/resources\//i, "");
					});
				}));
			}
			if (options.namespaces) {
github SAP / ui5-builder / lib / tasks / bundlers / generateBundle.js View on Github external
module.exports = function({workspace, dependencies, options}) {
	const combo = new ReaderCollectionPrioritized({
		name: `libraryBundler - prioritize workspace over dependencies: ${options.projectName}`,
		readers: [workspace, dependencies]
	});

	return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}").then((resources) => {
		return moduleBundler({
			options: {
				bundleDefinition: options.bundleDefinition,
				bundleOptions: options.bundleOptions
			},
			resources
		}).then((bundles) => {
			bundles.forEach((bundle) => {
				workspace.write(bundle);
			});
		});