How to use the @ui5/fs.resourceFactory.createResource 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 / processors / bundlers / manifestBundler.js View on Github external
const zip = new yazl.ZipFile();
		const rBasePath = new RegExp(`^/resources/${options.namespace}/`);
		archiveContent.forEach((content, path) => {
			if (!rBasePath.test(path)) {
				log.verbose(`Not bundling resource with path ${path} since it is not based on path ` +
					`/resources/${options.namespace}/`);
				return;
			}
			// Remove base path. Absolute paths are not allowed in ZIP files
			const normalizedPath = path.replace(rBasePath, "");
			zip.addBuffer(content, normalizedPath);
		});
		zip.end();

		const pathPrefix = "/resources/" + options.namespace + "/";
		const res = resourceFactory.createResource({
			path: pathPrefix + options.bundleName,
			stream: zip.outputStream
		});
		resolve([res]);
	}));
};
github SAP / ui5-builder / lib / processors / versionInfoGenerator.js View on Github external
name: options.rootProjectName,
		version: options.rootProjectVersion, // TODO: insert current application version here
		buildTimestamp: buildTimestamp,
		scmRevision: "", // TODO: insert current application scm revision here
		// gav: "", // TODO: insert current application id + version here
		libraries: options.libraryInfos.map(function(libraryInfo) {
			return {
				name: libraryInfo.name,
				version: libraryInfo.version,
				buildTimestamp: buildTimestamp,
				scmRevision: "" // TODO: insert current library scm revision here
			};
		})
	};

	return [resourceFactory.createResource({
		path: "/resources/sap-ui-version.json",
		string: JSON.stringify(versionJson, null, "\t")
	})];
};
github SAP / ui5-builder / lib / processors / jsdoc / apiIndexGenerator.js View on Github external
return Object.keys(resourceMap).map((resPath) => {
		return resourceFactory.createResource({
			path: resPath,
			string: resourceMap[resPath]
		});
	});
};
github SAP / ui5-builder / lib / processors / bundlers / flexChangesBundler.js View on Github external
})).then((changesContent) => {
		const nNumberOfChanges = changesContent.length;
		log.info("Changes collected. Number of changes: " + nNumberOfChanges);
		const result = [];
		if (nNumberOfChanges > 0) {
			changesContent = sortAndStringifyInFlexFormat(changesContent);
			result.push(resourceFactory.createResource({
				path: `${options.pathPrefix}/changes/${bundleName}`,
				string: changesContent
			}));
		}
		return result;
	});
};
github SAP / ui5-builder / lib / tasks / generateCachebusterInfo.js View on Github external
.then(async (resources) => {
			const cachebusterInfo = {};
			const regex = new RegExp(`^/resources/${options.namespace}/`);
			const signer = getSigner(options.signatureType);

			await Promise.all(resources.map(async (resource) => {
				const normalizedPath = resource.getPath().replace(regex, "");
				cachebusterInfo[normalizedPath] = await signer(resource);
			}));
			const cachebusterInfoResource = resourceFactory.createResource({
				path: `/resources/${options.namespace}/sap-ui-cachebuster-info.json`,
				string: JSON.stringify(cachebusterInfo, null, 2)
			});
			return workspace.write(cachebusterInfoResource);
		});
};
github SAP / ui5-builder / lib / processors / jsdoc / sdkTransformer.js View on Github external
const sdkTransformer = async function({
	apiJsonPath, dotLibraryPath, dependencyApiJsonPaths, targetApiJsonPath, fs} = {}
) {
	if (!apiJsonPath || !dotLibraryPath || !targetApiJsonPath || !dependencyApiJsonPaths || !fs) {
		throw new Error("[sdkTransformer]: One or more mandatory parameters not provided");
	}
	const fakeTargetPath = "/ignore/this/path/resource/will/be/returned";
	const apiJsonContent = await transformer(apiJsonPath, fakeTargetPath, dotLibraryPath, dependencyApiJsonPaths, {
		fs,
		returnOutputFiles: true
	});
	return [resourceFactory.createResource({
		path: targetApiJsonPath,
		string: apiJsonContent
	})];
};