license-cop 1.9.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +25 -5
  3. package/dist/bin.js +545 -0
  4. package/dist/bin.js.map +1 -0
  5. package/package.json +21 -14
  6. package/src/bin/license-cop +0 -4
  7. package/src/index.d.ts +0 -3
  8. package/src/index.js +0 -10
  9. package/src/index.js.map +0 -1
  10. package/src/lib/cli/commands/init.d.ts +0 -5
  11. package/src/lib/cli/commands/init.js +0 -39
  12. package/src/lib/cli/commands/init.js.map +0 -1
  13. package/src/lib/cli/commands/main.d.ts +0 -7
  14. package/src/lib/cli/commands/main.js +0 -61
  15. package/src/lib/cli/commands/main.js.map +0 -1
  16. package/src/lib/cli/commands/version.d.ts +0 -4
  17. package/src/lib/cli/commands/version.js +0 -21
  18. package/src/lib/cli/commands/version.js.map +0 -1
  19. package/src/lib/cli/create-command.d.ts +0 -5
  20. package/src/lib/cli/create-command.js +0 -17
  21. package/src/lib/cli/create-command.js.map +0 -1
  22. package/src/lib/cli/index.d.ts +0 -1
  23. package/src/lib/cli/index.js +0 -18
  24. package/src/lib/cli/index.js.map +0 -1
  25. package/src/lib/cli/report-failure.d.ts +0 -2
  26. package/src/lib/cli/report-failure.js +0 -36
  27. package/src/lib/cli/report-failure.js.map +0 -1
  28. package/src/lib/cli/report-success.d.ts +0 -2
  29. package/src/lib/cli/report-success.js +0 -22
  30. package/src/lib/cli/report-success.js.map +0 -1
  31. package/src/lib/config/config-error.d.ts +0 -4
  32. package/src/lib/config/config-error.js +0 -27
  33. package/src/lib/config/config-error.js.map +0 -1
  34. package/src/lib/config/config.d.ts +0 -25
  35. package/src/lib/config/config.js +0 -35
  36. package/src/lib/config/config.js.map +0 -1
  37. package/src/lib/config/find-config.d.ts +0 -1
  38. package/src/lib/config/find-config.js +0 -67
  39. package/src/lib/config/find-config.js.map +0 -1
  40. package/src/lib/config/load-config.d.ts +0 -7
  41. package/src/lib/config/load-config.js +0 -26
  42. package/src/lib/config/load-config.js.map +0 -1
  43. package/src/lib/config/load-parent-config.d.ts +0 -1
  44. package/src/lib/config/load-parent-config.js +0 -30
  45. package/src/lib/config/load-parent-config.js.map +0 -1
  46. package/src/lib/config/parent-resolutions/github.d.ts +0 -1
  47. package/src/lib/config/parent-resolutions/github.js +0 -28
  48. package/src/lib/config/parent-resolutions/github.js.map +0 -1
  49. package/src/lib/config/parent-resolutions/http.d.ts +0 -1
  50. package/src/lib/config/parent-resolutions/http.js +0 -20
  51. package/src/lib/config/parent-resolutions/http.js.map +0 -1
  52. package/src/lib/config/parent-resolutions/npm.d.ts +0 -2
  53. package/src/lib/config/parent-resolutions/npm.js +0 -32
  54. package/src/lib/config/parent-resolutions/npm.js.map +0 -1
  55. package/src/lib/config/parsers/json5.d.ts +0 -1
  56. package/src/lib/config/parsers/json5.js +0 -11
  57. package/src/lib/config/parsers/json5.js.map +0 -1
  58. package/src/lib/dependency/get-package-manager.d.ts +0 -2
  59. package/src/lib/dependency/get-package-manager.js +0 -52
  60. package/src/lib/dependency/get-package-manager.js.map +0 -1
  61. package/src/lib/dependency/package-json.d.ts +0 -18
  62. package/src/lib/dependency/package-json.js +0 -75
  63. package/src/lib/dependency/package-json.js.map +0 -1
  64. package/src/lib/dependency/package-rules.d.ts +0 -1
  65. package/src/lib/dependency/package-rules.js +0 -24
  66. package/src/lib/dependency/package-rules.js.map +0 -1
  67. package/src/lib/dependency-scanning/npm.d.ts +0 -3
  68. package/src/lib/dependency-scanning/npm.js +0 -100
  69. package/src/lib/dependency-scanning/npm.js.map +0 -1
  70. package/src/lib/dependency-scanning/options.d.ts +0 -2
  71. package/src/lib/dependency-scanning/options.js +0 -3
  72. package/src/lib/dependency-scanning/options.js.map +0 -1
  73. package/src/lib/dependency-scanning/pnpm.d.ts +0 -3
  74. package/src/lib/dependency-scanning/pnpm.js +0 -103
  75. package/src/lib/dependency-scanning/pnpm.js.map +0 -1
  76. package/src/lib/license-cop.d.ts +0 -9
  77. package/src/lib/license-cop.js +0 -51
  78. package/src/lib/license-cop.js.map +0 -1
  79. package/src/lib/logger.d.ts +0 -8
  80. package/src/lib/logger.js +0 -41
  81. package/src/lib/logger.js.map +0 -1
  82. package/src/lib/result.d.ts +0 -27
  83. package/src/lib/result.js +0 -3
  84. package/src/lib/result.js.map +0 -1
  85. package/src/lib/spdx/calculate-issues.d.ts +0 -2
  86. package/src/lib/spdx/calculate-issues.js +0 -45
  87. package/src/lib/spdx/calculate-issues.js.map +0 -1
  88. package/src/lib/spdx/get-tokens.d.ts +0 -2
  89. package/src/lib/spdx/get-tokens.js +0 -54
  90. package/src/lib/spdx/get-tokens.js.map +0 -1
  91. package/src/lib/spdx/parse-license-expression.d.ts +0 -2
  92. package/src/lib/spdx/parse-license-expression.js +0 -20
  93. package/src/lib/spdx/parse-license-expression.js.map +0 -1
  94. package/src/lib/spdx/parse-tokens.d.ts +0 -3
  95. package/src/lib/spdx/parse-tokens.js +0 -122
  96. package/src/lib/spdx/parse-tokens.js.map +0 -1
  97. package/src/lib/spdx/types/spdx-expression.d.ts +0 -20
  98. package/src/lib/spdx/types/spdx-expression.js +0 -3
  99. package/src/lib/spdx/types/spdx-expression.js.map +0 -1
  100. package/src/lib/spdx/types/token.d.ts +0 -23
  101. package/src/lib/spdx/types/token.js +0 -29
  102. package/src/lib/spdx/types/token.js.map +0 -1
  103. package/src/lib/utils/join-string-array.d.ts +0 -1
  104. package/src/lib/utils/join-string-array.js +0 -28
  105. package/src/lib/utils/join-string-array.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":["_exhaustiveCheck","stat","join","_exhaustiveCheck"],"sources":["../src/io.ts","../src/errors.ts","../src/args/schema.ts","../src/args/parse.ts","../src/config/parsers/json5.ts","../src/read-project-name.ts","../src/config/dev-dependencies.ts","../src/config/config-error.ts","../src/config/config.ts","../src/config/find-config.ts","../src/config/parent-resolutions/github.ts","../src/config/parent-resolutions/http.ts","../src/config/parent-resolutions/npm.ts","../src/config/load-parent-config.ts","../src/config/load-config.ts","../src/config/resolve-check-options.ts","../src/report-failure.ts","../src/report-success.ts","../src/commands/check.ts","../src/commands/init.ts","../src/help.ts","../src/report-error.ts","../src/main.ts","../src/bin.ts"],"sourcesContent":["import type { OnVerbose } from \"@license-cop/core\";\n\nexport type Io = {\n stdout: (line: string) => void;\n stderr: (line: string) => void;\n};\n\nexport const defaultIo: Io = {\n stdout: line => console.log(line),\n stderr: line => console.error(line)\n};\n\nexport const createVerboseLogger = (io: Io, enabled: boolean): OnVerbose => {\n if (!enabled) {\n return () => {};\n }\n\n const verbose: OnVerbose = message => io.stdout(message);\n verbose(\"Verbose logging enabled\");\n\n return verbose;\n};\n","export class UsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UsageError\";\n }\n}\n","import { z } from \"zod\";\nimport type { DevDependenciesMode } from \"../config/dev-dependencies\";\n\n// The modes themselves belong to the config code, which acts on them; `satisfies` keeps the two from drifting\nexport const devDependenciesModeSchema = z.enum(\n [\"include\", \"only\"] as const satisfies DevDependenciesMode[],\n {\n error: issue =>\n `--dev-dependencies must be 'include' or 'only', but got '${String(issue.input)}'`\n }\n);\n\n/** What the command line asks for. Each `error` is what the user sees, so it reads as a sentence. */\nexport const cliInvocationSchema = z.discriminatedUnion(\"kind\", [\n z.object({\n kind: z.literal(\"check\"),\n directory: z.string(),\n verbose: z.boolean(),\n devDependencies: devDependenciesModeSchema.optional()\n }),\n z.object({\n kind: z.literal(\"init\"),\n directory: z.string(),\n verbose: z.boolean(),\n devDependencies: z.undefined({ error: \"'init' does not accept --dev-dependencies\" }).optional()\n }),\n z.object({ kind: z.literal(\"version\") }),\n z.object({ kind: z.literal(\"help\") })\n]);\n\nexport type CliInvocation = z.infer<typeof cliInvocationSchema>;\n","import { parseArgs, type ParseArgsConfig } from \"node:util\";\nimport type { z } from \"zod\";\nimport { UsageError } from \"../errors\";\nimport { cliInvocationSchema, type CliInvocation } from \"./schema\";\n\nconst removedFlagHints: Record<string, string> = {\n \"--init\": \"the --init flag has been removed, use 'license-cop init' instead\",\n \"-D\": \"the -D flag has been removed, use '--dev-dependencies include' instead\",\n \"--include-dev\":\n \"the --include-dev flag has been removed, use '--dev-dependencies include' instead\",\n \"--dev-only\": \"the --dev-only flag has been removed, use '--dev-dependencies only' instead\"\n};\n\nexport const cliOptions = {\n directory: { type: \"string\", short: \"d\" },\n verbose: { type: \"boolean\" },\n \"dev-dependencies\": { type: \"string\" },\n version: { type: \"boolean\", short: \"v\" },\n help: { type: \"boolean\", short: \"h\" }\n} as const satisfies ParseArgsConfig[\"options\"];\n\nexport const parseCliArgs = (args: string[], defaultDirectory: string): CliInvocation => {\n throwIfRemovedFlag(args);\n\n const tokens = tokenize(args);\n const candidate = toCandidate(tokens, defaultDirectory);\n\n // What each value may be, and what may go with what, is the schema's to say\n const result = cliInvocationSchema.safeParse(candidate);\n\n if (!result.success) {\n throw new UsageError(firstMessage(result.error));\n }\n\n return result.data;\n};\n\nconst throwIfRemovedFlag = (args: string[]) => {\n for (const arg of args) {\n const hint = removedFlagHints[arg];\n\n if (hint) {\n throw new UsageError(hint);\n }\n }\n};\n\ntype Tokens = ReturnType<typeof tokenize>;\n\nconst tokenize = (args: string[]) => {\n try {\n const { values, positionals } = parseArgs({\n args,\n allowPositionals: true,\n strict: true,\n options: cliOptions\n });\n\n return { values, positionals };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new UsageError(message);\n }\n};\n\n/**\n * Decides which command was asked for, once, and lays the flags out for the schema to check. Help\n * and the version win over everything else on the command line.\n */\nconst toCandidate = ({ values, positionals }: Tokens, defaultDirectory: string) => {\n if (values.help) {\n return { kind: \"help\" };\n }\n\n if (values.version) {\n return { kind: \"version\" };\n }\n\n const isInit = positionals[0] === \"init\";\n const unexpected = isInit ? positionals[1] : positionals[0];\n\n if (unexpected !== undefined) {\n throw new UsageError(`unexpected argument '${unexpected}'`);\n }\n\n return {\n kind: isInit ? \"init\" : \"check\",\n directory: values.directory ?? defaultDirectory,\n verbose: values.verbose ?? false,\n devDependencies: values[\"dev-dependencies\"]\n };\n};\n\nconst firstMessage = (error: z.ZodError): string => error.issues[0]?.message ?? error.message;\n","import JSON5 from \"json5\";\n\nexport const json5Parse = <T>(content: string): T => JSON5.parse<T>(content);\n","import { PackageJsonError, type OnVerbose } from \"@license-cop/core\";\nimport { readFile } from \"node:fs/promises\";\nimport { z } from \"zod\";\nimport { json5Parse } from \"./config/parsers/json5\";\n\nconst projectPackageJsonSchema = z.object({ name: z.string() });\n\n/** The name in a project's package.json, for saying what's being scanned. */\nexport const readProjectName = async (\n pathToPackageJson: string,\n onVerbose: OnVerbose\n): Promise<string> => {\n const contents = await readFile(pathToPackageJson, \"utf8\").catch(() => {\n onVerbose(`Cannot find the package.json: '${pathToPackageJson}'`);\n throw new PackageJsonError(`Cannot find the file: '${pathToPackageJson}'`);\n });\n\n let parsed: unknown;\n\n try {\n parsed = json5Parse<unknown>(contents);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new PackageJsonError(`Unable to parse package.json: ${pathToPackageJson}: ${reason}`);\n }\n\n const result = projectPackageJsonSchema.safeParse(parsed);\n\n if (!result.success) {\n throw new PackageJsonError(\n `Unable to parse package.json: ${pathToPackageJson}: ${result.error.message}`\n );\n }\n\n return result.data.name;\n};\n","/** What `--dev-dependencies` can ask for. Leaving it out means \"whatever the config says\". */\nexport type DevDependenciesMode = \"include\" | \"only\";\n\nexport type DevDependencyOptions = {\n includeDevDependencies: boolean;\n devDependenciesOnly: boolean;\n};\n\n/**\n * The `--dev-dependencies` flag, when given, decides on its own and the config file's keys are\n * ignored; only when it's absent do the config keys apply. This means the two options are never\n * both true when they come from the flag.\n */\nexport const resolveDevDependencyOptions = (\n flag: DevDependenciesMode | undefined,\n config: DevDependencyOptions\n): DevDependencyOptions => {\n switch (flag) {\n case undefined:\n return {\n includeDevDependencies: config.includeDevDependencies,\n devDependenciesOnly: config.devDependenciesOnly\n };\n case \"include\":\n return { includeDevDependencies: true, devDependenciesOnly: false };\n case \"only\":\n return { includeDevDependencies: false, devDependenciesOnly: true };\n default: {\n const _exhaustiveCheck: never = flag;\n throw new Error(`Unknown dev dependencies mode: ${_exhaustiveCheck}`);\n }\n }\n};\n","import { LicenseCopError } from \"@license-cop/core\";\n\nexport class ConfigError extends LicenseCopError {\n constructor(message: string) {\n super(`Config error: ${message}`);\n }\n\n static fromUnknown(e: unknown): ConfigError {\n const message = resolveMessage(e);\n return new ConfigError(message);\n }\n}\n\nconst resolveMessage = (e: unknown): string => {\n if (e instanceof Error) {\n return e.message;\n }\n\n if (typeof e === \"string\") {\n return e;\n }\n\n return \"Unknown error\";\n};\n","import { z } from \"zod\";\nimport { ConfigError } from \"./config-error\";\n\nconst rawConfigParser = z.object({\n extends: z.string().optional(),\n licenses: z.array(z.string()).optional(),\n packages: z.array(z.string()).optional(),\n includeDevDependencies: z.boolean().optional(),\n devDependenciesOnly: z.boolean().optional(),\n directory: z.string().optional()\n});\n\n/** A config as written, with none of the defaults applied. */\nexport type RawConfig = z.infer<typeof rawConfigParser>;\n\nexport type Config = {\n extends: string | undefined;\n licenses: string[];\n packages: string[];\n includeDevDependencies: boolean;\n devDependenciesOnly: boolean;\n};\n\nexport const parseConfig = (config: unknown): Config => {\n const rawConfig = parseRawConfig(config);\n return applyConfigDefaults(rawConfig);\n};\n\n/**\n * Validates a config without applying any defaults. Configs must be merged in this form,\n * otherwise a default on the child would override a value that was explicitly set on its parent.\n */\nexport const parseRawConfig = (config: unknown): RawConfig => {\n const parseResult = rawConfigParser.safeParse(config);\n\n if (!parseResult.success) {\n throw new ConfigError(parseResult.error.message);\n }\n\n return parseResult.data;\n};\n\nexport const applyConfigDefaults = (config: RawConfig): Config => ({\n extends: config.extends,\n licenses: config.licenses ?? [],\n packages: config.packages ?? [],\n includeDevDependencies: config.includeDevDependencies ?? false,\n devDependenciesOnly: config.devDependenciesOnly ?? false\n});\n","import {\n cosmiconfig,\n type Options as CosmiconfigOptions,\n type CosmiconfigResult,\n type Loader\n} from \"cosmiconfig\";\nimport { ConfigError } from \"./config-error\";\nimport { json5Parse } from \"./parsers/json5\";\n\n// cspell:disable-next-line\nconst moduleNames = [\"licenses\", \"licences\", \"licensesrc\", \"licencesrc\"];\n\nconst generateSearchPlaces = (moduleName: string): string[] => [\n `.${moduleName}`,\n `.${moduleName}.json`,\n `.${moduleName}.jsonc`,\n `.${moduleName}.json5`,\n `.${moduleName}.yaml`,\n `.${moduleName}.yml`,\n `.${moduleName}.js`,\n `.${moduleName}.cjs`,\n `.config/${moduleName}`,\n `.config/${moduleName}.json`,\n `.config/${moduleName}.jsonc`,\n `.config/${moduleName}.json5`,\n `.config/${moduleName}.yaml`,\n `.config/${moduleName}.yml`,\n `.config/${moduleName}.js`,\n `.config/${moduleName}.cjs`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`\n];\n\nconst searchPlaces: string[] = [\"package.json\"];\n\nfor (const moduleName of moduleNames) {\n searchPlaces.push(...generateSearchPlaces(moduleName));\n}\n\nconst json5Loader: Loader = (_filepath, content) => Promise.resolve(json5Parse(content));\n\n/**\n * Looks for a config in the directory, loading it the way a normal run would. Resolves to `null`\n * when there isn't one, and throws a `ConfigError` when there is one that can't be loaded. Empty\n * files are skipped, so they don't count as a config.\n */\nexport const searchConfig = async (rootDir: string): Promise<CosmiconfigResult> => {\n const options: Partial<CosmiconfigOptions> = {\n stopDir: rootDir,\n searchPlaces,\n loaders: {\n \".json\": json5Loader,\n \".jsonc\": json5Loader,\n \".json5\": json5Loader\n }\n };\n\n const explorer = cosmiconfig(\"licensecop\", options);\n\n try {\n return await explorer.search(rootDir);\n } catch (e) {\n throw ConfigError.fromUnknown(e);\n }\n};\n\nexport const findConfig = async (rootDir: string): Promise<unknown> => {\n const result = await searchConfig(rootDir);\n\n if (!result?.config) {\n throw ConfigError.fromUnknown(\"No config file found\");\n }\n\n return result.config;\n};\n","import type { OnVerbose } from \"@license-cop/core\";\nimport { ConfigError } from \"../config-error\";\nimport { json5Parse } from \"../parsers/json5\";\n\nexport const githubResolution = async (repoId: string, onVerbose: OnVerbose) => {\n onVerbose(`Resolving config from GitHub repo: ${repoId}`);\n\n const parts = repoId.split(\"/\");\n const [owner, repoName] = parts;\n\n if (\n parts.length !== 2 ||\n owner === undefined ||\n repoName === undefined ||\n owner.length === 0 ||\n repoName.length === 0\n ) {\n throw new ConfigError(`Invalid GitHub repo ID: ${repoId}`);\n }\n\n try {\n const url = `https://api.github.com/repos/${owner}/${repoName}/contents/.licenses.json`;\n const response = await fetch(url, {\n headers: {\n accept: \"application/vnd.github.raw+json\",\n \"user-agent\": \"license-cop\"\n }\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with status code ${response.status}`);\n }\n\n const fileContent = await response.text();\n\n return json5Parse(fileContent);\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n throw new ConfigError(`Could not resolve config from GitHub repo: ${repoId}, error: ${reason}`);\n }\n};\n","import type { OnVerbose } from \"@license-cop/core\";\nimport { json5Parse } from \"../parsers/json5\";\n\nexport const httpResolution = async (url: string, onVerbose: OnVerbose) => {\n onVerbose(`Resolving http config: ${url}`);\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`Request failed with status code ${response.status}`);\n }\n\n const body = await response.text();\n\n return json5Parse(body);\n};\n","import type { OnVerbose } from \"@license-cop/core\";\nimport { stat } from \"fs/promises\";\nimport { join } from \"path\";\nimport { findConfig } from \"../find-config\";\n\nexport const npmResolution = async (packageName: string, rootDir: string, onVerbose: OnVerbose) => {\n onVerbose(`Resolving npm package: ${packageName}`);\n\n const packagePath = getPackagePath(rootDir, packageName);\n return await findConfig(packagePath);\n};\n\nexport const nodeModuleExists = async (packageName: string, rootDir: string) => {\n const packagePath = getPackagePath(rootDir, packageName);\n\n try {\n const statResult = await stat(packagePath);\n return statResult.isDirectory();\n } catch {\n return false;\n }\n};\n\nconst getPackagePath = (rootDir: string, packageName: string) =>\n join(rootDir, \"node_modules\", packageName);\n","import type { OnVerbose } from \"@license-cop/core\";\nimport { ConfigError } from \"./config-error\";\nimport { githubResolution } from \"./parent-resolutions/github\";\nimport { httpResolution } from \"./parent-resolutions/http\";\nimport { nodeModuleExists, npmResolution } from \"./parent-resolutions/npm\";\n\nexport const loadParentConfig = async (\n parentConfigPath: string,\n rootDir: string,\n onVerbose: OnVerbose\n): Promise<unknown> => {\n if (parentConfigPath.startsWith(\"npm:\")) {\n const packageName = parentConfigPath.substring(4);\n return await npmResolution(packageName, rootDir, onVerbose);\n }\n\n if (parentConfigPath.startsWith(\"github:\")) {\n const repo = parentConfigPath.substring(7);\n return await githubResolution(repo, onVerbose);\n }\n\n if (parentConfigPath.startsWith(\"http\")) {\n return await httpResolution(parentConfigPath, onVerbose);\n }\n\n if (await nodeModuleExists(parentConfigPath, rootDir)) {\n return await npmResolution(parentConfigPath, rootDir, onVerbose);\n }\n\n throw new ConfigError(`Invalid parent config location: ${parentConfigPath}`);\n};\n","import type { OnVerbose } from \"@license-cop/core\";\nimport deepMerge from \"deepmerge\";\nimport { applyConfigDefaults, parseRawConfig, type Config } from \"./config\";\nimport { ConfigError } from \"./config-error\";\nimport { findConfig } from \"./find-config\";\nimport { loadParentConfig } from \"./load-parent-config\";\n\nexport const loadConfig = async (rootDir: string, onVerbose: OnVerbose): Promise<Config> => {\n const foundConfig = await findConfig(rootDir);\n\n let config = parseRawConfig(foundConfig);\n const visitedParents = new Set<string>();\n\n while (config.extends) {\n const parentLocation = config.extends;\n\n if (visitedParents.has(parentLocation)) {\n throw new ConfigError(`Circular config extension: ${parentLocation}`);\n }\n visitedParents.add(parentLocation);\n\n onVerbose(`Extending config with ${parentLocation}`);\n const loadedParentConfig = await loadParentConfig(parentLocation, rootDir, onVerbose);\n const parsedParentConfig = parseRawConfig(loadedParentConfig);\n\n config = deepMerge(parsedParentConfig, config);\n config.extends = parsedParentConfig.extends;\n }\n\n return applyConfigDefaults(config);\n};\n","import type { LicenseCopOptions, OnVerbose } from \"@license-cop/core\";\nimport { join } from \"node:path\";\nimport { readProjectName } from \"../read-project-name\";\nimport { resolveDevDependencyOptions, type DevDependenciesMode } from \"./dev-dependencies\";\nimport { loadConfig } from \"./load-config\";\n\nexport type ResolveCheckOptionsInput = {\n /** Replaces the dev-dependency settings of the config file when given. */\n devDependencies: DevDependenciesMode | undefined;\n onVerbose: OnVerbose;\n};\n\nexport type ResolvedCheck = {\n /** The name of the project, for saying what's being scanned. */\n productName: string;\n /** Ready to hand to `checkLicenses`. */\n options: LicenseCopOptions;\n};\n\n/**\n * Everything needed to check a project before scanning it: reads the project's name and its config\n * file (with anything it extends) and combines them with what the command line asked for into the\n * options for `checkLicenses`. Nothing is scanned, so it's quick, and it fails on a bad config\n * before a slow scan.\n */\nexport const resolveCheckOptions = async (\n directory: string,\n input: ResolveCheckOptionsInput\n): Promise<ResolvedCheck> => {\n const { devDependencies, onVerbose } = input;\n\n const packageJsonPath = join(directory, \"package.json\");\n const productName = await readProjectName(packageJsonPath, onVerbose);\n const config = await loadConfig(directory, onVerbose);\n\n const options: LicenseCopOptions = {\n allowedLicenses: config.licenses,\n allowedPackages: config.packages,\n workingDirectory: directory,\n ...resolveDevDependencyOptions(devDependencies, config),\n onVerbose\n };\n\n return { productName, options };\n};\n","import type {\n CheckLicensesResult,\n ForbiddenLicenseResult,\n NoLicenseResult\n} from \"@license-cop/core\";\nimport type { Io } from \"./io\";\n\nexport const reportFailure = (result: CheckLicensesResult, io: Io): void => {\n const { noLicenses, forbiddenLicenses } = result;\n\n io.stderr(\"Found the following issues...\\n\");\n\n if (noLicenses.size > 0) {\n logNoLicenseIssues(noLicenses, io);\n }\n\n if (forbiddenLicenses.size > 0) {\n logForbiddenLicenseIssues(forbiddenLicenses, io);\n }\n};\n\nconst logNoLicenseIssues = (noLicenseResults: Set<NoLicenseResult>, io: Io) => {\n io.stderr(\"Packages with no license:\");\n\n for (const result of noLicenseResults.values()) {\n const { name, version } = result;\n io.stderr(`${name}@${version}`);\n }\n\n io.stderr(\"\");\n};\n\nconst logForbiddenLicenseIssues = (\n forbiddenLicensesResults: Set<ForbiddenLicenseResult>,\n io: Io\n): void => {\n io.stderr(\"Packages with forbidden licenses:\");\n\n for (const result of forbiddenLicensesResults.values()) {\n const { name, version, licenseIdentifiers, spdxExpression } = result;\n\n const licenseDetails =\n licenseIdentifiers === spdxExpression\n ? licenseIdentifiers\n : `${licenseIdentifiers} from ${spdxExpression}`;\n\n io.stderr(`${name}@${version} - ${licenseDetails}`);\n }\n};\n","import type { CheckLicensesResult } from \"@license-cop/core\";\nimport type { Io } from \"./io\";\n\nexport const reportSuccess = (result: CheckLicensesResult, io: Io): void => {\n const { allowedPackages, allowedLicenses } = result;\n\n io.stdout(\"\\nDone! No issues found\");\n\n if (allowedPackages.size !== 0) {\n io.stdout(`Found ${allowedPackages.size} allowed packages`);\n }\n\n if (allowedLicenses.size !== 0) {\n io.stdout(`Found ${allowedLicenses.size} packages with allowed licenses`);\n }\n};\n","import { checkLicenses } from \"@license-cop/core\";\nimport type { DevDependenciesMode } from \"../config/dev-dependencies\";\nimport { resolveCheckOptions } from \"../config/resolve-check-options\";\nimport { createVerboseLogger, type Io } from \"../io\";\nimport { reportFailure } from \"../report-failure\";\nimport { reportSuccess } from \"../report-success\";\n\nexport type CheckOptions = {\n directory: string;\n verbose: boolean;\n devDependencies?: DevDependenciesMode | undefined;\n};\n\nexport const runCheck = async (options: CheckOptions, io: Io): Promise<number> => {\n const { directory, verbose: verboseEnabled, devDependencies } = options;\n const verbose = createVerboseLogger(io, verboseEnabled);\n\n verbose(`Using directory: ${directory}`);\n\n const resolved = await resolveCheckOptions(directory, { devDependencies, onVerbose: verbose });\n io.stdout(`Scanning dependencies of: ${resolved.productName}`);\n\n const result = await checkLicenses(resolved.options);\n const exitCode = result.noLicenses.size > 0 || result.forbiddenLicenses.size > 0 ? 1 : 0;\n\n if (exitCode === 0) {\n reportSuccess(result, io);\n } else {\n reportFailure(result, io);\n }\n\n // 0 isn't an error code, so it's just the code\n verbose(`Exiting with code ${exitCode}`);\n return exitCode;\n};\n","import { stat, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { ConfigError } from \"../config/config-error\";\nimport { searchConfig } from \"../config/find-config\";\nimport { createVerboseLogger, type Io } from \"../io\";\n\nexport type InitOptions = {\n directory: string;\n verbose: boolean;\n};\n\nconst defaultConfig = `{\n \"$schema\": \"https://license-cop.js.org/schema.json\",\n \"licenses\": [\"MIT\", \"ISC\", \"Apache-2.0\"],\n \"packages\": []\n}\n`;\n\nexport const runInit = async (options: InitOptions, io: Io): Promise<number> => {\n const { directory, verbose: verboseEnabled } = options;\n const verbose = createVerboseLogger(io, verboseEnabled);\n\n const isDirectory = await stat(directory).then(\n stats => stats.isDirectory(),\n () => false\n );\n\n if (!isDirectory) {\n io.stderr(`Cannot set up a config file: ${directory} isn't a directory that exists`);\n return 1;\n }\n\n // Loaded the way a normal run would, so a config counts if license-cop would use it\n const existingConfig = await searchConfig(directory);\n\n if (existingConfig) {\n throw new ConfigError(`this project already has a config file: ${existingConfig.filepath}`);\n }\n\n io.stdout(\"Setting up a new license-cop config file...\");\n\n const configPath = join(directory, \".licenses.json\");\n verbose(`Writing config file to: ${configPath}`);\n await writeFile(configPath, defaultConfig);\n\n io.stdout(\"Done!\");\n io.stdout(\"Run `npx license-cop` to check your dependencies\");\n\n return 0;\n};\n","import { readFile } from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\nimport { z } from \"zod\";\n\nexport const helpText = (): string =>\n `Usage: license-cop [options] [command]\n\nYet another license checker tool for your dependencies; focused on simplicity\n\nOptions:\n --dev-dependencies <mode> Which dev dependencies to check: 'include' checks them as well as\n production dependencies, 'only' checks only them. Defaults to production\n dependencies only.\n --verbose Enable verbose logging\n -d, --directory <dir> The directory of the project. Defaults to the current working directory.\n -v, --version Print the installed version of license-cop\n -h, --help Display this help\n\nCommands:\n init Create a new license-cop configuration file`;\n\nexport const versionText = async (): Promise<string> => {\n const packageJsonLocation = fileURLToPath(new URL(\"../package.json\", import.meta.url));\n const contents = await readFile(packageJsonLocation, \"utf8\");\n const { version } = ownPackageJsonSchema.parse(JSON.parse(contents));\n\n return `v${version}`;\n};\n\n// The CLI's own package.json, which is always there and always valid, unlike a project's\nconst ownPackageJsonSchema = z.object({ version: z.string() });\n","import { LicenseCopError } from \"@license-cop/core\";\nimport { UsageError } from \"./errors\";\nimport type { Io } from \"./io\";\n\n/**\n * Turns anything a command threw into a message and an exit code, so that `run` never throws. What\n * the user did wrong reads as a sentence; only what nobody expected shows a stack, and only when\n * asked to, since a stack trace is no help to someone who just mistyped a directory.\n */\nexport const reportError = (error: unknown, io: Io, verbose: boolean): number => {\n if (error instanceof UsageError) {\n io.stderr(`error: ${error.message}`);\n io.stderr(\"Run 'license-cop --help' for usage\");\n return 1;\n }\n\n if (error instanceof LicenseCopError) {\n io.stderr(error.message);\n return 1;\n }\n\n io.stderr(`error: ${describeUnexpectedError(error)}`);\n\n if (!verbose) {\n io.stderr(\"Run again with --verbose to see the full stack trace\");\n return 1;\n }\n\n if (error instanceof Error && error.stack) {\n io.stderr(error.stack);\n }\n\n return 1;\n};\n\n// The failures of reading or writing files that are down to the environment rather than a bug\nconst fileSystemProblems: Record<string, string> = {\n ENOENT: \"no such file or directory\",\n EACCES: \"permission denied\",\n EPERM: \"operation not permitted\",\n EISDIR: \"is a directory\",\n EROFS: \"read-only file system\"\n};\n\nconst describeUnexpectedError = (error: unknown): string => {\n if (!(error instanceof Error)) {\n return String(error);\n }\n\n const { code, path } = error as Error & { code?: unknown; path?: unknown };\n const problem = typeof code === \"string\" ? fileSystemProblems[code] : undefined;\n\n if (problem && typeof path === \"string\") {\n return `${problem}: ${path}`;\n }\n\n return error.message;\n};\n","import { parseCliArgs } from \"./args/parse\";\nimport type { CliInvocation } from \"./args/schema\";\nimport { runCheck } from \"./commands/check\";\nimport { runInit } from \"./commands/init\";\nimport { helpText, versionText } from \"./help\";\nimport { defaultIo, type Io } from \"./io\";\nimport { reportError } from \"./report-error\";\n\nexport const run = async (\n args: string[],\n io: Io = defaultIo,\n cwd: string = process.cwd()\n): Promise<number> => {\n let verbose = false;\n\n try {\n const invocation = parseCliArgs(args, cwd);\n verbose = \"verbose\" in invocation && invocation.verbose;\n\n return await execute(invocation, io);\n } catch (error) {\n return reportError(error, io, verbose);\n }\n};\n\nconst execute = async (invocation: CliInvocation, io: Io): Promise<number> => {\n switch (invocation.kind) {\n case \"check\":\n return await runCheck(invocation, io);\n case \"init\":\n return await runInit(invocation, io);\n case \"version\": {\n const text = await versionText();\n io.stdout(text);\n return 0;\n }\n case \"help\":\n io.stdout(helpText());\n return 0;\n default: {\n const _exhaustiveCheck: never = invocation;\n throw new Error(`Unknown invocation: ${JSON.stringify(_exhaustiveCheck)}`);\n }\n }\n};\n","#!/usr/bin/env node\n\nimport { defaultIo } from \"./io\";\nimport { run } from \"./main\";\n\n// `run` reports every failure itself and resolves to the exit code, so there is nothing to catch\nvoid run(process.argv.slice(2), defaultIo).then(exitCode => {\n process.exitCode = exitCode;\n});\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,YAAgB;CAC3B,SAAQ,SAAQ,QAAQ,IAAI,IAAI;CAChC,SAAQ,SAAQ,QAAQ,MAAM,IAAI;AACpC;AAEA,MAAa,uBAAuB,IAAQ,YAAgC;CAC1E,IAAI,CAAC,SACH,aAAa,CAAC;CAGhB,MAAM,WAAqB,YAAW,GAAG,OAAO,OAAO;CACvD,QAAQ,yBAAyB;CAEjC,OAAO;AACT;;;ACrBA,IAAa,aAAb,cAAgC,MAAM;CACpC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;ACDA,MAAa,4BAA4B,EAAE,KACzC,CAAC,WAAW,MAAM,GAClB,EACE,QAAO,UACL,4DAA4D,OAAO,MAAM,KAAK,EAAE,GACpF,CACF;;AAGA,MAAa,sBAAsB,EAAE,mBAAmB,QAAQ;CAC9D,EAAE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AW;GACd,MAAM,OAAO,MAAM,YAAY;GAC/B,GAAG,OAAO,IAAI;GACd,OAAO;EACT;EACA,KAAK;GACH,GAAG,OAAO,SAAS,CAAC;GACpB,OAAO;EACT,SAEE,MAAM,IAAI,MAAM,uBAAuB,KAAK,UAAUC,UAAgB,GAAG;CAE7E;AACF;;;ACtCK,IAAI,QAAQ,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,MAAK,aAAY;CAC1D,QAAQ,WAAW;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,21 @@
