@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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/xy/common/checkCommand.ts","../../../src/lib/concurrency.ts","../../../src/pm/detectPackageManager.ts","../../../src/pm/registry.ts","../../../src/lib/initCwd.ts","../../../src/lib/generateReadmeFiles.ts","../../../src/lib/latestVersions.ts","../../../src/lib/loadConfig.ts","../../../src/lib/runInstall.ts","../../../src/actions/package-lint-deps.ts","../../../src/actions/gitlint.ts","../../../src/actions/gitlint-fix.ts","../../../src/actions/lint-init.ts","../../../src/actions/lintlint.ts","../../../src/actions/package/compile/XyConfig.ts","../../../src/actions/package/publint.ts","../../../src/actions/package-lint.ts","../../../src/actions/publint.ts","../../../src/actions/readme-lint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport type { CommandModule } from 'yargs'\n\nimport type { XyConfig } from '../../actions/index.ts'\nimport {\n gitlint, gitlintFix, lintlint, packageLintMonorepo, publint, readmeLint,\n} from '../../actions/index.ts'\nimport { loadConfig } from '../../lib/index.ts'\n\nexport const checkCommand: CommandModule = {\n command: 'check',\n describe: 'Check - Run gitlint, publint, repo lint, lintlint, and readme lint',\n builder: (yargs) => {\n return yargs.option('fix', {\n default: false,\n description: 'Auto-fix fixable issues',\n type: 'boolean',\n })\n },\n handler: async (argv) => {\n const verbose = !!argv.verbose\n const fix = !!argv.fix\n const jobs = argv.jobs as number\n let errors = 0\n\n if (verbose) console.log('Check')\n\n console.log(chalk.blue('\\n— gitlint —'))\n errors += fix ? gitlintFix() : gitlint()\n\n console.log(chalk.blue('\\n— publint —'))\n errors += await publint({\n fix, jobs, verbose,\n })\n\n console.log(chalk.blue('\\n— repo lint —'))\n errors += packageLintMonorepo(fix)\n\n console.log(chalk.blue('\\n— lintlint —'))\n errors += await lintlint({ fix, verbose })\n\n console.log(chalk.blue('\\n— readme lint —'))\n const config = await loadConfig<XyConfig>()\n errors += readmeLint({ config, verbose })\n\n if (errors > 0) {\n console.log(chalk.red(`${errors} issue(s) found`))\n } else {\n console.log(chalk.green('All checks passed'))\n }\n process.exitCode = errors > 0 ? 1 : 0\n },\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 { execFile } from 'node:child_process'\nimport FS, { readFileSync } from 'node:fs'\nimport {\n mkdir, readFile, writeFile,\n} from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport PATH from 'node:path'\nimport { createInterface } from 'node:readline'\nimport { promisify } from 'node:util'\n\nimport chalk from 'chalk'\n\nimport { detectPackageManager, getPackageManager } from '../pm/index.ts'\nimport { fillTemplate } from './fillTemplate.ts'\nimport { INIT_CWD } from './initCwd.ts'\n\nconst execFileAsync = promisify(execFile)\n\nconst require = createRequire(import.meta.url)\nconst packageRoot = PATH.dirname(require.resolve('@xylabs/ts-scripts-common/package.json'))\nconst readmeTemplatesDir = PATH.resolve(packageRoot, 'templates', 'readme')\n\ninterface GenerateReadmeFilesParams {\n jobs: number\n logoLinkUrl?: string\n logoUrl?: string\n pkg?: string\n templatePath?: string\n typedoc?: boolean\n verbose?: boolean\n}\n\nfunction fillReadmeTemplate(template: string, data: Record<string, string>): string {\n const additionalData: Record<string, string> = { ...data, safeName: data.name.replaceAll('/', '__').replaceAll('@', '') }\n return fillTemplate(template, additionalData)\n}\n\nasync function generateTypedoc(packageLocation: string, entryPoints: string[]): Promise<string> {\n const tempDir = PATH.join(packageLocation, '.temp-typedoc')\n\n try {\n if (!FS.existsSync(tempDir)) {\n FS.mkdirSync(tempDir, { recursive: true })\n }\n\n const typedocConfig = {\n disableSources: true,\n entryPointStrategy: 'expand',\n entryPoints: entryPoints.map(ep => PATH.resolve(packageLocation, ep)),\n excludeExternals: true,\n excludeInternal: true,\n excludePrivate: true,\n githubPages: false,\n hideBreadcrumbs: true,\n hideGenerator: true,\n hidePageTitle: true,\n out: tempDir,\n plugin: ['typedoc-plugin-markdown'],\n readme: 'none',\n skipErrorChecking: true,\n sort: ['source-order'],\n theme: 'markdown',\n useCodeBlocks: true,\n }\n\n const typedocJsonPath = PATH.join(tempDir, 'typedoc.json')\n FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2))\n\n try {\n await execFileAsync('npx', ['typedoc', '--options', typedocJsonPath], { cwd: process.cwd() })\n } catch {\n return ''\n }\n\n return consolidateMarkdown(tempDir)\n } catch {\n return ''\n } finally {\n try {\n FS.rmSync(tempDir, { force: true, recursive: true })\n } catch {\n // ignore cleanup errors\n }\n }\n}\n\nfunction consolidateMarkdown(tempDir: string): string {\n let consolidated = '## Reference\\n\\n'\n\n const mainReadmePath = PATH.join(tempDir, 'README.md')\n if (FS.existsSync(mainReadmePath)) {\n const mainContent = FS.readFileSync(mainReadmePath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '')\n .replace(/^# .+\\n/, '')\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)')\n\n consolidated += mainContent + '\\n\\n'\n }\n\n consolidated += processDirectory(tempDir)\n\n return consolidated\n .replaceAll(/\\n\\n\\n+/g, '\\n\\n')\n .replaceAll(/^#### /gm, '### ')\n .replaceAll(/^##### /gm, '#### ')\n .replaceAll(/^###### /gm, '##### ')\n}\n\nfunction processDirectory(dir: string, level = 0): string {\n const indent = ' '.repeat(level)\n let content = ''\n\n try {\n const items = FS.readdirSync(dir, { withFileTypes: true })\n\n for (const item of items) {\n if (item.isDirectory()) continue\n if (item.name === 'README.md' || !item.name.endsWith('.md')) continue\n\n const fileContent = FS.readFileSync(PATH.join(dir, item.name), 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '')\n const moduleName = item.name.replace('.md', '')\n\n content += `\\n\\n${indent}### <a id=\"${moduleName}\"></a>${moduleName}\\n\\n`\n content += fileContent\n .replace(/^# .+\\n/, '')\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)')\n }\n\n for (const item of items) {\n if (!item.isDirectory()) continue\n if (item.name === 'spec' || item.name.includes('.spec')) continue\n\n content += `\\n\\n${indent}### ${item.name}\\n`\n content += processDirectory(PATH.join(dir, item.name), level + 1)\n }\n } catch {\n // skip unreadable directories\n }\n\n return content\n}\n\nfunction askConfirmation(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n rl.close()\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes')\n })\n })\n}\n\nexport const DEFAULT_README_TEMPLATE = readFileSync(PATH.resolve(readmeTemplatesDir, 'README.template.md'), 'utf8')\nexport const DEFAULT_README_BODY = readFileSync(PATH.resolve(readmeTemplatesDir, 'README.body.md'), 'utf8')\n\nexport function applyLogoConfig(template: string, logoUrl?: string, logoLinkUrl?: string): string {\n let result = template\n if (logoUrl) {\n result = result.replace(/\\[logo]: .+/, `[logo]: ${logoUrl}`)\n if (logoLinkUrl) {\n result = result.replace(/\\[!\\[logo]\\[]][^)]*\\)/, `[![logo][]](${logoLinkUrl})`)\n }\n } else {\n result = result.replace(/\\[!\\[logo]\\[]][^\\n]*\\n*/, '')\n result = result.replace(/\\[logo]: [^\\n]*\\n?/, '')\n }\n return result\n}\n\nexport function resolveTemplatePath(templatePath?: string): string {\n const cwd = INIT_CWD()\n return templatePath ?? PATH.join(cwd, '.xy', 'README.template.md')\n}\n\nasync function loadOrCreateTemplate(resolvedTemplatePath: string): Promise<{\n created: boolean\n template: string\n}> {\n try {\n const template = await readFile(resolvedTemplatePath, 'utf8')\n return { created: false, template }\n } catch {\n console.log(chalk.yellow(`Template not found: ${resolvedTemplatePath}`))\n const shouldCreate = await askConfirmation('Would you like to create a stock template? (y/N) ')\n if (!shouldCreate) {\n throw new Error('Template creation declined')\n }\n const template = DEFAULT_README_TEMPLATE\n await scaffoldTemplate(resolvedTemplatePath, template)\n return { created: true, template }\n }\n}\n\nexport async function scaffoldTemplate(resolvedTemplatePath: string, template: string): Promise<void> {\n const xyDir = PATH.dirname(resolvedTemplatePath)\n await mkdir(xyDir, { recursive: true })\n await writeFile(resolvedTemplatePath, template)\n console.log(chalk.green(`Created template: ${resolvedTemplatePath}`))\n const bodyPath = PATH.join(xyDir, 'README.body.md')\n await writeFile(bodyPath, DEFAULT_README_BODY)\n console.log(chalk.green(`Created body template: ${bodyPath}`))\n}\n\nasync function resolveBody(location: string, defaultBody: string): Promise<string> {\n const localBodyPath = PATH.join(location, 'README.body.md')\n try {\n return await readFile(localBodyPath, 'utf8')\n } catch {\n return defaultBody\n }\n}\n\nasync function generateReadmeForWorkspace(\n location: string,\n name: string,\n template: string,\n defaultBody: string,\n typedoc: boolean,\n verbose: boolean,\n pm: string,\n): Promise<boolean> {\n try {\n const pkgJsonPath = PATH.join(location, 'package.json')\n const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf8')) as Record<string, string>\n const body = await resolveBody(location, defaultBody)\n const typedocContent = typedoc ? await generateTypedoc(location, ['src/index*.ts']) : ''\n const readmeContent = fillReadmeTemplate(template, {\n ...pkgJson, body, pm, typedoc: typedocContent,\n })\n await writeFile(PATH.join(location, 'README.md'), readmeContent)\n if (verbose) console.log(chalk.green(` ${name}`))\n return true\n } catch (ex) {\n const error = ex as Error\n console.warn(chalk.yellow(` Skipped ${location}: ${error.message}`))\n return false\n }\n}\n\nimport {\n installOutputCapture, outputStorage, runWithConcurrency,\n} from './concurrency.ts'\n\ninterface CapturedResult {\n output: string[]\n success: boolean\n}\n\nasync function loadDefaultBody(resolvedTemplatePath: string): Promise<string> {\n const xyBodyPath = PATH.join(PATH.dirname(resolvedTemplatePath), 'README.body.md')\n try {\n return await readFile(xyBodyPath, 'utf8')\n } catch {\n return DEFAULT_README_BODY\n }\n}\n\nfunction flushResults(results: CapturedResult[]): boolean {\n let failed = false\n for (const { output, success } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n if (!success) failed = true\n }\n return failed\n}\n\nexport async function generateReadmeFiles({\n jobs, logoLinkUrl, logoUrl, pkg, templatePath, typedoc = false, verbose = false,\n}: GenerateReadmeFilesParams): Promise<number> {\n console.log(chalk.green('Generate README Files'))\n const resolvedTemplatePath = resolveTemplatePath(templatePath)\n\n let template: string\n let templateCreated: boolean\n try {\n ({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath))\n } catch {\n return 1\n }\n\n template = applyLogoConfig(template, logoUrl, logoLinkUrl)\n\n if (templateCreated) {\n console.log(chalk.green('Generating README files for all packages...'))\n }\n\n const defaultBody = await loadDefaultBody(resolvedTemplatePath)\n const pmName = detectPackageManager()\n const pm = getPackageManager()\n const singleWorkspace = pkg && !templateCreated ? pm.findWorkspace(pkg) : undefined\n const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces()\n const concurrency = jobs\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ output: [], success: true }))\n\n installOutputCapture()\n\n const start = performance.now()\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 const success = await generateReadmeForWorkspace(ws.location, ws.name, template, defaultBody, typedoc, verbose, pmName)\n results[i] = { output, success }\n })\n },\n )\n\n const failed = flushResults(results)\n const ms = performance.now() - start\n console.log(chalk.blue(`Generated ${workspaces.length} README(s) in ${ms.toFixed(0)}ms`))\n\n return failed ? 1 : 0\n}\n","// Auto-generated — run `yarn update-latest-versions` to refresh\n// Source: nodejs.org/dist/index.json, npm registry\n\nexport const latestVersions = {\n node: '24.14.1',\n nodeLtsCodename: 'Krypton',\n npm: '11.11.0',\n pnpm: '10.33.0',\n yarn: '4.13.0',\n} as const\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 { 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","import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync() as Record<string, Record<string, unknown>>\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 0 : 1\n}\n","import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync() as Record<string, Record<string, unknown>>\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n","import {\n existsSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\nimport { createInterface } from 'node:readline'\n\nimport chalk from 'chalk'\nimport { globSync } from 'glob'\n\nimport { INIT_CWD, runInstall } from '../lib/index.ts'\n\nexport interface LintInitParams {\n verbose?: boolean\n}\n\nfunction askConfirmation(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n rl.close()\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes')\n })\n })\n}\n\nconst DISALLOWED_IMPORTS_XYLABS = [\n '@xylabs/api',\n '@xylabs/array',\n '@xylabs/arraybuffer',\n '@xylabs/assert',\n '@xylabs/axios',\n '@xylabs/base',\n '@xylabs/bignumber',\n '@xylabs/buffer',\n '@xylabs/creatable',\n '@xylabs/decimal-precision',\n '@xylabs/delay',\n '@xylabs/enum',\n '@xylabs/error',\n '@xylabs/eth-address',\n '@xylabs/events',\n '@xylabs/exists',\n '@xylabs/forget',\n '@xylabs/function-name',\n '@xylabs/hex',\n '@xylabs/log',\n '@xylabs/logger',\n '@xylabs/object',\n '@xylabs/platform',\n '@xylabs/profile',\n '@xylabs/promise',\n '@xylabs/retry',\n '@xylabs/set',\n '@xylabs/static-implements',\n '@xylabs/storage',\n '@xylabs/telemetry',\n '@xylabs/telemetry-exporter',\n '@xylabs/timer',\n '@xylabs/typeof',\n '@xylabs/url',\n '@xylabs/zod',\n]\n\nconst DISALLOWED_IMPORTS_XYO = [\n '@xyo-network/core-payload-plugins',\n '@xyo-network/manifest',\n '@xyo-network/modules',\n '@xyo-network/protocol',\n '@xyo-network/sdk-utils',\n '@xyo-network/shared',\n '@xyo-network/manifest-model',\n '@xyo-network/manifest-wrapper',\n '@xyo-network/boundwitness',\n '@xyo-network/core',\n '@xyo-network/crypto',\n '@xyo-network/payload',\n '@xyo-network/api',\n '@xyo-network/api-models',\n '@xyo-network/dns',\n '@xyo-network/metamask-connector',\n '@xyo-network/module-factory-locator',\n '@xyo-network/schema-payload-plugin',\n '@xyo-network/archivist-memory',\n '@xyo-network/id-payload-plugin',\n '@xyo-network/wallet',\n '@xyo-network/network',\n '@xyo-network/payload-plugin',\n '@xyo-network/payloadset-plugin',\n '@xyo-network/quadkey',\n '@xyo-network/schema-cache',\n '@xyo-network/schema-name-validator',\n '@xyo-network/witnesses',\n]\n\nfunction getRequiredDevDependencies(react: boolean): Record<string, string> {\n const configPkg = react ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n return {\n [configPkg]: 'workspace:^',\n eslint: '^10.0.0',\n }\n}\n\nfunction formatDisallowedArray(name: string, imports: readonly string[]): string {\n const items = imports.map(i => ` '${i}',`).join('\\n')\n return `const ${name} = [\\n${items}\\n]`\n}\n\nfunction generateEslintConfig({\n react, useXyLabsBarrel, useXyoBarrel,\n}: { react: boolean; useXyLabsBarrel: boolean; useXyoBarrel: boolean }): string {\n const configPkg = react ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n const lines: string[] = [\n \"import type { Linter } from 'eslint'\",\n '',\n `import { config as xylabsConfig } from '${configPkg}'`,\n '',\n ]\n\n if (useXyLabsBarrel) {\n lines.push(formatDisallowedArray('disallowedImportsXyLabs', DISALLOWED_IMPORTS_XYLABS), '')\n }\n\n if (useXyoBarrel) {\n lines.push(formatDisallowedArray('disallowedImportsXyo', DISALLOWED_IMPORTS_XYO), '')\n }\n\n // eslint-disable-next-line @stylistic/max-len\n lines.push('const config: Linter.Config[] = [', \" { ignores: ['.yarn/**', 'build', '**/build/**', '**/dist/**', 'dist', 'node_modules/**', '**/node_modules/**', '**/*.md/**', '.claude/worktrees/*'] },\", ' ...xylabsConfig,')\n\n if (useXyLabsBarrel || useXyoBarrel) {\n lines.push(' {', ' rules:', ' {', \" 'no-restricted-imports': [\", \" 'warn',\", ' {')\n\n if (useXyLabsBarrel && useXyoBarrel) {\n lines.push(' paths: [', ' ...disallowedImportsXyLabs,', ' ...disallowedImportsXyo,', ' ],')\n } else if (useXyLabsBarrel) {\n lines.push(' paths: [', ' ...disallowedImportsXyLabs,', ' ],')\n } else {\n lines.push(' paths: [', ' ...disallowedImportsXyo,', ' ],')\n }\n\n lines.push(' },', ' ],', ' },', ' },')\n }\n\n lines.push(']', '', 'export default config', '')\n\n return lines.join('\\n')\n}\n\nfunction addDevDependencies(packageJsonPath: string, requiredDeps: Record<string, string>, verbose?: boolean): boolean {\n const content = readFileSync(packageJsonPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n const devDeps = (pkg.devDependencies ?? {}) as Record<string, string>\n let changed = false\n\n for (const [name, version] of Object.entries(requiredDeps)) {\n if (!devDeps[name]) {\n devDeps[name] = version\n changed = true\n if (verbose) console.log(chalk.gray(` Added ${name}@${version} to devDependencies`))\n } else if (verbose) {\n console.log(chalk.gray(` ${name} already in devDependencies`))\n }\n }\n\n if (changed) {\n // sort devDependencies alphabetically\n const sorted = Object.fromEntries(Object.entries(devDeps).toSorted(([a], [b]) => a.localeCompare(b)))\n pkg.devDependencies = sorted\n writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green('Updated package.json devDependencies'))\n } else {\n console.log(chalk.gray('package.json devDependencies already up to date'))\n }\n return changed\n}\n\nexport function detectReactInMonorepo(cwd: string, verbose?: boolean): boolean {\n const packageJsonPaths = globSync('packages/**/package.json', {\n cwd,\n ignore: ['**/node_modules/**'],\n })\n\n for (const relPath of packageJsonPaths) {\n const fullPath = PATH.resolve(cwd, relPath)\n try {\n const content = readFileSync(fullPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n // Only check dependencies and peerDependencies — devDependencies on react\n // can appear in tooling packages (eslint configs, test utilities) that don't\n // indicate the repo actually uses React\n const deps = pkg.dependencies as Record<string, string> | undefined\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (deps?.react || peerDeps?.react) {\n if (verbose) console.log(chalk.gray(` React detected in ${relPath}`))\n return true\n }\n } catch {\n // skip unreadable package.json\n }\n }\n return false\n}\n\nfunction findExistingConfig(configPath: string, legacyConfigPath: string): string | undefined {\n if (existsSync(configPath)) return configPath\n if (existsSync(legacyConfigPath)) return legacyConfigPath\n return undefined\n}\n\nfunction removeLegacyConfig(legacyConfigPath: string): void {\n if (existsSync(legacyConfigPath)) {\n unlinkSync(legacyConfigPath)\n console.log(chalk.gray('Removed legacy eslint.config.mjs'))\n }\n}\n\nfunction updateDependencies(packageJsonPath: string, react: boolean, cwd: string, verbose?: boolean): void {\n if (!existsSync(packageJsonPath)) {\n console.log(chalk.yellow('No package.json found — skipping dependency updates'))\n return\n }\n const changed = addDevDependencies(packageJsonPath, getRequiredDevDependencies(react), verbose)\n if (changed) {\n runInstall(cwd)\n }\n}\n\nexport async function lintInit({ verbose }: LintInitParams = {}): Promise<number> {\n const cwd = INIT_CWD()\n const configPath = PATH.resolve(cwd, 'eslint.config.ts')\n const legacyConfigPath = PATH.resolve(cwd, 'eslint.config.mjs')\n\n const existingPath = findExistingConfig(configPath, legacyConfigPath)\n if (existingPath) {\n const filename = PATH.basename(existingPath)\n const confirmed = await askConfirmation(\n chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `),\n )\n if (!confirmed) {\n console.log(chalk.gray(`Skipped — existing ${filename} preserved`))\n return 0\n }\n }\n\n const react = detectReactInMonorepo(cwd, verbose)\n if (react) {\n console.log(chalk.cyan('Detected React packages — using @xylabs/eslint-config-react-flat'))\n } else if (verbose) {\n console.log(chalk.gray(' No React packages detected — using @xylabs/eslint-config-flat'))\n }\n\n const useXyLabsBarrel = await askConfirmation(\n chalk.cyan('Disallow @xylabs/sdk-js barrel imports? (y/N) '),\n )\n const useXyoBarrel = await askConfirmation(\n chalk.cyan('Disallow @xyo-network/sdk-js barrel imports? (y/N) '),\n )\n\n const config = generateEslintConfig({\n react, useXyLabsBarrel, useXyoBarrel,\n })\n writeFileSync(configPath, config, 'utf8')\n console.log(chalk.green('Generated eslint.config.ts'))\n\n removeLegacyConfig(legacyConfigPath)\n updateDependencies(PATH.resolve(cwd, 'package.json'), react, cwd, verbose)\n\n return 0\n}\n","import { spawnSync } from 'node:child_process'\nimport {\n existsSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport { findUp } from 'find-up'\n\nimport { runInstall } from '../lib/index.ts'\nimport { detectReactInMonorepo } from './lint-init.ts'\n\ninterface RuleEntry {\n level: string\n options?: unknown[]\n}\n\ninterface LintlintParams {\n fix?: boolean\n verbose?: boolean\n}\n\ninterface ConfigBlock {\n rules?: Record<string, unknown>\n}\n\ninterface RuleComparison {\n additions: { local: RuleEntry; rule: string }[]\n overrides: { local: RuleEntry; rule: string; shared: RuleEntry }[]\n redundant: { local: RuleEntry; rule: string; shared: RuleEntry }[]\n}\n\nfunction parseRuleValue(value: unknown): RuleEntry | undefined {\n if (typeof value === 'string') {\n return { level: value }\n }\n if (typeof value === 'number') {\n return { level: String(value) }\n }\n if (Array.isArray(value) && value.length > 0) {\n return {\n level: String(value[0]),\n options: value.length > 1 ? value.slice(1) : undefined,\n }\n }\n return undefined\n}\n\nfunction normalizeLevel(level: string): string {\n if (level === '0' || level === 'off') return 'off'\n if (level === '1' || level === 'warn') return 'warn'\n if (level === '2' || level === 'error') return 'error'\n return level\n}\n\nfunction rulesMatch(a: RuleEntry, b: RuleEntry): boolean {\n if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false\n return JSON.stringify(a.options) === JSON.stringify(b.options)\n}\n\nfunction formatRule(entry: RuleEntry): string {\n if (entry.options) {\n return JSON.stringify([entry.level, ...entry.options])\n }\n return JSON.stringify([entry.level])\n}\n\nfunction mergeRulesFromBlocks(blocks: ConfigBlock[]): Map<string, RuleEntry> {\n const merged = new Map<string, RuleEntry>()\n for (const block of blocks) {\n if (!block.rules) continue\n for (const [name, value] of Object.entries(block.rules)) {\n const parsed = parseRuleValue(value)\n if (parsed) merged.set(name, parsed)\n }\n }\n return merged\n}\n\nfunction detectSharedPackage(source: string): string | undefined {\n if (source.includes('@xylabs/eslint-config-react-flat')) return '@xylabs/eslint-config-react-flat'\n if (source.includes('@xylabs/eslint-config-flat')) return '@xylabs/eslint-config-flat'\n return undefined\n}\n\nfunction extractLocalRuleBlocks(source: string): string[] {\n const blocks: string[] = []\n const ruleBlockRegex = /\\{\\s*(?:files\\s*:\\s*\\[.*?\\]\\s*,\\s*)?rules\\s*:\\s*\\{([^}]*(?:\\{[^}]*\\}[^}]*)*)\\}/g\n let match\n while ((match = ruleBlockRegex.exec(source)) !== null) {\n blocks.push(match[1])\n }\n return blocks\n}\n\nfunction extractRulesFromSourceBlocks(blocks: string[]): Map<string, string> {\n const rules = new Map<string, string>()\n for (const block of blocks) {\n const ruleRegex = /['\"]([^'\"]+)['\"]\\s*:\\s*(\\[[\\s\\S]*?\\](?=\\s*,|\\s*$))/gm\n let match\n while ((match = ruleRegex.exec(block)) !== null) {\n rules.set(match[1], match[2])\n }\n }\n return rules\n}\n\nfunction extractConfigBlocks(sharedModule: Record<string, unknown>): ConfigBlock[] {\n const config = sharedModule.config ?? sharedModule.default\n if (Array.isArray(config)) return config as ConfigBlock[]\n return []\n}\n\nasync function resolveSharedConfig(configDir: string, sharedPkg: string): Promise<ConfigBlock[]> {\n try {\n const sharedModule = await import(sharedPkg) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n } catch {\n const distPath = PATH.resolve(configDir, 'node_modules', sharedPkg, 'dist', 'node', 'index.mjs')\n try {\n const sharedModule = await import(distPath) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n } catch {\n const neutralPath = PATH.resolve(configDir, 'node_modules', sharedPkg, 'dist', 'neutral', 'index.mjs')\n const sharedModule = await import(neutralPath) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n }\n return []\n }\n}\n\nasync function loadSharedRules(configDir: string, sharedPkg: string, verbose: boolean): Promise<Map<string, RuleEntry> | undefined> {\n const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg)\n const sharedRules = mergeRulesFromBlocks(sharedBlocks)\n\n if (verbose) {\n console.log(chalk.gray(`Shared config defines ${sharedRules.size} rules`))\n }\n\n if (sharedRules.size === 0) {\n console.error(chalk.red('Could not load rules from shared config. Is it installed and built?'))\n return undefined\n }\n\n return sharedRules\n}\n\nasync function loadLocalRules(eslintConfigPath: string, source: string, verbose: boolean): Promise<{ explicit: Map<string, string>; resolved: Map<string, RuleEntry> }> {\n const localModule = await import(eslintConfigPath) as Record<string, unknown>\n const localConfig = localModule.default ?? localModule\n const localBlocks: ConfigBlock[] = Array.isArray(localConfig) ? localConfig as ConfigBlock[] : [localConfig as ConfigBlock]\n const resolved = mergeRulesFromBlocks(localBlocks)\n\n const localRuleBlocks = extractLocalRuleBlocks(source)\n const explicit = extractRulesFromSourceBlocks(localRuleBlocks)\n\n if (verbose) {\n console.log(chalk.gray(`Local config has ${explicit.size} explicit rule setting(s)`))\n }\n\n return { explicit, resolved }\n}\n\nfunction compareRules(\n explicitRuleNames: Map<string, string>,\n allResolvedRules: Map<string, RuleEntry>,\n sharedRules: Map<string, RuleEntry>,\n): RuleComparison {\n const redundant: RuleComparison['redundant'] = []\n const overrides: RuleComparison['overrides'] = []\n const additions: RuleComparison['additions'] = []\n\n for (const ruleName of explicitRuleNames.keys()) {\n const resolvedEntry = allResolvedRules.get(ruleName)\n const sharedEntry = sharedRules.get(ruleName)\n\n if (!resolvedEntry) continue\n\n if (!sharedEntry) {\n additions.push({ local: resolvedEntry, rule: ruleName })\n } else if (rulesMatch(resolvedEntry, sharedEntry)) {\n redundant.push({\n local: resolvedEntry, rule: ruleName, shared: sharedEntry,\n })\n } else {\n overrides.push({\n local: resolvedEntry, rule: ruleName, shared: sharedEntry,\n })\n }\n }\n\n return {\n additions,\n overrides,\n redundant,\n }\n}\n\nfunction reportResults({\n additions, overrides, redundant,\n}: RuleComparison, verbose: boolean): void {\n if (redundant.length > 0) {\n console.log(chalk.yellow(`\\n${redundant.length} redundant rule(s) (same as shared config — can be removed):`))\n for (const { rule, local } of redundant) {\n console.log(chalk.yellow(` ${rule}: ${formatRule(local)}`))\n }\n }\n\n if (overrides.length > 0) {\n console.log(chalk.cyan(`\\n${overrides.length} rule override(s) (different from shared config):`))\n for (const {\n rule, local, shared,\n } of overrides) {\n console.log(chalk.cyan(` ${rule}:`))\n console.log(chalk.gray(` shared: ${formatRule(shared)}`))\n console.log(chalk.white(` local: ${formatRule(local)}`))\n }\n }\n\n if (additions.length > 0 && verbose) {\n console.log(chalk.gray(`\\n${additions.length} local addition(s) (not in shared config):`))\n for (const { rule, local } of additions) {\n console.log(chalk.gray(` ${rule}: ${formatRule(local)}`))\n }\n }\n\n if (redundant.length === 0 && overrides.length === 0) {\n console.log(chalk.green('No redundant or overridden rules found'))\n }\n}\n\nfunction fixRedundantRules(eslintConfigPath: string, redundant: RuleComparison['redundant']): void {\n let updated = readFileSync(eslintConfigPath, 'utf8')\n const original = updated\n for (const { rule } of redundant) {\n const escaped = rule.replaceAll('/', String.raw`\\/`)\n const pattern = new RegExp(String.raw`[ \\t]*['\"]${escaped}['\"]\\s*:\\s*\\[[^\\]]*\\],?[ \\t]*\\n?`, 'g')\n updated = updated.replace(pattern, '')\n }\n // Clean up empty rule blocks left behind\n updated = updated.replaceAll(/\\{\\s*rules\\s*:\\s*\\{\\s*\\}\\s*,?\\s*\\}\\s*,?/g, '')\n updated = updated.replaceAll(/\\n{3,}/g, '\\n\\n')\n\n if (updated !== original) {\n writeFileSync(eslintConfigPath, updated, 'utf8')\n console.log(chalk.green(`\\nFixed: removed ${redundant.length} redundant rule(s)`))\n }\n}\n\nfunction formatConfigFile(eslintConfigPath: string): void {\n spawnSync('eslint', ['--fix', eslintConfigPath], { stdio: 'inherit' })\n}\n\nfunction fixConfigMismatch(\n eslintConfigPath: string,\n configDir: string,\n source: string,\n sharedPkg: string,\n expectedPkg: string,\n): void {\n const updated = source.replaceAll(sharedPkg, expectedPkg)\n writeFileSync(eslintConfigPath, updated, 'utf8')\n console.log(chalk.green(`Fixed: replaced ${sharedPkg} with ${expectedPkg}`))\n\n const packageJsonPath = PATH.resolve(configDir, 'package.json')\n if (!existsSync(packageJsonPath)) return\n\n const content = readFileSync(packageJsonPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n const devDeps = (pkg.devDependencies ?? {}) as Record<string, string>\n const oldVersion = devDeps[sharedPkg]\n if (!oldVersion) return\n\n delete devDeps[sharedPkg]\n devDeps[expectedPkg] = oldVersion\n const sorted = Object.fromEntries(Object.entries(devDeps).toSorted(([a], [b]) => a.localeCompare(b)))\n pkg.devDependencies = sorted\n writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(`Updated package.json: ${sharedPkg} → ${expectedPkg}`))\n runInstall(configDir)\n}\n\nfunction checkConfigVariant(\n eslintConfigPath: string,\n configDir: string,\n source: string,\n sharedPkg: string,\n fix: boolean,\n verbose: boolean,\n): boolean {\n const hasReact = detectReactInMonorepo(configDir, verbose)\n const expectedPkg = hasReact ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n\n if (sharedPkg === expectedPkg) return false\n\n console.log(chalk.yellow(`\\nConfig mismatch: using ${sharedPkg} but ${hasReact ? 'React packages detected' : 'no React packages found'}`))\n console.log(chalk.yellow(` Expected: ${expectedPkg}`))\n\n if (fix) {\n fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expectedPkg)\n }\n\n return true\n}\n\nexport async function lintlint({ fix, verbose }: LintlintParams = {}): Promise<number> {\n const eslintConfigPath = await findUp(['eslint.config.ts', 'eslint.config.mjs'])\n if (!eslintConfigPath) {\n console.error(chalk.red('No eslint.config.ts found'))\n return 1\n }\n\n const configDir = PATH.dirname(eslintConfigPath)\n\n if (verbose) {\n console.log(chalk.gray(`Found config: ${eslintConfigPath}`))\n }\n\n const source = readFileSync(eslintConfigPath, 'utf8')\n const sharedPkg = detectSharedPackage(source)\n\n if (!sharedPkg) {\n console.log(chalk.yellow('No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found'))\n return 0\n }\n\n if (verbose) {\n console.log(chalk.gray(`Shared package: ${sharedPkg}`))\n }\n\n const hasMismatch = checkConfigVariant(eslintConfigPath, configDir, source, sharedPkg, !!fix, !!verbose)\n\n // Re-read source after potential mismatch fix to avoid overwriting changes\n const currentSource = (hasMismatch && fix) ? readFileSync(eslintConfigPath, 'utf8') : source\n\n const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose)\n if (!sharedRules) return 1\n\n const { explicit, resolved } = await loadLocalRules(eslintConfigPath, currentSource, !!verbose)\n const results = compareRules(explicit, resolved, sharedRules)\n\n reportResults(results, !!verbose)\n\n if (results.redundant.length > 0 && fix) {\n fixRedundantRules(eslintConfigPath, results.redundant)\n }\n\n const didFix = fix && (hasMismatch || results.redundant.length > 0)\n if (didFix) {\n formatConfigFile(eslintConfigPath)\n }\n\n const hasUnfixedMismatch = hasMismatch && !fix\n const hasUnfixedRedundant = results.redundant.length > 0 && !fix\n return hasUnfixedMismatch || hasUnfixedRedundant ? 1 : 0\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 {\n existsSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport picomatch from 'picomatch'\nimport semver from 'semver'\n\nimport {\n INIT_CWD, latestVersions, runInstall,\n} from '../lib/index.ts'\nimport { detectPackageManager, getPackageManager } from '../pm/index.ts'\nimport {\n checkInternalDepVersions,\n checkInternalPeerVersions,\n checkVersionConsistency,\n checkWorkspaceProtocol,\n fixInternalDepVersions,\n fixInternalPeerVersions,\n fixVersionConsistency,\n fixWorkspaceProtocol,\n} from './package-lint-deps.ts'\n\nexport interface LintResult {\n errors: string[]\n fixable: string[]\n warnings: string[]\n}\n\nfunction emptyResult(): LintResult {\n return {\n errors: [], fixable: [], warnings: [],\n }\n}\n\nfunction readRootPackageJson(cwd: string): Record<string, unknown> {\n const raw = readFileSync(PATH.resolve(cwd, 'package.json'), 'utf8')\n return JSON.parse(raw) as Record<string, unknown>\n}\n\nfunction writeRootPackageJson(cwd: string, pkg: Record<string, unknown>) {\n const path = PATH.resolve(cwd, 'package.json')\n writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n}\n\nfunction readPnpmWorkspaceGlobs(cwd: string): string[] | undefined {\n const wsPath = PATH.resolve(cwd, 'pnpm-workspace.yaml')\n if (!existsSync(wsPath)) return undefined\n const raw = readFileSync(wsPath, 'utf8')\n const globs: string[] = []\n let inPackages = false\n for (const line of raw.split('\\n')) {\n if (/^packages\\s*:/.test(line)) {\n inPackages = true\n continue\n }\n if (inPackages) {\n const match = /^\\s+-\\s+['\"]?([^'\"]+)['\"]?\\s*$/.exec(line)\n if (match) {\n globs.push(match[1])\n } else if (/^\\S/.test(line) && line.trim() !== '') {\n break\n }\n }\n }\n return globs.length > 0 ? globs : undefined\n}\n\nfunction isMonorepo(pkg: Record<string, unknown>, cwd: string): boolean {\n const workspaces = pkg.workspaces\n if (Array.isArray(workspaces) && workspaces.length > 0) return true\n return readPnpmWorkspaceGlobs(cwd) !== undefined\n}\n\nfunction checkPackagesFolder(workspaces: { location: string; name: string }[]): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!location.startsWith('packages/') && !location.startsWith('packages\\\\')) {\n result.errors.push(`${name} (${location}) is not inside a packages/ folder`)\n }\n }\n\n return result\n}\n\nfunction checkRootPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (!pkg.private) {\n result.fixable.push('Root package.json must be private to prevent accidental publishing')\n }\n\n return result\n}\n\nfunction fixRootPrivate(cwd: string, pkg: Record<string, unknown>) {\n pkg.private = true\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: set \"private\": true in root package.json'))\n}\n\nfunction checkNoPublishConfigOnPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (pkg.private && pkg.publishConfig) {\n result.fixable.push('Root package.json has publishConfig but is private — publishConfig is unnecessary')\n }\n\n return result\n}\n\nfunction fixNoPublishConfigOnPrivate(cwd: string, pkg: Record<string, unknown>) {\n delete pkg.publishConfig\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: removed publishConfig from private root package.json'))\n}\n\nfunction checkNoPackageManagerInWorkspaces(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.packageManager) {\n result.fixable.push(`${name} (${location}) has a packageManager field — only the root should define this`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixNoPackageManagerInWorkspaces(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.packageManager) {\n delete pkg.packageManager\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed packageManager from ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction checkWorkspacesFieldPlacement(\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n // For pnpm: no package should have workspaces (including root)\n // For yarn: only root should have workspaces\n if (pm === 'pnpm' ? true : location !== '.') {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.workspaces) {\n const label = location === '.' ? 'Root' : `${name} (${location})`\n const reason = pm === 'pnpm'\n ? 'pnpm uses pnpm-workspace.yaml instead'\n : 'only the root should define workspaces'\n result.fixable.push(`${label} has a workspaces field — ${reason}`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n }\n\n return result\n}\n\nfunction fixWorkspacesFieldPlacement(\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): void {\n for (const { location } of workspaces) {\n if (pm === 'pnpm' ? true : location !== '.') {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.workspaces) {\n delete pkg.workspaces\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n const label = location === '.' ? 'root' : location\n console.log(chalk.green(` ✔ Fixed: removed workspaces from ${label}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n }\n}\n\nfunction checkWorkspaceGlobCoverage(\n pkg: Record<string, unknown>,\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n const globs = pm === 'pnpm'\n ? readPnpmWorkspaceGlobs(cwd) ?? []\n : (Array.isArray(pkg.workspaces) ? pkg.workspaces as string[] : [])\n\n if (globs.length === 0) {\n const source = pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'root package.json workspaces'\n result.errors.push(`No workspace globs found in ${source}`)\n return result\n }\n\n const matchers = globs.map(glob => picomatch(glob))\n const isMatch = (location: string) => matchers.some(m => m(location))\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!isMatch(location)) {\n const source = pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'root package.json workspaces'\n result.errors.push(`${name} (${location}) is not matched by any glob in ${source}`)\n }\n }\n\n return result\n}\n\nfunction logResults(label: string, result: LintResult, fix: boolean): { errors: number; fixed: number } {\n let errors = 0\n let fixed = 0\n\n for (const error of result.errors) {\n console.log(chalk.red(` ✗ ${error}`))\n errors++\n }\n for (const fixable of result.fixable) {\n if (fix) {\n fixed++\n } else {\n console.log(chalk.red(` ✗ ${fixable} (fixable)`))\n errors++\n }\n }\n for (const warning of result.warnings) {\n console.log(chalk.yellow(` ⚠ ${warning}`))\n }\n if (errors === 0 && fixed === 0 && result.warnings.length === 0) {\n console.log(chalk.green(` ✓ ${label}`))\n }\n\n return { errors, fixed }\n}\n\ninterface CheckEntry {\n check: () => LintResult\n fix?: (cwd: string, pkg: Record<string, unknown>) => void\n label: string\n}\n\nfunction runChecks(entries: CheckEntry[], cwd: string, pkg: Record<string, unknown>, fix: boolean): { errors: number; fixed: number } {\n let totalErrors = 0\n let totalFixed = 0\n\n for (const entry of entries) {\n const result = entry.check()\n const log = logResults(entry.label, result, fix)\n if (fix && entry.fix && result.fixable.length > 0) {\n entry.fix(cwd, pkg)\n }\n totalErrors += log.errors\n totalFixed += log.fixed\n }\n\n return { errors: totalErrors, fixed: totalFixed }\n}\n\nfunction checkVoltaOnlyInRoot(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.volta) {\n result.fixable.push(`${name} (${location}) has a volta field — only the root should define this`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixVoltaOnlyInRoot(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.volta) {\n delete pkg.volta\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed volta from ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction isTerminalPackage(pkg: Record<string, unknown>): boolean {\n return pkg.private === true\n}\n\nfunction checkEnginesOnlyInNonTerminal(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n // Check root (always terminal/private) — should not have engines\n const rootPkg = JSON.parse(readFileSync(PATH.resolve(cwd, 'package.json'), 'utf8')) as Record<string, unknown>\n if (rootPkg.engines) {\n result.fixable.push('Root package.json has engines — terminal packages should not declare engines (use volta instead)')\n }\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (isTerminalPackage(pkg) && pkg.engines) {\n result.fixable.push(`${name} (${location}) is terminal (private) but has engines — terminal packages should not declare engines`)\n }\n if (!isTerminalPackage(pkg) && !pkg.engines) {\n result.fixable.push(`${name} (${location}) is a library but has no engines field`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixEnginesOnlyInNonTerminal(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n // Remove engines from root\n const rootPath = PATH.resolve(cwd, 'package.json')\n const rootRaw = readFileSync(rootPath, 'utf8')\n const rootPkg = JSON.parse(rootRaw) as Record<string, unknown>\n if (rootPkg.engines) {\n delete rootPkg.engines\n writeFileSync(rootPath, `${JSON.stringify(rootPkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(' ✔ Fixed: removed engines from root package.json'))\n }\n\n // Remove engines from terminal workspace packages, add engines to libraries missing them\n const enginesTemplate = resolveEnginesTemplate(cwd, workspaces)\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (isTerminalPackage(pkg) && pkg.engines) {\n delete pkg.engines\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed engines from ${location}/package.json`))\n }\n if (!isTerminalPackage(pkg) && !pkg.engines && enginesTemplate) {\n pkg.engines = enginesTemplate\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: added engines to ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction resolveEnginesTemplate(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): Record<string, string> | undefined {\n // Use engines from the first sibling library package that has one\n for (const { location } of workspaces) {\n if (location === '.') continue\n try {\n const pkg = JSON.parse(readFileSync(PATH.resolve(cwd, location, 'package.json'), 'utf8')) as Record<string, unknown>\n if (!isTerminalPackage(pkg) && pkg.engines) {\n return pkg.engines as Record<string, string>\n }\n } catch {\n // skip\n }\n }\n return undefined\n}\n\nfunction checkVersionsIncludeLts(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n const toolVersions: Record<string, string> = {\n node: latestVersions.node,\n npm: latestVersions.npm,\n pnpm: latestVersions.pnpm,\n yarn: latestVersions.yarn,\n }\n\n // Check engines in all non-terminal packages\n for (const { location, name } of workspaces) {\n const pkgPath = location === '.'\n ? PATH.resolve(cwd, 'package.json')\n : PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n const label = location === '.' ? 'root' : `${name} (${location})`\n\n // Check engines ranges\n const engines = pkg.engines as Record<string, string> | undefined\n if (engines) {\n for (const [tool, range] of Object.entries(engines)) {\n const latest = toolVersions[tool]\n if (latest && !semver.satisfies(latest, range)) {\n result.errors.push(\n `${label} engines.${tool} \"${range}\" does not include latest ${tool === 'node' ? 'LTS ' : ''}version ${latest}`,\n )\n }\n }\n }\n\n // Check volta pins\n const volta = pkg.volta as Record<string, string> | undefined\n if (volta) {\n for (const [tool, pinnedVersion] of Object.entries(volta)) {\n const latest = toolVersions[tool]\n if (latest && semver.lt(pinnedVersion, latest)) {\n result.warnings.push(\n `${label} volta.${tool} \"${pinnedVersion}\" is older than latest ${tool === 'node' ? 'LTS ' : ''}version ${latest}`,\n )\n }\n }\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction logSummary(errors: number, fixed: number) {\n if (fixed > 0) {\n console.log(chalk.green(`\\n Fixed ${fixed} issue(s)`))\n }\n if (errors > 0) {\n console.log(chalk.red(`\\n ${errors} error(s) found`))\n } else if (fixed === 0) {\n console.log(chalk.green('\\n All checks passed'))\n }\n}\n\nexport function packageLintMonorepo(fix = false): number {\n const cwd = INIT_CWD()\n\n let pkg: Record<string, unknown>\n try {\n pkg = readRootPackageJson(cwd)\n } catch {\n console.error(chalk.red('Could not read package.json'))\n return 1\n }\n\n if (!isMonorepo(pkg, cwd)) {\n console.log(chalk.gray('Not a monorepo — skipping repo lint checks'))\n return 0\n }\n\n console.log(chalk.green('Repo Lint'))\n\n const pm = detectPackageManager()\n const workspaces = getPackageManager().listWorkspaces()\n\n const internalDepCheck: CheckEntry = pm === 'pnpm'\n ? {\n check: () => checkWorkspaceProtocol(cwd, workspaces),\n fix: () => fixWorkspaceProtocol(cwd, workspaces),\n label: 'Internal deps/devDeps use workspace: protocol',\n }\n : {\n check: () => checkInternalDepVersions(cwd, workspaces),\n fix: () => fixInternalDepVersions(cwd, workspaces),\n label: 'Internal deps/devDeps use correct version ranges',\n }\n\n const checks: CheckEntry[] = [\n {\n check: () => checkRootPrivate(pkg), fix: fixRootPrivate, label: 'Root package is private',\n },\n {\n check: () => checkNoPublishConfigOnPrivate(pkg), fix: fixNoPublishConfigOnPrivate, label: 'No publishConfig on private root',\n },\n { check: () => checkPackagesFolder(workspaces), label: 'All packages are in packages/ folder' },\n {\n check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),\n fix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),\n label: pm === 'pnpm' ? 'No workspaces field in package.json (use pnpm-workspace.yaml)' : 'Workspaces field only in root package.json',\n },\n {\n check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),\n label: 'Workspace globs cover all packages',\n },\n {\n check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),\n fix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),\n label: 'No packageManager in workspace packages',\n },\n {\n check: () => checkVoltaOnlyInRoot(cwd, workspaces),\n fix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),\n label: 'Volta only in root package.json',\n },\n {\n check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),\n fix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),\n label: 'Engines only in non-terminal (library) packages',\n },\n {\n check: () => checkVersionsIncludeLts(cwd, workspaces),\n label: 'Engine/volta versions include latest LTS',\n },\n {\n check: () => checkVersionConsistency(cwd, pkg, workspaces),\n fix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),\n label: 'Consistent versions across packages',\n },\n internalDepCheck,\n {\n check: () => checkInternalPeerVersions(cwd, workspaces),\n fix: () => fixInternalPeerVersions(cwd, workspaces),\n label: 'Internal peerDeps use semver ranges (not workspace: protocol)',\n },\n ]\n\n const { errors, fixed } = runChecks(checks, cwd, pkg, fix)\n logSummary(errors, fixed)\n\n if (fix && fixed > 0) {\n runInstall()\n }\n\n return errors > 0 ? 1 : 0\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","import { existsSync, readFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\n\nimport { INIT_CWD, resolveTemplatePath } from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type { XyConfig } from './package/index.ts'\n\ninterface ReadmeLintResult {\n errors: string[]\n warnings: string[]\n}\n\nfunction lintTemplate(cwd: string): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const templatePath = resolveTemplatePath()\n\n if (!existsSync(templatePath)) {\n result.errors.push('Missing .xy/README.template.md (run \"xy readme init\" to create)')\n return result\n }\n\n const template = readFileSync(templatePath, 'utf8')\n\n if (!template.includes('{{body}}')) {\n result.warnings.push('.xy/README.template.md does not contain a {{body}} placeholder')\n }\n if (!template.includes('{{description}}')) {\n result.warnings.push('.xy/README.template.md does not contain a {{description}} placeholder')\n }\n\n const bodyPath = PATH.join(cwd, '.xy', 'README.body.md')\n if (!existsSync(bodyPath)) {\n result.errors.push('Missing .xy/README.body.md (run \"xy readme init\" to create)')\n }\n\n return result\n}\n\nfunction lintLogoConfig(cwd: string, config: XyConfig): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const templatePath = resolveTemplatePath()\n\n if (existsSync(templatePath)) {\n const template = readFileSync(templatePath, 'utf8')\n const logoRef = /\\[logo]: (.+)/.exec(template)\n if (logoRef?.[1].includes('example.com')) {\n result.warnings.push('.xy/README.template.md still has the example.com logo placeholder — update it or set readme.logoUrl in xy.config.ts')\n } else if (!logoRef && !config.readme?.logoUrl) {\n result.warnings.push('No logo URL configured in xy.config.ts (readme.logoUrl) or template')\n }\n }\n\n if (!config.readme?.logoUrl && !config.readme?.logoLinkUrl) {\n result.warnings.push('No readme.logoUrl or readme.logoLinkUrl configured in xy.config.ts')\n }\n\n return result\n}\n\nfunction lintPackages(cwd: string): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n\n const pkgPath = PATH.join(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n\n if (pkg.private) continue\n\n if (!pkg.description) {\n result.warnings.push(`${name} is missing a \"description\" in package.json`)\n }\n\n const readmePath = PATH.join(cwd, location, 'README.md')\n if (!existsSync(readmePath)) {\n result.errors.push(`${name} is missing README.md`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nexport interface ReadmeLintParams {\n config: XyConfig\n verbose?: boolean\n}\n\nexport function readmeLint({ config, verbose }: ReadmeLintParams): number {\n const cwd = INIT_CWD()\n console.log(chalk.green('Readme Lint'))\n\n const checks = [\n lintTemplate(cwd),\n lintLogoConfig(cwd, config),\n lintPackages(cwd),\n ]\n\n let errorCount = 0\n let warningCount = 0\n\n for (const { errors, warnings } of checks) {\n for (const error of errors) {\n console.log(chalk.red(` ✗ ${error}`))\n errorCount++\n }\n for (const warning of warnings) {\n console.log(chalk.yellow(` ⚠ ${warning}`))\n warningCount++\n }\n }\n\n if (errorCount === 0 && warningCount === 0) {\n console.log(chalk.green(' All checks passed'))\n } else {\n if (verbose) {\n console.log(chalk.gray(` ${errorCount} error(s), ${warningCount} warning(s)`))\n }\n }\n\n return errorCount > 0 ? 1 : 0\n}\n"],"mappings":";AAAA,OAAOA,aAAW;;;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;A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AS,SAAQ,IAAI,OAAO;AAEhC,YAAQ,IAAIC,QAAM,KAAK,yBAAe,CAAC;AACvC,cAAU,MAAM,WAAW,IAAI,QAAQ;AAEvC,YAAQ,IAAIA,QAAM,KAAK,yBAAe,CAAC;AACvC,cAAU,MAAM,QAAQ;AAAA,MACtB;AAAA,MAAK;AAAA,MAAM;AAAA,IACb,CAAC;AAED,YAAQ,IAAIA,QAAM,KAAK,2BAAiB,CAAC;AACzC,cAAU,oBAAoB,GAAG;AAEjC,YAAQ,IAAIA,QAAM,KAAK,0BAAgB,CAAC;AACxC,cAAU,MAAM,SAAS,EAAE,KAAK,QAAQ,CAAC;AAEzC,YAAQ,IAAIA,QAAM,KAAK,6BAAmB,CAAC;AAC3C,UAAMC,UAAS,MAAM,WAAqB;AAC1C,cAAU,WAAW,EAAE,QAAAA,SAAQ,QAAQ,CAAC;AAExC,QAAI,SAAS,GAAG;AACd,cAAQ,IAAID,QAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC;AAAA,IACnD,OAAO;AACL,cAAQ,IAAIA,QAAM,MAAM,mBAAmB,CAAC;AAAA,IAC9C;AACA,YAAQ,WAAW,SAAS,IAAI,IAAI;AAAA,EACtC;AACF;","names":["chalk","require","chalk","chalk","chalk","readFileSync","PATH","chalk","PATH","readFileSync","writeRootPackageJson","chalk","expected","chalk","chalk","ParseGitConfig","existsSync","readFileSync","writeFileSync","PATH","createInterface","chalk","PATH","readFileSync","chalk","spawnSync","existsSync","readFileSync","writeFileSync","PATH","chalk","config","PATH","chalk","readFileSync","writeFileSync","spawnSync","existsSync","chalk","chalk","publint","existsSync","readFileSync","writeFileSync","PATH","chalk","semver","readFileSync","PATH","path","writeFileSync","existsSync","chalk","glob","semver","chalk","chalk","chalk","existsSync","readFileSync","PATH","chalk","existsSync","readFileSync","PATH","config","chalk","chalk","config"]}
1
+ {"version":3,"sources":["../../../src/xy/common/checkCommand.ts","../../../src/lib/concurrency.ts","../../../src/pm/detectPackageManager.ts","../../../src/pm/registry.ts","../../../src/lib/initCwd.ts","../../../src/lib/generateReadmeFiles.ts","../../../src/lib/latestVersions.ts","../../../src/lib/loadConfig.ts","../../../src/lib/runInstall.ts","../../../src/actions/package-lint-deps.ts","../../../src/actions/gitlint.ts","../../../src/actions/gitlint-fix.ts","../../../src/actions/lint-init.ts","../../../src/actions/lintlint.ts","../../../src/actions/package/compile/XyConfig.ts","../../../src/actions/package/publint.ts","../../../src/actions/package-lint.ts","../../../src/actions/publint.ts","../../../src/actions/readme-lint.ts"],"sourcesContent":["import chalk from 'chalk'\nimport type { CommandModule } from 'yargs'\n\nimport type { XyConfig } from '../../actions/index.ts'\nimport {\n gitlint, gitlintFix, lintlint, packageLintMonorepo, publint, readmeLint,\n} from '../../actions/index.ts'\nimport { loadConfig } from '../../lib/index.ts'\n\nexport const checkCommand: CommandModule = {\n command: 'check',\n describe: 'Check - Run gitlint, publint, repo lint, lintlint, and readme lint',\n builder: (yargs) => {\n return yargs.option('fix', {\n default: false,\n description: 'Auto-fix fixable issues',\n type: 'boolean',\n })\n },\n handler: async (argv) => {\n const verbose = !!argv.verbose\n const fix = !!argv.fix\n const jobs = argv.jobs as number\n let errors = 0\n\n if (verbose) console.log('Check')\n\n console.log(chalk.blue('\\n— gitlint —'))\n errors += fix ? gitlintFix() : gitlint()\n\n console.log(chalk.blue('\\n— publint —'))\n errors += await publint({\n fix, jobs, verbose,\n })\n\n console.log(chalk.blue('\\n— repo lint —'))\n errors += packageLintMonorepo(fix)\n\n console.log(chalk.blue('\\n— lintlint —'))\n errors += await lintlint({ fix, verbose })\n\n console.log(chalk.blue('\\n— readme lint —'))\n const config = await loadConfig<XyConfig>()\n errors += readmeLint({ config, verbose })\n\n if (errors > 0) {\n console.log(chalk.red(`${errors} issue(s) found`))\n } else {\n console.log(chalk.green('All checks passed'))\n }\n process.exitCode = errors > 0 ? 1 : 0\n },\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 { execFile } from 'node:child_process'\nimport FS, { readFileSync } from 'node:fs'\nimport {\n mkdir, readFile, writeFile,\n} from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport PATH from 'node:path'\nimport { createInterface } from 'node:readline'\nimport { promisify } from 'node:util'\n\nimport chalk from 'chalk'\n\nimport { detectPackageManager, getPackageManager } from '../pm/index.ts'\nimport { fillTemplate } from './fillTemplate.ts'\nimport { INIT_CWD } from './initCwd.ts'\n\nconst execFileAsync = promisify(execFile)\n\nconst require = createRequire(import.meta.url)\nconst packageRoot = PATH.dirname(require.resolve('@xylabs/ts-scripts-common/package.json'))\nconst readmeTemplatesDir = PATH.resolve(packageRoot, 'templates', 'readme')\n\ninterface GenerateReadmeFilesParams {\n jobs: number\n logoLinkUrl?: string\n logoUrl?: string\n pkg?: string\n templatePath?: string\n typedoc?: boolean\n verbose?: boolean\n}\n\nfunction fillReadmeTemplate(template: string, data: Record<string, string>): string {\n const additionalData: Record<string, string> = { ...data, safeName: data.name.replaceAll('/', '__').replaceAll('@', '') }\n return fillTemplate(template, additionalData)\n}\n\nasync function generateTypedoc(packageLocation: string, entryPoints: string[]): Promise<string> {\n const tempDir = PATH.join(packageLocation, '.temp-typedoc')\n\n try {\n if (!FS.existsSync(tempDir)) {\n FS.mkdirSync(tempDir, { recursive: true })\n }\n\n const typedocConfig = {\n disableSources: true,\n entryPointStrategy: 'expand',\n entryPoints: entryPoints.map(ep => PATH.resolve(packageLocation, ep)),\n excludeExternals: true,\n excludeInternal: true,\n excludePrivate: true,\n githubPages: false,\n hideBreadcrumbs: true,\n hideGenerator: true,\n hidePageTitle: true,\n out: tempDir,\n plugin: ['typedoc-plugin-markdown'],\n readme: 'none',\n skipErrorChecking: true,\n sort: ['source-order'],\n theme: 'markdown',\n useCodeBlocks: true,\n }\n\n const typedocJsonPath = PATH.join(tempDir, 'typedoc.json')\n FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2))\n\n try {\n await execFileAsync('npx', ['typedoc', '--options', typedocJsonPath], { cwd: process.cwd() })\n } catch {\n return ''\n }\n\n return consolidateMarkdown(tempDir)\n } catch {\n return ''\n } finally {\n try {\n FS.rmSync(tempDir, { force: true, recursive: true })\n } catch {\n // ignore cleanup errors\n }\n }\n}\n\nfunction consolidateMarkdown(tempDir: string): string {\n let consolidated = '## Reference\\n\\n'\n\n const mainReadmePath = PATH.join(tempDir, 'README.md')\n if (FS.existsSync(mainReadmePath)) {\n const mainContent = FS.readFileSync(mainReadmePath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '')\n .replace(/^# .+\\n/, '')\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)')\n\n consolidated += mainContent + '\\n\\n'\n }\n\n consolidated += processDirectory(tempDir)\n\n return consolidated\n .replaceAll(/\\n\\n\\n+/g, '\\n\\n')\n .replaceAll(/^#### /gm, '### ')\n .replaceAll(/^##### /gm, '#### ')\n .replaceAll(/^###### /gm, '##### ')\n}\n\nfunction processDirectory(dir: string, level = 0): string {\n const indent = ' '.repeat(level)\n let content = ''\n\n try {\n const items = FS.readdirSync(dir, { withFileTypes: true })\n\n for (const item of items) {\n if (item.isDirectory()) continue\n if (item.name === 'README.md' || !item.name.endsWith('.md')) continue\n\n const fileContent = FS.readFileSync(PATH.join(dir, item.name), 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '')\n const moduleName = item.name.replace('.md', '')\n\n content += `\\n\\n${indent}### <a id=\"${moduleName}\"></a>${moduleName}\\n\\n`\n content += fileContent\n .replace(/^# .+\\n/, '')\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)')\n }\n\n for (const item of items) {\n if (!item.isDirectory()) continue\n if (item.name === 'spec' || item.name.includes('.spec')) continue\n\n content += `\\n\\n${indent}### ${item.name}\\n`\n content += processDirectory(PATH.join(dir, item.name), level + 1)\n }\n } catch {\n // skip unreadable directories\n }\n\n return content\n}\n\nfunction askConfirmation(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n rl.close()\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes')\n })\n })\n}\n\nexport const DEFAULT_README_TEMPLATE = readFileSync(PATH.resolve(readmeTemplatesDir, 'README.template.md'), 'utf8')\nexport const DEFAULT_README_BODY = readFileSync(PATH.resolve(readmeTemplatesDir, 'README.body.md'), 'utf8')\n\nexport function applyLogoConfig(template: string, logoUrl?: string, logoLinkUrl?: string): string {\n let result = template\n if (logoUrl) {\n result = result.replace(/\\[logo]: .+/, `[logo]: ${logoUrl}`)\n if (logoLinkUrl) {\n result = result.replace(/\\[!\\[logo]\\[]][^)]*\\)/, `[![logo][]](${logoLinkUrl})`)\n }\n } else {\n result = result.replace(/\\[!\\[logo]\\[]][^\\n]*\\n*/, '')\n result = result.replace(/\\[logo]: [^\\n]*\\n?/, '')\n }\n return result\n}\n\nexport function resolveTemplatePath(templatePath?: string): string {\n const cwd = INIT_CWD()\n return templatePath ?? PATH.join(cwd, '.xy', 'README.template.md')\n}\n\nasync function loadOrCreateTemplate(resolvedTemplatePath: string): Promise<{\n created: boolean\n template: string\n}> {\n try {\n const template = await readFile(resolvedTemplatePath, 'utf8')\n return { created: false, template }\n } catch {\n console.log(chalk.yellow(`Template not found: ${resolvedTemplatePath}`))\n const shouldCreate = await askConfirmation('Would you like to create a stock template? (y/N) ')\n if (!shouldCreate) {\n throw new Error('Template creation declined')\n }\n const template = DEFAULT_README_TEMPLATE\n await scaffoldTemplate(resolvedTemplatePath, template)\n return { created: true, template }\n }\n}\n\nexport async function scaffoldTemplate(resolvedTemplatePath: string, template: string): Promise<void> {\n const xyDir = PATH.dirname(resolvedTemplatePath)\n await mkdir(xyDir, { recursive: true })\n await writeFile(resolvedTemplatePath, template)\n console.log(chalk.green(`Created template: ${resolvedTemplatePath}`))\n const bodyPath = PATH.join(xyDir, 'README.body.md')\n await writeFile(bodyPath, DEFAULT_README_BODY)\n console.log(chalk.green(`Created body template: ${bodyPath}`))\n}\n\nasync function resolveBody(location: string, defaultBody: string): Promise<string> {\n const localBodyPath = PATH.join(location, 'README.body.md')\n try {\n return await readFile(localBodyPath, 'utf8')\n } catch {\n return defaultBody\n }\n}\n\nasync function generateReadmeForWorkspace(\n location: string,\n name: string,\n template: string,\n defaultBody: string,\n typedoc: boolean,\n verbose: boolean,\n pm: string,\n): Promise<boolean> {\n try {\n const pkgJsonPath = PATH.join(location, 'package.json')\n const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf8')) as Record<string, string>\n const body = await resolveBody(location, defaultBody)\n const typedocContent = typedoc ? await generateTypedoc(location, ['src/index*.ts']) : ''\n const readmeContent = fillReadmeTemplate(template, {\n ...pkgJson, body, pm, typedoc: typedocContent,\n })\n await writeFile(PATH.join(location, 'README.md'), readmeContent)\n if (verbose) console.log(chalk.green(` ${name}`))\n return true\n } catch (ex) {\n const error = ex as Error\n console.warn(chalk.yellow(` Skipped ${location}: ${error.message}`))\n return false\n }\n}\n\nimport {\n installOutputCapture, outputStorage, runWithConcurrency,\n} from './concurrency.ts'\n\ninterface CapturedResult {\n output: string[]\n success: boolean\n}\n\nasync function loadDefaultBody(resolvedTemplatePath: string): Promise<string> {\n const xyBodyPath = PATH.join(PATH.dirname(resolvedTemplatePath), 'README.body.md')\n try {\n return await readFile(xyBodyPath, 'utf8')\n } catch {\n return DEFAULT_README_BODY\n }\n}\n\nfunction flushResults(results: CapturedResult[]): boolean {\n let failed = false\n for (const { output, success } of results) {\n for (const line of output) {\n process.stdout.write(line)\n }\n if (!success) failed = true\n }\n return failed\n}\n\nexport async function generateReadmeFiles({\n jobs, logoLinkUrl, logoUrl, pkg, templatePath, typedoc = false, verbose = false,\n}: GenerateReadmeFilesParams): Promise<number> {\n console.log(chalk.green('Generate README Files'))\n const resolvedTemplatePath = resolveTemplatePath(templatePath)\n\n let template: string\n let templateCreated: boolean\n try {\n ({ template, created: templateCreated } = await loadOrCreateTemplate(resolvedTemplatePath))\n } catch {\n return 1\n }\n\n template = applyLogoConfig(template, logoUrl, logoLinkUrl)\n\n if (templateCreated) {\n console.log(chalk.green('Generating README files for all packages...'))\n }\n\n const defaultBody = await loadDefaultBody(resolvedTemplatePath)\n const pmName = detectPackageManager()\n const pm = getPackageManager()\n const singleWorkspace = pkg && !templateCreated ? pm.findWorkspace(pkg) : undefined\n const workspaces = singleWorkspace ? [singleWorkspace] : pm.listWorkspaces()\n const concurrency = jobs\n const results: CapturedResult[] = Array.from({ length: workspaces.length }, () => ({ output: [], success: true }))\n\n installOutputCapture()\n\n const start = performance.now()\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 const success = await generateReadmeForWorkspace(ws.location, ws.name, template, defaultBody, typedoc, verbose, pmName)\n results[i] = { output, success }\n })\n },\n )\n\n const failed = flushResults(results)\n const ms = performance.now() - start\n console.log(chalk.blue(`Generated ${workspaces.length} README(s) in ${ms.toFixed(0)}ms`))\n\n return failed ? 1 : 0\n}\n","// Auto-generated — run `yarn update-latest-versions` to refresh\n// Source: nodejs.org/dist/index.json, npm registry\n\nexport const latestVersions = {\n node: '24.14.1',\n nodeLtsCodename: 'Krypton',\n npm: '11.11.0',\n pnpm: '10.33.0',\n yarn: '4.13.0',\n} as const\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 { 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","import chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlint = () => {\n console.log(`\\nGitlint Start [${process.cwd()}]\\n`)\n let valid = 0\n let warnings = 0\n const errors = 0\n const gitConfig = ParseGitConfig.sync() as Record<string, Record<string, unknown>>\n\n const warn = (message: string) => {\n console.warn(chalk.yellow(`Warning: ${message}`))\n warnings++\n }\n\n if (gitConfig.core.ignorecase) {\n warn('Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]')\n } else {\n valid++\n }\n\n if (gitConfig.core.autocrlf === false) {\n valid++\n } else {\n warn('Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]')\n }\n\n if (gitConfig.core.eol === 'lf') {\n valid++\n } else {\n warn('Please set core.eol to \"lf\" in .git/config file [run yarn gitlint-fix]')\n }\n\n const resultMessages: string[] = []\n if (valid > 0) {\n resultMessages.push(chalk.green(`Passed: ${valid}`))\n }\n if (warnings > 0) {\n resultMessages.push(chalk.yellow(`Warnings: ${warnings}`))\n }\n if (errors > 0) {\n resultMessages.push(chalk.red(` Errors: ${errors}`))\n }\n console.warn(`Gitlint Finish [ ${resultMessages.join(' | ')} ]\\n`)\n return warnings + errors === 0 ? 0 : 1\n}\n","import { execSync } from 'node:child_process'\n\nimport chalk from 'chalk'\nimport ParseGitConfig from 'parse-git-config'\n\nexport const gitlintFix = () => {\n console.log(`\\nGitlint Fix Start [${process.cwd()}]\\n`)\n\n const gitConfig = ParseGitConfig.sync() as Record<string, Record<string, unknown>>\n\n if (gitConfig.core.ignorecase) {\n execSync('git config core.ignorecase false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.ignorecase to be false\\n'))\n }\n\n if (gitConfig.core.autocrlf !== false) {\n execSync('git config core.autocrlf false', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.autocrlf to be false\\n'))\n }\n\n if (gitConfig.core.eol !== 'lf') {\n execSync('git config core.eol lf', { stdio: 'inherit' })\n console.warn(chalk.yellow('\\nGitlint Fix: Updated core.eol to be \"lf\"\\n'))\n }\n\n return 1\n}\n","import {\n existsSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\nimport { createInterface } from 'node:readline'\n\nimport chalk from 'chalk'\nimport { globSync } from 'glob'\n\nimport { INIT_CWD, runInstall } from '../lib/index.ts'\n\nexport interface LintInitParams {\n verbose?: boolean\n}\n\nfunction askConfirmation(question: string): Promise<boolean> {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n rl.close()\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes')\n })\n })\n}\n\nconst DISALLOWED_IMPORTS_XYLABS = [\n '@xylabs/api',\n '@xylabs/array',\n '@xylabs/arraybuffer',\n '@xylabs/assert',\n '@xylabs/axios',\n '@xylabs/base',\n '@xylabs/bignumber',\n '@xylabs/buffer',\n '@xylabs/creatable',\n '@xylabs/decimal-precision',\n '@xylabs/delay',\n '@xylabs/enum',\n '@xylabs/error',\n '@xylabs/eth-address',\n '@xylabs/events',\n '@xylabs/exists',\n '@xylabs/forget',\n '@xylabs/function-name',\n '@xylabs/hex',\n '@xylabs/log',\n '@xylabs/logger',\n '@xylabs/object',\n '@xylabs/platform',\n '@xylabs/profile',\n '@xylabs/promise',\n '@xylabs/retry',\n '@xylabs/set',\n '@xylabs/static-implements',\n '@xylabs/storage',\n '@xylabs/telemetry',\n '@xylabs/telemetry-exporter',\n '@xylabs/timer',\n '@xylabs/typeof',\n '@xylabs/url',\n '@xylabs/zod',\n]\n\nconst DISALLOWED_IMPORTS_XYO = [\n '@xyo-network/core-payload-plugins',\n '@xyo-network/manifest',\n '@xyo-network/modules',\n '@xyo-network/protocol',\n '@xyo-network/sdk-utils',\n '@xyo-network/shared',\n '@xyo-network/manifest-model',\n '@xyo-network/manifest-wrapper',\n '@xyo-network/boundwitness',\n '@xyo-network/core',\n '@xyo-network/crypto',\n '@xyo-network/payload',\n '@xyo-network/api',\n '@xyo-network/api-models',\n '@xyo-network/dns',\n '@xyo-network/metamask-connector',\n '@xyo-network/module-factory-locator',\n '@xyo-network/schema-payload-plugin',\n '@xyo-network/archivist-memory',\n '@xyo-network/id-payload-plugin',\n '@xyo-network/wallet',\n '@xyo-network/network',\n '@xyo-network/payload-plugin',\n '@xyo-network/payloadset-plugin',\n '@xyo-network/quadkey',\n '@xyo-network/schema-cache',\n '@xyo-network/schema-name-validator',\n '@xyo-network/witnesses',\n]\n\nfunction getRequiredDevDependencies(react: boolean): Record<string, string> {\n const configPkg = react ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n return {\n [configPkg]: 'workspace:^',\n eslint: '^10.0.0',\n }\n}\n\nfunction formatDisallowedArray(name: string, imports: readonly string[]): string {\n const items = imports.map(i => ` '${i}',`).join('\\n')\n return `const ${name} = [\\n${items}\\n]`\n}\n\nfunction generateEslintConfig({\n react, useXyLabsBarrel, useXyoBarrel,\n}: { react: boolean; useXyLabsBarrel: boolean; useXyoBarrel: boolean }): string {\n const configPkg = react ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n const lines: string[] = [\n \"import type { Linter } from 'eslint'\",\n '',\n `import { config as xylabsConfig } from '${configPkg}'`,\n '',\n ]\n\n if (useXyLabsBarrel) {\n lines.push(formatDisallowedArray('disallowedImportsXyLabs', DISALLOWED_IMPORTS_XYLABS), '')\n }\n\n if (useXyoBarrel) {\n lines.push(formatDisallowedArray('disallowedImportsXyo', DISALLOWED_IMPORTS_XYO), '')\n }\n\n // eslint-disable-next-line @stylistic/max-len\n lines.push('const config: Linter.Config[] = [', \" { ignores: ['.yarn/**', 'build', '**/build/**', '**/dist/**', 'dist', 'node_modules/**', '**/node_modules/**', '**/*.md/**', '.claude/worktrees/*'] },\", ' ...xylabsConfig,')\n\n if (useXyLabsBarrel || useXyoBarrel) {\n lines.push(' {', ' rules:', ' {', \" 'no-restricted-imports': [\", \" 'warn',\", ' {')\n\n if (useXyLabsBarrel && useXyoBarrel) {\n lines.push(' paths: [', ' ...disallowedImportsXyLabs,', ' ...disallowedImportsXyo,', ' ],')\n } else if (useXyLabsBarrel) {\n lines.push(' paths: [', ' ...disallowedImportsXyLabs,', ' ],')\n } else {\n lines.push(' paths: [', ' ...disallowedImportsXyo,', ' ],')\n }\n\n lines.push(' },', ' ],', ' },', ' },')\n }\n\n lines.push(']', '', 'export default config', '')\n\n return lines.join('\\n')\n}\n\nfunction addDevDependencies(packageJsonPath: string, requiredDeps: Record<string, string>, verbose?: boolean): boolean {\n const content = readFileSync(packageJsonPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n const devDeps = (pkg.devDependencies ?? {}) as Record<string, string>\n let changed = false\n\n for (const [name, version] of Object.entries(requiredDeps)) {\n if (!devDeps[name]) {\n devDeps[name] = version\n changed = true\n if (verbose) console.log(chalk.gray(` Added ${name}@${version} to devDependencies`))\n } else if (verbose) {\n console.log(chalk.gray(` ${name} already in devDependencies`))\n }\n }\n\n if (changed) {\n // sort devDependencies alphabetically\n const sorted = Object.fromEntries(Object.entries(devDeps).toSorted(([a], [b]) => a.localeCompare(b)))\n pkg.devDependencies = sorted\n writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green('Updated package.json devDependencies'))\n } else {\n console.log(chalk.gray('package.json devDependencies already up to date'))\n }\n return changed\n}\n\nexport function detectReactInMonorepo(cwd: string, verbose?: boolean): boolean {\n const packageJsonPaths = globSync('packages/**/package.json', {\n cwd,\n ignore: ['**/node_modules/**'],\n })\n\n for (const relPath of packageJsonPaths) {\n const fullPath = PATH.resolve(cwd, relPath)\n try {\n const content = readFileSync(fullPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n // Only check dependencies and peerDependencies — devDependencies on react\n // can appear in tooling packages (eslint configs, test utilities) that don't\n // indicate the repo actually uses React\n const deps = pkg.dependencies as Record<string, string> | undefined\n const peerDeps = pkg.peerDependencies as Record<string, string> | undefined\n if (deps?.react || peerDeps?.react) {\n if (verbose) console.log(chalk.gray(` React detected in ${relPath}`))\n return true\n }\n } catch {\n // skip unreadable package.json\n }\n }\n return false\n}\n\nfunction findExistingConfig(configPath: string, legacyConfigPath: string): string | undefined {\n if (existsSync(configPath)) return configPath\n if (existsSync(legacyConfigPath)) return legacyConfigPath\n return undefined\n}\n\nfunction removeLegacyConfig(legacyConfigPath: string): void {\n if (existsSync(legacyConfigPath)) {\n unlinkSync(legacyConfigPath)\n console.log(chalk.gray('Removed legacy eslint.config.mjs'))\n }\n}\n\nfunction updateDependencies(packageJsonPath: string, react: boolean, cwd: string, verbose?: boolean): void {\n if (!existsSync(packageJsonPath)) {\n console.log(chalk.yellow('No package.json found — skipping dependency updates'))\n return\n }\n const changed = addDevDependencies(packageJsonPath, getRequiredDevDependencies(react), verbose)\n if (changed) {\n runInstall(cwd)\n }\n}\n\nexport async function lintInit({ verbose }: LintInitParams = {}): Promise<number> {\n const cwd = INIT_CWD()\n const configPath = PATH.resolve(cwd, 'eslint.config.ts')\n const legacyConfigPath = PATH.resolve(cwd, 'eslint.config.mjs')\n\n const existingPath = findExistingConfig(configPath, legacyConfigPath)\n if (existingPath) {\n const filename = PATH.basename(existingPath)\n const confirmed = await askConfirmation(\n chalk.yellow(`${filename} already exists. Replace it with eslint.config.ts? (y/N) `),\n )\n if (!confirmed) {\n console.log(chalk.gray(`Skipped — existing ${filename} preserved`))\n return 0\n }\n }\n\n const react = detectReactInMonorepo(cwd, verbose)\n if (react) {\n console.log(chalk.cyan('Detected React packages — using @xylabs/eslint-config-react-flat'))\n } else if (verbose) {\n console.log(chalk.gray(' No React packages detected — using @xylabs/eslint-config-flat'))\n }\n\n const useXyLabsBarrel = await askConfirmation(\n chalk.cyan('Disallow @xylabs/sdk-js barrel imports? (y/N) '),\n )\n const useXyoBarrel = await askConfirmation(\n chalk.cyan('Disallow @xyo-network/sdk-js barrel imports? (y/N) '),\n )\n\n const config = generateEslintConfig({\n react, useXyLabsBarrel, useXyoBarrel,\n })\n writeFileSync(configPath, config, 'utf8')\n console.log(chalk.green('Generated eslint.config.ts'))\n\n removeLegacyConfig(legacyConfigPath)\n updateDependencies(PATH.resolve(cwd, 'package.json'), react, cwd, verbose)\n\n return 0\n}\n","import { spawnSync } from 'node:child_process'\nimport {\n existsSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport { findUp } from 'find-up'\n\nimport { runInstall } from '../lib/index.ts'\nimport { detectReactInMonorepo } from './lint-init.ts'\n\ninterface RuleEntry {\n level: string\n options?: unknown[]\n}\n\ninterface LintlintParams {\n fix?: boolean\n verbose?: boolean\n}\n\ninterface ConfigBlock {\n rules?: Record<string, unknown>\n}\n\ninterface RuleComparison {\n additions: { local: RuleEntry; rule: string }[]\n overrides: { local: RuleEntry; rule: string; shared: RuleEntry }[]\n redundant: { local: RuleEntry; rule: string; shared: RuleEntry }[]\n}\n\nfunction parseRuleValue(value: unknown): RuleEntry | undefined {\n if (typeof value === 'string') {\n return { level: value }\n }\n if (typeof value === 'number') {\n return { level: String(value) }\n }\n if (Array.isArray(value) && value.length > 0) {\n return {\n level: String(value[0]),\n options: value.length > 1 ? value.slice(1) : undefined,\n }\n }\n return undefined\n}\n\nfunction normalizeLevel(level: string): string {\n if (level === '0' || level === 'off') return 'off'\n if (level === '1' || level === 'warn') return 'warn'\n if (level === '2' || level === 'error') return 'error'\n return level\n}\n\nfunction rulesMatch(a: RuleEntry, b: RuleEntry): boolean {\n if (normalizeLevel(a.level) !== normalizeLevel(b.level)) return false\n return JSON.stringify(a.options) === JSON.stringify(b.options)\n}\n\nfunction formatRule(entry: RuleEntry): string {\n if (entry.options) {\n return JSON.stringify([entry.level, ...entry.options])\n }\n return JSON.stringify([entry.level])\n}\n\nfunction mergeRulesFromBlocks(blocks: ConfigBlock[]): Map<string, RuleEntry> {\n const merged = new Map<string, RuleEntry>()\n for (const block of blocks) {\n if (!block.rules) continue\n for (const [name, value] of Object.entries(block.rules)) {\n const parsed = parseRuleValue(value)\n if (parsed) merged.set(name, parsed)\n }\n }\n return merged\n}\n\nfunction detectSharedPackage(source: string): string | undefined {\n if (source.includes('@xylabs/eslint-config-react-flat')) return '@xylabs/eslint-config-react-flat'\n if (source.includes('@xylabs/eslint-config-flat')) return '@xylabs/eslint-config-flat'\n return undefined\n}\n\nfunction extractLocalRuleBlocks(source: string): string[] {\n const blocks: string[] = []\n const ruleBlockRegex = /\\{\\s*(?:files\\s*:\\s*\\[.*?\\]\\s*,\\s*)?rules\\s*:\\s*\\{([^}]*(?:\\{[^}]*\\}[^}]*)*)\\}/g\n let match\n while ((match = ruleBlockRegex.exec(source)) !== null) {\n blocks.push(match[1])\n }\n return blocks\n}\n\nfunction extractRulesFromSourceBlocks(blocks: string[]): Map<string, string> {\n const rules = new Map<string, string>()\n for (const block of blocks) {\n const ruleRegex = /['\"]([^'\"]+)['\"]\\s*:\\s*(\\[[\\s\\S]*?\\](?=\\s*,|\\s*$))/gm\n let match\n while ((match = ruleRegex.exec(block)) !== null) {\n rules.set(match[1], match[2])\n }\n }\n return rules\n}\n\nfunction extractConfigBlocks(sharedModule: Record<string, unknown>): ConfigBlock[] {\n const config = sharedModule.config ?? sharedModule.default\n if (Array.isArray(config)) return config as ConfigBlock[]\n return []\n}\n\nasync function resolveSharedConfig(configDir: string, sharedPkg: string): Promise<ConfigBlock[]> {\n try {\n const sharedModule = await import(sharedPkg) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n } catch {\n const distPath = PATH.resolve(configDir, 'node_modules', sharedPkg, 'dist', 'node', 'index.mjs')\n try {\n const sharedModule = await import(distPath) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n } catch {\n const neutralPath = PATH.resolve(configDir, 'node_modules', sharedPkg, 'dist', 'neutral', 'index.mjs')\n const sharedModule = await import(neutralPath) as Record<string, unknown>\n return extractConfigBlocks(sharedModule)\n }\n return []\n }\n}\n\nasync function loadSharedRules(configDir: string, sharedPkg: string, verbose: boolean): Promise<Map<string, RuleEntry> | undefined> {\n const sharedBlocks = await resolveSharedConfig(configDir, sharedPkg)\n const sharedRules = mergeRulesFromBlocks(sharedBlocks)\n\n if (verbose) {\n console.log(chalk.gray(`Shared config defines ${sharedRules.size} rules`))\n }\n\n if (sharedRules.size === 0) {\n console.error(chalk.red('Could not load rules from shared config. Is it installed and built?'))\n return undefined\n }\n\n return sharedRules\n}\n\nasync function loadLocalRules(eslintConfigPath: string, source: string, verbose: boolean): Promise<{ explicit: Map<string, string>; resolved: Map<string, RuleEntry> }> {\n const localModule = await import(eslintConfigPath) as Record<string, unknown>\n const localConfig = localModule.default ?? localModule\n const localBlocks: ConfigBlock[] = Array.isArray(localConfig) ? localConfig as ConfigBlock[] : [localConfig as ConfigBlock]\n const resolved = mergeRulesFromBlocks(localBlocks)\n\n const localRuleBlocks = extractLocalRuleBlocks(source)\n const explicit = extractRulesFromSourceBlocks(localRuleBlocks)\n\n if (verbose) {\n console.log(chalk.gray(`Local config has ${explicit.size} explicit rule setting(s)`))\n }\n\n return { explicit, resolved }\n}\n\nfunction compareRules(\n explicitRuleNames: Map<string, string>,\n allResolvedRules: Map<string, RuleEntry>,\n sharedRules: Map<string, RuleEntry>,\n): RuleComparison {\n const redundant: RuleComparison['redundant'] = []\n const overrides: RuleComparison['overrides'] = []\n const additions: RuleComparison['additions'] = []\n\n for (const ruleName of explicitRuleNames.keys()) {\n const resolvedEntry = allResolvedRules.get(ruleName)\n const sharedEntry = sharedRules.get(ruleName)\n\n if (!resolvedEntry) continue\n\n if (!sharedEntry) {\n additions.push({ local: resolvedEntry, rule: ruleName })\n } else if (rulesMatch(resolvedEntry, sharedEntry)) {\n redundant.push({\n local: resolvedEntry, rule: ruleName, shared: sharedEntry,\n })\n } else {\n overrides.push({\n local: resolvedEntry, rule: ruleName, shared: sharedEntry,\n })\n }\n }\n\n return {\n additions,\n overrides,\n redundant,\n }\n}\n\nfunction reportResults({\n additions, overrides, redundant,\n}: RuleComparison, verbose: boolean): void {\n if (redundant.length > 0) {\n console.log(chalk.yellow(`\\n${redundant.length} redundant rule(s) (same as shared config — can be removed):`))\n for (const { rule, local } of redundant) {\n console.log(chalk.yellow(` ${rule}: ${formatRule(local)}`))\n }\n }\n\n if (overrides.length > 0) {\n console.log(chalk.cyan(`\\n${overrides.length} rule override(s) (different from shared config):`))\n for (const {\n rule, local, shared,\n } of overrides) {\n console.log(chalk.cyan(` ${rule}:`))\n console.log(chalk.gray(` shared: ${formatRule(shared)}`))\n console.log(chalk.white(` local: ${formatRule(local)}`))\n }\n }\n\n if (additions.length > 0 && verbose) {\n console.log(chalk.gray(`\\n${additions.length} local addition(s) (not in shared config):`))\n for (const { rule, local } of additions) {\n console.log(chalk.gray(` ${rule}: ${formatRule(local)}`))\n }\n }\n\n if (redundant.length === 0 && overrides.length === 0) {\n console.log(chalk.green('No redundant or overridden rules found'))\n }\n}\n\nfunction fixRedundantRules(eslintConfigPath: string, redundant: RuleComparison['redundant']): void {\n let updated = readFileSync(eslintConfigPath, 'utf8')\n const original = updated\n for (const { rule } of redundant) {\n const escaped = rule.replaceAll('/', String.raw`\\/`)\n const pattern = new RegExp(String.raw`[ \\t]*['\"]${escaped}['\"]\\s*:\\s*\\[[^\\]]*\\],?[ \\t]*\\n?`, 'g')\n updated = updated.replace(pattern, '')\n }\n // Clean up empty rule blocks left behind\n updated = updated.replaceAll(/\\{\\s*rules\\s*:\\s*\\{\\s*\\}\\s*,?\\s*\\}\\s*,?/g, '')\n updated = updated.replaceAll(/\\n{3,}/g, '\\n\\n')\n\n if (updated !== original) {\n writeFileSync(eslintConfigPath, updated, 'utf8')\n console.log(chalk.green(`\\nFixed: removed ${redundant.length} redundant rule(s)`))\n }\n}\n\nfunction formatConfigFile(eslintConfigPath: string): void {\n spawnSync('eslint', ['--fix', eslintConfigPath], { stdio: 'inherit' })\n}\n\nfunction fixConfigMismatch(\n eslintConfigPath: string,\n configDir: string,\n source: string,\n sharedPkg: string,\n expectedPkg: string,\n): void {\n const updated = source.replaceAll(sharedPkg, expectedPkg)\n writeFileSync(eslintConfigPath, updated, 'utf8')\n console.log(chalk.green(`Fixed: replaced ${sharedPkg} with ${expectedPkg}`))\n\n const packageJsonPath = PATH.resolve(configDir, 'package.json')\n if (!existsSync(packageJsonPath)) return\n\n const content = readFileSync(packageJsonPath, 'utf8')\n const pkg = JSON.parse(content) as Record<string, unknown>\n const devDeps = (pkg.devDependencies ?? {}) as Record<string, string>\n const oldVersion = devDeps[sharedPkg]\n if (!oldVersion) return\n\n delete devDeps[sharedPkg]\n devDeps[expectedPkg] = oldVersion\n const sorted = Object.fromEntries(Object.entries(devDeps).toSorted(([a], [b]) => a.localeCompare(b)))\n pkg.devDependencies = sorted\n writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(`Updated package.json: ${sharedPkg} → ${expectedPkg}`))\n runInstall(configDir)\n}\n\nfunction checkConfigVariant(\n eslintConfigPath: string,\n configDir: string,\n source: string,\n sharedPkg: string,\n fix: boolean,\n verbose: boolean,\n): boolean {\n const hasReact = detectReactInMonorepo(configDir, verbose)\n const expectedPkg = hasReact ? '@xylabs/eslint-config-react-flat' : '@xylabs/eslint-config-flat'\n\n if (sharedPkg === expectedPkg) return false\n\n console.log(chalk.yellow(`\\nConfig mismatch: using ${sharedPkg} but ${hasReact ? 'React packages detected' : 'no React packages found'}`))\n console.log(chalk.yellow(` Expected: ${expectedPkg}`))\n\n if (fix) {\n fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expectedPkg)\n }\n\n return true\n}\n\nexport async function lintlint({ fix, verbose }: LintlintParams = {}): Promise<number> {\n const eslintConfigPath = await findUp(['eslint.config.ts', 'eslint.config.mjs'])\n if (!eslintConfigPath) {\n console.error(chalk.red('No eslint.config.ts found'))\n return 1\n }\n\n const configDir = PATH.dirname(eslintConfigPath)\n\n if (verbose) {\n console.log(chalk.gray(`Found config: ${eslintConfigPath}`))\n }\n\n const source = readFileSync(eslintConfigPath, 'utf8')\n const sharedPkg = detectSharedPackage(source)\n\n if (!sharedPkg) {\n console.log(chalk.yellow('No @xylabs/eslint-config-flat or @xylabs/eslint-config-react-flat imports found'))\n return 0\n }\n\n if (verbose) {\n console.log(chalk.gray(`Shared package: ${sharedPkg}`))\n }\n\n const hasMismatch = checkConfigVariant(eslintConfigPath, configDir, source, sharedPkg, !!fix, !!verbose)\n\n // Re-read source after potential mismatch fix to avoid overwriting changes\n const currentSource = (hasMismatch && fix) ? readFileSync(eslintConfigPath, 'utf8') : source\n\n const sharedRules = await loadSharedRules(configDir, sharedPkg, !!verbose)\n if (!sharedRules) return 1\n\n const { explicit, resolved } = await loadLocalRules(eslintConfigPath, currentSource, !!verbose)\n const results = compareRules(explicit, resolved, sharedRules)\n\n reportResults(results, !!verbose)\n\n if (results.redundant.length > 0 && fix) {\n fixRedundantRules(eslintConfigPath, results.redundant)\n }\n\n const didFix = fix && (hasMismatch || results.redundant.length > 0)\n if (didFix) {\n formatConfigFile(eslintConfigPath)\n }\n\n const hasUnfixedMismatch = hasMismatch && !fix\n const hasUnfixedRedundant = results.redundant.length > 0 && !fix\n return hasUnfixedMismatch || hasUnfixedRedundant ? 1 : 0\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 {\n existsSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\nimport picomatch from 'picomatch'\nimport semver from 'semver'\n\nimport {\n INIT_CWD, latestVersions, runInstall,\n} from '../lib/index.ts'\nimport { detectPackageManager, getPackageManager } from '../pm/index.ts'\nimport {\n checkInternalDepVersions,\n checkInternalPeerVersions,\n checkVersionConsistency,\n checkWorkspaceProtocol,\n fixInternalDepVersions,\n fixInternalPeerVersions,\n fixVersionConsistency,\n fixWorkspaceProtocol,\n} from './package-lint-deps.ts'\n\nexport interface LintResult {\n errors: string[]\n fixable: string[]\n warnings: string[]\n}\n\nfunction emptyResult(): LintResult {\n return {\n errors: [], fixable: [], warnings: [],\n }\n}\n\nfunction readRootPackageJson(cwd: string): Record<string, unknown> {\n const raw = readFileSync(PATH.resolve(cwd, 'package.json'), 'utf8')\n return JSON.parse(raw) as Record<string, unknown>\n}\n\nfunction writeRootPackageJson(cwd: string, pkg: Record<string, unknown>) {\n const path = PATH.resolve(cwd, 'package.json')\n writeFileSync(path, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n}\n\nfunction readPnpmWorkspaceGlobs(cwd: string): string[] | undefined {\n const wsPath = PATH.resolve(cwd, 'pnpm-workspace.yaml')\n if (!existsSync(wsPath)) return undefined\n const raw = readFileSync(wsPath, 'utf8')\n const globs: string[] = []\n let inPackages = false\n for (const line of raw.split('\\n')) {\n if (/^packages\\s*:/.test(line)) {\n inPackages = true\n continue\n }\n if (inPackages) {\n const match = /^\\s+-\\s+['\"]?([^'\"]+)['\"]?\\s*$/.exec(line)\n if (match) {\n globs.push(match[1])\n } else if (/^\\S/.test(line) && line.trim() !== '') {\n break\n }\n }\n }\n return globs.length > 0 ? globs : undefined\n}\n\nfunction isMonorepo(pkg: Record<string, unknown>, cwd: string): boolean {\n const workspaces = pkg.workspaces\n if (Array.isArray(workspaces) && workspaces.length > 0) return true\n return readPnpmWorkspaceGlobs(cwd) !== undefined\n}\n\nfunction checkPackagesFolder(workspaces: { location: string; name: string }[]): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!location.startsWith('packages/') && !location.startsWith('packages\\\\')) {\n result.errors.push(`${name} (${location}) is not inside a packages/ folder`)\n }\n }\n\n return result\n}\n\nfunction checkRootPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (!pkg.private) {\n result.fixable.push('Root package.json must be private to prevent accidental publishing')\n }\n\n return result\n}\n\nfunction fixRootPrivate(cwd: string, pkg: Record<string, unknown>) {\n pkg.private = true\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: set \"private\": true in root package.json'))\n}\n\nfunction checkNoPublishConfigOnPrivate(pkg: Record<string, unknown>): LintResult {\n const result = emptyResult()\n\n if (pkg.private && pkg.publishConfig) {\n result.fixable.push('Root package.json has publishConfig but is private — publishConfig is unnecessary')\n }\n\n return result\n}\n\nfunction fixNoPublishConfigOnPrivate(cwd: string, pkg: Record<string, unknown>) {\n delete pkg.publishConfig\n writeRootPackageJson(cwd, pkg)\n console.log(chalk.green(' ✔ Fixed: removed publishConfig from private root package.json'))\n}\n\nfunction checkNoPackageManagerInWorkspaces(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.packageManager) {\n result.fixable.push(`${name} (${location}) has a packageManager field — only the root should define this`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixNoPackageManagerInWorkspaces(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.packageManager) {\n delete pkg.packageManager\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed packageManager from ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction checkWorkspacesFieldPlacement(\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n // For pnpm: no package should have workspaces (including root)\n // For yarn: only root should have workspaces\n if (pm === 'pnpm' ? true : location !== '.') {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.workspaces) {\n const label = location === '.' ? 'Root' : `${name} (${location})`\n const reason = pm === 'pnpm'\n ? 'pnpm uses pnpm-workspace.yaml instead'\n : 'only the root should define workspaces'\n result.fixable.push(`${label} has a workspaces field — ${reason}`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n }\n\n return result\n}\n\nfunction fixWorkspacesFieldPlacement(\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): void {\n for (const { location } of workspaces) {\n if (pm === 'pnpm' ? true : location !== '.') {\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.workspaces) {\n delete pkg.workspaces\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n const label = location === '.' ? 'root' : location\n console.log(chalk.green(` ✔ Fixed: removed workspaces from ${label}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n }\n}\n\nfunction checkWorkspaceGlobCoverage(\n pkg: Record<string, unknown>,\n cwd: string,\n pm: 'pnpm' | 'yarn',\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n const globs = pm === 'pnpm'\n ? readPnpmWorkspaceGlobs(cwd) ?? []\n : (Array.isArray(pkg.workspaces) ? pkg.workspaces as string[] : [])\n\n if (globs.length === 0) {\n const source = pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'root package.json workspaces'\n result.errors.push(`No workspace globs found in ${source}`)\n return result\n }\n\n const matchers = globs.map(glob => picomatch(glob))\n const isMatch = (location: string) => matchers.some(m => m(location))\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n if (!isMatch(location)) {\n const source = pm === 'pnpm' ? 'pnpm-workspace.yaml' : 'root package.json workspaces'\n result.errors.push(`${name} (${location}) is not matched by any glob in ${source}`)\n }\n }\n\n return result\n}\n\nfunction logResults(label: string, result: LintResult, fix: boolean): { errors: number; fixed: number } {\n let errors = 0\n let fixed = 0\n\n for (const error of result.errors) {\n console.log(chalk.red(` ✗ ${error}`))\n errors++\n }\n for (const fixable of result.fixable) {\n if (fix) {\n fixed++\n } else {\n console.log(chalk.red(` ✗ ${fixable} (fixable)`))\n errors++\n }\n }\n for (const warning of result.warnings) {\n console.log(chalk.yellow(` ⚠ ${warning}`))\n }\n if (errors === 0 && fixed === 0 && result.warnings.length === 0) {\n console.log(chalk.green(` ✓ ${label}`))\n }\n\n return { errors, fixed }\n}\n\ninterface CheckEntry {\n check: () => LintResult\n fix?: (cwd: string, pkg: Record<string, unknown>) => void\n label: string\n}\n\nfunction runChecks(entries: CheckEntry[], cwd: string, pkg: Record<string, unknown>, fix: boolean): { errors: number; fixed: number } {\n let totalErrors = 0\n let totalFixed = 0\n\n for (const entry of entries) {\n const result = entry.check()\n const log = logResults(entry.label, result, fix)\n if (fix && entry.fix && result.fixable.length > 0) {\n entry.fix(cwd, pkg)\n }\n totalErrors += log.errors\n totalFixed += log.fixed\n }\n\n return { errors: totalErrors, fixed: totalFixed }\n}\n\nfunction checkVoltaOnlyInRoot(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (pkg.volta) {\n result.fixable.push(`${name} (${location}) has a volta field — only the root should define this`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixVoltaOnlyInRoot(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (pkg.volta) {\n delete pkg.volta\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed volta from ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction isTerminalPackage(pkg: Record<string, unknown>): boolean {\n return pkg.private === true\n}\n\nfunction checkEnginesOnlyInNonTerminal(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n // Check root (always terminal/private) — should not have engines\n const rootPkg = JSON.parse(readFileSync(PATH.resolve(cwd, 'package.json'), 'utf8')) as Record<string, unknown>\n if (rootPkg.engines) {\n result.fixable.push('Root package.json has engines — terminal packages should not declare engines (use volta instead)')\n }\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n if (isTerminalPackage(pkg) && pkg.engines) {\n result.fixable.push(`${name} (${location}) is terminal (private) but has engines — terminal packages should not declare engines`)\n }\n if (!isTerminalPackage(pkg) && !pkg.engines) {\n result.fixable.push(`${name} (${location}) is a library but has no engines field`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction fixEnginesOnlyInNonTerminal(cwd: string, _pkg: Record<string, unknown>, workspaces: { location: string; name: string }[]) {\n // Remove engines from root\n const rootPath = PATH.resolve(cwd, 'package.json')\n const rootRaw = readFileSync(rootPath, 'utf8')\n const rootPkg = JSON.parse(rootRaw) as Record<string, unknown>\n if (rootPkg.engines) {\n delete rootPkg.engines\n writeFileSync(rootPath, `${JSON.stringify(rootPkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(' ✔ Fixed: removed engines from root package.json'))\n }\n\n // Remove engines from terminal workspace packages, add engines to libraries missing them\n const enginesTemplate = resolveEnginesTemplate(cwd, workspaces)\n for (const { location } of workspaces) {\n if (location === '.') continue\n const pkgPath = PATH.resolve(cwd, location, 'package.json')\n try {\n const raw = readFileSync(pkgPath, 'utf8')\n const pkg = JSON.parse(raw) as Record<string, unknown>\n if (isTerminalPackage(pkg) && pkg.engines) {\n delete pkg.engines\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: removed engines from ${location}/package.json`))\n }\n if (!isTerminalPackage(pkg) && !pkg.engines && enginesTemplate) {\n pkg.engines = enginesTemplate\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`, 'utf8')\n console.log(chalk.green(` ✔ Fixed: added engines to ${location}/package.json`))\n }\n } catch {\n // skip unreadable packages\n }\n }\n}\n\nfunction resolveEnginesTemplate(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): Record<string, string> | undefined {\n // Use engines from the first sibling library package that has one\n for (const { location } of workspaces) {\n if (location === '.') continue\n try {\n const pkg = JSON.parse(readFileSync(PATH.resolve(cwd, location, 'package.json'), 'utf8')) as Record<string, unknown>\n if (!isTerminalPackage(pkg) && pkg.engines) {\n return pkg.engines as Record<string, string>\n }\n } catch {\n // skip\n }\n }\n return undefined\n}\n\nfunction checkVersionsIncludeLts(\n cwd: string,\n workspaces: { location: string; name: string }[],\n): LintResult {\n const result = emptyResult()\n\n const toolVersions: Record<string, string> = {\n node: latestVersions.node,\n npm: latestVersions.npm,\n pnpm: latestVersions.pnpm,\n yarn: latestVersions.yarn,\n }\n\n // Check engines in all non-terminal packages\n for (const { location, name } of workspaces) {\n const pkgPath = location === '.'\n ? PATH.resolve(cwd, 'package.json')\n : PATH.resolve(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n const label = location === '.' ? 'root' : `${name} (${location})`\n\n // Check engines ranges\n const engines = pkg.engines as Record<string, string> | undefined\n if (engines) {\n for (const [tool, range] of Object.entries(engines)) {\n const latest = toolVersions[tool]\n if (latest && !semver.satisfies(latest, range)) {\n result.errors.push(\n `${label} engines.${tool} \"${range}\" does not include latest ${tool === 'node' ? 'LTS ' : ''}version ${latest}`,\n )\n }\n }\n }\n\n // Check volta pins\n const volta = pkg.volta as Record<string, string> | undefined\n if (volta) {\n for (const [tool, pinnedVersion] of Object.entries(volta)) {\n const latest = toolVersions[tool]\n if (latest && semver.lt(pinnedVersion, latest)) {\n result.warnings.push(\n `${label} volta.${tool} \"${pinnedVersion}\" is older than latest ${tool === 'node' ? 'LTS ' : ''}version ${latest}`,\n )\n }\n }\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nfunction logSummary(errors: number, fixed: number) {\n if (fixed > 0) {\n console.log(chalk.green(`\\n Fixed ${fixed} issue(s)`))\n }\n if (errors > 0) {\n console.log(chalk.red(`\\n ${errors} error(s) found`))\n } else if (fixed === 0) {\n console.log(chalk.green('\\n All checks passed'))\n }\n}\n\nexport function packageLintMonorepo(fix = false): number {\n const cwd = INIT_CWD()\n\n let pkg: Record<string, unknown>\n try {\n pkg = readRootPackageJson(cwd)\n } catch {\n console.error(chalk.red('Could not read package.json'))\n return 1\n }\n\n if (!isMonorepo(pkg, cwd)) {\n console.log(chalk.gray('Not a monorepo — skipping repo lint checks'))\n return 0\n }\n\n console.log(chalk.green('Repo Lint'))\n\n const pm = detectPackageManager()\n const workspaces = getPackageManager().listWorkspaces()\n\n const internalDepCheck: CheckEntry = pm === 'pnpm'\n ? {\n check: () => checkWorkspaceProtocol(cwd, workspaces),\n fix: () => fixWorkspaceProtocol(cwd, workspaces),\n label: 'Internal deps/devDeps use workspace: protocol',\n }\n : {\n check: () => checkInternalDepVersions(cwd, workspaces),\n fix: () => fixInternalDepVersions(cwd, workspaces),\n label: 'Internal deps/devDeps use correct version ranges',\n }\n\n const checks: CheckEntry[] = [\n {\n check: () => checkRootPrivate(pkg), fix: fixRootPrivate, label: 'Root package is private',\n },\n {\n check: () => checkNoPublishConfigOnPrivate(pkg), fix: fixNoPublishConfigOnPrivate, label: 'No publishConfig on private root',\n },\n { check: () => checkPackagesFolder(workspaces), label: 'All packages are in packages/ folder' },\n {\n check: () => checkWorkspacesFieldPlacement(cwd, pm, workspaces),\n fix: () => fixWorkspacesFieldPlacement(cwd, pm, workspaces),\n label: pm === 'pnpm' ? 'No workspaces field in package.json (use pnpm-workspace.yaml)' : 'Workspaces field only in root package.json',\n },\n {\n check: () => checkWorkspaceGlobCoverage(pkg, cwd, pm, workspaces),\n label: 'Workspace globs cover all packages',\n },\n {\n check: () => checkNoPackageManagerInWorkspaces(cwd, workspaces),\n fix: () => fixNoPackageManagerInWorkspaces(cwd, pkg, workspaces),\n label: 'No packageManager in workspace packages',\n },\n {\n check: () => checkVoltaOnlyInRoot(cwd, workspaces),\n fix: () => fixVoltaOnlyInRoot(cwd, pkg, workspaces),\n label: 'Volta only in root package.json',\n },\n {\n check: () => checkEnginesOnlyInNonTerminal(cwd, workspaces),\n fix: () => fixEnginesOnlyInNonTerminal(cwd, pkg, workspaces),\n label: 'Engines only in non-terminal (library) packages',\n },\n {\n check: () => checkVersionsIncludeLts(cwd, workspaces),\n label: 'Engine/volta versions include latest LTS',\n },\n {\n check: () => checkVersionConsistency(cwd, pkg, workspaces),\n fix: () => fixVersionConsistency(cwd, pkg, writeRootPackageJson, workspaces),\n label: 'Consistent versions across packages',\n },\n internalDepCheck,\n {\n check: () => checkInternalPeerVersions(cwd, workspaces),\n fix: () => fixInternalPeerVersions(cwd, workspaces),\n label: 'Internal peerDeps use semver ranges (not workspace: protocol)',\n },\n ]\n\n const { errors, fixed } = runChecks(checks, cwd, pkg, fix)\n logSummary(errors, fixed)\n\n if (fix && fixed > 0) {\n runInstall()\n }\n\n return errors > 0 ? 1 : 0\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","import { existsSync, readFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\n\nimport { INIT_CWD, resolveTemplatePath } from '../lib/index.ts'\nimport { getPackageManager } from '../pm/index.ts'\nimport type { XyConfig } from './package/index.ts'\n\ninterface ReadmeLintResult {\n errors: string[]\n warnings: string[]\n}\n\nfunction lintTemplate(cwd: string): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const templatePath = resolveTemplatePath()\n\n if (!existsSync(templatePath)) {\n result.errors.push('Missing .xy/README.template.md (run \"xy readme init\" to create)')\n return result\n }\n\n const template = readFileSync(templatePath, 'utf8')\n\n if (!template.includes('{{body}}')) {\n result.warnings.push('.xy/README.template.md does not contain a {{body}} placeholder')\n }\n if (!template.includes('{{description}}')) {\n result.warnings.push('.xy/README.template.md does not contain a {{description}} placeholder')\n }\n\n const bodyPath = PATH.join(cwd, '.xy', 'README.body.md')\n if (!existsSync(bodyPath)) {\n result.errors.push('Missing .xy/README.body.md (run \"xy readme init\" to create)')\n }\n\n return result\n}\n\nfunction lintLogoConfig(cwd: string, config: XyConfig): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const templatePath = resolveTemplatePath()\n\n if (existsSync(templatePath)) {\n const template = readFileSync(templatePath, 'utf8')\n const logoRef = /\\[logo]: (.+)/.exec(template)\n if (logoRef?.[1].includes('example.com')) {\n result.warnings.push('.xy/README.template.md still has the example.com logo placeholder — update it or set readme.logoUrl in xy.config.ts')\n } else if (!logoRef && !config.readme?.logoUrl) {\n result.warnings.push('No logo URL configured in xy.config.ts (readme.logoUrl) or template')\n }\n }\n\n if (!config.readme?.logoUrl && !config.readme?.logoLinkUrl) {\n result.warnings.push('No readme.logoUrl or readme.logoLinkUrl configured in xy.config.ts')\n }\n\n return result\n}\n\nfunction lintPackages(cwd: string): ReadmeLintResult {\n const result: ReadmeLintResult = { errors: [], warnings: [] }\n const pm = getPackageManager()\n const workspaces = pm.listWorkspaces()\n\n for (const { location, name } of workspaces) {\n if (location === '.') continue\n\n const pkgPath = PATH.join(cwd, location, 'package.json')\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as Record<string, unknown>\n\n if (pkg.private) continue\n\n if (!pkg.description) {\n result.warnings.push(`${name} is missing a \"description\" in package.json`)\n }\n\n const readmePath = PATH.join(cwd, location, 'README.md')\n if (!existsSync(readmePath)) {\n result.errors.push(`${name} is missing README.md`)\n }\n } catch {\n // skip unreadable packages\n }\n }\n\n return result\n}\n\nexport interface ReadmeLintParams {\n config: XyConfig\n verbose?: boolean\n}\n\nexport function readmeLint({ config, verbose }: ReadmeLintParams): number {\n const cwd = INIT_CWD()\n console.log(chalk.green('Readme Lint'))\n\n const checks = [\n lintTemplate(cwd),\n lintLogoConfig(cwd, config),\n lintPackages(cwd),\n ]\n\n let errorCount = 0\n let warningCount = 0\n\n for (const { errors, warnings } of checks) {\n for (const error of errors) {\n console.log(chalk.red(` ✗ ${error}`))\n errorCount++\n }\n for (const warning of warnings) {\n console.log(chalk.yellow(` ⚠ ${warning}`))\n warningCount++\n }\n }\n\n if (errorCount === 0 && warningCount === 0) {\n console.log(chalk.green(' All checks passed'))\n } else {\n if (verbose) {\n console.log(chalk.gray(` ${errorCount} error(s), ${warningCount} warning(s)`))\n }\n }\n\n return errorCount > 0 ? 1 : 0\n}\n"],"mappings":";AAAA,OAAOA,aAAW;;;ACAlB,SAAS,yBAAyB;AAE3B,IAAM,gBAAgB,IAAI,kBAA4B;AAE7D,IAAI,mBAAmB;AAEhB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U,CAAC,CAAC,KAAK;AACvB,UAAM,MAAM,CAAC,CAAC,KAAK;AACnB,UAAM,OAAO,KAAK;AAClB,QAAI,SAAS;AAEb,QAAI,QAAS,SAAQ,IAAI,OAAO;AAEhC,YAAQ,IAAIC,QAAM,KAAK,yBAAe,CAAC;AACvC,cAAU,MAAM,WAAW,IAAI,QAAQ;AAEvC,YAAQ,IAAIA,QAAM,KAAK,yBAAe,CAAC;AACvC,cAAU,MAAM,QAAQ;AAAA,MACtB;AAAA,MAAK;AAAA,MAAM;AAAA,IACb,CAAC;AAED,YAAQ,IAAIA,QAAM,KAAK,2BAAiB,CAAC;AACzC,cAAU,oBAAoB,GAAG;AAEjC,YAAQ,IAAIA,QAAM,KAAK,0BAAgB,CAAC;AACxC,cAAU,MAAM,SAAS,EAAE,KAAK,QAAQ,CAAC;AAEzC,YAAQ,IAAIA,QAAM,KAAK,6BAAmB,CAAC;AAC3C,UAAMC,UAAS,MAAM,WAAqB;AAC1C,cAAU,WAAW,EAAE,QAAAA,SAAQ,QAAQ,CAAC;AAExC,QAAI,SAAS,GAAG;AACd,cAAQ,IAAID,QAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC;AAAA,IACnD,OAAO;AACL,cAAQ,IAAIA,QAAM,MAAM,mBAAmB,CAAC;AAAA,IAC9C;AACA,YAAQ,WAAW,SAAS,IAAI,IAAI;AAAA,EACtC;AACF;","names":["chalk","require","chalk","chalk","chalk","readFileSync","PATH","chalk","PATH","readFileSync","writeRootPackageJson","chalk","expected","chalk","chalk","ParseGitConfig","existsSync","readFileSync","writeFileSync","PATH","createInterface","chalk","PATH","readFileSync","chalk","spawnSync","existsSync","readFileSync","writeFileSync","PATH","chalk","config","PATH","chalk","readFileSync","writeFileSync","spawnSync","existsSync","chalk","chalk","publint","existsSync","readFileSync","writeFileSync","PATH","chalk","semver","readFileSync","PATH","path","writeFileSync","existsSync","chalk","glob","semver","chalk","chalk","chalk","existsSync","readFileSync","PATH","chalk","existsSync","readFileSync","PATH","config","chalk","chalk","config"]}