Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getDependency(fromPath, relativeParent, srcPath, nodeModulesList, fromWithinModule, requestedBy, isLazy, bundleName, rootAlias, triedToCorrectPath, doNotAdd) {
const dependencies = {};
const requestedByRelativeToSrc = path.relative(srcPath, requestedBy);
let split = requestedByRelativeToSrc.split(pathSep);
if (split[0] == 'node_modules') {
// handle edge case when adding htmlCounterpart
nodeModulesList = nodeModulesList.concat([path.join(srcPath, 'node_modules')]);
srcPath = path.join(srcPath, split[0], split[1]);
fromWithinModule = split[1];
}
async function addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias, moduleName, modulePath) {
if (/*filesProcessed.indexOf(webpackRequireString) == -1 && */webpackRequireString.indexOf('..') == -1) {
dependencies[webpackRequireString] = webpackPath;
console.log((fromWithinModule ? '<' + fromWithinModule + '> ' + '[' + path.basename(requestedBy) : '[' + requestedByRelativeToSrc) + '] required "' + webpackRequireString + '" from "' + webpackPath.replace(optionsGlobal.root + pathSep, '') + '".')
filesProcessed.push(webpackRequireString);
}
compiled.result
}\n/*# ${sourcemapStr}*/`;
} else if (compiled.extension === '.js') {
// # sourceMappingURL=script.js.map
// eslint-disable-next-line no-param-reassign
compiled.result = `${
compiled.result
}\n//# ${sourcemapStr}`;
}
}
writeFiles.push(
fsp.writeFile(compiledOutputFullPath, compiled.result)
);
fileNames.push(
path.relative(outputDir, compiledOutputFullPath)
);
shas.push({
type: compiled.transformId,
inputSha: compiled.inputSha.map(x => ({
file: path.relative(inputDir, x.file),
sha: x.sha,
})),
outputSha: createHash(compiled.result),
input: relativePath,
output: fileNames,
});
eventEmitter.emit('compile-done', file);
return Promise.all(writeFiles).then(() => {
fileNames.forEach(addFileToWhitelist);
});
return new Promise((resolve, reject) => {
try {
// Figure out what line we want to add.
const resolvedPath = upath.relative(upath.dirname(data.sourceFilePath), data.snippetData.absPath);
let lineToAdd = `\\input{${resolvedPath}}`;
if (data.snippetData.module && data.snippetData.name)
lineToAdd += ` %-- module-snippet: ${data.snippetData.module.name}/${data.snippetData.name}`;
lineToAdd += `${os.EOL}`;
// Find where to append that line. The logic is as follows:
//
// 1. Look for the first valid Rammy region - with correct opening and closing comments. When found,
// append the line right before the closing comment.
// 2. If during (1) we find a Rammy region that has an opening comment but no closing comment, we
// append the new snippet in the beginning (and show a warning).
// 3. If the file doesn't have a Rammy region, we initialise a Rammy region right before the
// `\begin{document}` command and add the line there.
// 4. If we can't find `\begin{document}`, we initialise a Rammy region right after the
// `\documentclass{...}` command.
//
try {
fileSystem.statSync(fullPathNoExt + '.html');
htmlCounterpart = fullPathNoExt + '.html';
} catch (_) {}
}
if (stats && stats.isFile()) {
extension = path.extname(fullPath);
// load relative file
webpackPath = getPath(fullPath, isLazy, bundleName);
if (!fromWithinModule) {
// if user used './somepath' then traverse from local directory; else 'somepath', he meant /src/somepath
webpackRequireString = './' + (pathIsLocal ? path.relative(srcPath, path.join(relativeParent, fromPath)) : fromPath);
await addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias);
if (rootAlias) {
webpackRequireString = './' + (pathIsLocal ? path.relative(rootAlias, path.join(relativeParent, fromPath)) : fromPath);
await addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias);
}
} else {
// resolves to: 'some-module/some-file'
webpackRequireString = './' + fromWithinModule + '/' + path.relative(srcPath, path.join(relativeParent, fromPath));
await addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias);
if (rootAlias) {
webpackRequireString = './' + fromWithinModule + '/' + path.relative(rootAlias, path.join(relativeParent, fromPath));
await addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias);
_writeIndexHtml: async function(compileInfo) {
var t = this;
var application = compileInfo.application;
if (!application.isBrowserApp()) {
return;
}
if (!t.isGenerateIndexHtml()) {
return;
}
var resDir = this.getApplicationRoot(application);
let pathToTarget = path.relative(path.join(t.getOutputDir(), t.getProjectDir(application)), t.getOutputDir()) + "/";
let TEMPLATE_VARS = {
"resourcePath": pathToTarget + "resource/",
"targetPath": pathToTarget,
"appPath": "",
"preBootJs": "",
"appTitle": (application.getTitle()||"Qooxdoo Application")
};
function replaceVars(code) {
for (let varName in TEMPLATE_VARS) {
code = code.replace(new RegExp(`\\$\{${varName}\}`, "g"), TEMPLATE_VARS[varName]);
}
return code;
}
/* eslint-disable no-template-curly-in-string */
let defaultIndexHtml =
case 102:
if (webpackPath) {
_context5.next = 119;
break;
}
pathParts = fromPath.split(pathSep);
if (!(!pathIsLocal && pathParts.length > 1 && rootAlias && rootAlias !== srcPath)) {
_context5.next = 116;
break;
}
_moduleName2 = pathParts.shift();
relativeRootAlias = path.relative(srcPath, rootAlias);
relativeRootSplit = relativeRootAlias.split(pathSep);
if (relativeRootSplit[0] == '..') {
relativeRootSplit.shift();
}
while (relativeRootSplit[0] == 'node_modules') {
relativeRootSplit.shift();
relativeRootSplit.shift();
}
relativeRootAlias = relativeRootSplit.join('/');
rootedFromPath = path.join(_moduleName2, relativeRootAlias, pathParts.join(pathSep));
if (!(rootedFromPath !== fromPath && !triedToCorrectPath)) {
_context5.next = 116;
break;
],
css: [
upath.joinSafe(nodeModulesPath, 'semantic-ui-css/semantic.min.css'),
upath.joinSafe(vendorUiPath, 'Resources/private/css/**'),
upath.joinSafe(adminPath, 'css/**'),
],
img: [
upath.joinSafe(vendorUiPath, 'Resources/private/img/**'),
upath.joinSafe(adminPath, 'img/**'),
],
},
};
const sourcePathMap = [
{
sourceDir: upath.relative('', upath.joinSafe(adminPath, '/')),
destPath: '/SyliusAdminBundle',
},
{
sourceDir: upath.relative('', upath.joinSafe(vendorUiPath, '/')),
destPath: '/SyliusUiBundle',
},
{
sourceDir: upath.relative('', nodeModulesPath),
destPath: '/node_modules',
},
];
const mapSourcePath = function mapSourcePath(sourcePath) {
const match = sourcePathMap.find(({ sourceDir }) => (
sourcePath.substring(0, sourceDir.length) === sourceDir
));
return __awaiter(this, void 0, void 0, function* () {
let p1 = paths.map(Q => this.resolve(Q));
let resolutions = yield Promise.all(p1);
let p2 = resolutions.map(Q => fse.readFile(Q, 'utf8'));
let contents = yield Promise.all(p2);
let files = {};
for (let i = 0; i < resolutions.length; i++) {
let key = '/' + upath.relative(this.settings.root, resolutions[i]);
files[key] = contents[i];
}
return files;
});
}
transform(code, id) {
if (upath.relative('', id) === upath.relative('', upath.joinSafe(vendorShopPath, 'Resources/private/js/app.js'))) {
return {
code: dedent`
import './shim/shim-polyfill';
import './shim/shim-jquery';
import './shim/shim-semantic-ui';
import './shim/shim-lightbox';
${code}
`,
map: null,
};
}
return undefined;
},
},
fs.readFile(filePath, (err, data) => {
if (err) {
reject(err);
}
else {
resolve({
['webpack:///' + upath.relative(compiler.options.context, filePath)]: data.toString()
});
}
});
})