* [grunt/build] refactor _build:notice task to not depend on npm The _build:notice task used to rely on the output of `npm ls` to determine where modules were defined, but the task now just asks `license-checker` to include the `realPath` of the modules it describes in it's output, which is ultimately the same thing but works with `yarn` too. * [grunt/licenses] convert to use lib/packages/getInstalledPackages() * [grunt/notice/generate] test generateNoticeText() * [grunt/licenses] tested assertLicensesValid() * [npm] remove npm dev dep * [tasks/lib/packages] do not include kibana in "installed packages" * [tasks/lib/notice] join all notices with the same separator
23 lines
681 B
JavaScript
23 lines
681 B
JavaScript
import { getBundledNotices } from './bundled_notices';
|
|
|
|
const concatNotices = notices => (
|
|
notices.map(notice => notice.text).join('\n')
|
|
);
|
|
|
|
export async function generatePackageNoticeText(pkg) {
|
|
const bundledNotices = concatNotices(await getBundledNotices(pkg.directory));
|
|
|
|
const intro = `This product bundles ${pkg.name}@${pkg.version}`;
|
|
const license = ` which is available under ${
|
|
pkg.licenses.length > 1
|
|
? `the\n"${pkg.licenses.join('", ')} licenses.`
|
|
: `a\n"${pkg.licenses[0]}" license.`
|
|
}`;
|
|
|
|
const moreInfo = bundledNotices
|
|
? `\n${bundledNotices}\n`
|
|
: ` For details, see ${pkg.relative}/.`;
|
|
|
|
return `${intro}${license}${moreInfo}`;
|
|
}
|