packages/oss-report-builder/index.js
function parseDependencies(info, runtimeDependencies, isParentRoot) {
	const dependencies = info.dependencies
	const devDependencies = info.devDependencies
	const nodeModulesPath = path.join(path.resolve('./'), 'node_modules/')
	let csv =
		'' /* licence */ /* URL */ /* description */ /* version */ /* type */ /* usage */ /* included in product */ /* in git repository */

	/* dependency */ Object.keys(dependencies).forEach(key => {
		const dependency = dependencies[key]
		const name = readObjectValue(dependency.name)
		const version = readObjectValue(dependency.version)

		if (dependency.name && dependency.version) {
			const type = isParentRoot ? 'dependency' : 'sub-dependency'
			const usage = devDependencies.hasOwnProperty(key)
				? 'development'
				: 'runtime'
			const included =
				!runtimeDependencies.hasOwnProperty(key) ||
				!runtimeDependencies[key]
					? 'No'
					: 'Yes'
			/* TODO: This could be done using `git check-ignore` for better results */
			const inRepo =
				dependency.link && !dependency.link.startsWith(nodeModulesPath)
					? 'Yes'
					: 'No'
			const license = readObjectValue(dependency.license)
			const url = readObjectValue(
				dependency.homepage || dependency.repository || null
			)
			const description = readObjectValue(dependency.description)
			csv +=
				'"' +
				name +
				'","' +
				version +
				'","' +
				type +
				'","' +
				usage +
				'","' +
				included +
				'","' +
				inRepo +
				'","' +
				license +
				'","' +
				url +
				'","' +
				description +
				'"\n'
		}

		if (dependency.dependencies) {
			csv += parseDependencies(dependency, runtimeDependencies, false)
		}
	})

	return csv
}
function parseDependencies(info, runtimeDependencies, isParentRoot) {
	const dependencies = info.dependencies
	const devDependencies = info.devDependencies
	const nodeModulesPath = path.join(path.resolve('./'), 'node_modules/')
	let csv =
		'' /* licence */ /* URL */ /* description */ /* version */ /* type */ /* usage */ /* included in product */ /* in git repository */

	/* dependency */ Object.keys(dependencies).forEach(key => {
		const dependency = dependencies[key]
		const name = readObjectValue(dependency.name)
		const version = readObjectValue(dependency.version)

		if (dependency.name && dependency.version) {
			const type = isParentRoot ? 'dependency' : 'sub-dependency'
			const usage = devDependencies.hasOwnProperty(key)
				? 'development'
				: 'runtime'
			const included =
				!runtimeDependencies.hasOwnProperty(key) ||
				!runtimeDependencies[key]
					? 'No'
					: 'Yes'
			/* TODO: This could be done using `git check-ignore` for better results */
			const inRepo =
				dependency.link && !dependency.link.startsWith(nodeModulesPath)
					? 'Yes'
					: 'No'
			const license = readObjectValue(dependency.license)
			const url = readObjectValue(
				dependency.homepage || dependency.repository || null
			)
			const description = readObjectValue(dependency.description)
			csv +=
				'"' +
				name +
				'","' +
				version +
				'","' +
				type +
				'","' +
				usage +
				'","' +
				included +
				'","' +
				inRepo +
				'","' +
				license +
				'","' +
				url +
				'","' +
				description +
				'"\n'
		}

		if (dependency.dependencies) {
			csv += parseDependencies(dependency, runtimeDependencies, false)
		}
	})

	return csv
}
function parseDependencies ( info , runtimeDependencies , isParentRoot ) { const dependencies = info . dependencies const devDependencies = info . devDependencies const nodeModulesPath = path . join ( path . resolve ( './' ) , 'node_modules/' ) let csv = '' /* licence */ /* URL */ /* description */ /* version */ /* type */ /* usage */ /* included in product */ /* in git repository */ /* dependency */ Object . keys ( dependencies ) . forEach ( key => { const dependency = dependencies [ key ] const name = readObjectValue ( dependency . name ) const version = readObjectValue ( dependency . version ) if ( dependency . name && dependency . version ) { const type = isParentRoot ? 'dependency' : 'sub-dependency' const usage = devDependencies . hasOwnProperty ( key ) ? 'development' : 'runtime' const included = ! runtimeDependencies . hasOwnProperty ( key ) || ! runtimeDependencies [ key ] ? 'No' : 'Yes' /* TODO: This could be done using `git check-ignore` for better results */ const inRepo = dependency . link && ! dependency . link . startsWith ( nodeModulesPath ) ? 'Yes' : 'No' const license = readObjectValue ( dependency . license ) const url = readObjectValue ( dependency . homepage || dependency . repository || null ) const description = readObjectValue ( dependency . description ) csv += '"' + name + '","' + version + '","' + type + '","' + usage + '","' + included + '","' + inRepo + '","' + license + '","' + url + '","' + description + '"\n' } if ( dependency . dependencies ) { csv += parseDependencies ( dependency , runtimeDependencies , false ) } } ) return csv }
Recursively parses the dependencies object withing the given info object and returns them as a CSV string.

@method parseDependencies
@param {Object} info - An info object containing the `dependencies` property to parse.
@param {Object} runtimeDependencies - An Object containing the runtime dependencies of this project.
@param {Boolean} isParentRoot - Flag defining if the parent object of this dependencies is the root of the project.
@returns {String}
Recursively parses the dependencies object withing the given info object and returns them as a CSV string .