1
1
  {
2
2
  "name": "license-cop",
3
- "version": "1.9.0",
4
- "type": "commonjs",
3
+ "version": "2.0.0",
4
+ "type": "module",
5
5
  "bin": {
6
- "license-cop": "./src/bin/license-cop"
6
+ "license-cop": "./dist/bin.js"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsdown",
13
+ "typecheck": "tsc -p tsconfig.json",
14
+ "lint": "eslint . --max-warnings 0",
15
+ "test": "bun test --isolate --coverage --coverage-reporter=lcov --coverage-dir=coverage",
16
+ "version": "bun pm pkg set version=$VERSION",
17
+ "pack": "bun pm pack",
18
+ "publish": "npm publish *.tgz --access public --provenance --tag $NPM_TAG"
7
19
  },
8
20
  "author": {
9
21
  "name": "Toby Smith",
@@ -16,7 +28,7 @@
16
28
  "repository": {
17
29
  "type": "git",
18
30
  "url": "git+https://github.com/tobysmith568/license-cop.git",
19
- "directory": "packages/license-cop"
31
+ "directory": "packages/cli"
20
32
  },
21
33
  "bugs": {
22
34
  "url": "https://github.com/tobysmith568/license-cop/issues"
@@ -31,18 +43,13 @@
31
43
  "oss"
32
44
  ],
33
45
  "dependencies": {
34
- "@commander-js/extra-typings": "^14.0.0",
35
- "@npmcli/arborist": "^9.0.0",
36
- "@pnpm/reviewing.dependencies-hierarchy": "^1001.0.0",
37
- "axios": "^1.6.0",
38
- "commander": "^14.0.0",
39
- "compare-versions": "^6.0.0-rc.1",
46
+ "@license-cop/core": "0.0.0",
40
47
  "cosmiconfig": "^9.0.0",
41
48
  "deepmerge": "^4.3.1",
42
- "git-filesystem": "^0.0.6",
43
49
  "json5": "^2.2.3",
44
50
  "zod": "^4.0.0"
45
51
  },
46
- "types": "./src/index.d.ts",
47
- "main": "./src/index.js"
48
- }
52
+ "devDependencies": {
53
+ "@license-cop/test-utils": "0.0.0"
54
+ }
55
+ }
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- require("../lib/cli").main(process.argv);
package/src/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { checkLicenses } from "./lib/license-cop";
2
- export type { LicenseCopOptions } from "./lib/license-cop";
3
- export type { AllowedPackage, CheckLicensesResult, ForbiddenLicenseResult, LicensedPackage, NoLicenseResult } from "./lib/result";
package/src/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "checkLicenses", {
3
- enumerable: true,
4
- get: function() {
5
- return _licensecop.checkLicenses;
6
- }
7
- });
8
- const _licensecop = require("./lib/license-cop");
9
-
10
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../packages/license-cop/src/index.ts"],"sourcesContent":["export { checkLicenses } from \"./lib/license-cop\";\nexport type { LicenseCopOptions } from \"./lib/license-cop\";\nexport type {\n AllowedPackage,\n CheckLicensesResult,\n ForbiddenLicenseResult,\n LicensedPackage,\n NoLicenseResult\n} from \"./lib/result\";\n\n// The following is included to insure that Nx doesn't remove \"commander\"\n// as a dependency from packages/license-cop/package.json.\n//\n// This is necessary because the @nx/dependency-checks eslint rule will\n// remove commander if the license-cop package never imports from it directly.\n//\n// This approach was chosen over using the ignoredDependencies config option\n// to insure that the same eslint rule continues to catch when the commander\n// version falls out of sync with the @commander-js/extra-typings version.\nimport type { Command as _Command } from \"commander\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype _UnusedCommand = _Command;\n"],"names":["checkLicenses"],"mappings":";+BAASA;;;eAAAA,yBAAa;;;4BAAQ"}
@@ -1,5 +0,0 @@
1
- export declare const initCommand: import("@commander-js/extra-typings").Command<[], {
2
- verbose?: true | undefined;
3
- directory: string;
4
- }, {}>;
5
- export declare const initCommandAction: (rootDir: string) => Promise<void>;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- function _export(target, all) {
3
- for(var name in all)Object.defineProperty(target, name, {
4
- enumerable: true,
5
- get: Object.getOwnPropertyDescriptor(all, name).get
6
- });
7
- }
8
- _export(exports, {
9
- get initCommand () {
10
- return initCommand;
11
- },
12
- get initCommandAction () {
13
- return initCommandAction;
14
- }
15
- });
16
- const _promises = require("fs/promises");
17
- const _path = require("path");
18
- const _logger = require("../../logger");
19
- const _createcommand = require("../create-command");
20
- const defaultConfig = `{
21
- "$schema": "https://license-cop.js.org/schema.json",
22
- "licenses": ["MIT", "ISC", "Apache-2.0"],
23
- "packages": []
24
- }
25
- `;
26
- const initCommand = (0, _createcommand.createCommandWithGlobalOptions)().name("init").description("Create a new license-cop configuration file").action(async (options)=>{
27
- const { directory } = options;
28
- await initCommandAction(directory);
29
- });
30
- const initCommandAction = async (rootDir)=>{
31
- _logger.default.log("Setting up a new license-cop config file...");
32
- const configPath = (0, _path.join)(rootDir, ".licenses.json");
33
- _logger.default.verbose(`Writing config file to: ${configPath}`);
34
- await (0, _promises.writeFile)(configPath, defaultConfig);
35
- _logger.default.log("Done!");
36
- _logger.default.log("Run `npx license-cop` to check your dependencies");
37
- };
38
-
39
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/cli/commands/init.ts"],"sourcesContent":["import { writeFile } from \"fs/promises\";\nimport { join } from \"path\";\nimport logger from \"../../logger\";\nimport { createCommandWithGlobalOptions } from \"../create-command\";\n\nconst defaultConfig = `{\n \"$schema\": \"https://license-cop.js.org/schema.json\",\n \"licenses\": [\"MIT\", \"ISC\", \"Apache-2.0\"],\n \"packages\": []\n}\n`;\n\nexport const initCommand = createCommandWithGlobalOptions()\n .name(\"init\")\n .description(\"Create a new license-cop configuration file\")\n .action(async options => {\n const { directory } = options;\n\n await initCommandAction(directory);\n });\n\nexport const initCommandAction = async (rootDir: string) => {\n logger.log(\"Setting up a new license-cop config file...\");\n\n const configPath = join(rootDir, \".licenses.json\");\n logger.verbose(`Writing config file to: ${configPath}`);\n await writeFile(configPath, defaultConfig);\n\n logger.log(\"Done!\");\n logger.log(\"Run `npx license-cop` to check your dependencies\");\n};\n"],"names":["initCommand","initCommandAction","defaultConfig","createCommandWithGlobalOptions","name","description","action","options","directory","rootDir","logger","log","configPath","join","verbose","writeFile"],"mappings":";;;;;;;;QAYaA;eAAAA;;QASAC;eAAAA;;;0BArBa;sBACL;wBACF;+BAC4B;AAE/C,MAAMC,gBAAgB,CAAC;;;;;AAKvB,CAAC;AAEM,MAAMF,cAAcG,IAAAA,6CAA8B,IACtDC,IAAI,CAAC,QACLC,WAAW,CAAC,+CACZC,MAAM,CAAC,OAAMC;IACZ,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,MAAMN,kBAAkBO;AAC1B;AAEK,MAAMP,oBAAoB,OAAOQ;IACtCC,eAAM,CAACC,GAAG,CAAC;IAEX,MAAMC,aAAaC,IAAAA,UAAI,EAACJ,SAAS;IACjCC,eAAM,CAACI,OAAO,CAAC,CAAC,wBAAwB,EAAEF,YAAY;IACtD,MAAMG,IAAAA,mBAAS,EAACH,YAAYV;IAE5BQ,eAAM,CAACC,GAAG,CAAC;IACXD,eAAM,CAACC,GAAG,CAAC;AACb"}
@@ -1,7 +0,0 @@
1
- export declare const mainCommand: import("@commander-js/extra-typings").Command<[], {
2
- verbose?: true | undefined;
3
- directory: string;
4
- includeDev: boolean;
5
- devOnly: boolean;
6
- init: boolean;
7
- }, {}>;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "mainCommand", {
3
- enumerable: true,
4
- get: function() {
5
- return mainCommand;
6
- }
7
- });
8
- const _path = require("path");
9
- const _configerror = require("../../config/config-error");
10
- const _loadconfig = require("../../config/load-config");
11
- const _packagejson = require("../../dependency/package-json");
12
- const _licensecop = require("../../license-cop");
13
- const _logger = require("../../logger");
14
- const _createcommand = require("../create-command");
15
- const _reportfailure = require("../report-failure");
16
- const _reportsuccess = require("../report-success");
17
- const _init = require("./init");
18
- const mainCommand = (0, _createcommand.createCommandWithGlobalOptions)().name("license-cop").description("Yet another license checker tool for your dependencies; focused on simplicity").option("-D,--include-dev", "Include dev dependencies", false).option("--dev-only", "Only check dev dependencies", false).option("--init", "An alias for 'license-cop init'", false).action(async (options)=>{
19
- const { directory, includeDev, devOnly } = options;
20
- if (options.init) {
21
- await (0, _init.initCommandAction)(directory);
22
- return;
23
- }
24
- try {
25
- await runLicenseCop(directory, includeDev, devOnly);
26
- } catch (e) {
27
- if (e instanceof _configerror.ConfigError) {
28
- _logger.default.error(e.message);
29
- process.exitCode = 1;
30
- return;
31
- }
32
- throw e;
33
- }
34
- });
35
- const runLicenseCop = async (directory, includeDevDependencies, devDependenciesOnly)=>{
36
- _logger.default.verbose(`Using directory: ${directory}`);
37
- const productName = await getProductName(directory);
38
- _logger.default.log(`Scanning dependencies of: ${productName}`);
39
- const config = await (0, _loadconfig.loadConfig)(directory);
40
- const options = {
41
- allowedLicenses: config.licenses,
42
- allowedPackages: config.packages,
43
- workingDirectory: directory,
44
- includeDevDependencies: includeDevDependencies || config.includeDevDependencies,
45
- devDependenciesOnly: devDependenciesOnly || config.devDependenciesOnly
46
- };
47
- const result = await (0, _licensecop.checkLicenses)(options);
48
- if (result.noLicenses.size > 0 || result.forbiddenLicenses.size > 0) {
49
- (0, _reportfailure.reportFailure)(result);
50
- process.exitCode = 1;
51
- } else {
52
- (0, _reportsuccess.reportSuccess)(result);
53
- }
54
- };
55
- const getProductName = async (directory)=>{
56
- const packageJsonPath = (0, _path.join)(directory, "package.json");
57
- const packageJson = await (0, _packagejson.readPackageJson)(packageJsonPath);
58
- return packageJson.name;
59
- };
60
-
61
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/cli/commands/main.ts"],"sourcesContent":["import { join } from \"path\";\nimport { ConfigError } from \"../../config/config-error\";\nimport { loadConfig } from \"../../config/load-config\";\nimport { readPackageJson } from \"../../dependency/package-json\";\nimport { checkLicenses, LicenseCopOptions } from \"../../license-cop\";\nimport logger from \"../../logger\";\nimport { createCommandWithGlobalOptions } from \"../create-command\";\nimport { reportFailure } from \"../report-failure\";\nimport { reportSuccess } from \"../report-success\";\nimport { initCommandAction } from \"./init\";\n\nexport const mainCommand = createCommandWithGlobalOptions()\n .name(\"license-cop\")\n .description(\"Yet another license checker tool for your dependencies; focused on simplicity\")\n .option(\"-D,--include-dev\", \"Include dev dependencies\", false)\n .option(\"--dev-only\", \"Only check dev dependencies\", false)\n .option(\"--init\", \"An alias for 'license-cop init'\", false)\n .action(async options => {\n const { directory, includeDev, devOnly } = options;\n\n if (options.init) {\n await initCommandAction(directory);\n return;\n }\n\n try {\n await runLicenseCop(directory, includeDev, devOnly);\n } catch (e) {\n if (e instanceof ConfigError) {\n logger.error(e.message);\n process.exitCode = 1;\n return;\n }\n throw e;\n }\n });\n\nconst runLicenseCop = async (\n directory: string,\n includeDevDependencies: boolean,\n devDependenciesOnly: boolean\n) => {\n logger.verbose(`Using directory: ${directory}`);\n\n const productName = await getProductName(directory);\n logger.log(`Scanning dependencies of: ${productName}`);\n\n const config = await loadConfig(directory);\n\n const options: LicenseCopOptions = {\n allowedLicenses: config.licenses,\n allowedPackages: config.packages,\n\n workingDirectory: directory,\n includeDevDependencies: includeDevDependencies || config.includeDevDependencies,\n devDependenciesOnly: devDependenciesOnly || config.devDependenciesOnly\n };\n\n const result = await checkLicenses(options);\n\n if (result.noLicenses.size > 0 || result.forbiddenLicenses.size > 0) {\n reportFailure(result);\n process.exitCode = 1;\n } else {\n reportSuccess(result);\n }\n};\n\nconst getProductName = async (directory: string): Promise<string> => {\n const packageJsonPath = join(directory, \"package.json\");\n const packageJson = await readPackageJson(packageJsonPath);\n return packageJson.name;\n};\n"],"names":["mainCommand","createCommandWithGlobalOptions","name","description","option","action","options","directory","includeDev","devOnly","init","initCommandAction","runLicenseCop","e","ConfigError","logger","error","message","process","exitCode","includeDevDependencies","devDependenciesOnly","verbose","productName","getProductName","log","config","loadConfig","allowedLicenses","licenses","allowedPackages","packages","workingDirectory","result","checkLicenses","noLicenses","size","forbiddenLicenses","reportFailure","reportSuccess","packageJsonPath","join","packageJson","readPackageJson"],"mappings":";+BAWaA;;;eAAAA;;;sBAXQ;6BACO;4BACD;6BACK;4BACiB;wBAC9B;+BAC4B;+BACjB;+BACA;sBACI;AAE3B,MAAMA,cAAcC,IAAAA,6CAA8B,IACtDC,IAAI,CAAC,eACLC,WAAW,CAAC,iFACZC,MAAM,CAAC,oBAAoB,4BAA4B,OACvDA,MAAM,CAAC,cAAc,+BAA+B,OACpDA,MAAM,CAAC,UAAU,mCAAmC,OACpDC,MAAM,CAAC,OAAMC;IACZ,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAE,GAAGH;IAE3C,IAAIA,QAAQI,IAAI,EAAE;QAChB,MAAMC,IAAAA,uBAAiB,EAACJ;QACxB;IACF;IAEA,IAAI;QACF,MAAMK,cAAcL,WAAWC,YAAYC;IAC7C,EAAE,OAAOI,GAAG;QACV,IAAIA,aAAaC,wBAAW,EAAE;YAC5BC,eAAM,CAACC,KAAK,CAACH,EAAEI,OAAO;YACtBC,QAAQC,QAAQ,GAAG;YACnB;QACF;QACA,MAAMN;IACR;AACF;AAEF,MAAMD,gBAAgB,OACpBL,WACAa,wBACAC;IAEAN,eAAM,CAACO,OAAO,CAAC,CAAC,iBAAiB,EAAEf,WAAW;IAE9C,MAAMgB,cAAc,MAAMC,eAAejB;IACzCQ,eAAM,CAACU,GAAG,CAAC,CAAC,0BAA0B,EAAEF,aAAa;IAErD,MAAMG,SAAS,MAAMC,IAAAA,sBAAU,EAACpB;IAEhC,MAAMD,UAA6B;QACjCsB,iBAAiBF,OAAOG,QAAQ;QAChCC,iBAAiBJ,OAAOK,QAAQ;QAEhCC,kBAAkBzB;QAClBa,wBAAwBA,0BAA0BM,OAAON,sBAAsB;QAC/EC,qBAAqBA,uBAAuBK,OAAOL,mBAAmB;IACxE;IAEA,MAAMY,SAAS,MAAMC,IAAAA,yBAAa,EAAC5B;IAEnC,IAAI2B,OAAOE,UAAU,CAACC,IAAI,GAAG,KAAKH,OAAOI,iBAAiB,CAACD,IAAI,GAAG,GAAG;QACnEE,IAAAA,4BAAa,EAACL;QACdf,QAAQC,QAAQ,GAAG;IACrB,OAAO;QACLoB,IAAAA,4BAAa,EAACN;IAChB;AACF;AAEA,MAAMT,iBAAiB,OAAOjB;IAC5B,MAAMiC,kBAAkBC,IAAAA,UAAI,EAAClC,WAAW;IACxC,MAAMmC,cAAc,MAAMC,IAAAA,4BAAe,EAACH;IAC1C,OAAOE,YAAYxC,IAAI;AACzB"}
@@ -1,4 +0,0 @@
1
- export declare const versionCommand: import("@commander-js/extra-typings").Command<[], {
2
- verbose?: true | undefined;
3
- directory: string;
4
- }, {}>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "versionCommand", {
3
- enumerable: true,
4
- get: function() {
5
- return versionCommand;
6
- }
7
- });
8
- const _path = require("path");
9
- const _packagejson = require("../../dependency/package-json");
10
- const _logger = require("../../logger");
11
- const _createcommand = require("../create-command");
12
- const versionCommand = (0, _createcommand.createCommandWithGlobalOptions)().name("-v").alias("--version").description("Print the installed version of license-cop").action(async ()=>{
13
- await printPackageVersion();
14
- });
15
- const printPackageVersion = async ()=>{
16
- const packageJsonLocation = (0, _path.join)(__dirname, "../../../../package.json");
17
- const { version } = await (0, _packagejson.readPackageJson)(packageJsonLocation);
18
- _logger.default.log(`v${version}`);
19
- };
20
-
21
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../packages/license-cop/src/lib/cli/commands/version.ts"],"sourcesContent":["import { join } from \"path\";\nimport { readPackageJson } from \"../../dependency/package-json\";\nimport logger from \"../../logger\";\nimport { createCommandWithGlobalOptions } from \"../create-command\";\n\nexport const versionCommand = createCommandWithGlobalOptions()\n .name(\"-v\")\n .alias(\"--version\")\n .description(\"Print the installed version of license-cop\")\n .action(async () => {\n await printPackageVersion();\n });\n\nconst printPackageVersion = async (): Promise<void> => {\n const packageJsonLocation = join(__dirname, \"../../../../package.json\");\n const { version } = await readPackageJson(packageJsonLocation);\n logger.log(`v${version}`);\n};\n"],"names":["versionCommand","createCommandWithGlobalOptions","name","alias","description","action","printPackageVersion","packageJsonLocation","join","__dirname","version","readPackageJson","logger","log"],"mappings":";+BAKaA;;;eAAAA;;;sBALQ;6BACW;wBACb;+BAC4B;AAExC,MAAMA,iBAAiBC,IAAAA,6CAA8B,IACzDC,IAAI,CAAC,MACLC,KAAK,CAAC,aACNC,WAAW,CAAC,8CACZC,MAAM,CAAC;IACN,MAAMC;AACR;AAEF,MAAMA,sBAAsB;IAC1B,MAAMC,sBAAsBC,IAAAA,UAAI,EAACC,WAAW;IAC5C,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMC,IAAAA,4BAAe,EAACJ;IAC1CK,eAAM,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEH,SAAS;AAC1B"}
@@ -1,5 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- export declare const createCommandWithGlobalOptions: () => Command<[], {
3
- verbose?: true | undefined;
4
- directory: string;
5
- }, {}>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "createCommandWithGlobalOptions", {
3
- enumerable: true,
4
- get: function() {
5
- return createCommandWithGlobalOptions;
6
- }
7
- });
8
- const _extratypings = require("@commander-js/extra-typings");
9
- const _logger = require("../logger");
10
- const createCommandWithGlobalOptions = ()=>new _extratypings.Command().option("--verbose", "Enable verbose logging").option("-d,--directory <directory>", "The directory of the project. Defaults to the current working directory.", process.cwd()).hook("preAction", (thisCommand)=>{
11
- const { verbose } = thisCommand.opts();
12
- if (verbose) {
13
- _logger.default.enableVerboseLogging();
14
- }
15
- });
16
-
17
- //# sourceMappingURL=create-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/cli/create-command.ts"],"sourcesContent":["import { Command } from \"@commander-js/extra-typings\";\nimport logger from \"../logger\";\n\nexport const createCommandWithGlobalOptions = () =>\n new Command()\n .option(\"--verbose\", \"Enable verbose logging\")\n .option(\n \"-d,--directory <directory>\",\n \"The directory of the project. Defaults to the current working directory.\",\n process.cwd()\n )\n .hook(\"preAction\", thisCommand => {\n const { verbose } = thisCommand.opts();\n\n if (verbose) {\n logger.enableVerboseLogging();\n }\n });\n"],"names":["createCommandWithGlobalOptions","Command","option","process","cwd","hook","thisCommand","verbose","opts","logger","enableVerboseLogging"],"mappings":";+BAGaA;;;eAAAA;;;8BAHW;wBACL;AAEZ,MAAMA,iCAAiC,IAC5C,IAAIC,qBAAO,GACRC,MAAM,CAAC,aAAa,0BACpBA,MAAM,CACL,8BACA,4EACAC,QAAQC,GAAG,IAEZC,IAAI,CAAC,aAAaC,CAAAA;QACjB,MAAM,EAAEC,OAAO,EAAE,GAAGD,YAAYE,IAAI;QAEpC,IAAID,SAAS;YACXE,eAAM,CAACC,oBAAoB;QAC7B;IACF"}
@@ -1 +0,0 @@
1
- export declare const main: (args: string[]) => Promise<void>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "main", {
3
- enumerable: true,
4
- get: function() {
5
- return main;
6
- }
7
- });
8
- const _logger = require("../logger");
9
- const _init = require("./commands/init");
10
- const _main = require("./commands/main");
11
- const _version = require("./commands/version");
12
- const main = async (args)=>{
13
- _logger.default.enableLogging();
14
- await program.parseAsync(args);
15
- };
16
- const program = _main.mainCommand.addCommand(_init.initCommand).addCommand(_version.versionCommand);
17
-
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/cli/index.ts"],"sourcesContent":["import logger from \"../logger\";\nimport { initCommand } from \"./commands/init\";\nimport { mainCommand } from \"./commands/main\";\nimport { versionCommand } from \"./commands/version\";\n\nexport const main = async (args: string[]): Promise<void> => {\n logger.enableLogging();\n await program.parseAsync(args);\n};\n\nconst program = mainCommand.addCommand(initCommand).addCommand(versionCommand);\n"],"names":["main","args","logger","enableLogging","program","parseAsync","mainCommand","addCommand","initCommand","versionCommand"],"mappings":";+BAKaA;;;eAAAA;;;wBALM;sBACS;sBACA;yBACG;AAExB,MAAMA,OAAO,OAAOC;IACzBC,eAAM,CAACC,aAAa;IACpB,MAAMC,QAAQC,UAAU,CAACJ;AAC3B;AAEA,MAAMG,UAAUE,iBAAW,CAACC,UAAU,CAACC,iBAAW,EAAED,UAAU,CAACE,uBAAc"}
@@ -1,2 +0,0 @@
1
- import { CheckLicensesResult } from "../result";
2
- export declare const reportFailure: (result: CheckLicensesResult) => void;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "reportFailure", {
3
- enumerable: true,
4
- get: function() {
5
- return reportFailure;
6
- }
7
- });
8
- const _logger = require("../logger");
9
- const reportFailure = (result)=>{
10
- const { noLicenses, forbiddenLicenses } = result;
11
- _logger.default.log("Found the following issues...\n");
12
- if (noLicenses.size > 0) {
13
- logNoLicenseIssues(noLicenses);
14
- }
15
- if (forbiddenLicenses.size > 0) {
16
- logForbiddenLicenseIssues(forbiddenLicenses);
17
- }
18
- };
19
- const logNoLicenseIssues = (noLicenseResults)=>{
20
- _logger.default.error("Packages with no license:");
21
- for (const result of noLicenseResults.values()){
22
- const { name, version } = result;
23
- _logger.default.error(`${name}@${version}`);
24
- }
25
- _logger.default.error("");
26
- };
27
- const logForbiddenLicenseIssues = (forbiddenLicensesResults)=>{
28
- _logger.default.error("Packages with forbidden licenses:");
29
- for (const result of forbiddenLicensesResults.values()){
30
- const { name, version, licenseIdentifiers, spdxExpression } = result;
31
- const licenseDetails = licenseIdentifiers === spdxExpression ? licenseIdentifiers : `${licenseIdentifiers} from ${spdxExpression}`;
32
- _logger.default.error(`${name}@${version} - ${licenseDetails}`);
33
- }
34
- };
35
-
36
- //# sourceMappingURL=report-failure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/cli/report-failure.ts"],"sourcesContent":["import logger from \"../logger\";\nimport { CheckLicensesResult, ForbiddenLicenseResult, NoLicenseResult } from \"../result\";\n\nexport const reportFailure = (result: CheckLicensesResult): void => {\n const { noLicenses, forbiddenLicenses } = result;\n\n logger.log(\"Found the following issues...\\n\");\n\n if (noLicenses.size > 0) {\n logNoLicenseIssues(noLicenses);\n }\n\n if (forbiddenLicenses.size > 0) {\n logForbiddenLicenseIssues(forbiddenLicenses);\n }\n};\n\nconst logNoLicenseIssues = (noLicenseResults: Set<NoLicenseResult>) => {\n logger.error(\"Packages with no license:\");\n\n for (const result of noLicenseResults.values()) {\n const { name, version } = result;\n logger.error(`${name}@${version}`);\n }\n\n logger.error(\"\");\n};\n\nconst logForbiddenLicenseIssues = (forbiddenLicensesResults: Set<ForbiddenLicenseResult>): void => {\n logger.error(\"Packages with forbidden licenses:\");\n\n for (const result of forbiddenLicensesResults.values()) {\n const { name, version, licenseIdentifiers, spdxExpression } = result;\n\n const licenseDetails =\n licenseIdentifiers === spdxExpression\n ? licenseIdentifiers\n : `${licenseIdentifiers} from ${spdxExpression}`;\n\n logger.error(`${name}@${version} - ${licenseDetails}`);\n }\n};\n"],"names":["reportFailure","result","noLicenses","forbiddenLicenses","logger","log","size","logNoLicenseIssues","logForbiddenLicenseIssues","noLicenseResults","error","values","name","version","forbiddenLicensesResults","licenseIdentifiers","spdxExpression","licenseDetails"],"mappings":";+BAGaA;;;eAAAA;;;wBAHM;AAGZ,MAAMA,gBAAgB,CAACC;IAC5B,MAAM,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGF;IAE1CG,eAAM,CAACC,GAAG,CAAC;IAEX,IAAIH,WAAWI,IAAI,GAAG,GAAG;QACvBC,mBAAmBL;IACrB;IAEA,IAAIC,kBAAkBG,IAAI,GAAG,GAAG;QAC9BE,0BAA0BL;IAC5B;AACF;AAEA,MAAMI,qBAAqB,CAACE;IAC1BL,eAAM,CAACM,KAAK,CAAC;IAEb,KAAK,MAAMT,UAAUQ,iBAAiBE,MAAM,GAAI;QAC9C,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGZ;QAC1BG,eAAM,CAACM,KAAK,CAAC,GAAGE,KAAK,CAAC,EAAEC,SAAS;IACnC;IAEAT,eAAM,CAACM,KAAK,CAAC;AACf;AAEA,MAAMF,4BAA4B,CAACM;IACjCV,eAAM,CAACM,KAAK,CAAC;IAEb,KAAK,MAAMT,UAAUa,yBAAyBH,MAAM,GAAI;QACtD,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEE,kBAAkB,EAAEC,cAAc,EAAE,GAAGf;QAE9D,MAAMgB,iBACJF,uBAAuBC,iBACnBD,qBACA,GAAGA,mBAAmB,MAAM,EAAEC,gBAAgB;QAEpDZ,eAAM,CAACM,KAAK,CAAC,GAAGE,KAAK,CAAC,EAAEC,QAAQ,GAAG,EAAEI,gBAAgB;IACvD;AACF"}
@@ -1,2 +0,0 @@
1
- import { CheckLicensesResult } from "../result";
2
- export declare const reportSuccess: (result: CheckLicensesResult) => void;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "reportSuccess", {
3
- enumerable: true,
4
- get: function() {
5
- return reportSuccess;
6
- }
7
- });
8
- const _logger = require("../logger");
9
- const reportSuccess = (result)=>{
10
- const { allowedPackages, allowedLicenses } = result;
11
- _logger.default.log("\nDone! No issues found");
12
- if (allowedPackages.size !== 0) {
13
- _logger.default.log(`Found ${allowedPackages.size} allowed packages`);
14
- }
15
- if (allowedLicenses.size !== 0) {
16
- _logger.default.log(`Found ${allowedLicenses.size} packages with allowed licenses`);
17
- }
18
- _logger.default.verbose("\nExiting with error code 0");
19
- process.exitCode = 0;
20
- };
21
-
22
- //# sourceMappingURL=report-success.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/cli/report-success.ts"],"sourcesContent":["import logger from \"../logger\";\nimport { CheckLicensesResult } from \"../result\";\n\nexport const reportSuccess = (result: CheckLicensesResult): void => {\n const { allowedPackages, allowedLicenses } = result;\n\n logger.log(\"\\nDone! No issues found\");\n\n if (allowedPackages.size !== 0) {\n logger.log(`Found ${allowedPackages.size} allowed packages`);\n }\n\n if (allowedLicenses.size !== 0) {\n logger.log(`Found ${allowedLicenses.size} packages with allowed licenses`);\n }\n\n logger.verbose(\"\\nExiting with error code 0\");\n process.exitCode = 0;\n};\n"],"names":["reportSuccess","result","allowedPackages","allowedLicenses","logger","log","size","verbose","process","exitCode"],"mappings":";+BAGaA;;;eAAAA;;;wBAHM;AAGZ,MAAMA,gBAAgB,CAACC;IAC5B,MAAM,EAAEC,eAAe,EAAEC,eAAe,EAAE,GAAGF;IAE7CG,eAAM,CAACC,GAAG,CAAC;IAEX,IAAIH,gBAAgBI,IAAI,KAAK,GAAG;QAC9BF,eAAM,CAACC,GAAG,CAAC,CAAC,MAAM,EAAEH,gBAAgBI,IAAI,CAAC,iBAAiB,CAAC;IAC7D;IAEA,IAAIH,gBAAgBG,IAAI,KAAK,GAAG;QAC9BF,eAAM,CAACC,GAAG,CAAC,CAAC,MAAM,EAAEF,gBAAgBG,IAAI,CAAC,+BAA+B,CAAC;IAC3E;IAEAF,eAAM,CAACG,OAAO,CAAC;IACfC,QAAQC,QAAQ,GAAG;AACrB"}
@@ -1,4 +0,0 @@
1
- export declare class ConfigError extends Error {
2
- constructor(message: string);
3
- static fromUnknown(e: unknown): ConfigError;
4
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "ConfigError", {
3
- enumerable: true,
4
- get: function() {
5
- return ConfigError;
6
- }
7
- });
8
- let ConfigError = class ConfigError extends Error {
9
- static fromUnknown(e) {
10
- const message = resolveMessage(e);
11
- return new ConfigError(message);
12
- }
13
- constructor(message){
14
- super(`Config error: ${message}`);
15
- }
16
- };
17
- const resolveMessage = (e)=>{
18
- if (e instanceof Error) {
19
- return e.message;
20
- }
21
- if (typeof e === "string") {
22
- return e;
23
- }
24
- return "Unknown error";
25
- };
26
-
27
- //# sourceMappingURL=config-error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config-error.ts"],"sourcesContent":["export class ConfigError extends Error {\n constructor(message: string) {\n super(`Config error: ${message}`);\n }\n\n static fromUnknown(e: unknown): ConfigError {\n const message = resolveMessage(e);\n return new ConfigError(message);\n }\n}\n\nconst resolveMessage = (e: unknown): string => {\n if (e instanceof Error) {\n return e.message;\n }\n\n if (typeof e === \"string\") {\n return e;\n }\n\n return \"Unknown error\";\n};\n"],"names":["ConfigError","Error","fromUnknown","e","message","resolveMessage"],"mappings":";+BAAaA;;;eAAAA;;;AAAN,IAAA,AAAMA,cAAN,MAAMA,oBAAoBC;IAK/B,OAAOC,YAAYC,CAAU,EAAe;QAC1C,MAAMC,UAAUC,eAAeF;QAC/B,OAAO,IAAIH,YAAYI;IACzB;IAPA,YAAYA,OAAe,CAAE;QAC3B,KAAK,CAAC,CAAC,cAAc,EAAEA,SAAS;IAClC;AAMF;AAEA,MAAMC,iBAAiB,CAACF;IACtB,IAAIA,aAAaF,OAAO;QACtB,OAAOE,EAAEC,OAAO;IAClB;IAEA,IAAI,OAAOD,MAAM,UAAU;QACzB,OAAOA;IACT;IAEA,OAAO;AACT"}
@@ -1,25 +0,0 @@
1
- import { z } from "zod";
2
- declare const configParser: z.ZodPipe<z.ZodObject<{
3
- extends: z.ZodOptional<z.ZodString>;
4
- licenses: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
- packages: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- includeDevDependencies: z.ZodOptional<z.ZodBoolean>;
7
- devDependenciesOnly: z.ZodOptional<z.ZodBoolean>;
8
- directory: z.ZodOptional<z.ZodString>;
9
- }, z.core.$strip>, z.ZodTransform<{
10
- extends: string | undefined;
11
- licenses: string[];
12
- packages: string[];
13
- includeDevDependencies: boolean;
14
- devDependenciesOnly: boolean;
15
- }, {
16
- extends?: string | undefined;
17
- licenses?: string[] | undefined;
18
- packages?: string[] | undefined;
19
- includeDevDependencies?: boolean | undefined;
20
- devDependenciesOnly?: boolean | undefined;
21
- directory?: string | undefined;
22
- }>>;
23
- export type Config = z.infer<typeof configParser>;
24
- export declare const parseConfig: (config: unknown) => Config;
25
- export {};
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "parseConfig", {
3
- enumerable: true,
4
- get: function() {
5
- return parseConfig;
6
- }
7
- });
8
- const _zod = require("zod");
9
- const _configerror = require("./config-error");
10
- const configParser = _zod.z.object({
11
- extends: _zod.z.string().optional(),
12
- licenses: _zod.z.array(_zod.z.string()).optional(),
13
- packages: _zod.z.array(_zod.z.string()).optional(),
14
- includeDevDependencies: _zod.z.boolean().optional(),
15
- devDependenciesOnly: _zod.z.boolean().optional(),
16
- directory: _zod.z.string().optional()
17
- }).transform((c)=>{
18
- var _c_licenses, _c_packages, _c_includeDevDependencies, _c_devDependenciesOnly;
19
- return {
20
- extends: c.extends,
21
- licenses: (_c_licenses = c.licenses) != null ? _c_licenses : [],
22
- packages: (_c_packages = c.packages) != null ? _c_packages : [],
23
- includeDevDependencies: (_c_includeDevDependencies = c.includeDevDependencies) != null ? _c_includeDevDependencies : false,
24
- devDependenciesOnly: (_c_devDependenciesOnly = c.devDependenciesOnly) != null ? _c_devDependenciesOnly : false
25
- };
26
- });
27
- const parseConfig = (config)=>{
28
- const parseResult = configParser.safeParse(config);
29
- if (!parseResult.success) {
30
- throw new _configerror.ConfigError(parseResult.error.message);
31
- }
32
- return parseResult.data;
33
- };
34
-
35
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../packages/license-cop/src/lib/config/config.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ConfigError } from \"./config-error\";\n\nconst configParser = z\n .object({\n extends: z.string().optional(),\n licenses: z.array(z.string()).optional(),\n packages: z.array(z.string()).optional(),\n includeDevDependencies: z.boolean().optional(),\n devDependenciesOnly: z.boolean().optional(),\n directory: z.string().optional()\n })\n .transform(c => ({\n extends: c.extends,\n licenses: c.licenses ?? [],\n packages: c.packages ?? [],\n includeDevDependencies: c.includeDevDependencies ?? false,\n devDependenciesOnly: c.devDependenciesOnly ?? false\n }));\n\nexport type Config = z.infer<typeof configParser>;\n\nexport const parseConfig = (config: unknown): Config => {\n const parseResult = configParser.safeParse(config);\n\n if (!parseResult.success) {\n throw new ConfigError(parseResult.error.message);\n }\n\n return parseResult.data;\n};\n"],"names":["parseConfig","configParser","z","object","extends","string","optional","licenses","array","packages","includeDevDependencies","boolean","devDependenciesOnly","directory","transform","c","config","parseResult","safeParse","success","ConfigError","error","message","data"],"mappings":";+BAsBaA;;;eAAAA;;;qBAtBK;6BACU;AAE5B,MAAMC,eAAeC,MAAC,CACnBC,MAAM,CAAC;IACNC,SAASF,MAAC,CAACG,MAAM,GAAGC,QAAQ;IAC5BC,UAAUL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCG,UAAUP,MAAC,CAACM,KAAK,CAACN,MAAC,CAACG,MAAM,IAAIC,QAAQ;IACtCI,wBAAwBR,MAAC,CAACS,OAAO,GAAGL,QAAQ;IAC5CM,qBAAqBV,MAAC,CAACS,OAAO,GAAGL,QAAQ;IACzCO,WAAWX,MAAC,CAACG,MAAM,GAAGC,QAAQ;AAChC,GACCQ,SAAS,CAACC,CAAAA;QAECA,aACAA,aACcA,2BACHA;WALN;QACfX,SAASW,EAAEX,OAAO;QAClBG,QAAQ,GAAEQ,cAAAA,EAAER,QAAQ,YAAVQ,cAAc,EAAE;QAC1BN,QAAQ,GAAEM,cAAAA,EAAEN,QAAQ,YAAVM,cAAc,EAAE;QAC1BL,sBAAsB,GAAEK,4BAAAA,EAAEL,sBAAsB,YAAxBK,4BAA4B;QACpDH,mBAAmB,GAAEG,yBAAAA,EAAEH,mBAAmB,YAArBG,yBAAyB;IAChD;;AAIK,MAAMf,cAAc,CAACgB;IAC1B,MAAMC,cAAchB,aAAaiB,SAAS,CAACF;IAE3C,IAAI,CAACC,YAAYE,OAAO,EAAE;QACxB,MAAM,IAAIC,wBAAW,CAACH,YAAYI,KAAK,CAACC,OAAO;IACjD;IAEA,OAAOL,YAAYM,IAAI;AACzB"}
@@ -1 +0,0 @@
1
- export declare const findConfig: (rootDir: string) => Promise<unknown>;