Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Get root package
const rootPkg = getRootPkg();
report.rootPackage(rootPkg);
// Compute dependency packages
const depPkgsMap = addPackageDependencies(
{},
project.dir.asNative,
project.copy.includedDependencies
);
const depPkgs = Object.values(depPkgsMap).filter(pkg => !pkg.isRoot);
report.dependencies(depPkgs);
reportLinkedDependencies(project.pkgJson);
// Report rules config
report.rulesConfig(project.rules.config);
// Warn about incremental builds
if (manifest.loadedFromFile) {
report.warn(
'This report is from an incremental build: some steps may be ' +
'missing (you may remove the output directory to force a ' +
'full build).'
);
}
// Do things
copyPackages(rootPkg, depPkgs)
.then(() => runRules(rootPkg, depPkgs))
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
import childProcess from 'child_process';
import project from 'liferay-npm-build-tools-common/lib/project';
import os from 'os';
import path from 'path';
import util from 'util';
import * as cfg from '../config';
import {Renderer} from '../util';
const templatesDir = path.join(__dirname, '..', 'resources', 'start');
const webpackDir = project.dir.join('.webpack');
const pkgJson = project.pkgJson;
/**
*
*/
export default function() {
copyWebpackResources();
runWebpackDevServer();
}
/**
*
*/
function copyWebpackResources() {
const renderer = new Renderer(templatesDir, webpackDir.asNative);
renderer.render('index.html', {
/**
* © 2017 Liferay, Inc.
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
import PkgDesc from 'liferay-npm-build-tools-common/lib/pkg-desc';
import project from 'liferay-npm-build-tools-common/lib/project';
import path from 'path';
import readJsonSync from 'read-json-sync';
import resolveModule from 'resolve';
import report from './report';
const pkgJson = project.pkgJson;
const rootPkg = new PkgDesc(pkgJson.name, pkgJson.version);
/**
* Get root package descriptor
* @return {PkgDesc} the root package descriptor
*/
export function getRootPkg() {
return rootPkg;
}
/**
* Recursively find the dependencies of a package and return them as PkgDesc
* objects.
* @param {object} collectedDependencies a hash of objects where key is the
* package id and values are PkgDesc objects
* @param {string} basedirPath directory where package lives in
* © 2017 Liferay, Inc.
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
import fs from 'fs-extra';
import globby from 'globby';
import JSZip from 'jszip';
import FilePath from 'liferay-npm-build-tools-common/lib/file-path';
import project from 'liferay-npm-build-tools-common/lib/project';
import path from 'path';
import * as ddm from './ddm';
import * as xml from './xml';
const pkgJson = project.pkgJson;
/**
* Create an OSGi bundle with build's output
* @return {Promise}
*/
export default function createJar() {
const zip = new JSZip();
addManifest(zip);
addBuildFiles(zip);
addLocalizationFiles(zip);
addSystemConfigurationFiles(zip);
addPortletInstanceConfigurationFile(zip);
return zip.generateAsync({type: 'nodebuffer'}).then(buffer => {
fs.mkdirpSync(project.jar.outputDir.asNative);
restoringBackup: [
info`
Restoring backup of {'src/index.js'} after React's build has finished.
`,
],
usingPreviousBackup: [
``,
success`
Using previous backup of {'src/index.js'} for this build.
`,
],
};
const createReactAppBuildDir = project.dir.join('build');
const explodedJarDir = project.dir.join('build.liferay', 'jar');
const pkgJson = project.pkgJson;
const templatesPath = path.join(
__dirname,
'..',
'..',
'resources',
'build',
'create-react-app'
);
const renderer = new Renderer(templatesPath, explodedJarDir.asNative);
/**
* Run the specialized build
*/
export default function run() {
return Promise.resolve()
'namespace-webpack',
`No ocurrences of 'webpackJsonp' found; nothing to be done`
);
return content;
}
log.info(
'namespace-webpack',
`Replaced ${matches.length} occurences of 'webpackJsonp'`
);
const hash = crypto.createHash('MD5');
hash.update(project.pkgJson['name']);
hash.update(project.pkgJson['version']);
const uuid = hash
.digest('base64')
.replace(/\+/g, '_')
.replace(/\//g, '_')
.replace(/=/g, '');
return content.replace(regexp, `webpackJsonp_${uuid}`);
}
log.info(
'namespace-webpack',
`No ocurrences of 'webpackJsonp' found; nothing to be done`
);
return content;
}
log.info(
'namespace-webpack',
`Replaced ${matches.length} occurences of 'webpackJsonp'`
);
const hash = crypto.createHash('MD5');
hash.update(project.pkgJson['name']);
hash.update(project.pkgJson['version']);
const uuid = hash
.digest('base64')
.replace(/\+/g, '_')
.replace(/\//g, '_')
.replace(/=/g, '');
return content.replace(regexp, `webpackJsonp_${uuid}`);
}
return new Promise(resolve => {
const logger = new PluginLogger();
babelIpc.set(project.dir.join(prjRelPath).asNative, {
log: logger,
manifest,
rootPkgJson: clone(project.pkgJson),
globalConfig: clone(project.globalConfig),
});
const fileAbsPath = project.dir.join(prjRelPath).asNative;
const filePkgRelPath = project.dir
.join(destPkg.dir)
.relative(fileAbsPath).asNative;
babel.transformFile(
fileAbsPath,
{
filename: fileAbsPath,
filenameRelative: prjRelPath,
inputSourceMap: loadSourceMap(fileAbsPath),
...babelConfig,
},