Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getHref(filePath, extension, pathModule) {
let webContextPath;
if (project.jar.supported) {
webContextPath = project.jar.webContextPath;
} else {
const bnd = fs
.readFileSync(project.dir.join('bnd.bnd').asNative)
.toString();
const lines = bnd.split('\n');
const webContextPathLine = lines.find(line =>
line.startsWith('Web-ContextPath:')
);
webContextPath = webContextPathLine.substring(16).trim();
}
project.sources
export default function() {
const liferayDirPath = cfg.getLiferayDir();
const outputDir = project.jar.outputDir;
const jarName = project.jar.outputFilename;
fs.copyFileSync(
outputDir.join(jarName).asNative,
path.join(liferayDirPath, 'osgi', 'modules', jarName)
);
console.log(`Deployed ${jarName} to ${liferayDirPath}`);
}
export default function() {
const liferayDirPath = cfg.getLiferayDir();
const outputDir = project.jar.outputDir;
const jarName = project.jar.outputFilename;
fs.copyFileSync(
outputDir.join(jarName).asNative,
path.join(liferayDirPath, 'osgi', 'modules', jarName)
);
console.log(`Deployed ${jarName} to ${liferayDirPath}`);
}
function getPortletInstanceConfigurationJson() {
if (!project.jar.configurationFile) {
return undefined;
}
const filePath = project.jar.configurationFile.asNative;
const configurationJson = fs.readJSONSync(filePath);
if (
!configurationJson.portletInstance ||
!configurationJson.portletInstance.fields ||
Object.keys(configurationJson.portletInstance.fields).length == 0
) {
return undefined;
}
return configurationJson.portletInstance;
}
const minimumExtenderVersion = getMinimumExtenderVersion();
if (minimumExtenderVersion) {
filter =
`(&` +
`(osgi.extender=liferay.frontend.js.portlet)` +
`(version>=${minimumExtenderVersion})` +
`)`;
} else {
filter = `(osgi.extender=liferay.frontend.js.portlet)`;
}
contents += `Require-Capability: osgi.extender;filter:="${filter}"\n`;
}
Object.entries(project.jar.customManifestHeaders).forEach(
([key, value]) => {
contents += `${key}: ${value}\n`;
}
);
zip.folder('META-INF').file('MANIFEST.MF', contents);
}
const jsFilePaths = fs
.readdirSync(jsDirPath)
.filter(jsFilePath => jsFilePath.endsWith('.js'));
const jsRuntimeFilePath = jsFilePaths.find(jsFilePath =>
jsFilePath.startsWith('runtime')
);
renderer.render('index.js', {
jsFiles: [
...jsFilePaths.filter(jsFile => jsFile !== jsRuntimeFilePath),
jsRuntimeFilePath,
],
pkgJson,
webContextPath: project.jar.webContextPath,
});
}
const minimumExtenderVersion = getMinimumExtenderVersion();
if (minimumExtenderVersion) {
filter =
`(&` +
`(osgi.extender=liferay.frontend.js.portlet)` +
`(version>=${minimumExtenderVersion})` +
`)`;
} else {
filter = `(osgi.extender=liferay.frontend.js.portlet)`;
}
contents += `Require-Capability: osgi.extender;filter:="${filter}"\n`;
}
Object.entries(project.jar.customManifestHeaders).forEach(
([key, value]) => {
contents += `${key}: ${value}\n`;
}
);
zip.folder('META-INF').file('MANIFEST.MF', contents);
}
const matches = regexp.exec(content);
if (!matches) {
return;
}
log.info(
'adapt-static-urls',
`Adapted ${matches.length} occurrences of URL '${filePosixPath}'`
);
modifiedContent = modifiedContent.replace(
regexp,
(prependSlash ? '/' : '') +
`o${project.jar.webContextPath}/${prefix}${filePosixPath}`
);
});
.then(() => (project.jar.supported ? createJar() : undefined))
.then(() => {