Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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]);
}));
};
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")
})];
};
return Object.keys(resourceMap).map((resPath) => {
return resourceFactory.createResource({
path: resPath,
string: resourceMap[resPath]
});
});
};
})).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;
});
};
.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);
});
};
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
})];
};