How to use the @ui5/fs.resourceFactory.createAdapter 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 / builder / builder.js View on Github external
async build({
		tree, destPath, cleanDest = false,
		buildDependencies = false, includedDependencies = [], excludedDependencies = [],
		dev = false, selfContained = false, jsdoc = false,
		includedTasks = [], excludedTasks = [], devExcludeProject = []
	}) {
		const startTime = process.hrtime();
		log.info(`Building project ${tree.metadata.name}` + (buildDependencies ? "" : " not") +
			" including dependencies..." + (dev ? " [dev mode]" : ""));
		log.verbose(`Building to ${destPath}...`);

		const selectedTasks = composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks});

		const fsTarget = resourceFactory.createAdapter({
			fsBasePath: destPath,
			virBasePath: "/"
		});

		const buildContext = new BuildContext();
		const cleanupSigHooks = registerCleanupSigHooks(buildContext);

		const projects = {}; // Unique project index to prevent building the same project multiple times
		const projectWriters = {}; // Collection of memory adapters of already built libraries
		function projectFilter(project) {
			function projectMatchesAny(deps) {
				return deps.some((dep) => dep instanceof RegExp ?
					dep.test(project.metadata.name) : dep === project.metadata.name);
			}

			// if everything is included, this overrules exclude lists
github SAP / ui5-builder / lib / tasks / jsdoc / generateJsdoc.js View on Github external
async function writeDependencyApisToDir({dependencies, targetPath}) {
	const depApis = await dependencies.byGlob("/test-resources/**/designtime/api.json");

	// Clone resources before changing their path
	const apis = await Promise.all(depApis.map((resource) => resource.clone()));

	for (let i = 0; i < apis.length; i++) {
		apis[i].setPath(`/api-${i}.json`);
	}

	const fsTarget = resourceFactory.createAdapter({
		fsBasePath: targetPath,
		virBasePath: "/"
	});
	await Promise.all(apis.map((resource) => fsTarget.write(resource)));
	return apis.length;
}
github SAP / ui5-builder / lib / tasks / jsdoc / generateJsdoc.js View on Github external
async function writeResourcesToDir({workspace, pattern, targetPath}) {
	const fsTarget = resourceFactory.createAdapter({
		fsBasePath: targetPath,
		virBasePath: "/resources/"
	});

	let allResources;
	if (workspace.byGlobSource) { // API only available on duplex collections
		allResources = await workspace.byGlobSource(pattern);
	} else {
		allResources = await workspace.byGlob(pattern);
	}

	// write all resources to the tmp folder
	await Promise.all(allResources.map((resource) => fsTarget.write(resource)));
	return allResources.length;
}