{"version":3,"sources":["../src/get-dependencies.ts","../src/generate-disclaimer.ts","../src/get-license-text.ts","../src/utils/indentation.ts","../src/resolve-licenses-best-effort.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport { exec } from 'child_process'\nimport { z } from 'zod'\nimport type { $ZodIssueInvalidType } from 'zod/v4/core'\n\n// match errors that are caused by missing required properties, and return the provided message instead\n// in all other cases return undefined which will result in zod using the default error handling for the issue\nconst matchRequiredError = (msg: string) => (iss: Pick<$ZodIssueInvalidType, 'code' | 'input'>) =>\n  iss.code === 'invalid_type' && iss.input === undefined ? msg : undefined\n\nconst pnpmDependencyBaseSchema = z.object({\n  name: z.string(),\n  license: z.string(),\n  author: z.string().optional(),\n  homepage: z.string().optional(),\n  description: z.string().optional()\n})\n\nconst pnpmDependencyGroupedSchema = pnpmDependencyBaseSchema.extend({\n  versions: z.array(z.string(), {\n    error: (iss) => matchRequiredError('versions: string[] is required (pnpm>=9.0.0)')(iss)\n  }),\n  paths: z.array(z.string(), { error: matchRequiredError('paths: string[] is required (pnpm>=9.0.0)') })\n})\n\nconst pnpmDependencyFlattenedSchema = pnpmDependencyBaseSchema.extend({\n  version: z.string({ error: matchRequiredError('version: string is required (pnpm<9.0.0)') }),\n  path: z.string({ error: matchRequiredError('path: string is required (pnpm<9.0.0)') })\n})\n\nconst pnpmDependencySchema = z.union([pnpmDependencyGroupedSchema, pnpmDependencyFlattenedSchema])\n\nconst pnpmInputSchema = z.record(z.string(), z.array(pnpmDependencySchema))\n\nconst pnpmError = z.object({\n  error: z.object({\n    code: z.string(),\n    message: z.string()\n  })\n})\n\nexport type PnpmDependency = z.infer<typeof pnpmDependencySchema>\nexport type PnpmJson = z.infer<typeof pnpmInputSchema>\n\nexport type PnpmDependencyFlattened = z.infer<typeof pnpmDependencyFlattenedSchema>\n\nexport const flattenDependencies = (deps: PnpmDependency[]): PnpmDependencyFlattened[] =>\n  deps.flatMap(({ name, license, author, homepage, description, ...rest }) => {\n    if ('version' in rest) {\n      return [{ name, license, author, homepage, description, ...rest }]\n    } else {\n      const { versions, paths } = rest\n      return versions.map((version, i) => ({\n        name,\n        version,\n        path: paths[i],\n        license,\n        author,\n        homepage,\n        description\n      }))\n    }\n  })\n\nasync function read(stream: NodeJS.ReadableStream) {\n  const chunks: Buffer[] = []\n  for await (const chunk of stream) {\n    chunks.push(chunk as Buffer)\n  }\n  return Buffer.concat(chunks).toString('utf8')\n}\n\nconst parse =\n  <T>(schema: z.ZodType<T>) =>\n  (value: unknown): T => {\n    const result = schema.safeParse(value)\n\n    if (result.success) return result.data\n\n    const stringifiedInput = JSON.stringify(value, null, 2)\n    const prettifiedError = z.prettifyError(result.error)\n    const treeifiedError = JSON.stringify(z.treeifyError(result.error), null, 2)\n\n    throw new Error(\n      `Failed to parse input, received the following:\\n${stringifiedInput}\\n\\nThe type error was:\\n${treeifiedError} (raw)\\n\\n${prettifiedError} (prettified)`\n    )\n  }\n\n// special treatment for pnpm errors in the input\n// the errors are of the form { error: { code: string, message: string } } and would result in a zod error, but treating\n// them specially is more helpful, as otherwise the error is harder to reason about with the zod validation mixed in\nconst checkForPnpmError = (value: unknown) => {\n  const result = pnpmError.safeParse(value)\n\n  if (!result.success) return value\n\n  const { code, message, ...rest } = result.data.error\n\n  // there shouldn't be anything else contained in the error object, but just to be sure that no information is lost we\n  // include any other properties in the error message as json if present\n  const stringifiedRest = Object.keys(rest).length > 0 ? ` (${JSON.stringify(rest, null, 2)})` : ''\n  throw new Error(`${code} - ${message}${stringifiedRest}`)\n}\n\nexport type IOOptions = (\n  | { stdin: false; inputFile: undefined }\n  | { stdin: true; inputFile: undefined }\n  | { stdin: false; inputFile: string }\n) &\n  ({ stdout: true; outputFile: undefined } | { stdout: false; outputFile: string })\n\nexport const getDependencies = (\n  options: { prod: boolean },\n  ioOptions: IOOptions\n): Promise<PnpmDependencyFlattened[]> => {\n  let inputPromise: Promise<string> | undefined\n\n  if (ioOptions.stdin) {\n    inputPromise = read(process.stdin)\n  } else if (ioOptions.inputFile !== undefined) {\n    inputPromise = fs.readFile(ioOptions.inputFile, 'utf8')\n  } else {\n    inputPromise = new Promise((resolve, reject) => {\n      exec(`pnpm licenses list ${options.prod ? '--prod' : ''} --json`, (error, stdout, stderr) => {\n        if (error) return reject(new Error(`${error.message}\\nstdout: ${stdout}\\nstderr: ${stderr}`))\n        resolve(stdout)\n      })\n    })\n  }\n\n  return inputPromise\n    .then(JSON.parse)\n    .then(checkForPnpmError)\n    .then(parse(pnpmInputSchema))\n    .then(Object.values)\n    .then((deps: PnpmDependency[][]) => deps.flat())\n    .then(flattenDependencies)\n}\n","import type { PnpmDependencyResolvedLicenseText } from './get-license-text'\n\nexport const generateDisclaimer = (deps: PnpmDependencyResolvedLicenseText[]) => {\n  const beginning = `THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THIS PRODUCT\\n\\n`\n\n  const licenseTexts = deps\n    .map((dep) => {\n      const maybeNotice = dep.noticeText ? ['\\nNOTICE:\\n', dep.noticeText, '\\nLICENSE:\\n'] : []\n\n      const disclaimer = [\n        `The following software may be included in this product: ${dep.name} (${dep.version})`,\n        dep.additionalText,\n        'This software contains the following license and notice below:',\n        ...maybeNotice\n      ]\n        .filter(Boolean)\n        .join('\\n')\n      const license = dep.licenseText\n      return `${disclaimer}\\n\\n${license}`\n    })\n    .join('\\n\\n---\\n\\n')\n\n  const trailingNewline = licenseTexts.endsWith('\\n') ? '' : '\\n'\n\n  return beginning + licenseTexts + trailingNewline\n}\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport licenseTexts from 'spdx-license-list/full.js'\nimport removeMarkdown from 'remove-markdown'\nimport { dedent } from './utils/indentation'\nimport type { PnpmDependencyFlattened } from './get-dependencies'\n\nconst LICENSE_BASENAMES = [/* eslint-disable prettier/prettier */\n  /^LICENSE$/i,           // e.g. LICENSE\n  /^LICENSE\\.\\w+$/i,      // e.g. LICENSE.md\n  /^LICENSE-\\w+$/i,      // e.g. LICENSE-MIT\n  /^LICENSE-\\w+.\\w+$/i,  // e.g. LICENSE-MIT.md\n  /^UNLICENSE$/i,         // e.g. UNLICENSE\n\n  // common typo variants\n  /^LICENCE$/i,           // e.g. LICENCE\n  /^LICENCE-\\w+$/i,      // e.g. LICENCE-MIT\n  /^LICENCE-\\w+.\\w+$/i,  // e.g. LICENCE-MIT.md\n  /^LICENCE\\.\\w+$/i,      // e.g. LICENCE.md\n  /^UNLICENCE$/i,         // e.g. UNLICENCE\n\n  /^COPYING$/i\n] /* eslint-enable prettier/prettier */\n\nconst README_BASENAMES = [\n  /^readme$/i, // e.g. readme or README\n  /^readme\\.\\w+$/i // e.g. readme.md or README.md\n]\n\nconst LICENSE_TEXT_SUBSTRINGS = {\n  mit_license: /ermission is hereby granted, free of charge, to any/,\n  bsd_license: /edistribution and use in source and binary forms, with or withou/,\n  bsd_source_code_license: /edistribution and use of this software in source and binary forms, with or withou/,\n  // eslint-disable-next-line prettier/prettier\n  cc0_1_0: /The\\s+person\\s+who\\s+associated\\s+a\\s+work\\s+with\\s+this\\s+deed\\s+has\\s+dedicated\\s+the\\s+work\\s+to\\s+the\\s+public\\s+domain\\s+by\\s+waiving\\s+all\\s+of\\s+his\\s+or\\s+her\\s+rights\\s+to\\s+the\\s+work\\s+worldwide\\s+under\\s+copyright\\s+law,\\s+including\\s+all\\s+related\\s+and\\s+neighboring\\s+rights,\\s+to\\s+the\\s+extent\\s+allowed\\s+by\\s+law.\\s+You\\s+can\\s+copy,\\s+modify,\\s+distribute\\s+and\\s+perform\\s+the\\s+work,\\s+even\\s+for\\s+commercial\\s+purposes,\\s+all\\s+without\\s+asking\\s+permission./i,\n}\n\nconst NOTICE_BASENAMES = [/^NOTICE$/i]\n\nexport class MissingLicenseError extends Error {\n  constructor(public dependency: PnpmDependencyFlattened) {\n    super('No license text found for dependency ' + dependency.name)\n  }\n}\n\nconst resolvedByTypes = ['license-file', 'readme-search', 'fallback-author', 'fallback-homepage'] as const\n\nconst sanitizeText = (text: string) => dedent(text.replaceAll('\\r', '').replaceAll(' \\n', '\\n')).trim()\n\nexport type PnpmDependencyResolvedLicenseText = PnpmDependencyFlattened & {\n  licenseText: string\n  additionalText?: string\n  noticeText?: string\n  resolvedBy: (typeof resolvedByTypes)[number]\n}\n\nexport const getLicenseText = async (\n  dependency: PnpmDependencyFlattened\n): Promise<{\n  licenseText: string\n  additionalText?: string\n  noticeText?: string\n  resolvedBy: (typeof resolvedByTypes)[number]\n}> => {\n  const files = await fs.readdir(dependency.path)\n\n  const licenseFiles = LICENSE_BASENAMES.map((basename) => files.filter((file) => basename.test(file))).flat()\n  const noticeFiles = NOTICE_BASENAMES.map((basename) => files.filter((file) => basename.test(file))).flat()\n\n  // we found a license file, easy\n  if (licenseFiles.length > 0) {\n    const licensePromise = fs.readFile(path.join(dependency.path, licenseFiles[0]), 'utf8').then(sanitizeText)\n    const noticePromise =\n      noticeFiles.length > 0\n        ? fs.readFile(path.join(dependency.path, noticeFiles[0]), 'utf8').then(sanitizeText)\n        : Promise.resolve(undefined)\n\n    const [licenseText, noticeText] = await Promise.all([licensePromise, noticePromise] as const)\n\n    return { licenseText, noticeText, resolvedBy: 'license-file' }\n  }\n\n  // no license file found, fallback to other methods\n  // 1. search in the readme.md file for a license section\n  // 2. auto-generate a license file based on the license type listed in the package.json\n\n  // 1. search in the readme.md file for a license section\n  const readmeFiles = README_BASENAMES.map((basename) => files.filter((file) => basename.test(file))).flat()\n\n  if (readmeFiles.length > 0) {\n    const readme = await fs.readFile(path.join(dependency.path, readmeFiles[0]), 'utf8')\n    const maybeLicenseSection = readme.match(/#{1,6} Licen[cs]e([\\s\\S]+?)(##|$)/)\n\n    if (maybeLicenseSection) {\n      const licenseSection = maybeLicenseSection[1].trim()\n\n      // there are essentially two situations here:\n      // 1. licenseSection is the whole license text, **good**\n      // 2. licenseSection is only a short text blob that refers to the license in some way, **bad**\n      //    examples:\n      //     - \"This project is licensed under the MIT license.\" or\n      //    - \"Released under MIT license\" or\n      //     - \"[MIT](https://some-kind-of-link-to-the-license-file.example.com)\" or\n      //     - \"[MIT][license] © [Jane Doe][author]\"\n      //     We cannot really deal with this, thus we have to fall back to the next method\n\n      // we check for the first case by comparing the text to a bunch of known license texts, if we find a match, we're good\n      const isFullLicenseText = Object.entries(LICENSE_TEXT_SUBSTRINGS).find(([, regex]) => regex.test(licenseSection))\n\n      if (isFullLicenseText) {\n        return { licenseText: sanitizeText(removeMarkdown(licenseSection)), resolvedBy: 'readme-search' }\n      }\n    }\n  }\n\n  // 2. auto-generate a license file based on the license type listed in the package.json\n  if (dependency.license in licenseTexts) {\n    const licenseText = licenseTexts[dependency.license].licenseText\n\n    const isPublicDomainLikeLicense = ['WTFPL', 'CC0-1.0', 'Unlicense', 'MIT-0'].includes(dependency.license)\n\n    // for public domain like licenses it doesn't make sense to add \"Copyright (c) 2023, Jane Doe\",\n    // we rather want to add additional information about the authors without mentioning copyright\n    if (isPublicDomainLikeLicense) {\n      if (dependency.author) {\n        return {\n          licenseText,\n          additionalText: `This software was created by ${dependency.author}`,\n          resolvedBy: 'fallback-author'\n        }\n      }\n\n      if (dependency.homepage) {\n        return {\n          licenseText,\n          resolvedBy: 'fallback-homepage'\n        }\n      }\n    }\n\n    const authors = dependency.author\n      ? dependency.author\n      : dependency.homepage\n        ? `The maintainers of ${dependency.name} <${dependency.homepage}>`\n        : `The maintainers of ${dependency.name}`\n\n    // TODO: some license files contain placeholders like <year>, <owner> or <copyright holders>. We ideally want to replace those with the actual values\n    // TODO: for now we only handle the most common cases here\n    if (dependency.license === 'MIT') {\n      return {\n        licenseText: licenseText.replace('<year> <copyright holders>', authors),\n        resolvedBy: dependency.author ? 'fallback-author' : 'fallback-homepage'\n      }\n    } else if (dependency.license === 'BSD-3-Clause' || dependency.license === 'BSD-2-Clause') {\n      return {\n        licenseText: licenseText.replace('<year> <owner>', authors),\n        resolvedBy: dependency.author ? 'fallback-author' : 'fallback-homepage'\n      }\n    }\n\n    return {\n      licenseText: `Copyright (c) ${authors}\\n\\n${licenseText}`,\n      resolvedBy: dependency.author ? 'fallback-author' : 'fallback-homepage'\n    }\n  }\n\n  return Promise.reject(new MissingLicenseError(dependency))\n}\n","export const dedent = (input: string) => {\n  // leading whitespace on lines with text (i.e. ignoring whitespace-only lines)\n  // note that this treats any kind of whitespace as being the same, i.e. 1 tab is the same as 1 space.\n  // for this to make sense the assumption is made that a file is using either tabs or spaces for indentation\n  const leading = input.match(/^[ \\t]*(?=\\S)/gm) ?? []\n  const indentation = leading.map((x) => x.length)\n\n  // find the smallest indentation size\n  const minIndent = Math.min(...indentation)\n\n  // if not indented or if all lines are whitespace-only, return the input as-is\n  if (minIndent === 0 || minIndent === Infinity) {\n    return input\n  }\n\n  const regex = new RegExp(`^[ \\\\t]{${minIndent}}`, 'gm')\n  return input.replace(regex, '')\n}\n\nexport const strip = (input: string) =>\n  input\n    .split('\\n')\n    .map((line) => line.trim())\n    .join('\\n')\n    .trim()\n","import type { PnpmDependencyFlattened } from './get-dependencies'\nimport { getLicenseText } from './get-license-text'\nimport type { PnpmDependencyResolvedLicenseText } from './get-license-text'\n\nexport const resolveLicensesBestEffort = async (\n  deps: PnpmDependencyFlattened[]\n): Promise<{ successful: PnpmDependencyResolvedLicenseText[]; failed: PnpmDependencyFlattened[] }> => {\n  const depsWithLicensesPromise = deps.map(async (dep) => ({ ...dep, ...(await getLicenseText(dep)) }))\n\n  // keep track of which licenses could be resolved and which couldn't\n  // include the index to restore the original order afterwards\n  const successful: [number, PnpmDependencyResolvedLicenseText][] = []\n  const failed: [number, PnpmDependencyFlattened][] = []\n\n  await Promise.all(\n    depsWithLicensesPromise.map((depPromise, index) =>\n      depPromise\n        .then((dep) => {\n          successful.push([index, dep])\n        })\n        .catch((error) => {\n          failed.push([index, error])\n        })\n    )\n  )\n\n  return {\n    successful: successful.sort((a, b) => a[0] - b[0]).map(([, dep]) => dep),\n    failed: failed.sort((a, b) => a[0] - b[0]).map(([, dep]) => dep)\n  }\n}\n"],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