How to use the liferay-npm-build-tools-common/lib/pkg-desc function in liferay-npm-build-tools-common

To help you get started, we’ve selected a few liferay-npm-build-tools-common 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 liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / dependencies.js View on Github external
/**
 * © 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
 * @param {Array} extraDependencies an array of package names to add to
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / dependencies.js View on Github external
export function addPackageDependencies(
	collectedDependencies,
	basedirPath,
	extraDependencies = []
) {
	const packageJson = readJsonSync(path.join(basedirPath, '/package.json'));
	const pkg = new PkgDesc(
		packageJson.name,
		packageJson.version,
		path.resolve(basedirPath) == path.resolve(project.dir.asNative)
			? null
			: basedirPath
	);

	if (collectedDependencies[pkg.id]) {
		return;
	}

	collectedDependencies[pkg.id] = pkg;

	let dependencies = packageJson.dependencies || {};
	dependencies = Object.keys(dependencies);
	dependencies = dependencies.concat(extraDependencies);
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / util.js View on Github external
() =>
					new PkgDesc(
						pkgJson.name,
						pkgJson.version,
						newDir,
						pkg.isRoot
					)
			);