@xylabs/toolchain 7.10.0 → 7.10.2
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.
- package/dist/actions/index.mjs +162 -30
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/XyConfig.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/publint.mjs.map +1 -1
- package/dist/actions/packman/index.mjs +270 -112
- package/dist/actions/packman/index.mjs.map +1 -1
- package/dist/actions/packman/lint.mjs +203 -36
- package/dist/actions/packman/lint.mjs.map +1 -1
- package/dist/actions/publint.mjs.map +1 -1
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/xy.mjs +164 -32
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.mjs +1040 -811
- package/dist/index.mjs.map +1 -1
- package/dist/lib/deprecationMigrate.mjs +99 -0
- package/dist/lib/deprecationMigrate.mjs.map +1 -0
- package/dist/lib/index.mjs +238 -141
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/common/checkCommand.mjs.map +1 -1
- package/dist/xy/common/index.mjs +164 -32
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/packmanCommand.mjs +272 -114
- package/dist/xy/common/packmanCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +164 -32
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/lint/index.mjs.map +1 -1
- package/dist/xy/lint/publintCommand.mjs.map +1 -1
- package/dist/xy/xy.mjs +164 -32
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/publint.ts","../../src/lib/concurrency.ts","../../src/pm/detectPackageManager.ts","../../src/pm/registry.ts","../../src/lib/initCwd.ts","../../src/lib/loadConfig.ts","../../src/lib/runInstall.ts","../../src/actions/package/compile/XyConfig.ts","../../src/actions/package/publint.ts","../../src/actions/package-lint-deps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport {\n INIT_CWD,\n installOutputCapture,\n loadConfig,\n loadWorkspaceCommandConfig,\n outputStorage,\n runInstall,\n runWithConcurrency,\n} from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type {\n PublintCheckName, PublintConfig, XyConfig,\n} from './package/index.ts'\nimport { ALL_PUBLINT_CHECKS, packagePublint } from './package/index.ts'\nimport {\n checkInternalPeerVersions,\n fixInternalPeerVersions,\n} from './package-lint-deps.ts'\n\nexport interface PublintParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface PublintPackageParams {\n exclude: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nfunction resolveExclude(\n publintConfig: { exclude?: PublintCheckName[]; include?: PublintCheckName[] },\n cliExclude?: string[],\n cliInclude?: string[],\n): Set<PublintCheckName> | undefined {\n const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0\n const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0\n\n if (hasExclude && hasInclude) {\n console.error(chalk.red('Publint: --include and --exclude cannot be used together'))\n return undefined\n }\n\n if (hasInclude) {\n const include = new Set<PublintCheckName>([\n ...((publintConfig.include ?? [])),\n ...((cliInclude ?? []) as PublintCheckName[]),\n ])\n return new Set(ALL_PUBLINT_CHECKS.filter(c => !include.has(c)))\n }\n\n return new Set<PublintCheckName>([\n ...(publintConfig.exclude ?? []),\n ...((cliExclude ?? []) as PublintCheckName[]),\n ])\n}\n\nfunction normalizePublintConfig(value: boolean | PublintConfig | undefined): PublintConfig {\n if (typeof value === 'object') return value\n return {}\n}\n\nexport interface ResolvedPublintOptions {\n exclude: Set<PublintCheckName>\n pack: boolean\n}\n\nexport async function loadPublintOptions(): Promise<ResolvedPublintOptions> {\n const config = await loadConfig<XyConfig>()\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint)\n const exclude = resolveExclude(publintConfig) ?? new Set<PublintCheckName>()\n return { exclude, pack: publintConfig.pack ?? true }\n}\n\nexport const publint = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose, pkg,\n}: PublintParams) => {\n return pkg === undefined\n ? await publintAll({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n })\n : await publintSingle({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n })\n}\n\nfunction logPublintSummary(packages: number, errors: number, ms: number): void {\n const color = errors > 0 ? chalk.red : chalk.blue\n console.log(color(`Checked ${packages} package(s) in ${ms.toFixed(0)}ms with ${errors} issue(s) found.`))\n}\n\ninterface PublintSingleParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nexport const publintSingle = async ({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n}: PublintSingleParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspace = pm.findWorkspace(pkg)\n if (!workspace) {\n console.error(chalk.red(`Publint: workspace \"${pkg}\" not found`))\n return 1\n }\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(workspace.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n if (!exclude) return 1\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: workspace.location, verbose,\n })\n logPublintSummary(1, errors, performance.now() - start)\n return errors\n}\n\ninterface PublintAllParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n verbose?: boolean\n}\n\ninterface CapturedResult {\n errors: number\n output: string[]\n}\n\nexport const publintAll = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n}: PublintAllParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n const concurrency = jobs\n\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ errors: 0, output: [] }))\n\n installOutputCapture()\n\n await runWithConcurrency(\n workspaces.map((ws, i) => ({ i, ws })),\n concurrency,\n async ({ i, ws }) => {\n const output: string[] = []\n await outputStorage.run(output, async () => {\n try {\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(ws.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n ?? new Set<PublintCheckName>()\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: ws.location, verbose,\n })\n results[i] = { errors, output }\n } catch (ex) {\n output.push(chalk.red(`Publint failed for ${ws.name}: ${(ex as Error).message}\\n`))\n results[i] = { errors: 1, output }\n }\n })\n },\n )\n\n let totalErrors = 0\n for (const { errors, output } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n totalErrors += errors\n }\n\n // Check internal peerDependencies use semver ranges (not workspace: protocol)\n const allExclude = resolveExclude({}, cliExclude, cliInclude) ?? new Set<PublintCheckName>()\n if (!allExclude.has('peerDeps')) {\n const cwd = INIT_CWD()\n const peerResult = checkInternalPeerVersions(cwd, workspaces)\n if (peerResult.fixable.length > 0) {\n if (fix) {\n fixInternalPeerVersions(cwd, workspaces)\n runInstall()\n } else {\n for (const msg of peerResult.fixable) {\n console.log(chalk.red(` ✗ ${msg} (fixable)`))\n }\n totalErrors += peerResult.fixable.length\n }\n }\n totalErrors += peerResult.errors.length\n }\n\n logPublintSummary(workspaces.length, totalErrors, performance.now() - start)\n return totalErrors\n}\n","import { AsyncLocalStorage } from 'node:async_hooks'\n\nexport const outputStorage = new AsyncLocalStorage<string[]>()\n\nlet captureInstalled = false\n\nexport function installOutputCapture(): void {\n if (captureInstalled) return\n captureInstalled = true\n\n const originalStdoutWrite = process.stdout.write.bind(process.stdout)\n const originalStderrWrite = process.stderr.write.bind(process.stderr)\n\n function intercept(\n original: typeof process.stdout.write,\n ): typeof process.stdout.write {\n return function (chunk: string | Uint8Array, ...args: unknown[]) {\n const buffer = outputStorage.getStore()\n if (buffer) {\n buffer.push(typeof chunk === 'string' ? chunk : new TextDecoder().decode(chunk))\n return true\n }\n return (original as (...params: unknown[]) => boolean)(chunk, ...args)\n } as typeof process.stdout.write\n }\n\n process.stdout.write = intercept(originalStdoutWrite)\n process.stderr.write = intercept(originalStderrWrite)\n}\n\nexport async function runWithConcurrency<T>(\n items: T[],\n concurrency: number,\n fn: (item: T) => Promise<void>,\n): Promise<void> {\n let next = 0\n async function worker(): Promise<void> {\n while (next < items.length) {\n const i = next++\n await fn(items[i])\n }\n }\n await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()))\n}\n","import { existsSync } from 'node:fs'\n\nexport type PackageManagerName = 'pnpm' | 'yarn'\n\nexport function detectPackageManager(): PackageManagerName {\n if (existsSync('pnpm-lock.yaml') || existsSync('pnpm-workspace.yaml')) return 'pnpm'\n return 'yarn'\n}\n","import type { PackageManagerName } from './detectPackageManager.ts'\nimport { detectPackageManager } from './detectPackageManager.ts'\nimport type { PackageManager } from './PackageManager.ts'\n\nconst implementations = new Map<PackageManagerName, PackageManager>()\n\nexport function registerPackageManager(pm: PackageManager): void {\n implementations.set(pm.name, pm)\n}\n\nexport function getPackageManager(name?: PackageManagerName): PackageManager {\n const pmName = name ?? detectPackageManager()\n const pm = implementations.get(pmName)\n if (!pm) {\n throw new Error(\n `No package manager implementation registered for \"${pmName}\". `\n + 'Ensure registerPackageManager() has been called before getPackageManager().',\n )\n }\n return pm\n}\n","export function INIT_CWD(): string {\n return process.env.INIT_CWD ?? process.cwd()\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\nlet rootConfigPath: string | undefined\n\nconst workspaceConfigCache = new Map<string, Record<string, unknown>>()\nconst deprecationWarned = new Set<string>()\n\nfunction createExplorer() {\n return cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } })\n}\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config === undefined) {\n const cosmicConfigResult = await createExplorer().search()\n config = (cosmicConfigResult?.config ?? {}) as Record<string, unknown>\n rootConfigPath = cosmicConfigResult?.filepath\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath !== undefined) {\n console.log(chalk.green(`Loaded config from ${configFilePath}`))\n if (config.verbose) {\n console.log(chalk.gray(`${JSON.stringify(config, null, 2)}`))\n }\n }\n }\n return deepmerge(config, params ?? {}) as T\n}\n\n/**\n * Loads the xy.config from a specific workspace directory.\n * Returns an empty object if the workspace has no config or if\n * the found config is the root config (avoids double-applying).\n */\nasync function loadWorkspaceConfig(workspaceDir: string): Promise<Record<string, unknown>> {\n const cached = workspaceConfigCache.get(workspaceDir)\n if (cached !== undefined) return cached\n\n const result = await createExplorer().search(workspaceDir)\n\n // If no config found or it's the root config, no workspace override\n if (!result || result.filepath === rootConfigPath) {\n workspaceConfigCache.set(workspaceDir, {})\n return {}\n }\n\n const wsConfig = (result.config ?? {}) as Record<string, unknown>\n workspaceConfigCache.set(workspaceDir, wsConfig)\n return wsConfig\n}\n\n/** Deprecated top-level fields that should be under `commands`. */\nconst DEPRECATED_COMMAND_FIELDS = new Set(['deplint', 'publint'])\n\n/**\n * Resolves a command's config field from a config object.\n * Prefers `commands.[name]` over top-level `[name]`.\n * Warns once per config file when a deprecated top-level field is used.\n */\nfunction resolveCommandField(\n cfg: Record<string, unknown>,\n commandName: string,\n configPath?: string,\n): Record<string, unknown> {\n const commands = cfg.commands as Record<string, unknown> | undefined\n const fromCommands = commands?.[commandName]\n const fromTopLevel = cfg[commandName]\n\n if (fromCommands !== undefined && typeof fromCommands === 'object') {\n return fromCommands as Record<string, unknown>\n }\n\n if (fromTopLevel !== undefined && typeof fromTopLevel === 'object'\n && DEPRECATED_COMMAND_FIELDS.has(commandName)) {\n const key = `${configPath ?? 'unknown'}:${commandName}`\n if (!deprecationWarned.has(key)) {\n deprecationWarned.add(key)\n console.warn(chalk.yellow(\n `[xy] Deprecated: top-level \"${commandName}\" in ${configPath ?? 'xy.config'} — move to \"commands.${commandName}\"`,\n ))\n }\n return fromTopLevel as Record<string, unknown>\n }\n\n return {}\n}\n\n/**\n * Loads a command-specific config merged from root and workspace levels.\n * The root config provides defaults; the workspace config extends/overrides.\n * Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged\n * via deepmerge, with workspace entries overriding root entries for the same key.\n */\nexport async function loadWorkspaceCommandConfig<C>(\n workspaceDir: string,\n commandName: string,\n): Promise<C> {\n // Ensure root config is loaded\n const root = await loadConfig()\n const rootCmd = resolveCommandField(root as Record<string, unknown>, commandName, rootConfigPath)\n\n const wsConfig = await loadWorkspaceConfig(workspaceDir)\n const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : undefined\n const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath)\n\n return deepmerge(rootCmd, wsCmd) as C\n}\n","import { spawnSync } from 'node:child_process'\n\nimport chalk from 'chalk'\n\nimport { detectPackageManager } from '../pm/index.ts'\n\nexport function runInstall(cwd?: string): boolean {\n const pm = detectPackageManager()\n console.log(chalk.gray(`Running ${pm} install...`))\n const result = spawnSync(pm, ['install'], {\n cwd,\n stdio: 'inherit',\n })\n if (result.status !== 0) {\n console.warn(chalk.yellow(`${pm} install failed`))\n return false\n }\n console.log(chalk.green('Dependencies installed'))\n return true\n}\n","import type { Options } from 'tsup'\n\nexport type EntryMode = 'all' | 'single' | 'auto' | 'platform' | 'custom'\n\n/**\n * Configuration for specifying which paths are targeted.\n */\nexport interface PathConfig {\n /**\n * Glob patterns to exclude (takes precedence over include).\n */\n exclude?: string[]\n /**\n * Glob patterns to include.\n */\n include?: string[]\n}\n\n/**\n * Configuration for Dynamic Share.\n */\n\nexport interface DynamicShareConfig extends PathConfig {}\n\n/**\n * Configuration for Live Share.\n */\n\nexport interface LiveShareConfig extends PathConfig {}\n\nexport interface CompileConfig {\n bundleTypes?: boolean\n /** @param entryMode all, single, custom, platform, or auto */\n entryMode?: EntryMode\n /** @param when building types with tsc, should it use the outDir to write to? */\n outDirAsBuildDir?: boolean\n}\n\nexport type PackageCompileTsupConfig = CompileConfig & {\n browser?: Record<string, Options | boolean>\n neutral?: Record<string, Options | boolean>\n node?: Record<string, Options | boolean>\n tsup?: { options?: Options }\n verbose?: boolean\n}\n\nexport type PackageCompileTscConfig = CompileConfig & { mode: 'tsc' }\n\n/**\n * How deplint should classify a dependency.\n * - `dep`: must stay in `dependencies` (never promoted to peerDependencies)\n * - `peer`: should be treated as a peerDependency (overrides a parent `dep` setting)\n */\nexport type DeplintRefType = 'dep' | 'peer'\n\n/**\n * Per-package configuration within deplint.\n */\nexport interface DeplintPackageConfig {\n /** How this dependency should be classified. */\n refType: DeplintRefType\n}\n\n/**\n * Configuration for deplint (dependency linting).\n */\nexport interface DeplintConfig {\n /**\n * Package names to exclude from unused-dependency checks.\n * Packages listed here will never be reported as \"unused\" by deplint,\n * even if no import for them is detected in source or dist files.\n * Useful for packages that are used implicitly (e.g. runtime plugins,\n * CSS-in-JS themes, or polyfills that have side effects on import).\n */\n exclude?: string[]\n /**\n * Per-dependency configuration keyed by package name.\n * Cascades from root to package configs (maps are merged, with\n * package-level entries overriding root-level entries for the same key).\n */\n packages?: Record<string, DeplintPackageConfig>\n}\n\n/**\n * Canonical names for individually toggleable publint checks.\n */\nexport type PublintCheckName\n = | 'files'\n | 'importToDefault'\n | 'main'\n | 'module'\n | 'peerDeps'\n | 'publint'\n | 'resolutions'\n | 'rootSource'\n | 'rootTypes'\n | 'sideEffects'\n | 'source'\n | 'types'\n\nexport const ALL_PUBLINT_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'peerDeps', 'publint', 'resolutions', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/** Checks that only apply to published (non-private) packages */\nexport const PUBLISH_ONLY_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'publint', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/**\n * Configuration for publint (package publishing linting).\n */\nexport interface PublintConfig {\n /**\n * Check names to exclude from publint runs.\n * All checks run by default; listed names are skipped.\n * Cannot be used together with `include`.\n */\n exclude?: PublintCheckName[]\n /**\n * Check names to include (whitelist) in publint runs.\n * Only listed checks will run; all others are skipped.\n * Cannot be used together with `exclude`.\n */\n include?: PublintCheckName[]\n /**\n * Whether to run `pack` when invoking the publint library.\n * When true (default), the package manager is used to determine which\n * files would be published. Set to false to skip packing for faster runs.\n */\n pack?: boolean\n}\n\n/**\n * Configuration for readme generation.\n */\nexport interface ReadmeConfig {\n /**\n * URL that the logo links to when clicked.\n * Replaces the placeholder in the template's [![logo][]](url) link.\n */\n logoLinkUrl?: string\n /**\n * Public URL for the logo image displayed at the top of generated READMEs.\n * Replaces the placeholder in the template's [logo] reference link.\n */\n logoUrl?: string\n}\n\n/**\n * Command-specific configuration that cascades from root to package.\n * Settings here override the legacy top-level equivalents.\n */\nexport interface CommandsConfig {\n deplint?: DeplintConfig\n publint?: boolean | PublintConfig\n}\n\nexport interface XyConfigBase {\n /**\n * Command-specific settings grouped under `commands`.\n * These cascade from root xy.config down to per-package xy.config files.\n * Takes precedence over the legacy top-level `deplint`/`publint` fields.\n */\n commands?: CommandsConfig\n compile?: CompileConfig\n /** @deprecated Use `commands.deplint` instead. */\n deplint?: DeplintConfig\n dynamicShare?: DynamicShareConfig\n liveShare?: LiveShareConfig\n /** @deprecated Use `commands.publint` instead. */\n publint?: boolean | PublintConfig\n\n readme?: ReadmeConfig\n verbose?: boolean\n}\n\nexport interface XyTsupConfig extends XyConfigBase { compile?: PackageCompileTsupConfig }\n\nexport interface XyTscConfig extends XyConfigBase { compile?: PackageCompileTscConfig }\n\nexport type XyConfigLegacy = XyTsupConfig | XyTscConfig\n\nexport type XyConfig = XyConfigLegacy & {\n dev?: {\n build?: {\n clean?: boolean /* default: true */\n compile?: boolean /* default: true */\n deplint?: boolean /* default: true */\n gendocs?: boolean /* default: false */\n gitlint?: boolean /* default: true */\n knip?: boolean /* default: true */\n license?: boolean /* default: true */\n lint?: boolean /* default: true */\n publint?: boolean /* default: true */\n statics?: boolean /* default: true */\n verbose?: boolean\n }\n compile?: PackageCompileTsupConfig\n verbose?: boolean\n }\n verbose?: boolean\n}\n","import { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { glob } from 'glob'\nimport sortPackageJson from 'sort-package-json'\n\nimport { INIT_CWD } from '../../lib/index.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport type { PublintCheckName } from './compile/XyConfig.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport { PUBLISH_ONLY_CHECKS } from './compile/XyConfig.ts'\n\nexport interface PackagePublintParams {\n exclude?: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkgDir?: string\n strict?: boolean\n verbose?: boolean\n}\n\nconst removeSourceFromExports = (exports: Record<string, unknown>): boolean => {\n let removed = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') {\n delete exports[key]\n removed = true\n } else if (typeof value === 'object' && value !== null && removeSourceFromExports(value as Record<string, unknown>)) removed = true\n }\n return removed\n}\n\nconst hasSourceInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') return true\n if (typeof value === 'object' && value !== null && hasSourceInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst hasImportKeyInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) return true\n if (typeof value === 'object' && value !== null && hasImportKeyInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst replaceImportWithDefault = (exports: Record<string, unknown>): boolean => {\n let modified = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) {\n if (exports.default === undefined) {\n exports.default = value\n }\n delete exports.import\n if (exports.types === undefined) {\n exports.types = value.replace(/\\.mjs$/, '.d.ts')\n }\n modified = true\n } else if (typeof value === 'object' && value !== null && replaceImportWithDefault(value as Record<string, unknown>)) modified = true\n }\n return modified\n}\n\nconst hasTypesInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'types') return true\n if (typeof value === 'object' && value !== null && hasTypesInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nfunction ensureExportsPath(value: string): string {\n if (value.startsWith('./') || value.startsWith('../')) return value\n return `./${value}`\n}\n\ninterface CustomLintResult {\n errors: number\n modified: boolean\n warnings: number\n}\n\nfunction emptyCustomResult(): CustomLintResult {\n return {\n errors: 0, modified: false, warnings: 0,\n }\n}\n\nfunction mergeResults(target: CustomLintResult, source: CustomLintResult): void {\n target.errors += source.errors\n target.warnings += source.warnings\n target.modified = target.modified || source.modified\n}\n\nfunction checkFiles(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const files = pkg.files as string[] | undefined\n if (files === undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"files\" field is missing'))\n result.warnings++\n }\n if (Array.isArray(files) && !files.includes('README.md')) {\n files.push('README.md')\n console.warn(chalk.yellow('Publint [custom]: added \"README.md\" to \"files\"'))\n result.modified = true\n result.warnings++\n }\n if (Array.isArray(files) && files.includes('src')) {\n if (fix) {\n pkg.files = files.filter((f: string) => f !== 'src')\n console.warn(chalk.yellow('Publint [custom]: removed \"src\" from \"files\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"src\" should not be in \"files\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction checkExportsSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object' && hasSourceInExports(exports)) {\n if (fix) {\n removeSourceFromExports(exports)\n console.warn(chalk.yellow('Publint [custom]: removed \"source\" entries from \"exports\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"source\" entries should not be in \"exports\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction migrateFieldToExports(\n pkg: Record<string, unknown>,\n field: string,\n exportKey: string,\n fix: boolean,\n): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg[field] === undefined) return result\n\n // Skip non-JS files (e.g. tsconfig packages use \"main\": \"./tsconfig.json\")\n const fieldValue = pkg[field] as string\n if (!fieldValue.endsWith('.js') && !fieldValue.endsWith('.mjs') && !fieldValue.endsWith('.cjs')) return result\n\n if (fix) {\n const exportValue = ensureExportsPath(fieldValue)\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object') {\n const dot = exports['.']\n if (dot && typeof dot === 'object' && !(dot as Record<string, unknown>)[exportKey]) {\n (dot as Record<string, unknown>)[exportKey] = exportValue\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports['.'].${exportKey}\" (${fieldValue})`))\n }\n } else if (!pkg.exports) {\n pkg.exports = { '.': { [exportKey]: exportValue } }\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports\" (.→${fieldValue})`))\n }\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed deprecated \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: \"${field}\" field is deprecated, use \"exports\" instead (use --fix to remove)`))\n }\n result.warnings++\n return result\n}\n\nfunction checkSideEffects(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.sideEffects !== false) {\n console.warn(chalk.yellow('Publint [custom]: \"sideEffects\" field should be set to false'))\n result.warnings++\n }\n return result\n}\n\nfunction checkRootSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n for (const field of ['source', 'src']) {\n if (pkg[field] !== undefined) {\n if (fix) {\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed root-level \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: root-level \"${field}\" field should not be in package.json (use --fix to remove)`))\n }\n result.warnings++\n }\n }\n return result\n}\n\nfunction checkResolutions(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.resolutions !== undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"resolutions\" in use'))\n console.warn(chalk.gray(JSON.stringify(pkg.resolutions, null, 2)))\n result.warnings++\n }\n return result\n}\n\nfunction checkImportToDefault(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object') return result\n if (!hasImportKeyInExports(exports)) return result\n\n if (fix) {\n replaceImportWithDefault(exports)\n console.warn(chalk.yellow('Publint [custom]: renamed \"import\" to \"default\" in \"exports\" and ensured \"types\" siblings'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"import\" entries in \"exports\" should use \"default\" instead (use --fix to rename)'))\n }\n result.warnings++\n return result\n}\n\nfunction checkRootTypes(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.types === undefined) return result\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object' || !hasTypesInExports(exports)) return result\n\n if (fix) {\n delete pkg.types\n console.warn(chalk.yellow('Publint [custom]: removed redundant root \"types\" field (already defined in \"exports\")'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: root \"types\" field is redundant when \"exports\" defines types (use --fix to remove)'))\n }\n result.warnings++\n return result\n}\n\nfunction customPubLint(\n pkg: Record<string, unknown>,\n fix = false,\n exclude = new Set<PublintCheckName>(),\n): [number, number, boolean] {\n const result = emptyCustomResult()\n if (!exclude.has('files')) mergeResults(result, checkFiles(pkg, fix))\n if (!exclude.has('source')) mergeResults(result, checkExportsSource(pkg, fix))\n if (!exclude.has('rootSource')) mergeResults(result, checkRootSource(pkg, fix))\n if (!exclude.has('main')) mergeResults(result, migrateFieldToExports(pkg, 'main', 'default', fix))\n if (!exclude.has('types')) mergeResults(result, migrateFieldToExports(pkg, 'types', 'types', fix))\n if (!exclude.has('module')) mergeResults(result, migrateFieldToExports(pkg, 'module', 'default', fix))\n if (!exclude.has('importToDefault')) mergeResults(result, checkImportToDefault(pkg, fix))\n if (!exclude.has('rootTypes')) mergeResults(result, checkRootTypes(pkg, fix))\n if (!exclude.has('sideEffects')) mergeResults(result, checkSideEffects(pkg))\n if (!exclude.has('resolutions')) mergeResults(result, checkResolutions(pkg))\n return [result.errors, result.warnings, result.modified]\n}\n\n// Always-included files that npm packs regardless of the \"files\" field\nconst ALWAYS_INCLUDED_PATTERNS = [\n 'package.json',\n 'README',\n 'README.*',\n 'LICENCE',\n 'LICENCE.*',\n 'LICENSE',\n 'LICENSE.*',\n 'CHANGELOG',\n 'CHANGELOG.*',\n]\n\ninterface PackFile {\n data: string\n name: string\n}\n\nasync function resolvePackFiles(pkgDir: string, filesField?: string[]): Promise<PackFile[]> {\n const patterns = [...ALWAYS_INCLUDED_PATTERNS]\n if (filesField) {\n for (const pattern of filesField) {\n // Negation patterns (e.g. \"!**/*.spec.*\") are exclusions, pass through as-is\n if (pattern.startsWith('!')) {\n patterns.push(pattern)\n } else {\n // Include pattern — glob both the pattern itself and its contents if it's a directory\n patterns.push(pattern, `${pattern}/**`)\n }\n }\n }\n\n const matched = await glob(patterns, {\n cwd: pkgDir,\n nodir: true,\n dot: false,\n })\n\n const files: PackFile[] = await Promise.all(\n matched.map(async (rel) => {\n const abs = path.join(pkgDir, rel)\n const data = await fs.readFile(abs, 'utf8').catch(() => '')\n // publint's tarball VFS looks up files by path.join(pkgDir, rel),\n // so names must be prefixed with pkgDir to match\n return { name: path.join(pkgDir, rel), data }\n }),\n )\n return files\n}\n\nasync function runPublintLibrary(pkgDir: string, pkg: Record<string, unknown>, strict: boolean, pack: boolean): Promise<{ errors: number; total: number }> {\n const { publint } = await import('publint')\n\n let packOption: { files: PackFile[] } | false = false\n if (pack) {\n const files = await resolvePackFiles(pkgDir, pkg.files as string[] | undefined)\n packOption = { files }\n }\n\n const { messages } = await publint({\n level: 'suggestion',\n pack: packOption,\n pkgDir,\n strict,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n for (const message of messages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n return {\n errors: messages.filter(message => message.type === 'error').length,\n total: messages.length,\n }\n}\n\nexport const packagePublint = async ({\n exclude = new Set(), fix = false, pack = true, pkgDir: pkgDirParam, strict = true, verbose: _verbose = false,\n}: PackagePublintParams = {}): Promise<number> => {\n const pkgDir = pkgDirParam ?? INIT_CWD()\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8')) as Record<string, unknown>\n\n const effectiveExclude = pkg.private\n ? new Set([...exclude, ...PUBLISH_ONLY_CHECKS])\n : exclude\n\n console.log(chalk.green(`Publint: ${String(pkg.name)}${pkg.private ? chalk.gray(' (private)') : ''}`))\n console.log(chalk.gray(pkgDir))\n\n let libraryErrors = 0\n if (!effectiveExclude.has('publint')) {\n const library = await runPublintLibrary(pkgDir, pkg, strict, pack)\n libraryErrors = library.errors\n }\n\n const [errorCount, _warningCount, modified] = customPubLint(pkg, fix, effectiveExclude)\n\n if (modified) {\n const sorted = sortPackageJson(JSON.stringify(pkg, null, 2))\n await fs.writeFile(`${pkgDir}/package.json`, sorted)\n }\n\n return libraryErrors + errorCount\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport semver from 'semver'\n\nimport { INIT_CWD } from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type { LintResult } from './package-lint.ts'\n\nfunction readWorkspacePackageJson(cwd: string, location: string): Record<string, unknown> | undefined {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n return JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n } catch {\n return undefined\n }\n}\n\nfunction writeWorkspacePackageJson(cwd: string, location: string, pkg: Record<string, unknown>) {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n}\n\nfunction buildWorkspaceVersionMap(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): Map<string, string> {\n const map = new Map<string, string>()\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) map.set(name, version)\n }\n return map\n}\n\n/**\n * Derives the expected peerDep range from the workspace protocol used in\n * the matching devDependency and the current version of the target package.\n *\n * workspace:~ + version 7.6.21 → ~7.6\n * workspace:^ + version 7.6.21 → ^7\n *\n * Falls back to ~major.minor if no matching devDep is found.\n */\nfunction expectedPeerRange(devDepVersion: string | undefined, targetVersion: string): string {\n const parsed = semver.parse(targetVersion)\n if (!parsed) return `~${targetVersion}`\n\n if (devDepVersion === 'workspace:^') {\n return `^${parsed.major}`\n }\n return `~${parsed.major}.${parsed.minor}`\n}\n\n// --- Version consistency checks ---\n\nexport function checkVersionConsistency(\n cwd: string,\n rootPkg: Record<string, unknown>,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n\n if (rootPkg.version !== undefined) {\n result.fixable.push('Root package.json should not have a \"version\" field in a monorepo')\n }\n\n const versions = new Map<string, string>()\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) {\n versions.set(name, version)\n } else {\n result.errors.push(`${name} (${location}) is missing a \"version\" field`)\n }\n }\n\n const uniqueVersions = new Set(versions.values())\n if (uniqueVersions.size > 1) {\n const versionList = [...uniqueVersions].toSorted(semver.rcompare)\n for (const [name, version] of versions) {\n if (version !== versionList[0]) {\n result.fixable.push(`${name} has version ${version} (expected ${versionList[0]})`)\n }\n }\n }\n\n return result\n}\n\nexport function fixVersionConsistency(\n cwd: string,\n rootPkg: Record<string, unknown>,\n writeRootPackageJson: (cwd: string, pkg: Record<string, unknown>) => void,\n workspaces: { location: string; name: string }[],\n): void {\n if (rootPkg.version !== undefined) {\n delete rootPkg.version\n writeRootPackageJson(cwd, rootPkg)\n console.log(chalk.green(' ✔ Fixed: removed \"version\" from root package.json'))\n }\n\n const versions: string[] = []\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version && semver.valid(version)) {\n versions.push(version)\n }\n }\n\n if (versions.length === 0) return\n\n const highest = versions.toSorted(semver.rcompare)[0]\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n if (pkg.version !== highest) {\n pkg.version = highest\n writeWorkspacePackageJson(cwd, location, pkg)\n console.log(chalk.green(` ✔ Fixed: set version to ${highest} in ${name} (${location})`))\n }\n }\n}\n\n// --- Internal dependency version checks (dependencies and devDependencies only) ---\n\nfunction expectedDepVersion(targetVersion: string): string {\n const parsed = semver.parse(targetVersion)\n if (!parsed) return `~${targetVersion}`\n return `~${targetVersion}`\n}\n\nexport function checkInternalDepVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n const expected = expectedDepVersion(targetVersion)\n if (version.startsWith('workspace:')) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should be \"${expected}\" (not workspace: protocol)`,\n )\n } else if (version !== expected) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should be \"${expected}\"`,\n )\n }\n }\n }\n }\n\n return result\n}\n\nexport function fixInternalDepVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n let modified = false\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n const expected = expectedDepVersion(targetVersion)\n if (version !== expected) {\n deps[dep] = expected\n console.log(chalk.green(` ✔ Fixed: set ${depField}.${dep} to \"${expected}\" in ${name} (${location})`))\n modified = true\n }\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n// --- Workspace protocol checks (pnpm — dependencies and devDependencies only) ---\n\nexport function checkWorkspaceProtocol(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceNames = new Set(workspaces.map(w => w.name))\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n if (!workspaceNames.has(dep)) continue\n if (!version.startsWith('workspace:')) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should use workspace: protocol`,\n )\n }\n }\n }\n }\n\n return result\n}\n\nexport function fixWorkspaceProtocol(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceNames = new Set(workspaces.map(w => w.name))\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n let modified = false\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n if (!workspaceNames.has(dep)) continue\n if (!version.startsWith('workspace:')) {\n deps[dep] = 'workspace:~'\n console.log(chalk.green(` ✔ Fixed: set ${depField}.${dep} to \"workspace:~\" in ${name} (${location})`))\n modified = true\n }\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n// --- Internal peerDependency version checks ---\n\nexport function checkInternalPeerVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n if (version.startsWith('workspace:')) {\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n result.fixable.push(\n `${name} (${location}) peerDependencies.${dep} uses workspace: protocol — should be \"${expected}\"`,\n )\n continue\n }\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected && !semver.satisfies(targetVersion, version)) {\n result.fixable.push(\n `${name} (${location}) peerDependencies.${dep} is \"${version}\" — current version ${targetVersion} is not satisfied; expected \"${expected}\"`,\n )\n }\n }\n }\n\n return result\n}\n\nexport function fixInternalPeerVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n let modified = false\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected) {\n peerDeps[dep] = expected\n console.log(chalk.green(` ✔ Fixed: set peerDependencies.${dep} to \"${expected}\" in ${name} (${location})`))\n modified = true\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n/**\n * Syncs all internal peerDependency versions to match current workspace versions.\n * Called by xy publish to ensure peerDeps are correct before publishing.\n */\nexport function syncInternalPeerVersions(): number {\n const cwd = INIT_CWD()\n const workspaces = getPackageManager().listWorkspaces()\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n let updated = 0\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n let modified = false\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected) {\n peerDeps[dep] = expected\n console.log(chalk.green(`Publish: updated ${name} peerDependencies.${dep} to \"${expected}\"`))\n modified = true\n updated++\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n\n return updated\n}\n\n/**\n * Reads the shared monorepo version from the first non-root workspace\n * and logs it. Call at the end of deploy to report the new version.\n */\nexport function logMonorepoVersion(): void {\n const cwd = INIT_CWD()\n const workspaces = getPackageManager().listWorkspaces()\n\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) {\n console.log(chalk.green(`\\nDeployed version: ${chalk.bold(version)}`))\n return\n }\n }\n}\n"],"mappings":";AAAA,OAAOA,YAAW;;;ACAlB,SAAS,yBAAyB;AAE3B,IAAM,gBAAgB,IAAI,kBAA4B;AAE7D,IAAI,mBAAmB;AAEhB,SAAS,uBAA6B;AAC3C,MAAI,iBAAkB;AACtB,qBAAmB;AAEnB,QAAM,sBAAsB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;AACpE,QAAM,sBAAsB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;AAEpE,WAAS,UACP,UAC6B;AAC7B,WAAO,SAAU,UAA+B,MAAiB;AAC/D,YAAM,SAAS,cAAc,SAAS;AACtC,UAAI,QAAQ;AACV,eAAO,KAAK,OAAO,UAAU,WAAW,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK,CAAC;AAC/E,eAAO;AAAA,MACT;AACA,aAAQ,SAA+C,OAAO,GAAG,IAAI;AAAA,IACvE;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;","names":["chalk","chalk","chalk","chalk","chalk","publint","chalk","expected","chalk","chalk","config"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/publint.ts","../../src/lib/concurrency.ts","../../src/pm/detectPackageManager.ts","../../src/pm/registry.ts","../../src/lib/initCwd.ts","../../src/lib/loadConfig.ts","../../src/lib/runInstall.ts","../../src/actions/package/compile/XyConfig.ts","../../src/actions/package/publint.ts","../../src/actions/package-lint-deps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport {\n INIT_CWD,\n installOutputCapture,\n loadConfig,\n loadWorkspaceCommandConfig,\n outputStorage,\n runInstall,\n runWithConcurrency,\n} from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type {\n PublintCheckName, PublintConfig, XyConfig,\n} from './package/index.ts'\nimport { ALL_PUBLINT_CHECKS, packagePublint } from './package/index.ts'\nimport {\n checkInternalPeerVersions,\n fixInternalPeerVersions,\n} from './package-lint-deps.ts'\n\nexport interface PublintParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface PublintPackageParams {\n exclude: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nfunction resolveExclude(\n publintConfig: { exclude?: PublintCheckName[]; include?: PublintCheckName[] },\n cliExclude?: string[],\n cliInclude?: string[],\n): Set<PublintCheckName> | undefined {\n const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0\n const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0\n\n if (hasExclude && hasInclude) {\n console.error(chalk.red('Publint: --include and --exclude cannot be used together'))\n return undefined\n }\n\n if (hasInclude) {\n const include = new Set<PublintCheckName>([\n ...((publintConfig.include ?? [])),\n ...((cliInclude ?? []) as PublintCheckName[]),\n ])\n return new Set(ALL_PUBLINT_CHECKS.filter(c => !include.has(c)))\n }\n\n return new Set<PublintCheckName>([\n ...(publintConfig.exclude ?? []),\n ...((cliExclude ?? []) as PublintCheckName[]),\n ])\n}\n\nfunction normalizePublintConfig(value: boolean | PublintConfig | undefined): PublintConfig {\n if (typeof value === 'object') return value\n return {}\n}\n\nexport interface ResolvedPublintOptions {\n exclude: Set<PublintCheckName>\n pack: boolean\n}\n\nexport async function loadPublintOptions(): Promise<ResolvedPublintOptions> {\n const config = await loadConfig<XyConfig>()\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint)\n const exclude = resolveExclude(publintConfig) ?? new Set<PublintCheckName>()\n return { exclude, pack: publintConfig.pack ?? true }\n}\n\nexport const publint = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose, pkg,\n}: PublintParams) => {\n return pkg === undefined\n ? await publintAll({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n })\n : await publintSingle({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n })\n}\n\nfunction logPublintSummary(packages: number, errors: number, ms: number): void {\n const color = errors > 0 ? chalk.red : chalk.blue\n console.log(color(`Checked ${packages} package(s) in ${ms.toFixed(0)}ms with ${errors} issue(s) found.`))\n}\n\ninterface PublintSingleParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nexport const publintSingle = async ({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n}: PublintSingleParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspace = pm.findWorkspace(pkg)\n if (!workspace) {\n console.error(chalk.red(`Publint: workspace \"${pkg}\" not found`))\n return 1\n }\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(workspace.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n if (!exclude) return 1\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: workspace.location, verbose,\n })\n logPublintSummary(1, errors, performance.now() - start)\n return errors\n}\n\ninterface PublintAllParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n verbose?: boolean\n}\n\ninterface CapturedResult {\n errors: number\n output: string[]\n}\n\nexport const publintAll = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n}: PublintAllParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n const concurrency = jobs\n\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ errors: 0, output: [] }))\n\n installOutputCapture()\n\n await runWithConcurrency(\n workspaces.map((ws, i) => ({ i, ws })),\n concurrency,\n async ({ i, ws }) => {\n const output: string[] = []\n await outputStorage.run(output, async () => {\n try {\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(ws.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n ?? new Set<PublintCheckName>()\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: ws.location, verbose,\n })\n results[i] = { errors, output }\n } catch (ex) {\n output.push(chalk.red(`Publint failed for ${ws.name}: ${(ex as Error).message}\\n`))\n results[i] = { errors: 1, output }\n }\n })\n },\n )\n\n let totalErrors = 0\n for (const { errors, output } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n totalErrors += errors\n }\n\n // Check internal peerDependencies use semver ranges (not workspace: protocol)\n const allExclude = resolveExclude({}, cliExclude, cliInclude) ?? new Set<PublintCheckName>()\n if (!allExclude.has('peerDeps')) {\n const cwd = INIT_CWD()\n const peerResult = checkInternalPeerVersions(cwd, workspaces)\n if (peerResult.fixable.length > 0) {\n if (fix) {\n fixInternalPeerVersions(cwd, workspaces)\n runInstall()\n } else {\n for (const msg of peerResult.fixable) {\n console.log(chalk.red(` ✗ ${msg} (fixable)`))\n }\n totalErrors += peerResult.fixable.length\n }\n }\n totalErrors += peerResult.errors.length\n }\n\n logPublintSummary(workspaces.length, totalErrors, performance.now() - start)\n return totalErrors\n}\n","import { AsyncLocalStorage } from 'node:async_hooks'\n\nexport const outputStorage = new AsyncLocalStorage<string[]>()\n\nlet captureInstalled = false\n\nexport function installOutputCapture(): void {\n if (captureInstalled) return\n captureInstalled = true\n\n const originalStdoutWrite = process.stdout.write.bind(process.stdout)\n const originalStderrWrite = process.stderr.write.bind(process.stderr)\n\n function intercept(\n original: typeof process.stdout.write,\n ): typeof process.stdout.write {\n return function (chunk: string | Uint8Array, ...args: unknown[]) {\n const buffer = outputStorage.getStore()\n if (buffer) {\n buffer.push(typeof chunk === 'string' ? chunk : new TextDecoder().decode(chunk))\n return true\n }\n return (original as (...params: unknown[]) => boolean)(chunk, ...args)\n } as typeof process.stdout.write\n }\n\n process.stdout.write = intercept(originalStdoutWrite)\n process.stderr.write = intercept(originalStderrWrite)\n}\n\nexport async function runWithConcurrency<T>(\n items: T[],\n concurrency: number,\n fn: (item: T) => Promise<void>,\n): Promise<void> {\n let next = 0\n async function worker(): Promise<void> {\n while (next < items.length) {\n const i = next++\n await fn(items[i])\n }\n }\n await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()))\n}\n","import { existsSync } from 'node:fs'\n\nexport type PackageManagerName = 'pnpm' | 'yarn'\n\nexport function detectPackageManager(): PackageManagerName {\n if (existsSync('pnpm-lock.yaml') || existsSync('pnpm-workspace.yaml')) return 'pnpm'\n return 'yarn'\n}\n","import type { PackageManagerName } from './detectPackageManager.ts'\nimport { detectPackageManager } from './detectPackageManager.ts'\nimport type { PackageManager } from './PackageManager.ts'\n\nconst implementations = new Map<PackageManagerName, PackageManager>()\n\nexport function registerPackageManager(pm: PackageManager): void {\n implementations.set(pm.name, pm)\n}\n\nexport function getPackageManager(name?: PackageManagerName): PackageManager {\n const pmName = name ?? detectPackageManager()\n const pm = implementations.get(pmName)\n if (!pm) {\n throw new Error(\n `No package manager implementation registered for \"${pmName}\". `\n + 'Ensure registerPackageManager() has been called before getPackageManager().',\n )\n }\n return pm\n}\n","export function INIT_CWD(): string {\n return process.env.INIT_CWD ?? process.cwd()\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\nlet rootConfigPath: string | undefined\n\nconst workspaceConfigCache = new Map<string, Record<string, unknown>>()\nconst deprecationWarned = new Set<string>()\n\nfunction createExplorer() {\n return cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } })\n}\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config === undefined) {\n const cosmicConfigResult = await createExplorer().search()\n config = (cosmicConfigResult?.config ?? {}) as Record<string, unknown>\n rootConfigPath = cosmicConfigResult?.filepath\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath !== undefined) {\n console.log(chalk.green(`Loaded config from ${configFilePath}`))\n if (config.verbose) {\n console.log(chalk.gray(`${JSON.stringify(config, null, 2)}`))\n }\n }\n }\n return deepmerge(config, params ?? {}) as T\n}\n\n/**\n * Loads the xy.config from a specific workspace directory.\n * Returns an empty object if the workspace has no config or if\n * the found config is the root config (avoids double-applying).\n */\nasync function loadWorkspaceConfig(workspaceDir: string): Promise<Record<string, unknown>> {\n const cached = workspaceConfigCache.get(workspaceDir)\n if (cached !== undefined) return cached\n\n const result = await createExplorer().search(workspaceDir)\n\n // If no config found or it's the root config, no workspace override\n if (!result || result.filepath === rootConfigPath) {\n workspaceConfigCache.set(workspaceDir, {})\n return {}\n }\n\n const wsConfig = (result.config ?? {}) as Record<string, unknown>\n workspaceConfigCache.set(workspaceDir, wsConfig)\n return wsConfig\n}\n\n/** Deprecated top-level fields that should be under `commands`. */\nconst DEPRECATED_COMMAND_FIELDS = new Set(['deplint', 'publint'])\n\n/**\n * Resolves a command's config field from a config object.\n * Prefers `commands.[name]` over top-level `[name]`.\n * Warns once per config file when a deprecated top-level field is used.\n */\nfunction resolveCommandField(\n cfg: Record<string, unknown>,\n commandName: string,\n configPath?: string,\n): Record<string, unknown> {\n const commands = cfg.commands as Record<string, unknown> | undefined\n const fromCommands = commands?.[commandName]\n const fromTopLevel = cfg[commandName]\n\n if (fromCommands !== undefined && typeof fromCommands === 'object') {\n return fromCommands as Record<string, unknown>\n }\n\n if (fromTopLevel !== undefined && typeof fromTopLevel === 'object'\n && DEPRECATED_COMMAND_FIELDS.has(commandName)) {\n const key = `${configPath ?? 'unknown'}:${commandName}`\n if (!deprecationWarned.has(key)) {\n deprecationWarned.add(key)\n console.warn(chalk.yellow(\n `[xy] Deprecated: top-level \"${commandName}\" in ${configPath ?? 'xy.config'} — move to \"commands.${commandName}\"`,\n ))\n }\n return fromTopLevel as Record<string, unknown>\n }\n\n return {}\n}\n\n/**\n * Loads a command-specific config merged from root and workspace levels.\n * The root config provides defaults; the workspace config extends/overrides.\n * Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged\n * via deepmerge, with workspace entries overriding root entries for the same key.\n */\nexport async function loadWorkspaceCommandConfig<C>(\n workspaceDir: string,\n commandName: string,\n): Promise<C> {\n // Ensure root config is loaded\n const root = await loadConfig()\n const rootCmd = resolveCommandField(root as Record<string, unknown>, commandName, rootConfigPath)\n\n const wsConfig = await loadWorkspaceConfig(workspaceDir)\n const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : undefined\n const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath)\n\n return deepmerge(rootCmd, wsCmd) as C\n}\n","import { spawnSync } from 'node:child_process'\n\nimport chalk from 'chalk'\n\nimport { detectPackageManager } from '../pm/index.ts'\n\nexport function runInstall(cwd?: string): boolean {\n const pm = detectPackageManager()\n console.log(chalk.gray(`Running ${pm} install...`))\n const result = spawnSync(pm, ['install'], {\n cwd,\n stdio: 'inherit',\n })\n if (result.status !== 0) {\n console.warn(chalk.yellow(`${pm} install failed`))\n return false\n }\n console.log(chalk.green('Dependencies installed'))\n return true\n}\n","import type { Options } from 'tsup'\n\nexport type EntryMode = 'all' | 'single' | 'auto' | 'platform' | 'custom'\n\n/**\n * Configuration for specifying which paths are targeted.\n */\nexport interface PathConfig {\n /**\n * Glob patterns to exclude (takes precedence over include).\n */\n exclude?: string[]\n /**\n * Glob patterns to include.\n */\n include?: string[]\n}\n\n/**\n * Configuration for Dynamic Share.\n */\n\nexport interface DynamicShareConfig extends PathConfig {}\n\n/**\n * Configuration for Live Share.\n */\n\nexport interface LiveShareConfig extends PathConfig {}\n\nexport interface CompileConfig {\n bundleTypes?: boolean\n /** @param entryMode all, single, custom, platform, or auto */\n entryMode?: EntryMode\n /** @param when building types with tsc, should it use the outDir to write to? */\n outDirAsBuildDir?: boolean\n}\n\nexport type PackageCompileTsupConfig = CompileConfig & {\n browser?: Record<string, Options | boolean>\n neutral?: Record<string, Options | boolean>\n node?: Record<string, Options | boolean>\n tsup?: { options?: Options }\n verbose?: boolean\n}\n\nexport type PackageCompileTscConfig = CompileConfig & { mode: 'tsc' }\n\n/**\n * How deplint should classify a dependency.\n * - `dep`: must stay in `dependencies` (never promoted to peerDependencies)\n * - `peer`: should be treated as a peerDependency (overrides a parent `dep` setting)\n */\nexport type DeplintRefType = 'dep' | 'peer'\n\n/**\n * Per-package configuration within deplint.\n */\nexport interface DeplintPackageConfig {\n /** How this dependency should be classified. */\n refType: DeplintRefType\n}\n\n/**\n * Configuration for deplint (dependency linting).\n */\nexport interface DeplintConfig {\n /**\n * Package names to exclude from unused-dependency checks.\n * Packages listed here will never be reported as \"unused\" by deplint,\n * even if no import for them is detected in source or dist files.\n * Useful for packages that are used implicitly (e.g. runtime plugins,\n * CSS-in-JS themes, or polyfills that have side effects on import).\n */\n exclude?: string[]\n /**\n * Per-dependency configuration keyed by package name.\n * Cascades from root to package configs (maps are merged, with\n * package-level entries overriding root-level entries for the same key).\n */\n packages?: Record<string, DeplintPackageConfig>\n}\n\n/**\n * Canonical names for individually toggleable publint checks.\n */\nexport type PublintCheckName\n = | 'files'\n | 'importToDefault'\n | 'main'\n | 'module'\n | 'peerDeps'\n | 'publint'\n | 'resolutions'\n | 'rootSource'\n | 'rootTypes'\n | 'sideEffects'\n | 'source'\n | 'types'\n\nexport const ALL_PUBLINT_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'peerDeps', 'publint', 'resolutions', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/** Checks that only apply to published (non-private) packages */\nexport const PUBLISH_ONLY_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'publint', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/**\n * Configuration for publint (package publishing linting).\n */\nexport interface PublintConfig {\n /**\n * Check names to exclude from publint runs.\n * All checks run by default; listed names are skipped.\n * Cannot be used together with `include`.\n */\n exclude?: PublintCheckName[]\n /**\n * Check names to include (whitelist) in publint runs.\n * Only listed checks will run; all others are skipped.\n * Cannot be used together with `exclude`.\n */\n include?: PublintCheckName[]\n /**\n * Whether to run `pack` when invoking the publint library.\n * When true (default), the package manager is used to determine which\n * files would be published. Set to false to skip packing for faster runs.\n */\n pack?: boolean\n}\n\n/**\n * Configuration for readme generation.\n */\nexport interface ReadmeConfig {\n /**\n * URL that the logo links to when clicked.\n * Replaces the placeholder in the template's [![logo][]](url) link.\n */\n logoLinkUrl?: string\n /**\n * Public URL for the logo image displayed at the top of generated READMEs.\n * Replaces the placeholder in the template's [logo] reference link.\n */\n logoUrl?: string\n}\n\n/**\n * Configuration for packman lint (package manager config linting).\n */\nexport interface PackmanConfig {\n /**\n * Minimum age in minutes that a package must be published before pnpm will install it.\n * Only applies when pnpm is the detected package manager.\n * @default 4320 (3 days)\n */\n minimumReleaseAge?: number\n /**\n * Package patterns to exclude from the minimumReleaseAge requirement.\n * These packages can be installed immediately upon release.\n * Supports exact names and scoped wildcards (e.g. '@myorg/*').\n * @default [\"'@xylabs/*'\", \"'@xyo-network/*'\"]\n */\n minimumReleaseAgeExclude?: string[]\n}\n\n/**\n * Command-specific configuration that cascades from root to package.\n * Settings here override the legacy top-level equivalents.\n */\nexport interface CommandsConfig {\n deplint?: DeplintConfig\n packman?: PackmanConfig\n publint?: boolean | PublintConfig\n}\n\nexport interface XyConfigBase {\n /**\n * Command-specific settings grouped under `commands`.\n * These cascade from root xy.config down to per-package xy.config files.\n * Takes precedence over the legacy top-level `deplint`/`publint` fields.\n */\n commands?: CommandsConfig\n compile?: CompileConfig\n /** @deprecated Use `commands.deplint` instead. */\n deplint?: DeplintConfig\n dynamicShare?: DynamicShareConfig\n liveShare?: LiveShareConfig\n /** @deprecated Use `commands.publint` instead. */\n publint?: boolean | PublintConfig\n\n readme?: ReadmeConfig\n verbose?: boolean\n}\n\nexport interface XyTsupConfig extends XyConfigBase { compile?: PackageCompileTsupConfig }\n\nexport interface XyTscConfig extends XyConfigBase { compile?: PackageCompileTscConfig }\n\nexport type XyConfigLegacy = XyTsupConfig | XyTscConfig\n\nexport type XyConfig = XyConfigLegacy & {\n dev?: {\n build?: {\n clean?: boolean /* default: true */\n compile?: boolean /* default: true */\n deplint?: boolean /* default: true */\n gendocs?: boolean /* default: false */\n gitlint?: boolean /* default: true */\n knip?: boolean /* default: true */\n license?: boolean /* default: true */\n lint?: boolean /* default: true */\n publint?: boolean /* default: true */\n statics?: boolean /* default: true */\n verbose?: boolean\n }\n compile?: PackageCompileTsupConfig\n verbose?: boolean\n }\n verbose?: boolean\n}\n","import { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { glob } from 'glob'\nimport sortPackageJson from 'sort-package-json'\n\nimport { INIT_CWD } from '../../lib/index.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport type { PublintCheckName } from './compile/XyConfig.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport { PUBLISH_ONLY_CHECKS } from './compile/XyConfig.ts'\n\nexport interface PackagePublintParams {\n exclude?: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkgDir?: string\n strict?: boolean\n verbose?: boolean\n}\n\nconst removeSourceFromExports = (exports: Record<string, unknown>): boolean => {\n let removed = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') {\n delete exports[key]\n removed = true\n } else if (typeof value === 'object' && value !== null && removeSourceFromExports(value as Record<string, unknown>)) removed = true\n }\n return removed\n}\n\nconst hasSourceInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') return true\n if (typeof value === 'object' && value !== null && hasSourceInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst hasImportKeyInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) return true\n if (typeof value === 'object' && value !== null && hasImportKeyInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst replaceImportWithDefault = (exports: Record<string, unknown>): boolean => {\n let modified = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) {\n if (exports.default === undefined) {\n exports.default = value\n }\n delete exports.import\n if (exports.types === undefined) {\n exports.types = value.replace(/\\.mjs$/, '.d.ts')\n }\n modified = true\n } else if (typeof value === 'object' && value !== null && replaceImportWithDefault(value as Record<string, unknown>)) modified = true\n }\n return modified\n}\n\nconst hasTypesInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'types') return true\n if (typeof value === 'object' && value !== null && hasTypesInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nfunction ensureExportsPath(value: string): string {\n if (value.startsWith('./') || value.startsWith('../')) return value\n return `./${value}`\n}\n\ninterface CustomLintResult {\n errors: number\n modified: boolean\n warnings: number\n}\n\nfunction emptyCustomResult(): CustomLintResult {\n return {\n errors: 0, modified: false, warnings: 0,\n }\n}\n\nfunction mergeResults(target: CustomLintResult, source: CustomLintResult): void {\n target.errors += source.errors\n target.warnings += source.warnings\n target.modified = target.modified || source.modified\n}\n\nfunction checkFiles(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const files = pkg.files as string[] | undefined\n if (files === undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"files\" field is missing'))\n result.warnings++\n }\n if (Array.isArray(files) && !files.includes('README.md')) {\n files.push('README.md')\n console.warn(chalk.yellow('Publint [custom]: added \"README.md\" to \"files\"'))\n result.modified = true\n result.warnings++\n }\n if (Array.isArray(files) && files.includes('src')) {\n if (fix) {\n pkg.files = files.filter((f: string) => f !== 'src')\n console.warn(chalk.yellow('Publint [custom]: removed \"src\" from \"files\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"src\" should not be in \"files\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction checkExportsSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object' && hasSourceInExports(exports)) {\n if (fix) {\n removeSourceFromExports(exports)\n console.warn(chalk.yellow('Publint [custom]: removed \"source\" entries from \"exports\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"source\" entries should not be in \"exports\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction migrateFieldToExports(\n pkg: Record<string, unknown>,\n field: string,\n exportKey: string,\n fix: boolean,\n): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg[field] === undefined) return result\n\n // Skip non-JS files (e.g. tsconfig packages use \"main\": \"./tsconfig.json\")\n const fieldValue = pkg[field] as string\n if (!fieldValue.endsWith('.js') && !fieldValue.endsWith('.mjs') && !fieldValue.endsWith('.cjs')) return result\n\n if (fix) {\n const exportValue = ensureExportsPath(fieldValue)\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object') {\n const dot = exports['.']\n if (dot && typeof dot === 'object' && !(dot as Record<string, unknown>)[exportKey]) {\n (dot as Record<string, unknown>)[exportKey] = exportValue\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports['.'].${exportKey}\" (${fieldValue})`))\n }\n } else if (!pkg.exports) {\n pkg.exports = { '.': { [exportKey]: exportValue } }\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports\" (.→${fieldValue})`))\n }\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed deprecated \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: \"${field}\" field is deprecated, use \"exports\" instead (use --fix to remove)`))\n }\n result.warnings++\n return result\n}\n\nfunction checkSideEffects(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.sideEffects !== false) {\n console.warn(chalk.yellow('Publint [custom]: \"sideEffects\" field should be set to false'))\n result.warnings++\n }\n return result\n}\n\nfunction checkRootSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n for (const field of ['source', 'src']) {\n if (pkg[field] !== undefined) {\n if (fix) {\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed root-level \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: root-level \"${field}\" field should not be in package.json (use --fix to remove)`))\n }\n result.warnings++\n }\n }\n return result\n}\n\nfunction checkResolutions(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.resolutions !== undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"resolutions\" in use'))\n console.warn(chalk.gray(JSON.stringify(pkg.resolutions, null, 2)))\n result.warnings++\n }\n return result\n}\n\nfunction checkImportToDefault(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object') return result\n if (!hasImportKeyInExports(exports)) return result\n\n if (fix) {\n replaceImportWithDefault(exports)\n console.warn(chalk.yellow('Publint [custom]: renamed \"import\" to \"default\" in \"exports\" and ensured \"types\" siblings'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"import\" entries in \"exports\" should use \"default\" instead (use --fix to rename)'))\n }\n result.warnings++\n return result\n}\n\nfunction checkRootTypes(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.types === undefined) return result\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object' || !hasTypesInExports(exports)) return result\n\n if (fix) {\n delete pkg.types\n console.warn(chalk.yellow('Publint [custom]: removed redundant root \"types\" field (already defined in \"exports\")'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: root \"types\" field is redundant when \"exports\" defines types (use --fix to remove)'))\n }\n result.warnings++\n return result\n}\n\nfunction customPubLint(\n pkg: Record<string, unknown>,\n fix = false,\n exclude = new Set<PublintCheckName>(),\n): [number, number, boolean] {\n const result = emptyCustomResult()\n if (!exclude.has('files')) mergeResults(result, checkFiles(pkg, fix))\n if (!exclude.has('source')) mergeResults(result, checkExportsSource(pkg, fix))\n if (!exclude.has('rootSource')) mergeResults(result, checkRootSource(pkg, fix))\n if (!exclude.has('main')) mergeResults(result, migrateFieldToExports(pkg, 'main', 'default', fix))\n if (!exclude.has('types')) mergeResults(result, migrateFieldToExports(pkg, 'types', 'types', fix))\n if (!exclude.has('module')) mergeResults(result, migrateFieldToExports(pkg, 'module', 'default', fix))\n if (!exclude.has('importToDefault')) mergeResults(result, checkImportToDefault(pkg, fix))\n if (!exclude.has('rootTypes')) mergeResults(result, checkRootTypes(pkg, fix))\n if (!exclude.has('sideEffects')) mergeResults(result, checkSideEffects(pkg))\n if (!exclude.has('resolutions')) mergeResults(result, checkResolutions(pkg))\n return [result.errors, result.warnings, result.modified]\n}\n\n// Always-included files that npm packs regardless of the \"files\" field\nconst ALWAYS_INCLUDED_PATTERNS = [\n 'package.json',\n 'README',\n 'README.*',\n 'LICENCE',\n 'LICENCE.*',\n 'LICENSE',\n 'LICENSE.*',\n 'CHANGELOG',\n 'CHANGELOG.*',\n]\n\ninterface PackFile {\n data: string\n name: string\n}\n\nasync function resolvePackFiles(pkgDir: string, filesField?: string[]): Promise<PackFile[]> {\n const patterns = [...ALWAYS_INCLUDED_PATTERNS]\n if (filesField) {\n for (const pattern of filesField) {\n // Negation patterns (e.g. \"!**/*.spec.*\") are exclusions, pass through as-is\n if (pattern.startsWith('!')) {\n patterns.push(pattern)\n } else {\n // Include pattern — glob both the pattern itself and its contents if it's a directory\n patterns.push(pattern, `${pattern}/**`)\n }\n }\n }\n\n const matched = await glob(patterns, {\n cwd: pkgDir,\n nodir: true,\n dot: false,\n })\n\n const files: PackFile[] = await Promise.all(\n matched.map(async (rel) => {\n const abs = path.join(pkgDir, rel)\n const data = await fs.readFile(abs, 'utf8').catch(() => '')\n // publint's tarball VFS looks up files by path.join(pkgDir, rel),\n // so names must be prefixed with pkgDir to match\n return { name: path.join(pkgDir, rel), data }\n }),\n )\n return files\n}\n\nasync function runPublintLibrary(pkgDir: string, pkg: Record<string, unknown>, strict: boolean, pack: boolean): Promise<{ errors: number; total: number }> {\n const { publint } = await import('publint')\n\n let packOption: { files: PackFile[] } | false = false\n if (pack) {\n const files = await resolvePackFiles(pkgDir, pkg.files as string[] | undefined)\n packOption = { files }\n }\n\n const { messages } = await publint({\n level: 'suggestion',\n pack: packOption,\n pkgDir,\n strict,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n for (const message of messages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n return {\n errors: messages.filter(message => message.type === 'error').length,\n total: messages.length,\n }\n}\n\nexport const packagePublint = async ({\n exclude = new Set(), fix = false, pack = true, pkgDir: pkgDirParam, strict = true, verbose: _verbose = false,\n}: PackagePublintParams = {}): Promise<number> => {\n const pkgDir = pkgDirParam ?? INIT_CWD()\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8')) as Record<string, unknown>\n\n const effectiveExclude = pkg.private\n ? new Set([...exclude, ...PUBLISH_ONLY_CHECKS])\n : exclude\n\n console.log(chalk.green(`Publint: ${String(pkg.name)}${pkg.private ? chalk.gray(' (private)') : ''}`))\n console.log(chalk.gray(pkgDir))\n\n let libraryErrors = 0\n if (!effectiveExclude.has('publint')) {\n const library = await runPublintLibrary(pkgDir, pkg, strict, pack)\n libraryErrors = library.errors\n }\n\n const [errorCount, _warningCount, modified] = customPubLint(pkg, fix, effectiveExclude)\n\n if (modified) {\n const sorted = sortPackageJson(JSON.stringify(pkg, null, 2))\n await fs.writeFile(`${pkgDir}/package.json`, sorted)\n }\n\n return libraryErrors + errorCount\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport semver from 'semver'\n\nimport { INIT_CWD } from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type { LintResult } from './package-lint.ts'\n\nfunction readWorkspacePackageJson(cwd: string, location: string): Record<string, unknown> | undefined {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n return JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n } catch {\n return undefined\n }\n}\n\nfunction writeWorkspacePackageJson(cwd: string, location: string, pkg: Record<string, unknown>) {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n}\n\nfunction buildWorkspaceVersionMap(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): Map<string, string> {\n const map = new Map<string, string>()\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) map.set(name, version)\n }\n return map\n}\n\n/**\n * Derives the expected peerDep range from the workspace protocol used in\n * the matching devDependency and the current version of the target package.\n *\n * workspace:~ + version 7.6.21 → ~7.6\n * workspace:^ + version 7.6.21 → ^7\n *\n * Falls back to ~major.minor if no matching devDep is found.\n */\nfunction expectedPeerRange(devDepVersion: string | undefined, targetVersion: string): string {\n const parsed = semver.parse(targetVersion)\n if (!parsed) return `~${targetVersion}`\n\n if (devDepVersion === 'workspace:^') {\n return `^${parsed.major}`\n }\n return `~${parsed.major}.${parsed.minor}`\n}\n\n// --- Version consistency checks ---\n\nexport function checkVersionConsistency(\n cwd: string,\n rootPkg: Record<string, unknown>,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n\n if (rootPkg.version !== undefined) {\n result.fixable.push('Root package.json should not have a \"version\" field in a monorepo')\n }\n\n const versions = new Map<string, string>()\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) {\n versions.set(name, version)\n } else {\n result.errors.push(`${name} (${location}) is missing a \"version\" field`)\n }\n }\n\n const uniqueVersions = new Set(versions.values())\n if (uniqueVersions.size > 1) {\n const versionList = [...uniqueVersions].toSorted(semver.rcompare)\n for (const [name, version] of versions) {\n if (version !== versionList[0]) {\n result.fixable.push(`${name} has version ${version} (expected ${versionList[0]})`)\n }\n }\n }\n\n return result\n}\n\nexport function fixVersionConsistency(\n cwd: string,\n rootPkg: Record<string, unknown>,\n writeRootPackageJson: (cwd: string, pkg: Record<string, unknown>) => void,\n workspaces: { location: string; name: string }[],\n): void {\n if (rootPkg.version !== undefined) {\n delete rootPkg.version\n writeRootPackageJson(cwd, rootPkg)\n console.log(chalk.green(' ✔ Fixed: removed \"version\" from root package.json'))\n }\n\n const versions: string[] = []\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version && semver.valid(version)) {\n versions.push(version)\n }\n }\n\n if (versions.length === 0) return\n\n const highest = versions.toSorted(semver.rcompare)[0]\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n if (pkg.version !== highest) {\n pkg.version = highest\n writeWorkspacePackageJson(cwd, location, pkg)\n console.log(chalk.green(` ✔ Fixed: set version to ${highest} in ${name} (${location})`))\n }\n }\n}\n\n// --- Internal dependency version checks (dependencies and devDependencies only) ---\n\nfunction expectedDepVersion(targetVersion: string): string {\n const parsed = semver.parse(targetVersion)\n if (!parsed) return `~${targetVersion}`\n return `~${targetVersion}`\n}\n\nexport function checkInternalDepVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n const expected = expectedDepVersion(targetVersion)\n if (version.startsWith('workspace:')) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should be \"${expected}\" (not workspace: protocol)`,\n )\n } else if (version !== expected) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should be \"${expected}\"`,\n )\n }\n }\n }\n }\n\n return result\n}\n\nexport function fixInternalDepVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n let modified = false\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n const expected = expectedDepVersion(targetVersion)\n if (version !== expected) {\n deps[dep] = expected\n console.log(chalk.green(` ✔ Fixed: set ${depField}.${dep} to \"${expected}\" in ${name} (${location})`))\n modified = true\n }\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n// --- Workspace protocol checks (pnpm — dependencies and devDependencies only) ---\n\nexport function checkWorkspaceProtocol(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceNames = new Set(workspaces.map(w => w.name))\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n if (!workspaceNames.has(dep)) continue\n if (!version.startsWith('workspace:')) {\n result.fixable.push(\n `${name} (${location}) ${depField}.${dep} is \"${version}\" — should use workspace: protocol`,\n )\n }\n }\n }\n }\n\n return result\n}\n\nexport function fixWorkspaceProtocol(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceNames = new Set(workspaces.map(w => w.name))\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n let modified = false\n\n for (const depField of ['dependencies', 'devDependencies'] as const) {\n const deps = pkg[depField] as Record<string, string> | undefined\n if (!deps) continue\n for (const [dep, version] of Object.entries(deps)) {\n if (!workspaceNames.has(dep)) continue\n if (!version.startsWith('workspace:')) {\n deps[dep] = 'workspace:~'\n console.log(chalk.green(` ✔ Fixed: set ${depField}.${dep} to \"workspace:~\" in ${name} (${location})`))\n modified = true\n }\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n// --- Internal peerDependency version checks ---\n\nexport function checkInternalPeerVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result: LintResult = {\n errors: [], fixable: [], warnings: [],\n }\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n if (version.startsWith('workspace:')) {\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n result.fixable.push(\n `${name} (${location}) peerDependencies.${dep} uses workspace: protocol — should be \"${expected}\"`,\n )\n continue\n }\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected && !semver.satisfies(targetVersion, version)) {\n result.fixable.push(\n `${name} (${location}) peerDependencies.${dep} is \"${version}\" — current version ${targetVersion} is not satisfied; expected \"${expected}\"`,\n )\n }\n }\n }\n\n return result\n}\n\nexport function fixInternalPeerVersions(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): void {\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n let modified = false\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected) {\n peerDeps[dep] = expected\n console.log(chalk.green(` ✔ Fixed: set peerDependencies.${dep} to \"${expected}\" in ${name} (${location})`))\n modified = true\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n}\n\n/**\n * Syncs all internal peerDependency versions to match current workspace versions.\n * Called by xy publish to ensure peerDeps are correct before publishing.\n */\nexport function syncInternalPeerVersions(): number {\n const cwd = INIT_CWD()\n const workspaces = getPackageManager().listWorkspaces()\n const workspaceVersions = buildWorkspaceVersionMap(cwd, workspaces)\n let updated = 0\n\n for (const { location, name } of workspaces) {\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (!peerDeps) continue\n const devDeps = pkg.devDependencies as Record<string, string> | undefined\n let modified = false\n\n for (const [dep, version] of Object.entries(peerDeps)) {\n const targetVersion = workspaceVersions.get(dep)\n if (!targetVersion) continue\n\n const expected = expectedPeerRange(devDeps?.[dep], targetVersion)\n if (version !== expected) {\n peerDeps[dep] = expected\n console.log(chalk.green(`Publish: updated ${name} peerDependencies.${dep} to \"${expected}\"`))\n modified = true\n updated++\n }\n }\n\n if (modified) {\n writeWorkspacePackageJson(cwd, location, pkg)\n }\n }\n\n return updated\n}\n\n/**\n * Reads the shared monorepo version from the first non-root workspace\n * and logs it. Call at the end of deploy to report the new version.\n */\nexport function logMonorepoVersion(): void {\n const cwd = INIT_CWD()\n const workspaces = getPackageManager().listWorkspaces()\n\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkg = readWorkspacePackageJson(cwd, location)\n if (!pkg) continue\n const version = pkg.version as string | undefined\n if (version) {\n console.log(chalk.green(`\\nDeployed version: ${chalk.bold(version)}`))\n return\n }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AAA,EACjB;AAGA,QAAM,aAAa,eAAe,CAAC,GAAG,YAAY,UAAU,KAAK,oBAAI,IAAsB;AAC3F,MAAI,CAAC,WAAW,IAAI,UAAU,GAAG;AAC/B,UAAM,MAAM,SAAS;AACrB,UAAM,aAAa,0BAA0B,KAAK,UAAU;AAC5D,QAAI,WAAW,QAAQ,SAAS,GAAG;AACjC,UAAI,KAAK;AACP,gCAAwB,KAAK,UAAU;AACvC,mBAAW;AAAA,MACb,OAAO;AACL,mBAAW,OAAO,WAAW,SAAS;AACpC,kBAAQ,IAAIA,OAAM,IAAI,YAAO,GAAG,YAAY,CAAC;AAAA,QAC/C;AACA,uBAAe,WAAW,QAAQ;AAAA,MACpC;AAAA,IACF;AACA,mBAAe,WAAW,OAAO;AAAA,EACnC;AAEA,oBAAkB,WAAW,QAAQ,aAAa,YAAY,IAAI,IAAI,KAAK;AAC3E,SAAO;AACT;","names":["chalk","chalk","chalk","chalk","chalk","publint","chalk","expected","chalk","chalk","config"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/package/publint.ts","../../../src/lib/initCwd.ts","../../../src/lib/loadConfig.ts","../../../src/actions/package/compile/XyConfig.ts","../../../src/actions/package/publint.ts","../../../src/actions/publint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { loadPublintOptions, packagePublint } from '../../actions/index.ts'\n\nconst args = process.argv.slice(2)\nconst fix = args.includes('--fix')\n\nloadPublintOptions()\n .then(async ({ exclude, pack }) => {\n process.exitCode = await packagePublint({\n exclude, fix, pack,\n })\n })\n .catch((ex: Error) => {\n console.error(`Publint Failed: ${chalk.red(ex)}`)\n console.error(chalk.gray(ex.stack))\n process.exitCode = -1\n })\n","export function INIT_CWD(): string {\n return process.env.INIT_CWD ?? process.cwd()\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\nlet rootConfigPath: string | undefined\n\nconst workspaceConfigCache = new Map<string, Record<string, unknown>>()\nconst deprecationWarned = new Set<string>()\n\nfunction createExplorer() {\n return cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } })\n}\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config === undefined) {\n const cosmicConfigResult = await createExplorer().search()\n config = (cosmicConfigResult?.config ?? {}) as Record<string, unknown>\n rootConfigPath = cosmicConfigResult?.filepath\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath !== undefined) {\n console.log(chalk.green(`Loaded config from ${configFilePath}`))\n if (config.verbose) {\n console.log(chalk.gray(`${JSON.stringify(config, null, 2)}`))\n }\n }\n }\n return deepmerge(config, params ?? {}) as T\n}\n\n/**\n * Loads the xy.config from a specific workspace directory.\n * Returns an empty object if the workspace has no config or if\n * the found config is the root config (avoids double-applying).\n */\nasync function loadWorkspaceConfig(workspaceDir: string): Promise<Record<string, unknown>> {\n const cached = workspaceConfigCache.get(workspaceDir)\n if (cached !== undefined) return cached\n\n const result = await createExplorer().search(workspaceDir)\n\n // If no config found or it's the root config, no workspace override\n if (!result || result.filepath === rootConfigPath) {\n workspaceConfigCache.set(workspaceDir, {})\n return {}\n }\n\n const wsConfig = (result.config ?? {}) as Record<string, unknown>\n workspaceConfigCache.set(workspaceDir, wsConfig)\n return wsConfig\n}\n\n/** Deprecated top-level fields that should be under `commands`. */\nconst DEPRECATED_COMMAND_FIELDS = new Set(['deplint', 'publint'])\n\n/**\n * Resolves a command's config field from a config object.\n * Prefers `commands.[name]` over top-level `[name]`.\n * Warns once per config file when a deprecated top-level field is used.\n */\nfunction resolveCommandField(\n cfg: Record<string, unknown>,\n commandName: string,\n configPath?: string,\n): Record<string, unknown> {\n const commands = cfg.commands as Record<string, unknown> | undefined\n const fromCommands = commands?.[commandName]\n const fromTopLevel = cfg[commandName]\n\n if (fromCommands !== undefined && typeof fromCommands === 'object') {\n return fromCommands as Record<string, unknown>\n }\n\n if (fromTopLevel !== undefined && typeof fromTopLevel === 'object'\n && DEPRECATED_COMMAND_FIELDS.has(commandName)) {\n const key = `${configPath ?? 'unknown'}:${commandName}`\n if (!deprecationWarned.has(key)) {\n deprecationWarned.add(key)\n console.warn(chalk.yellow(\n `[xy] Deprecated: top-level \"${commandName}\" in ${configPath ?? 'xy.config'} — move to \"commands.${commandName}\"`,\n ))\n }\n return fromTopLevel as Record<string, unknown>\n }\n\n return {}\n}\n\n/**\n * Loads a command-specific config merged from root and workspace levels.\n * The root config provides defaults; the workspace config extends/overrides.\n * Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged\n * via deepmerge, with workspace entries overriding root entries for the same key.\n */\nexport async function loadWorkspaceCommandConfig<C>(\n workspaceDir: string,\n commandName: string,\n): Promise<C> {\n // Ensure root config is loaded\n const root = await loadConfig()\n const rootCmd = resolveCommandField(root as Record<string, unknown>, commandName, rootConfigPath)\n\n const wsConfig = await loadWorkspaceConfig(workspaceDir)\n const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : undefined\n const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath)\n\n return deepmerge(rootCmd, wsCmd) as C\n}\n","import type { Options } from 'tsup'\n\nexport type EntryMode = 'all' | 'single' | 'auto' | 'platform' | 'custom'\n\n/**\n * Configuration for specifying which paths are targeted.\n */\nexport interface PathConfig {\n /**\n * Glob patterns to exclude (takes precedence over include).\n */\n exclude?: string[]\n /**\n * Glob patterns to include.\n */\n include?: string[]\n}\n\n/**\n * Configuration for Dynamic Share.\n */\n\nexport interface DynamicShareConfig extends PathConfig {}\n\n/**\n * Configuration for Live Share.\n */\n\nexport interface LiveShareConfig extends PathConfig {}\n\nexport interface CompileConfig {\n bundleTypes?: boolean\n /** @param entryMode all, single, custom, platform, or auto */\n entryMode?: EntryMode\n /** @param when building types with tsc, should it use the outDir to write to? */\n outDirAsBuildDir?: boolean\n}\n\nexport type PackageCompileTsupConfig = CompileConfig & {\n browser?: Record<string, Options | boolean>\n neutral?: Record<string, Options | boolean>\n node?: Record<string, Options | boolean>\n tsup?: { options?: Options }\n verbose?: boolean\n}\n\nexport type PackageCompileTscConfig = CompileConfig & { mode: 'tsc' }\n\n/**\n * How deplint should classify a dependency.\n * - `dep`: must stay in `dependencies` (never promoted to peerDependencies)\n * - `peer`: should be treated as a peerDependency (overrides a parent `dep` setting)\n */\nexport type DeplintRefType = 'dep' | 'peer'\n\n/**\n * Per-package configuration within deplint.\n */\nexport interface DeplintPackageConfig {\n /** How this dependency should be classified. */\n refType: DeplintRefType\n}\n\n/**\n * Configuration for deplint (dependency linting).\n */\nexport interface DeplintConfig {\n /**\n * Package names to exclude from unused-dependency checks.\n * Packages listed here will never be reported as \"unused\" by deplint,\n * even if no import for them is detected in source or dist files.\n * Useful for packages that are used implicitly (e.g. runtime plugins,\n * CSS-in-JS themes, or polyfills that have side effects on import).\n */\n exclude?: string[]\n /**\n * Per-dependency configuration keyed by package name.\n * Cascades from root to package configs (maps are merged, with\n * package-level entries overriding root-level entries for the same key).\n */\n packages?: Record<string, DeplintPackageConfig>\n}\n\n/**\n * Canonical names for individually toggleable publint checks.\n */\nexport type PublintCheckName\n = | 'files'\n | 'importToDefault'\n | 'main'\n | 'module'\n | 'peerDeps'\n | 'publint'\n | 'resolutions'\n | 'rootSource'\n | 'rootTypes'\n | 'sideEffects'\n | 'source'\n | 'types'\n\nexport const ALL_PUBLINT_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'peerDeps', 'publint', 'resolutions', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/** Checks that only apply to published (non-private) packages */\nexport const PUBLISH_ONLY_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'publint', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/**\n * Configuration for publint (package publishing linting).\n */\nexport interface PublintConfig {\n /**\n * Check names to exclude from publint runs.\n * All checks run by default; listed names are skipped.\n * Cannot be used together with `include`.\n */\n exclude?: PublintCheckName[]\n /**\n * Check names to include (whitelist) in publint runs.\n * Only listed checks will run; all others are skipped.\n * Cannot be used together with `exclude`.\n */\n include?: PublintCheckName[]\n /**\n * Whether to run `pack` when invoking the publint library.\n * When true (default), the package manager is used to determine which\n * files would be published. Set to false to skip packing for faster runs.\n */\n pack?: boolean\n}\n\n/**\n * Configuration for readme generation.\n */\nexport interface ReadmeConfig {\n /**\n * URL that the logo links to when clicked.\n * Replaces the placeholder in the template's [![logo][]](url) link.\n */\n logoLinkUrl?: string\n /**\n * Public URL for the logo image displayed at the top of generated READMEs.\n * Replaces the placeholder in the template's [logo] reference link.\n */\n logoUrl?: string\n}\n\n/**\n * Command-specific configuration that cascades from root to package.\n * Settings here override the legacy top-level equivalents.\n */\nexport interface CommandsConfig {\n deplint?: DeplintConfig\n publint?: boolean | PublintConfig\n}\n\nexport interface XyConfigBase {\n /**\n * Command-specific settings grouped under `commands`.\n * These cascade from root xy.config down to per-package xy.config files.\n * Takes precedence over the legacy top-level `deplint`/`publint` fields.\n */\n commands?: CommandsConfig\n compile?: CompileConfig\n /** @deprecated Use `commands.deplint` instead. */\n deplint?: DeplintConfig\n dynamicShare?: DynamicShareConfig\n liveShare?: LiveShareConfig\n /** @deprecated Use `commands.publint` instead. */\n publint?: boolean | PublintConfig\n\n readme?: ReadmeConfig\n verbose?: boolean\n}\n\nexport interface XyTsupConfig extends XyConfigBase { compile?: PackageCompileTsupConfig }\n\nexport interface XyTscConfig extends XyConfigBase { compile?: PackageCompileTscConfig }\n\nexport type XyConfigLegacy = XyTsupConfig | XyTscConfig\n\nexport type XyConfig = XyConfigLegacy & {\n dev?: {\n build?: {\n clean?: boolean /* default: true */\n compile?: boolean /* default: true */\n deplint?: boolean /* default: true */\n gendocs?: boolean /* default: false */\n gitlint?: boolean /* default: true */\n knip?: boolean /* default: true */\n license?: boolean /* default: true */\n lint?: boolean /* default: true */\n publint?: boolean /* default: true */\n statics?: boolean /* default: true */\n verbose?: boolean\n }\n compile?: PackageCompileTsupConfig\n verbose?: boolean\n }\n verbose?: boolean\n}\n","import { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { glob } from 'glob'\nimport sortPackageJson from 'sort-package-json'\n\nimport { INIT_CWD } from '../../lib/index.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport type { PublintCheckName } from './compile/XyConfig.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport { PUBLISH_ONLY_CHECKS } from './compile/XyConfig.ts'\n\nexport interface PackagePublintParams {\n exclude?: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkgDir?: string\n strict?: boolean\n verbose?: boolean\n}\n\nconst removeSourceFromExports = (exports: Record<string, unknown>): boolean => {\n let removed = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') {\n delete exports[key]\n removed = true\n } else if (typeof value === 'object' && value !== null && removeSourceFromExports(value as Record<string, unknown>)) removed = true\n }\n return removed\n}\n\nconst hasSourceInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') return true\n if (typeof value === 'object' && value !== null && hasSourceInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst hasImportKeyInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) return true\n if (typeof value === 'object' && value !== null && hasImportKeyInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst replaceImportWithDefault = (exports: Record<string, unknown>): boolean => {\n let modified = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) {\n if (exports.default === undefined) {\n exports.default = value\n }\n delete exports.import\n if (exports.types === undefined) {\n exports.types = value.replace(/\\.mjs$/, '.d.ts')\n }\n modified = true\n } else if (typeof value === 'object' && value !== null && replaceImportWithDefault(value as Record<string, unknown>)) modified = true\n }\n return modified\n}\n\nconst hasTypesInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'types') return true\n if (typeof value === 'object' && value !== null && hasTypesInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nfunction ensureExportsPath(value: string): string {\n if (value.startsWith('./') || value.startsWith('../')) return value\n return `./${value}`\n}\n\ninterface CustomLintResult {\n errors: number\n modified: boolean\n warnings: number\n}\n\nfunction emptyCustomResult(): CustomLintResult {\n return {\n errors: 0, modified: false, warnings: 0,\n }\n}\n\nfunction mergeResults(target: CustomLintResult, source: CustomLintResult): void {\n target.errors += source.errors\n target.warnings += source.warnings\n target.modified = target.modified || source.modified\n}\n\nfunction checkFiles(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const files = pkg.files as string[] | undefined\n if (files === undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"files\" field is missing'))\n result.warnings++\n }\n if (Array.isArray(files) && !files.includes('README.md')) {\n files.push('README.md')\n console.warn(chalk.yellow('Publint [custom]: added \"README.md\" to \"files\"'))\n result.modified = true\n result.warnings++\n }\n if (Array.isArray(files) && files.includes('src')) {\n if (fix) {\n pkg.files = files.filter((f: string) => f !== 'src')\n console.warn(chalk.yellow('Publint [custom]: removed \"src\" from \"files\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"src\" should not be in \"files\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction checkExportsSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object' && hasSourceInExports(exports)) {\n if (fix) {\n removeSourceFromExports(exports)\n console.warn(chalk.yellow('Publint [custom]: removed \"source\" entries from \"exports\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"source\" entries should not be in \"exports\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction migrateFieldToExports(\n pkg: Record<string, unknown>,\n field: string,\n exportKey: string,\n fix: boolean,\n): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg[field] === undefined) return result\n\n // Skip non-JS files (e.g. tsconfig packages use \"main\": \"./tsconfig.json\")\n const fieldValue = pkg[field] as string\n if (!fieldValue.endsWith('.js') && !fieldValue.endsWith('.mjs') && !fieldValue.endsWith('.cjs')) return result\n\n if (fix) {\n const exportValue = ensureExportsPath(fieldValue)\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object') {\n const dot = exports['.']\n if (dot && typeof dot === 'object' && !(dot as Record<string, unknown>)[exportKey]) {\n (dot as Record<string, unknown>)[exportKey] = exportValue\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports['.'].${exportKey}\" (${fieldValue})`))\n }\n } else if (!pkg.exports) {\n pkg.exports = { '.': { [exportKey]: exportValue } }\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports\" (.→${fieldValue})`))\n }\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed deprecated \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: \"${field}\" field is deprecated, use \"exports\" instead (use --fix to remove)`))\n }\n result.warnings++\n return result\n}\n\nfunction checkSideEffects(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.sideEffects !== false) {\n console.warn(chalk.yellow('Publint [custom]: \"sideEffects\" field should be set to false'))\n result.warnings++\n }\n return result\n}\n\nfunction checkRootSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n for (const field of ['source', 'src']) {\n if (pkg[field] !== undefined) {\n if (fix) {\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed root-level \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: root-level \"${field}\" field should not be in package.json (use --fix to remove)`))\n }\n result.warnings++\n }\n }\n return result\n}\n\nfunction checkResolutions(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.resolutions !== undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"resolutions\" in use'))\n console.warn(chalk.gray(JSON.stringify(pkg.resolutions, null, 2)))\n result.warnings++\n }\n return result\n}\n\nfunction checkImportToDefault(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object') return result\n if (!hasImportKeyInExports(exports)) return result\n\n if (fix) {\n replaceImportWithDefault(exports)\n console.warn(chalk.yellow('Publint [custom]: renamed \"import\" to \"default\" in \"exports\" and ensured \"types\" siblings'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"import\" entries in \"exports\" should use \"default\" instead (use --fix to rename)'))\n }\n result.warnings++\n return result\n}\n\nfunction checkRootTypes(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.types === undefined) return result\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object' || !hasTypesInExports(exports)) return result\n\n if (fix) {\n delete pkg.types\n console.warn(chalk.yellow('Publint [custom]: removed redundant root \"types\" field (already defined in \"exports\")'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: root \"types\" field is redundant when \"exports\" defines types (use --fix to remove)'))\n }\n result.warnings++\n return result\n}\n\nfunction customPubLint(\n pkg: Record<string, unknown>,\n fix = false,\n exclude = new Set<PublintCheckName>(),\n): [number, number, boolean] {\n const result = emptyCustomResult()\n if (!exclude.has('files')) mergeResults(result, checkFiles(pkg, fix))\n if (!exclude.has('source')) mergeResults(result, checkExportsSource(pkg, fix))\n if (!exclude.has('rootSource')) mergeResults(result, checkRootSource(pkg, fix))\n if (!exclude.has('main')) mergeResults(result, migrateFieldToExports(pkg, 'main', 'default', fix))\n if (!exclude.has('types')) mergeResults(result, migrateFieldToExports(pkg, 'types', 'types', fix))\n if (!exclude.has('module')) mergeResults(result, migrateFieldToExports(pkg, 'module', 'default', fix))\n if (!exclude.has('importToDefault')) mergeResults(result, checkImportToDefault(pkg, fix))\n if (!exclude.has('rootTypes')) mergeResults(result, checkRootTypes(pkg, fix))\n if (!exclude.has('sideEffects')) mergeResults(result, checkSideEffects(pkg))\n if (!exclude.has('resolutions')) mergeResults(result, checkResolutions(pkg))\n return [result.errors, result.warnings, result.modified]\n}\n\n// Always-included files that npm packs regardless of the \"files\" field\nconst ALWAYS_INCLUDED_PATTERNS = [\n 'package.json',\n 'README',\n 'README.*',\n 'LICENCE',\n 'LICENCE.*',\n 'LICENSE',\n 'LICENSE.*',\n 'CHANGELOG',\n 'CHANGELOG.*',\n]\n\ninterface PackFile {\n data: string\n name: string\n}\n\nasync function resolvePackFiles(pkgDir: string, filesField?: string[]): Promise<PackFile[]> {\n const patterns = [...ALWAYS_INCLUDED_PATTERNS]\n if (filesField) {\n for (const pattern of filesField) {\n // Negation patterns (e.g. \"!**/*.spec.*\") are exclusions, pass through as-is\n if (pattern.startsWith('!')) {\n patterns.push(pattern)\n } else {\n // Include pattern — glob both the pattern itself and its contents if it's a directory\n patterns.push(pattern, `${pattern}/**`)\n }\n }\n }\n\n const matched = await glob(patterns, {\n cwd: pkgDir,\n nodir: true,\n dot: false,\n })\n\n const files: PackFile[] = await Promise.all(\n matched.map(async (rel) => {\n const abs = path.join(pkgDir, rel)\n const data = await fs.readFile(abs, 'utf8').catch(() => '')\n // publint's tarball VFS looks up files by path.join(pkgDir, rel),\n // so names must be prefixed with pkgDir to match\n return { name: path.join(pkgDir, rel), data }\n }),\n )\n return files\n}\n\nasync function runPublintLibrary(pkgDir: string, pkg: Record<string, unknown>, strict: boolean, pack: boolean): Promise<{ errors: number; total: number }> {\n const { publint } = await import('publint')\n\n let packOption: { files: PackFile[] } | false = false\n if (pack) {\n const files = await resolvePackFiles(pkgDir, pkg.files as string[] | undefined)\n packOption = { files }\n }\n\n const { messages } = await publint({\n level: 'suggestion',\n pack: packOption,\n pkgDir,\n strict,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n for (const message of messages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n return {\n errors: messages.filter(message => message.type === 'error').length,\n total: messages.length,\n }\n}\n\nexport const packagePublint = async ({\n exclude = new Set(), fix = false, pack = true, pkgDir: pkgDirParam, strict = true, verbose: _verbose = false,\n}: PackagePublintParams = {}): Promise<number> => {\n const pkgDir = pkgDirParam ?? INIT_CWD()\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8')) as Record<string, unknown>\n\n const effectiveExclude = pkg.private\n ? new Set([...exclude, ...PUBLISH_ONLY_CHECKS])\n : exclude\n\n console.log(chalk.green(`Publint: ${String(pkg.name)}${pkg.private ? chalk.gray(' (private)') : ''}`))\n console.log(chalk.gray(pkgDir))\n\n let libraryErrors = 0\n if (!effectiveExclude.has('publint')) {\n const library = await runPublintLibrary(pkgDir, pkg, strict, pack)\n libraryErrors = library.errors\n }\n\n const [errorCount, _warningCount, modified] = customPubLint(pkg, fix, effectiveExclude)\n\n if (modified) {\n const sorted = sortPackageJson(JSON.stringify(pkg, null, 2))\n await fs.writeFile(`${pkgDir}/package.json`, sorted)\n }\n\n return libraryErrors + errorCount\n}\n","import chalk from 'chalk'\n\nimport {\n INIT_CWD,\n installOutputCapture,\n loadConfig,\n loadWorkspaceCommandConfig,\n outputStorage,\n runInstall,\n runWithConcurrency,\n} from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type {\n PublintCheckName, PublintConfig, XyConfig,\n} from './package/index.ts'\nimport { ALL_PUBLINT_CHECKS, packagePublint } from './package/index.ts'\nimport {\n checkInternalPeerVersions,\n fixInternalPeerVersions,\n} from './package-lint-deps.ts'\n\nexport interface PublintParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface PublintPackageParams {\n exclude: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nfunction resolveExclude(\n publintConfig: { exclude?: PublintCheckName[]; include?: PublintCheckName[] },\n cliExclude?: string[],\n cliInclude?: string[],\n): Set<PublintCheckName> | undefined {\n const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0\n const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0\n\n if (hasExclude && hasInclude) {\n console.error(chalk.red('Publint: --include and --exclude cannot be used together'))\n return undefined\n }\n\n if (hasInclude) {\n const include = new Set<PublintCheckName>([\n ...((publintConfig.include ?? [])),\n ...((cliInclude ?? []) as PublintCheckName[]),\n ])\n return new Set(ALL_PUBLINT_CHECKS.filter(c => !include.has(c)))\n }\n\n return new Set<PublintCheckName>([\n ...(publintConfig.exclude ?? []),\n ...((cliExclude ?? []) as PublintCheckName[]),\n ])\n}\n\nfunction normalizePublintConfig(value: boolean | PublintConfig | undefined): PublintConfig {\n if (typeof value === 'object') return value\n return {}\n}\n\nexport interface ResolvedPublintOptions {\n exclude: Set<PublintCheckName>\n pack: boolean\n}\n\nexport async function loadPublintOptions(): Promise<ResolvedPublintOptions> {\n const config = await loadConfig<XyConfig>()\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint)\n const exclude = resolveExclude(publintConfig) ?? new Set<PublintCheckName>()\n return { exclude, pack: publintConfig.pack ?? true }\n}\n\nexport const publint = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose, pkg,\n}: PublintParams) => {\n return pkg === undefined\n ? await publintAll({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n })\n : await publintSingle({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n })\n}\n\nfunction logPublintSummary(packages: number, errors: number, ms: number): void {\n const color = errors > 0 ? chalk.red : chalk.blue\n console.log(color(`Checked ${packages} package(s) in ${ms.toFixed(0)}ms with ${errors} issue(s) found.`))\n}\n\ninterface PublintSingleParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nexport const publintSingle = async ({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n}: PublintSingleParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspace = pm.findWorkspace(pkg)\n if (!workspace) {\n console.error(chalk.red(`Publint: workspace \"${pkg}\" not found`))\n return 1\n }\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(workspace.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n if (!exclude) return 1\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: workspace.location, verbose,\n })\n logPublintSummary(1, errors, performance.now() - start)\n return errors\n}\n\ninterface PublintAllParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n verbose?: boolean\n}\n\ninterface CapturedResult {\n errors: number\n output: string[]\n}\n\nexport const publintAll = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n}: PublintAllParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n const concurrency = jobs\n\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ errors: 0, output: [] }))\n\n installOutputCapture()\n\n await runWithConcurrency(\n workspaces.map((ws, i) => ({ i, ws })),\n concurrency,\n async ({ i, ws }) => {\n const output: string[] = []\n await outputStorage.run(output, async () => {\n try {\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(ws.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n ?? new Set<PublintCheckName>()\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: ws.location, verbose,\n })\n results[i] = { errors, output }\n } catch (ex) {\n output.push(chalk.red(`Publint failed for ${ws.name}: ${(ex as Error).message}\\n`))\n results[i] = { errors: 1, output }\n }\n })\n },\n )\n\n let totalErrors = 0\n for (const { errors, output } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n totalErrors += errors\n }\n\n // Check internal peerDependencies use semver ranges (not workspace: protocol)\n const allExclude = resolveExclude({}, cliExclude, cliInclude) ?? new Set<PublintCheckName>()\n if (!allExclude.has('peerDeps')) {\n const cwd = INIT_CWD()\n const peerResult = checkInternalPeerVersions(cwd, workspaces)\n if (peerResult.fixable.length > 0) {\n if (fix) {\n fixInternalPeerVersions(cwd, workspaces)\n runInstall()\n } else {\n for (const msg of peerResult.fixable) {\n console.log(chalk.red(` ✗ ${msg} (fixable)`))\n }\n totalErrors += peerResult.fixable.length\n }\n }\n totalErrors += peerResult.errors.length\n }\n\n logPublintSummary(workspaces.length, totalErrors, performance.now() - start)\n return totalErrors\n}\n"],"mappings":";;;AAEA,OAAOA,YAAW;;;ACFX,SAAS,WAAmB;AACjC,SAAO,QAAQ,IAAI,YAAY,QAAQ,IAAI;AAC7C;;;ACFA,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,OAAO,eAAe;AAEtB,IAAI;AACJ,IAAI;AAKJ,SAAS,iBAAiB;AACxB,SAAO,YA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E,QAAMC,UAAS,MAAM,WAAqB;AAE1C,QAAM,gBAAgB,uBAAuBA,QAAO,UAAU,WAAWA,QAAO,OAAO;AACvF,QAAM,UAAU,eAAe,aAAa,KAAK,oBAAI,IAAsB;AAC3E,SAAO,EAAE,SAAS,MAAM,cAAc,QAAQ,KAAK;AACrD;;;AL5EA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,MAAM,KAAK,SAAS,OAAO;AAEjC,mBAAmB,EAChB,KAAK,OAAO,EAAE,SAAS,KAAK,MAAM;AACjC,UAAQ,WAAW,MAAM,eAAe;AAAA,IACtC;AAAA,IAAS;AAAA,IAAK;AAAA,EAChB,CAAC;AACH,CAAC,EACA,MAAM,CAAC,OAAc;AACpB,UAAQ,MAAM,mBAAmBC,OAAM,IAAI,EAAE,CAAC,EAAE;AAChD,UAAQ,MAAMA,OAAM,KAAK,GAAG,KAAK,CAAC;AAClC,UAAQ,WAAW;AACrB,CAAC;","names":["chalk","chalk","fix","chalk","chalk","chalk","config","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/package/publint.ts","../../../src/lib/initCwd.ts","../../../src/lib/loadConfig.ts","../../../src/actions/package/compile/XyConfig.ts","../../../src/actions/package/publint.ts","../../../src/actions/publint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { loadPublintOptions, packagePublint } from '../../actions/index.ts'\n\nconst args = process.argv.slice(2)\nconst fix = args.includes('--fix')\n\nloadPublintOptions()\n .then(async ({ exclude, pack }) => {\n process.exitCode = await packagePublint({\n exclude, fix, pack,\n })\n })\n .catch((ex: Error) => {\n console.error(`Publint Failed: ${chalk.red(ex)}`)\n console.error(chalk.gray(ex.stack))\n process.exitCode = -1\n })\n","export function INIT_CWD(): string {\n return process.env.INIT_CWD ?? process.cwd()\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\nlet rootConfigPath: string | undefined\n\nconst workspaceConfigCache = new Map<string, Record<string, unknown>>()\nconst deprecationWarned = new Set<string>()\n\nfunction createExplorer() {\n return cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } })\n}\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config === undefined) {\n const cosmicConfigResult = await createExplorer().search()\n config = (cosmicConfigResult?.config ?? {}) as Record<string, unknown>\n rootConfigPath = cosmicConfigResult?.filepath\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath !== undefined) {\n console.log(chalk.green(`Loaded config from ${configFilePath}`))\n if (config.verbose) {\n console.log(chalk.gray(`${JSON.stringify(config, null, 2)}`))\n }\n }\n }\n return deepmerge(config, params ?? {}) as T\n}\n\n/**\n * Loads the xy.config from a specific workspace directory.\n * Returns an empty object if the workspace has no config or if\n * the found config is the root config (avoids double-applying).\n */\nasync function loadWorkspaceConfig(workspaceDir: string): Promise<Record<string, unknown>> {\n const cached = workspaceConfigCache.get(workspaceDir)\n if (cached !== undefined) return cached\n\n const result = await createExplorer().search(workspaceDir)\n\n // If no config found or it's the root config, no workspace override\n if (!result || result.filepath === rootConfigPath) {\n workspaceConfigCache.set(workspaceDir, {})\n return {}\n }\n\n const wsConfig = (result.config ?? {}) as Record<string, unknown>\n workspaceConfigCache.set(workspaceDir, wsConfig)\n return wsConfig\n}\n\n/** Deprecated top-level fields that should be under `commands`. */\nconst DEPRECATED_COMMAND_FIELDS = new Set(['deplint', 'publint'])\n\n/**\n * Resolves a command's config field from a config object.\n * Prefers `commands.[name]` over top-level `[name]`.\n * Warns once per config file when a deprecated top-level field is used.\n */\nfunction resolveCommandField(\n cfg: Record<string, unknown>,\n commandName: string,\n configPath?: string,\n): Record<string, unknown> {\n const commands = cfg.commands as Record<string, unknown> | undefined\n const fromCommands = commands?.[commandName]\n const fromTopLevel = cfg[commandName]\n\n if (fromCommands !== undefined && typeof fromCommands === 'object') {\n return fromCommands as Record<string, unknown>\n }\n\n if (fromTopLevel !== undefined && typeof fromTopLevel === 'object'\n && DEPRECATED_COMMAND_FIELDS.has(commandName)) {\n const key = `${configPath ?? 'unknown'}:${commandName}`\n if (!deprecationWarned.has(key)) {\n deprecationWarned.add(key)\n console.warn(chalk.yellow(\n `[xy] Deprecated: top-level \"${commandName}\" in ${configPath ?? 'xy.config'} — move to \"commands.${commandName}\"`,\n ))\n }\n return fromTopLevel as Record<string, unknown>\n }\n\n return {}\n}\n\n/**\n * Loads a command-specific config merged from root and workspace levels.\n * The root config provides defaults; the workspace config extends/overrides.\n * Arrays (e.g. `exclude`) are unioned and maps (e.g. `packages`) are merged\n * via deepmerge, with workspace entries overriding root entries for the same key.\n */\nexport async function loadWorkspaceCommandConfig<C>(\n workspaceDir: string,\n commandName: string,\n): Promise<C> {\n // Ensure root config is loaded\n const root = await loadConfig()\n const rootCmd = resolveCommandField(root as Record<string, unknown>, commandName, rootConfigPath)\n\n const wsConfig = await loadWorkspaceConfig(workspaceDir)\n const wsConfigPath = workspaceConfigCache.has(workspaceDir) ? workspaceDir : undefined\n const wsCmd = resolveCommandField(wsConfig, commandName, wsConfigPath)\n\n return deepmerge(rootCmd, wsCmd) as C\n}\n","import type { Options } from 'tsup'\n\nexport type EntryMode = 'all' | 'single' | 'auto' | 'platform' | 'custom'\n\n/**\n * Configuration for specifying which paths are targeted.\n */\nexport interface PathConfig {\n /**\n * Glob patterns to exclude (takes precedence over include).\n */\n exclude?: string[]\n /**\n * Glob patterns to include.\n */\n include?: string[]\n}\n\n/**\n * Configuration for Dynamic Share.\n */\n\nexport interface DynamicShareConfig extends PathConfig {}\n\n/**\n * Configuration for Live Share.\n */\n\nexport interface LiveShareConfig extends PathConfig {}\n\nexport interface CompileConfig {\n bundleTypes?: boolean\n /** @param entryMode all, single, custom, platform, or auto */\n entryMode?: EntryMode\n /** @param when building types with tsc, should it use the outDir to write to? */\n outDirAsBuildDir?: boolean\n}\n\nexport type PackageCompileTsupConfig = CompileConfig & {\n browser?: Record<string, Options | boolean>\n neutral?: Record<string, Options | boolean>\n node?: Record<string, Options | boolean>\n tsup?: { options?: Options }\n verbose?: boolean\n}\n\nexport type PackageCompileTscConfig = CompileConfig & { mode: 'tsc' }\n\n/**\n * How deplint should classify a dependency.\n * - `dep`: must stay in `dependencies` (never promoted to peerDependencies)\n * - `peer`: should be treated as a peerDependency (overrides a parent `dep` setting)\n */\nexport type DeplintRefType = 'dep' | 'peer'\n\n/**\n * Per-package configuration within deplint.\n */\nexport interface DeplintPackageConfig {\n /** How this dependency should be classified. */\n refType: DeplintRefType\n}\n\n/**\n * Configuration for deplint (dependency linting).\n */\nexport interface DeplintConfig {\n /**\n * Package names to exclude from unused-dependency checks.\n * Packages listed here will never be reported as \"unused\" by deplint,\n * even if no import for them is detected in source or dist files.\n * Useful for packages that are used implicitly (e.g. runtime plugins,\n * CSS-in-JS themes, or polyfills that have side effects on import).\n */\n exclude?: string[]\n /**\n * Per-dependency configuration keyed by package name.\n * Cascades from root to package configs (maps are merged, with\n * package-level entries overriding root-level entries for the same key).\n */\n packages?: Record<string, DeplintPackageConfig>\n}\n\n/**\n * Canonical names for individually toggleable publint checks.\n */\nexport type PublintCheckName\n = | 'files'\n | 'importToDefault'\n | 'main'\n | 'module'\n | 'peerDeps'\n | 'publint'\n | 'resolutions'\n | 'rootSource'\n | 'rootTypes'\n | 'sideEffects'\n | 'source'\n | 'types'\n\nexport const ALL_PUBLINT_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'peerDeps', 'publint', 'resolutions', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/** Checks that only apply to published (non-private) packages */\nexport const PUBLISH_ONLY_CHECKS: PublintCheckName[] = [\n 'files', 'importToDefault', 'main', 'module', 'publint', 'rootSource', 'rootTypes', 'sideEffects', 'source', 'types',\n]\n\n/**\n * Configuration for publint (package publishing linting).\n */\nexport interface PublintConfig {\n /**\n * Check names to exclude from publint runs.\n * All checks run by default; listed names are skipped.\n * Cannot be used together with `include`.\n */\n exclude?: PublintCheckName[]\n /**\n * Check names to include (whitelist) in publint runs.\n * Only listed checks will run; all others are skipped.\n * Cannot be used together with `exclude`.\n */\n include?: PublintCheckName[]\n /**\n * Whether to run `pack` when invoking the publint library.\n * When true (default), the package manager is used to determine which\n * files would be published. Set to false to skip packing for faster runs.\n */\n pack?: boolean\n}\n\n/**\n * Configuration for readme generation.\n */\nexport interface ReadmeConfig {\n /**\n * URL that the logo links to when clicked.\n * Replaces the placeholder in the template's [![logo][]](url) link.\n */\n logoLinkUrl?: string\n /**\n * Public URL for the logo image displayed at the top of generated READMEs.\n * Replaces the placeholder in the template's [logo] reference link.\n */\n logoUrl?: string\n}\n\n/**\n * Configuration for packman lint (package manager config linting).\n */\nexport interface PackmanConfig {\n /**\n * Minimum age in minutes that a package must be published before pnpm will install it.\n * Only applies when pnpm is the detected package manager.\n * @default 4320 (3 days)\n */\n minimumReleaseAge?: number\n /**\n * Package patterns to exclude from the minimumReleaseAge requirement.\n * These packages can be installed immediately upon release.\n * Supports exact names and scoped wildcards (e.g. '@myorg/*').\n * @default [\"'@xylabs/*'\", \"'@xyo-network/*'\"]\n */\n minimumReleaseAgeExclude?: string[]\n}\n\n/**\n * Command-specific configuration that cascades from root to package.\n * Settings here override the legacy top-level equivalents.\n */\nexport interface CommandsConfig {\n deplint?: DeplintConfig\n packman?: PackmanConfig\n publint?: boolean | PublintConfig\n}\n\nexport interface XyConfigBase {\n /**\n * Command-specific settings grouped under `commands`.\n * These cascade from root xy.config down to per-package xy.config files.\n * Takes precedence over the legacy top-level `deplint`/`publint` fields.\n */\n commands?: CommandsConfig\n compile?: CompileConfig\n /** @deprecated Use `commands.deplint` instead. */\n deplint?: DeplintConfig\n dynamicShare?: DynamicShareConfig\n liveShare?: LiveShareConfig\n /** @deprecated Use `commands.publint` instead. */\n publint?: boolean | PublintConfig\n\n readme?: ReadmeConfig\n verbose?: boolean\n}\n\nexport interface XyTsupConfig extends XyConfigBase { compile?: PackageCompileTsupConfig }\n\nexport interface XyTscConfig extends XyConfigBase { compile?: PackageCompileTscConfig }\n\nexport type XyConfigLegacy = XyTsupConfig | XyTscConfig\n\nexport type XyConfig = XyConfigLegacy & {\n dev?: {\n build?: {\n clean?: boolean /* default: true */\n compile?: boolean /* default: true */\n deplint?: boolean /* default: true */\n gendocs?: boolean /* default: false */\n gitlint?: boolean /* default: true */\n knip?: boolean /* default: true */\n license?: boolean /* default: true */\n lint?: boolean /* default: true */\n publint?: boolean /* default: true */\n statics?: boolean /* default: true */\n verbose?: boolean\n }\n compile?: PackageCompileTsupConfig\n verbose?: boolean\n }\n verbose?: boolean\n}\n","import { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { glob } from 'glob'\nimport sortPackageJson from 'sort-package-json'\n\nimport { INIT_CWD } from '../../lib/index.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport type { PublintCheckName } from './compile/XyConfig.ts'\n// eslint-disable-next-line import-x/no-internal-modules\nimport { PUBLISH_ONLY_CHECKS } from './compile/XyConfig.ts'\n\nexport interface PackagePublintParams {\n exclude?: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkgDir?: string\n strict?: boolean\n verbose?: boolean\n}\n\nconst removeSourceFromExports = (exports: Record<string, unknown>): boolean => {\n let removed = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') {\n delete exports[key]\n removed = true\n } else if (typeof value === 'object' && value !== null && removeSourceFromExports(value as Record<string, unknown>)) removed = true\n }\n return removed\n}\n\nconst hasSourceInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'source') return true\n if (typeof value === 'object' && value !== null && hasSourceInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst hasImportKeyInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) return true\n if (typeof value === 'object' && value !== null && hasImportKeyInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nconst replaceImportWithDefault = (exports: Record<string, unknown>): boolean => {\n let modified = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'import' && typeof value === 'string' && value.endsWith('.mjs')) {\n if (exports.default === undefined) {\n exports.default = value\n }\n delete exports.import\n if (exports.types === undefined) {\n exports.types = value.replace(/\\.mjs$/, '.d.ts')\n }\n modified = true\n } else if (typeof value === 'object' && value !== null && replaceImportWithDefault(value as Record<string, unknown>)) modified = true\n }\n return modified\n}\n\nconst hasTypesInExports = (exports: Record<string, unknown>): boolean => {\n for (const [key, value] of Object.entries(exports)) {\n if (key === 'types') return true\n if (typeof value === 'object' && value !== null && hasTypesInExports(value as Record<string, unknown>)) return true\n }\n return false\n}\n\nfunction ensureExportsPath(value: string): string {\n if (value.startsWith('./') || value.startsWith('../')) return value\n return `./${value}`\n}\n\ninterface CustomLintResult {\n errors: number\n modified: boolean\n warnings: number\n}\n\nfunction emptyCustomResult(): CustomLintResult {\n return {\n errors: 0, modified: false, warnings: 0,\n }\n}\n\nfunction mergeResults(target: CustomLintResult, source: CustomLintResult): void {\n target.errors += source.errors\n target.warnings += source.warnings\n target.modified = target.modified || source.modified\n}\n\nfunction checkFiles(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const files = pkg.files as string[] | undefined\n if (files === undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"files\" field is missing'))\n result.warnings++\n }\n if (Array.isArray(files) && !files.includes('README.md')) {\n files.push('README.md')\n console.warn(chalk.yellow('Publint [custom]: added \"README.md\" to \"files\"'))\n result.modified = true\n result.warnings++\n }\n if (Array.isArray(files) && files.includes('src')) {\n if (fix) {\n pkg.files = files.filter((f: string) => f !== 'src')\n console.warn(chalk.yellow('Publint [custom]: removed \"src\" from \"files\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"src\" should not be in \"files\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction checkExportsSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object' && hasSourceInExports(exports)) {\n if (fix) {\n removeSourceFromExports(exports)\n console.warn(chalk.yellow('Publint [custom]: removed \"source\" entries from \"exports\"'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"source\" entries should not be in \"exports\" (use --fix to remove)'))\n }\n result.warnings++\n }\n return result\n}\n\nfunction migrateFieldToExports(\n pkg: Record<string, unknown>,\n field: string,\n exportKey: string,\n fix: boolean,\n): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg[field] === undefined) return result\n\n // Skip non-JS files (e.g. tsconfig packages use \"main\": \"./tsconfig.json\")\n const fieldValue = pkg[field] as string\n if (!fieldValue.endsWith('.js') && !fieldValue.endsWith('.mjs') && !fieldValue.endsWith('.cjs')) return result\n\n if (fix) {\n const exportValue = ensureExportsPath(fieldValue)\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (exports && typeof exports === 'object') {\n const dot = exports['.']\n if (dot && typeof dot === 'object' && !(dot as Record<string, unknown>)[exportKey]) {\n (dot as Record<string, unknown>)[exportKey] = exportValue\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports['.'].${exportKey}\" (${fieldValue})`))\n }\n } else if (!pkg.exports) {\n pkg.exports = { '.': { [exportKey]: exportValue } }\n console.warn(chalk.yellow(`Publint [custom]: migrated \"${field}\" to \"exports\" (.→${fieldValue})`))\n }\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed deprecated \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: \"${field}\" field is deprecated, use \"exports\" instead (use --fix to remove)`))\n }\n result.warnings++\n return result\n}\n\nfunction checkSideEffects(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.sideEffects !== false) {\n console.warn(chalk.yellow('Publint [custom]: \"sideEffects\" field should be set to false'))\n result.warnings++\n }\n return result\n}\n\nfunction checkRootSource(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n for (const field of ['source', 'src']) {\n if (pkg[field] !== undefined) {\n if (fix) {\n delete pkg[field]\n console.warn(chalk.yellow(`Publint [custom]: removed root-level \"${field}\" field`))\n result.modified = true\n } else {\n console.warn(chalk.yellow(`Publint [custom]: root-level \"${field}\" field should not be in package.json (use --fix to remove)`))\n }\n result.warnings++\n }\n }\n return result\n}\n\nfunction checkResolutions(pkg: Record<string, unknown>): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.resolutions !== undefined) {\n console.warn(chalk.yellow('Publint [custom]: \"resolutions\" in use'))\n console.warn(chalk.gray(JSON.stringify(pkg.resolutions, null, 2)))\n result.warnings++\n }\n return result\n}\n\nfunction checkImportToDefault(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object') return result\n if (!hasImportKeyInExports(exports)) return result\n\n if (fix) {\n replaceImportWithDefault(exports)\n console.warn(chalk.yellow('Publint [custom]: renamed \"import\" to \"default\" in \"exports\" and ensured \"types\" siblings'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: \"import\" entries in \"exports\" should use \"default\" instead (use --fix to rename)'))\n }\n result.warnings++\n return result\n}\n\nfunction checkRootTypes(pkg: Record<string, unknown>, fix: boolean): CustomLintResult {\n const result = emptyCustomResult()\n if (pkg.types === undefined) return result\n const exports = pkg.exports as Record<string, unknown> | undefined\n if (!exports || typeof exports !== 'object' || !hasTypesInExports(exports)) return result\n\n if (fix) {\n delete pkg.types\n console.warn(chalk.yellow('Publint [custom]: removed redundant root \"types\" field (already defined in \"exports\")'))\n result.modified = true\n } else {\n console.warn(chalk.yellow('Publint [custom]: root \"types\" field is redundant when \"exports\" defines types (use --fix to remove)'))\n }\n result.warnings++\n return result\n}\n\nfunction customPubLint(\n pkg: Record<string, unknown>,\n fix = false,\n exclude = new Set<PublintCheckName>(),\n): [number, number, boolean] {\n const result = emptyCustomResult()\n if (!exclude.has('files')) mergeResults(result, checkFiles(pkg, fix))\n if (!exclude.has('source')) mergeResults(result, checkExportsSource(pkg, fix))\n if (!exclude.has('rootSource')) mergeResults(result, checkRootSource(pkg, fix))\n if (!exclude.has('main')) mergeResults(result, migrateFieldToExports(pkg, 'main', 'default', fix))\n if (!exclude.has('types')) mergeResults(result, migrateFieldToExports(pkg, 'types', 'types', fix))\n if (!exclude.has('module')) mergeResults(result, migrateFieldToExports(pkg, 'module', 'default', fix))\n if (!exclude.has('importToDefault')) mergeResults(result, checkImportToDefault(pkg, fix))\n if (!exclude.has('rootTypes')) mergeResults(result, checkRootTypes(pkg, fix))\n if (!exclude.has('sideEffects')) mergeResults(result, checkSideEffects(pkg))\n if (!exclude.has('resolutions')) mergeResults(result, checkResolutions(pkg))\n return [result.errors, result.warnings, result.modified]\n}\n\n// Always-included files that npm packs regardless of the \"files\" field\nconst ALWAYS_INCLUDED_PATTERNS = [\n 'package.json',\n 'README',\n 'README.*',\n 'LICENCE',\n 'LICENCE.*',\n 'LICENSE',\n 'LICENSE.*',\n 'CHANGELOG',\n 'CHANGELOG.*',\n]\n\ninterface PackFile {\n data: string\n name: string\n}\n\nasync function resolvePackFiles(pkgDir: string, filesField?: string[]): Promise<PackFile[]> {\n const patterns = [...ALWAYS_INCLUDED_PATTERNS]\n if (filesField) {\n for (const pattern of filesField) {\n // Negation patterns (e.g. \"!**/*.spec.*\") are exclusions, pass through as-is\n if (pattern.startsWith('!')) {\n patterns.push(pattern)\n } else {\n // Include pattern — glob both the pattern itself and its contents if it's a directory\n patterns.push(pattern, `${pattern}/**`)\n }\n }\n }\n\n const matched = await glob(patterns, {\n cwd: pkgDir,\n nodir: true,\n dot: false,\n })\n\n const files: PackFile[] = await Promise.all(\n matched.map(async (rel) => {\n const abs = path.join(pkgDir, rel)\n const data = await fs.readFile(abs, 'utf8').catch(() => '')\n // publint's tarball VFS looks up files by path.join(pkgDir, rel),\n // so names must be prefixed with pkgDir to match\n return { name: path.join(pkgDir, rel), data }\n }),\n )\n return files\n}\n\nasync function runPublintLibrary(pkgDir: string, pkg: Record<string, unknown>, strict: boolean, pack: boolean): Promise<{ errors: number; total: number }> {\n const { publint } = await import('publint')\n\n let packOption: { files: PackFile[] } | false = false\n if (pack) {\n const files = await resolvePackFiles(pkgDir, pkg.files as string[] | undefined)\n packOption = { files }\n }\n\n const { messages } = await publint({\n level: 'suggestion',\n pack: packOption,\n pkgDir,\n strict,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n for (const message of messages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n return {\n errors: messages.filter(message => message.type === 'error').length,\n total: messages.length,\n }\n}\n\nexport const packagePublint = async ({\n exclude = new Set(), fix = false, pack = true, pkgDir: pkgDirParam, strict = true, verbose: _verbose = false,\n}: PackagePublintParams = {}): Promise<number> => {\n const pkgDir = pkgDirParam ?? INIT_CWD()\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8')) as Record<string, unknown>\n\n const effectiveExclude = pkg.private\n ? new Set([...exclude, ...PUBLISH_ONLY_CHECKS])\n : exclude\n\n console.log(chalk.green(`Publint: ${String(pkg.name)}${pkg.private ? chalk.gray(' (private)') : ''}`))\n console.log(chalk.gray(pkgDir))\n\n let libraryErrors = 0\n if (!effectiveExclude.has('publint')) {\n const library = await runPublintLibrary(pkgDir, pkg, strict, pack)\n libraryErrors = library.errors\n }\n\n const [errorCount, _warningCount, modified] = customPubLint(pkg, fix, effectiveExclude)\n\n if (modified) {\n const sorted = sortPackageJson(JSON.stringify(pkg, null, 2))\n await fs.writeFile(`${pkgDir}/package.json`, sorted)\n }\n\n return libraryErrors + errorCount\n}\n","import chalk from 'chalk'\n\nimport {\n INIT_CWD,\n installOutputCapture,\n loadConfig,\n loadWorkspaceCommandConfig,\n outputStorage,\n runInstall,\n runWithConcurrency,\n} from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type {\n PublintCheckName, PublintConfig, XyConfig,\n} from './package/index.ts'\nimport { ALL_PUBLINT_CHECKS, packagePublint } from './package/index.ts'\nimport {\n checkInternalPeerVersions,\n fixInternalPeerVersions,\n} from './package-lint-deps.ts'\n\nexport interface PublintParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface PublintPackageParams {\n exclude: Set<PublintCheckName>\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nfunction resolveExclude(\n publintConfig: { exclude?: PublintCheckName[]; include?: PublintCheckName[] },\n cliExclude?: string[],\n cliInclude?: string[],\n): Set<PublintCheckName> | undefined {\n const hasExclude = (publintConfig.exclude?.length ?? 0) > 0 || (cliExclude?.length ?? 0) > 0\n const hasInclude = (publintConfig.include?.length ?? 0) > 0 || (cliInclude?.length ?? 0) > 0\n\n if (hasExclude && hasInclude) {\n console.error(chalk.red('Publint: --include and --exclude cannot be used together'))\n return undefined\n }\n\n if (hasInclude) {\n const include = new Set<PublintCheckName>([\n ...((publintConfig.include ?? [])),\n ...((cliInclude ?? []) as PublintCheckName[]),\n ])\n return new Set(ALL_PUBLINT_CHECKS.filter(c => !include.has(c)))\n }\n\n return new Set<PublintCheckName>([\n ...(publintConfig.exclude ?? []),\n ...((cliExclude ?? []) as PublintCheckName[]),\n ])\n}\n\nfunction normalizePublintConfig(value: boolean | PublintConfig | undefined): PublintConfig {\n if (typeof value === 'object') return value\n return {}\n}\n\nexport interface ResolvedPublintOptions {\n exclude: Set<PublintCheckName>\n pack: boolean\n}\n\nexport async function loadPublintOptions(): Promise<ResolvedPublintOptions> {\n const config = await loadConfig<XyConfig>()\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const publintConfig = normalizePublintConfig(config.commands?.publint ?? config.publint)\n const exclude = resolveExclude(publintConfig) ?? new Set<PublintCheckName>()\n return { exclude, pack: publintConfig.pack ?? true }\n}\n\nexport const publint = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose, pkg,\n}: PublintParams) => {\n return pkg === undefined\n ? await publintAll({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n })\n : await publintSingle({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n })\n}\n\nfunction logPublintSummary(packages: number, errors: number, ms: number): void {\n const color = errors > 0 ? chalk.red : chalk.blue\n console.log(color(`Checked ${packages} package(s) in ${ms.toFixed(0)}ms with ${errors} issue(s) found.`))\n}\n\ninterface PublintSingleParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n pack?: boolean\n pkg: string\n verbose?: boolean\n}\n\nexport const publintSingle = async ({\n cliExclude, cliInclude, fix, pack, pkg, verbose,\n}: PublintSingleParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspace = pm.findWorkspace(pkg)\n if (!workspace) {\n console.error(chalk.red(`Publint: workspace \"${pkg}\" not found`))\n return 1\n }\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(workspace.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n if (!exclude) return 1\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: workspace.location, verbose,\n })\n logPublintSummary(1, errors, performance.now() - start)\n return errors\n}\n\ninterface PublintAllParams {\n cliExclude?: string[]\n cliInclude?: string[]\n fix?: boolean\n jobs: number\n pack?: boolean\n verbose?: boolean\n}\n\ninterface CapturedResult {\n errors: number\n output: string[]\n}\n\nexport const publintAll = async ({\n cliExclude, cliInclude, fix, jobs, pack, verbose,\n}: PublintAllParams) => {\n const start = performance.now()\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n const concurrency = jobs\n\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ errors: 0, output: [] }))\n\n installOutputCapture()\n\n await runWithConcurrency(\n workspaces.map((ws, i) => ({ i, ws })),\n concurrency,\n async ({ i, ws }) => {\n const output: string[] = []\n await outputStorage.run(output, async () => {\n try {\n const wsPublintConfig = normalizePublintConfig(\n await loadWorkspaceCommandConfig<boolean | PublintConfig>(ws.location, 'publint'),\n )\n const exclude = resolveExclude(wsPublintConfig, cliExclude, cliInclude)\n ?? new Set<PublintCheckName>()\n const shouldPack = pack ?? wsPublintConfig.pack ?? true\n\n const errors = await packagePublint({\n exclude, fix, pack: shouldPack, pkgDir: ws.location, verbose,\n })\n results[i] = { errors, output }\n } catch (ex) {\n output.push(chalk.red(`Publint failed for ${ws.name}: ${(ex as Error).message}\\n`))\n results[i] = { errors: 1, output }\n }\n })\n },\n )\n\n let totalErrors = 0\n for (const { errors, output } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n totalErrors += errors\n }\n\n // Check internal peerDependencies use semver ranges (not workspace: protocol)\n const allExclude = resolveExclude({}, cliExclude, cliInclude) ?? new Set<PublintCheckName>()\n if (!allExclude.has('peerDeps')) {\n const cwd = INIT_CWD()\n const peerResult = checkInternalPeerVersions(cwd, workspaces)\n if (peerResult.fixable.length > 0) {\n if (fix) {\n fixInternalPeerVersions(cwd, workspaces)\n runInstall()\n } else {\n for (const msg of peerResult.fixable) {\n console.log(chalk.red(` ✗ ${msg} (fixable)`))\n }\n totalErrors += peerResult.fixable.length\n }\n }\n totalErrors += peerResult.errors.length\n }\n\n logPublintSummary(workspaces.length, totalErrors, performance.now() - start)\n return totalErrors\n}\n"],"mappings":";;;AAEA,OAAOA,YAAW;;;ACFX,SAAS,WAAmB;AACjC,SAAO,QAAQ,IAAI,YAAY,QAAQ,IAAI;AAC7C;;;ACFA,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,OAAO,eAAe;AAEtB,IAAI;AACJ,IAAI;AAKJ,SAAS,iBAAiB;AACxB,SAAO,YAAY,MAAM,EAAE,OAAO,MAAM,SAAS,EAAE,OAAO,iBAAiB,EAAE,EAAE,CAAC;AAClF;AAEO,IAAM,aAAa,OAAyB,WAA2B;AAC5E,MAAI,WAAW,QAAW;AACxB,UAAM,qBAAqB,MAAM,eAAe,EAAE,OAAO;AACzD,aAAU,oBAAoB,UAAU,CAAC;AACzC,qBAAiB,oBAAoB;AACrC,UAAM,iBAAiB,oBAAoB;AAC3C,QAAI,mBAAmB,QAAW;AAChC,cAAQ,IAAI,MAAM,MAAM,sBAAsB,cAAc,EAAE,CAAC;AAC/D,UAAI,OAAO,SAAS;AAClB,gBAAQ,IAAI,MAAM,KAAK,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACA,SAAO,UAAU,QAAQ,UAAU,CAAC,CAAC;AACvC;;;ACuEO,IAAM,qBAAyC;AAAA,EACpD;AAAA,EAAS;AAAA,EAAmB;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAY;AAAA,EAAW;AAAA,EAAe;AAAA,EAAc;AAAA,EAAa;AAAA,EAAe;AAAA,EAAU;AAC1I;AAGO,IAAM,sBAA0C;AAAA,EACrD;AAAA,EAAS;AAAA,EAAmB;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAW;AAAA,EAAc;AAAA,EAAa;AAAA,EAAe;AAAA,EAAU;AAC/G;;;AC3GA,SAAS,YAAY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