@bemoje/monorepo 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +2 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/package.json +4 -2
package/lib/index.cjs
CHANGED
|
@@ -824,3 +824,5 @@ exports.readWorkspace = readWorkspace;
|
|
|
824
824
|
exports.resolveModuleImportPath = resolveModuleImportPath;
|
|
825
825
|
exports.semverVersionBump = semverVersionBump;
|
|
826
826
|
exports.summarizeDependencies = summarizeDependencies;
|
|
827
|
+
//# sourceMappingURL=index.cjs.map
|
|
828
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/SemanticExtnamePrefix.ts","../../src/deps/getDependencyName.ts","../../src/util/getRepoRootDirpath.ts","../../src/workspace/readWorkspace.ts","../../src/workspace/getWorkspaces.ts","../../src/deps/createDependencyGraph.ts","../../src/deps/getExternalDependencyVersions.ts","../../src/deps/getReachableModules.ts","../../src/deps/summarizeDependencies.ts","../../src/deps/getImportsRecursively.ts","../../src/deps/getWorkspaceModules.ts","../../src/util/SemanticExtnamePrefixes.ts","../../src/util/hasExtnamePrefix.ts","../../src/util/isTestFile.ts","../../src/deps/getWorkspaceDependencies.ts","../../src/util/getTsconfigPaths.ts","../../src/deps/getWorkspaceDependencyProblems.ts","../../../tscode/src/importStatementToOneLiner.ts","../../../tscode/src/importStatementToFormattedOneLiner.ts","../../../regex/src/rexec.ts","../../../tscode/src/parseImportStatement.ts","../../../tscode/src/tsCrlfToLf.ts","../../../tscode/src/tsExtractImports.ts","../../src/imports/getFileImports.ts","../../src/workspace/getWorkspaceFiles.ts","../../../path/src/lib/hasParentDirname.ts","../../src/util/isSourceFile.ts","../../src/workspace/getWorkspaceSourceFiles.ts","../../src/imports/getAllImports.ts","../../src/imports/getWorkspaceSelfImports.ts","../../src/methods/getRootPackageJsonPath.ts","../../src/methods/getRootPackageJson.ts","../../src/methods/getAllWorkspacePaths.ts","../../src/methods/getAllWorkspacePackageJsonPaths.ts","../../src/methods/getAllWorkspacePackageJsons.ts","../../src/methods/getAllWorkspacePackageNames.ts","../../src/methods/findWorkspacePackageName.ts","../../src/util/SemanticExtnamePrefixDescriptions.ts","../../src/util/getWorkspaceDirpaths.ts","../../src/util/resolveModuleImportPath.ts","../../src/util/semverVersionBump.ts","../../src/workspace/findWorkspace.ts","../../src/workspace/getWorkspaceTestFiles.ts"],"names":["SemanticExtnamePrefix","d","test","examples","benchmark","temp","wip","getDependencyName","moduleSpecifier","split","slice","startsWith","join","getRepoRootDirpath","memoize","fspath","process","cwd","recurse","dirpath","upath","normalizeSafe","pkgpath","joinSafe","fs","existsSync","readJsonSync","throws","workspaces","parent","dirname","Error","readWorkspace","root","path","resolve","packageJsonPath","packageJson","name","relativePath","relative","origin","basename","getWorkspaces","filter","pattern","flatMap","globSync","posix","sort","map","NODE_MODULES","createDependencyGraph","options","graph","modules","Map","entries","ws","dir","entry","length","excludedPrefixes","Object","values","prefix","includeTests","tsConfigPath","hasTsConfig","cruise","default","extractTSConfig","output","baseDir","tsPreCompilationDeps","doNotFollow","exclude","tsConfig","fileName","enhancedResolveOptions","extensions","conditionNames","mainFields","exportsFields","undefined","TypeError","workspacesByPathLength","toSorted","a","b","findWorkspace","filepath","find","source","coreModule","couldNotResolve","dependencies","includes","workspace","module","dependency","toGraphDependency","set","from","specifier","resolved","circular","base","typeOnly","dependencyTypes","kind","pathInNodeModules","lastIndexOf","getExternalDependencyVersions","versions","packageDir","pkg","readPackageJson","toCaretRange","version","typesName","replace","typesPkg","hasOwnTypes","fromEntries","localeCompare","types","typings","JSON","stringify","exports","getReachableModules","follow","reached","stack","toReversed","pop","get","has","next","dep","push","summarizeDependencies","builtin","namesOf","external","internal","names","Set","getImportsRecursively","entryPoints","missing","entryModules","workspaceNames","size","workspaceName","unresolved","describe","filepaths","recursive","local","getWorkspaceModules","hasExtnamePrefix","tsFilepath","prefixes","SemanticExtnamePrefixes","RegExp","flat","isTestFile","getWorkspaceDependencies","own","summary","getTsconfigPaths","compilerOptions","paths","getWorkspaceDependencyProblems","rootPkg","tsconfigPaths","rootDependencies","rootDevDependencies","devDependencies","imported","importedNames","importedByTests","keys","unused","missingDev","importStatementToOneLiner","code","strip","replaceAll","trim","importStatementToFormattedOneLiner","m","rexec","regex","string","flags","result","match","exec","index","lastIndex","location","findLineColumn","groups","assign","content","lines","line","substring","splice","startOfLineIndex","col","parseImportStatement","statement","oneliner","keywords","hasTypeKeyword","type","specifiers","children","s","isType","o","modulePath","mod","p","isWorkspacePath","isAbsolute","isBuiltin","quote","semi","ImportStatementParser","getNames","splitBySpecifier","ins","unaliasNamedImports","Boolean","tsCrlfToLf","tsExtractImports","replaceImportStatementsInsideLiteralStrings","replaceImportStatementsInsideBlockComments","isFirstLine","isFirstLineInMulti","isLastLineInMulti","isMulti","impLines","l","matchOneLine","start","end","getFileImports","readFileSync","getWorkspaceFiles","ignore","hasParentDirname","isSourceFile","getWorkspaceSourceFiles","getAllImports","getWorkspaceSelfImports","sourceFilesByName","parse","indexFilepath","firstName","target","replaceValue","withValue","toRelativeSpecifier","fromFilepath","toFilepath","trimExt","getRootPackageJsonPath","getRootPackageJson","readJson","getAllWorkspacePaths","Promise","all","glob","fp","getAllWorkspacePackageJsonPaths","getAllWorkspacePackageJsons","getAllWorkspacePackageNames","pkgs","findWorkspacePackageName","wsPkgNames","n","SemanticExtnamePrefixDescriptions","getWorkspaceDirpaths","rootDirpath","resolveModuleImportPath","importFrom","rootdir","resolveModuleName","allowJs","allowArbitraryExtensions","allowImportingTsExtensions","allowSyntheticDefaultImports","esModuleInterop","strict","createCompilerHost","f","resolvedModule","resolvedFileName","semverVersionBump","level","arr","Number","query","normalize","getWorkspaceTestFiles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,qBAAAA,GAAwB;EACnCC,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,EAAAA,KAAOA,EAAAA,CAAGpB,IAAAA,KAAS8Q,KAAAA,CAAAA,IACpCxR,UAAAA,CAAWgE,IAAAA,CAAK,CAAClC,EAAAA,KAAOA,EAAAA,CAAGnB,YAAAA,KAAiBnB,uBAAAA,CAAMiS,SAAAA,CAAUD,KAAAA,CAAAA,CAAAA,IAC5DxR,UAAAA,CAAWgE,IAAAA,CAAK,CAAClC,EAAAA,KAAOtC,uBAAAA,CAAMsB,QAAAA,CAASgB,EAAAA,CAAGxB,IAAI,CAAA,KAAMkR,KAAAA,CAAAA;AAExD;AANgB1N,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA;;;ACPT,SAAS4N,sBAAsBpN,SAAAA,EAAoB;AACxD,EAAA,OAAO4J,iBAAAA,CAAkB5J,SAAAA,CAAAA,CAAWtD,MAAAA,CAAO,CAAC+C,QAAAA,KAAa6E,UAAAA,CAAW7E,QAAAA,CAAAA,CAAAA;AACtE;AAFgB2N,MAAAA,CAAAA,qBAAAA,EAAAA,uBAAAA,CAAAA","file":"index.cjs","sourcesContent":["/**\n * Constants for semantic filename prefixes used to categorize files by their purpose.\n */\nexport type SemanticExtnamePrefix = (typeof SemanticExtnamePrefix)[keyof typeof SemanticExtnamePrefix]\nexport const SemanticExtnamePrefix = {\n d: 'd',\n test: 'test',\n examples: 'examples',\n benchmark: 'benchmark',\n temp: 'temp',\n wip: 'wip',\n} as const\n","/**\n * Returns the package name part of a module specifier.\n *\n * @example\n * ```ts\n * getDependencyName('es-toolkit/array') // 'es-toolkit'\n * getDependencyName('@mono/string/camelCase') // '@mono/string'\n * ```\n */\nexport function getDependencyName(moduleSpecifier: string): string {\n return moduleSpecifier\n .split('/')\n .slice(0, moduleSpecifier.startsWith('@') ? 2 : 1)\n .join('/')\n}\n","import fs from 'fs-extra'\nimport { memoize } from 'es-toolkit'\nimport upath from 'upath'\n\n/**\n * Get the root directory path of the monorepo by finding the package.json with workspaces configuration.\n */\nexport const getRepoRootDirpath = memoize((fspath: string = process.cwd()) =>\n (function recurse(dirpath: string) {\n dirpath = upath.normalizeSafe(dirpath)\n const pkgpath = upath.joinSafe(dirpath, 'package.json')\n if (fs.existsSync(pkgpath) && !!fs.readJsonSync(pkgpath, { throws: false })?.workspaces?.join('')) {\n return dirpath\n }\n const parent = upath.dirname(dirpath)\n if (parent === dirpath) {\n throw new Error(`Could not find repo root from current dir: ${fspath}`)\n }\n return recurse(parent)\n })(fspath)\n)\n\n// /**\n// * Get the root directory path of the git repository containing the specified folder.\n// */\n// export const getRepoRootDirpath2 = memoize((rootFolder: string = process.cwd()) => {\n// /** How much git may print of the status of a working tree: far more than any real one. */\n// const LARGEST_GIT_OUTPUT_BYTES = 512 * 1024 * 1024\n\n// const runGit = (gitArguments: readonly string[]) =>\n// spawnSync('git', gitArguments, { cwd: rootFolder, maxBuffer: LARGEST_GIT_OUTPUT_BYTES, windowsHide: true })\n// const topLevel = runGit(['rev-parse', '--show-toplevel'])\n// if (topLevel.error) {\n// return { whyUnavailable: `git could not be started (${topLevel.error.message}), so the repository is unseen` }\n// }\n// if (topLevel.status !== 0) {\n// return { whyUnavailable: `${rootFolder} is not in a git checkout` }\n// }\n// }, {})\n","import type { PackageJson } from '@mono/types'\nimport type { Workspace } from './Workspace'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Reads the package.json of a workspace directory and returns the workspace as plain data.\n *\n * @param dirpath - The workspace directory. A relative path is resolved against the repo root.\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function readWorkspace(dirpath: string, root: string = getRepoRootDirpath()): Workspace {\n const path = upath.resolve(root, dirpath)\n const packageJsonPath = upath.join(path, 'package.json')\n const packageJson = fs.readJsonSync(packageJsonPath) as PackageJson\n if (!packageJson.name) {\n throw new Error(`Workspace package.json missing 'name' field: ${packageJsonPath}`)\n }\n return {\n name: packageJson.name,\n path,\n relativePath: upath.relative(upath.resolve(root), path),\n origin: upath.basename(upath.dirname(path)),\n packageJson,\n }\n}\n","import type { PackageJson } from '@mono/types'\nimport type { Workspace } from './Workspace'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { globSync } from 'glob'\nimport { readWorkspace } from './readWorkspace'\nimport upath from 'upath'\n\n/**\n * Reads every workspace matched by the 'workspaces' patterns of the root package.json.\n * The repo root itself is not included.\n *\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function getWorkspaces(root: string = getRepoRootDirpath()): Workspace[] {\n const packageJsonPath = upath.join(root, 'package.json')\n const packageJson = fs.readJsonSync(packageJsonPath) as PackageJson\n if (!packageJson.workspaces) {\n throw new Error(`Root package.json missing 'workspaces' field: ${packageJsonPath}`)\n }\n return packageJson.workspaces\n .filter((pattern) => pattern !== '.')\n .flatMap((pattern) => globSync(pattern, { cwd: root, posix: true }))\n .filter((dirpath) => fs.existsSync(upath.join(root, dirpath, 'package.json')))\n .sort()\n .map((dirpath) => readWorkspace(dirpath, root))\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphDependency } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { IDependency } from 'dependency-cruiser'\nimport { SemanticExtnamePrefix } from '../util/SemanticExtnamePrefix'\nimport type { Workspace } from '../workspace/Workspace'\nimport fs from 'fs-extra'\nimport { getDependencyName } from './getDependencyName'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { getWorkspaces } from '../workspace/getWorkspaces'\nimport upath from 'upath'\n\n/**\n * Options of `createDependencyGraph`.\n */\nexport interface CreateDependencyGraphOptions {\n /** The repo root. Defaults to the root of the repo that contains the current working directory. */\n root?: string\n /**\n * The files and directories to start from. Relative paths are resolved against the repo root.\n * Everything they import is followed, also into other workspaces. Defaults to the 'src' directory of every\n * workspace.\n */\n entries?: string[]\n /** Whether to include test files (*.test.*). Defaults to false. */\n includeTests?: boolean\n /** The workspaces of the repo. Defaults to `getWorkspaces(root)`. */\n workspaces?: Workspace[]\n}\n\nconst NODE_MODULES = 'node_modules/'\n\n/**\n * Analyzes which files import what, using dependency-cruiser, and returns it as a graph of plain data.\n *\n * Imports are resolved the same way the repo's TypeScript code is: with the 'paths' of the tsconfig.json in the\n * repo root and the 'exports' of package.json files. Files with a semantic extname prefix (examples, benchmarks,\n * declarations etc.) are left out, and so are test files unless `includeTests` is set. Packages in node_modules\n * are not followed.\n *\n * Analyzing a whole repo takes around a second, so create the graph once and pass it to the functions that\n * read from it.\n */\nexport async function createDependencyGraph(options: CreateDependencyGraphOptions = {}): Promise<DependencyGraph> {\n const root = upath.resolve(options.root ?? getRepoRootDirpath())\n const workspaces = options.workspaces ?? getWorkspaces(root)\n const graph: DependencyGraph = { root, workspaces, modules: new Map() }\n\n const entries = (\n options.entries ?? workspaces.map((ws) => upath.join(ws.path, 'src')).filter((dir) => fs.existsSync(dir))\n ).map((entry) => upath.relative(root, upath.resolve(root, entry)))\n if (!entries.length) {\n return graph\n }\n\n const excludedPrefixes = Object.values(SemanticExtnamePrefix).filter(\n (prefix) => !(options.includeTests && prefix === SemanticExtnamePrefix.test)\n )\n const tsConfigPath = upath.join(root, 'tsconfig.json')\n const hasTsConfig = fs.existsSync(tsConfigPath)\n\n // Loaded on demand: dependency-cruiser is ESM-only and slow to load, and most of this library does not need it.\n const { cruise } = await import('dependency-cruiser')\n const { default: extractTSConfig } = await import('dependency-cruiser/config-utl/extract-ts-config')\n\n const { output } = await cruise(\n entries,\n {\n baseDir: root,\n tsPreCompilationDeps: true,\n doNotFollow: { path: ['node_modules'] },\n // Only the repo's own files are excluded: packages often resolve to a file in 'dist' or to a '.d.ts' file.\n exclude: {\n path: [\n `^(?!.*${NODE_MODULES}).*[.](${excludedPrefixes.join('|')})[.][^/]+$`,\n `^(?!.*${NODE_MODULES}).*(^|/)(dist|coverage)/`,\n ],\n },\n ...(hasTsConfig && { tsConfig: { fileName: tsConfigPath } }),\n enhancedResolveOptions: {\n extensions: ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json'],\n conditionNames: ['import', 'require', 'node', 'default', 'types'],\n mainFields: ['module', 'main', 'types', 'typings'],\n exportsFields: ['exports'],\n },\n },\n undefined,\n hasTsConfig ? { tsConfig: extractTSConfig(tsConfigPath) } : undefined\n )\n if (typeof output === 'string') {\n throw new TypeError('Expected dependency-cruiser to return its result as an object.')\n }\n\n // Longest path first, so that a workspace nested in another one wins.\n const workspacesByPathLength = workspaces.toSorted((a, b) => b.relativePath.length - a.relativePath.length)\n const findWorkspace = (filepath: string) =>\n workspacesByPathLength.find((ws) => filepath.startsWith(`${ws.relativePath}/`))\n\n for (const { source, coreModule, couldNotResolve, dependencies } of output.modules) {\n // The output also lists what the repo's files depend on. Only the repo's own files are modules of the graph.\n if (coreModule || couldNotResolve || source.includes(NODE_MODULES)) {\n continue\n }\n const workspace = findWorkspace(source)\n const module: GraphModule = {\n path: source,\n ...(workspace && { workspace }),\n dependencies: dependencies.map((dependency) => toGraphDependency(dependency, workspace, findWorkspace)),\n }\n graph.modules.set(source, module)\n }\n\n return graph\n}\n\nfunction toGraphDependency(\n dependency: IDependency,\n from: Workspace | undefined,\n findWorkspace: (filepath: string) => Workspace | undefined\n): GraphDependency {\n const { module: specifier, resolved, circular } = dependency\n const base = { specifier, resolved, circular, typeOnly: dependency.dependencyTypes.includes('type-only') }\n\n if (dependency.coreModule) {\n return { ...base, kind: 'builtin', name: specifier }\n }\n if (dependency.couldNotResolve) {\n return { ...base, kind: 'unresolved' }\n }\n if (resolved.includes(NODE_MODULES)) {\n // Named after its directory in node_modules, which is what has to be listed in a package.json.\n const pathInNodeModules = resolved.slice(resolved.lastIndexOf(NODE_MODULES) + NODE_MODULES.length)\n return { ...base, kind: 'external', name: getDependencyName(pathInNodeModules) }\n }\n const workspace = findWorkspace(resolved)\n if (workspace && workspace.name !== from?.name) {\n return { ...base, kind: 'workspace', name: workspace.name }\n }\n return { ...base, kind: 'local' }\n}\n","import type { GraphModule } from './DependencyGraph'\nimport fs from 'fs-extra'\nimport upath from 'upath'\n\nconst NODE_MODULES = 'node_modules/'\n\n/**\n * Maps every package the given modules import to a caret range of its installed version, ready to be put in the\n * 'dependencies' of a package.json. Sorted by package name.\n *\n * If a package ships no types of its own and its `@types/` package is installed, that is included too.\n *\n * @param modules - Modules of a dependency graph.\n * @param root - The repo root: the `root` of the dependency graph.\n */\nexport function getExternalDependencyVersions(modules: GraphModule[], root: string): Record<string, string> {\n const versions: Record<string, string> = {}\n\n for (const dependency of modules.flatMap((module) => module.dependencies)) {\n if (dependency.kind !== 'external' || !dependency.name || dependency.name in versions) {\n continue\n }\n const { name, resolved } = dependency\n const packageDir = upath.join(root, resolved.slice(0, resolved.lastIndexOf(NODE_MODULES)), NODE_MODULES, name)\n const pkg = readPackageJson(packageDir)\n versions[name] = toCaretRange(pkg?.version)\n\n const typesName = `@types/${name.replace(/^@/, '').replace('/', '__')}`\n const typesPkg =\n !name.startsWith('@types/') && !hasOwnTypes(packageDir, pkg)\n ? readPackageJson(upath.join(root, NODE_MODULES, typesName))\n : undefined\n if (typesPkg) {\n versions[typesName] = toCaretRange(typesPkg.version)\n }\n }\n\n return Object.fromEntries(Object.entries(versions).sort(([a], [b]) => a.localeCompare(b)))\n}\n\ninterface InstalledPackageJson {\n version?: string\n types?: string\n typings?: string\n exports?: unknown\n}\n\nfunction readPackageJson(dirpath: string): InstalledPackageJson | undefined {\n return fs.readJsonSync(upath.join(dirpath, 'package.json'), { throws: false }) ?? undefined\n}\n\nfunction hasOwnTypes(packageDir: string, pkg: InstalledPackageJson | undefined): boolean {\n return (\n !!pkg?.types ||\n !!pkg?.typings ||\n JSON.stringify(pkg?.exports ?? '').includes('\"types\"') ||\n fs.existsSync(upath.join(packageDir, 'index.d.ts'))\n )\n}\n\nfunction toCaretRange(version: string | undefined): string {\n return version ? `^${version}` : ''\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { DependencyKind } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\n\n/**\n * Returns the given modules and every module they import, directly or through other modules, in the order they\n * are discovered. Each module is returned once.\n *\n * @param graph - The dependency graph.\n * @param entries - The paths of the modules to start from, relative to the repo root.\n * @param follow - The kinds of dependency to follow. Defaults to both `local` and `workspace`. Pass `['local']`\n * to stay within the workspaces of the entries.\n */\nexport function getReachableModules(\n graph: DependencyGraph,\n entries: string[],\n follow: DependencyKind[] = ['local', 'workspace']\n): GraphModule[] {\n const reached = new Map<string, GraphModule>()\n const stack = entries.toReversed()\n\n while (stack.length) {\n const path = stack.pop()!\n const module = graph.modules.get(path)\n if (!module || reached.has(path)) {\n continue\n }\n reached.set(path, module)\n const next = module.dependencies.filter((dep) => follow.includes(dep.kind)).map((dep) => dep.resolved)\n stack.push(...next.toReversed())\n }\n\n return [...reached.values()]\n}\n","import type { GraphDependency } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\n\n/**\n * The names of what a set of modules depends on, each sorted and without duplicates.\n */\nexport interface DependencySummary {\n /** Node built-in modules, without the 'node:' prefix. */\n builtin: string[]\n /** Package names of dependencies in node_modules. */\n external: string[]\n /** Package names of other workspaces of the repo. */\n internal: string[]\n}\n\n/**\n * Lists the names of everything the given modules import directly, grouped by kind.\n */\nexport function summarizeDependencies(modules: GraphModule[]): DependencySummary {\n const dependencies = modules.flatMap((module) => module.dependencies)\n return {\n builtin: namesOf(dependencies, 'builtin'),\n external: namesOf(dependencies, 'external'),\n internal: namesOf(dependencies, 'workspace'),\n }\n}\n\nfunction namesOf(dependencies: GraphDependency[], kind: GraphDependency['kind']): string[] {\n const names = dependencies.filter((dep) => dep.kind === kind).map((dep) => dep.name!)\n return [...new Set(names)].sort()\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport { createDependencyGraph } from './createDependencyGraph'\nimport fs from 'fs-extra'\nimport { getExternalDependencyVersions } from './getExternalDependencyVersions'\nimport { getReachableModules } from './getReachableModules'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { summarizeDependencies } from './summarizeDependencies'\nimport upath from 'upath'\n\n/**\n * What a set of files depends on.\n */\nexport interface ImportedDependencies {\n /** Packages in node_modules, mapped to a caret range of the installed version. */\n external: Record<string, string>\n /** Node built-in modules, without the 'node:' prefix. */\n builtin: string[]\n /** Package names of other workspaces of the repo. */\n internal: string[]\n}\n\n/**\n * The result of `getImportsRecursively`.\n */\nexport interface ImportsRecursivelyResult {\n /** Every file that is reached from the entry points, in the order of discovery. Relative to the repo root. */\n filepaths: string[]\n /** What all the reached files depend on, including the files in other workspaces. */\n recursive: ImportedDependencies\n /** What the reached files in the workspace of the entry points depend on. */\n local: ImportedDependencies\n}\n\n/**\n * Follows the imports of the given entry points through the repo and lists what is depended on along the way.\n *\n * @param entryPoints - Files of a single workspace. Relative paths are resolved against the repo root.\n * @param options.root - The repo root. Defaults to the root of the repo that contains the current working directory.\n * @param options.graph - A dependency graph to read from. By default one is created from the entry points.\n * @throws If the entry points are not all in the same workspace, or if an import cannot be resolved.\n */\nexport async function getImportsRecursively(\n entryPoints: string[],\n options: { root?: string; graph?: DependencyGraph } = {}\n): Promise<ImportsRecursivelyResult> {\n const root = upath.resolve(options.graph?.root ?? options.root ?? getRepoRootDirpath())\n const entries = entryPoints.map((entry) => upath.relative(root, upath.resolve(root, entry)))\n const missing = entries.find((entry) => !fs.existsSync(upath.join(root, entry)))\n if (missing) {\n throw new Error(`Entry point not found: ${missing}`)\n }\n const graph = options.graph ?? (await createDependencyGraph({ root, entries }))\n\n const entryModules = entries.map((entry) => {\n const module = graph.modules.get(entry)\n if (!module) {\n throw new Error(`Entry point is not in the dependency graph: ${entry}`)\n }\n return module\n })\n const workspaceNames = new Set(entryModules.map((module) => module.workspace?.name))\n if (workspaceNames.size > 1) {\n throw new Error(`All entry points must be in the same workspace. Got: ${[...workspaceNames].join(', ')}`)\n }\n const [workspaceName] = workspaceNames\n\n const reached = getReachableModules(graph, entries)\n for (const module of reached) {\n const unresolved = module.dependencies.find((dep) => dep.kind === 'unresolved')\n if (unresolved) {\n throw new Error(`Could not resolve \"${unresolved.specifier}\", imported in ${module.path}`)\n }\n }\n\n const describe = (modules: GraphModule[]): ImportedDependencies => {\n const { builtin, internal } = summarizeDependencies(modules)\n return {\n external: getExternalDependencyVersions(modules, root),\n builtin,\n internal: internal.filter((name) => name !== workspaceName),\n }\n }\n\n return {\n filepaths: reached.map((module) => module.path),\n recursive: describe(reached),\n local: describe(getReachableModules(graph, entries, ['local'])),\n }\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { Workspace } from '../workspace/Workspace'\n\n/**\n * Returns the modules of the dependency graph that belong to the given workspace.\n */\nexport function getWorkspaceModules(workspace: Workspace, graph: DependencyGraph): GraphModule[] {\n return [...graph.modules.values()].filter((module) => module.workspace?.name === workspace.name)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport type { UnionToTuple } from 'type-fest'\n\n/**\n * Array of all semantic extension prefixes used to categorize files by their purpose.\n */\nexport default Object.values(SemanticExtnamePrefix) as unknown as UnionToTuple<SemanticExtnamePrefix>\n","import type { Arrayable } from 'type-fest'\nimport type { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport SemanticExtnamePrefixes from './SemanticExtnamePrefixes'\n\n/**\n * Checks if a file path has any of the specified semantic extension prefixes (e.g., .test.ts).\n */\nexport function hasExtnamePrefix(\n tsFilepath: string,\n prefixes: Arrayable<SemanticExtnamePrefix> = SemanticExtnamePrefixes as unknown as SemanticExtnamePrefix[]\n) {\n return new RegExp(`[.](${[prefixes].flat(2).join('|')})[.][^/\\\\\\\\]+$`).test(tsFilepath)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport { hasExtnamePrefix } from './hasExtnamePrefix'\n\n/**\n * Whether the file is a test file, e.g. 'foo.test.ts'.\n */\nexport function isTestFile(filepath: string): boolean {\n return hasExtnamePrefix(filepath, SemanticExtnamePrefix.test)\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { DependencySummary } from './summarizeDependencies'\nimport type { Workspace } from '../workspace/Workspace'\nimport { getReachableModules } from './getReachableModules'\nimport { getWorkspaceModules } from './getWorkspaceModules'\nimport { isTestFile } from '../util/isTestFile'\nimport { summarizeDependencies } from './summarizeDependencies'\n\n/**\n * Lists what the source files of a workspace depend on: node built-ins, packages and other workspaces.\n * Test files are not counted.\n *\n * @param workspace - The workspace.\n * @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`.\n * @param options.recursive - Whether to also count what the imported files of other workspaces depend on,\n * and so on. Defaults to false: only what the workspace's own files import.\n */\nexport function getWorkspaceDependencies(\n workspace: Workspace,\n graph: DependencyGraph,\n options: { recursive?: boolean } = {}\n): DependencySummary {\n const own = getWorkspaceModules(workspace, graph).filter((module) => !isTestFile(module.path))\n if (!options.recursive) {\n return summarizeDependencies(own)\n }\n const summary = summarizeDependencies(\n getReachableModules(\n graph,\n own.map((module) => module.path)\n )\n )\n return { ...summary, internal: summary.internal.filter((name) => name !== workspace.name) }\n}\n","import fs from 'fs-extra'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Reads the 'compilerOptions.paths' of the tsconfig.paths.json file in the repo root.\n * Returns an empty object if the file does not exist.\n *\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function getTsconfigPaths(root: string = getRepoRootDirpath()): Record<string, string[]> {\n const filepath = upath.join(root, 'tsconfig.paths.json')\n if (!fs.existsSync(filepath)) {\n return {}\n }\n return fs.readJsonSync(filepath).compilerOptions?.paths ?? {}\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { PackageJson } from '@mono/types'\nimport type { Workspace } from '../workspace/Workspace'\nimport fs from 'fs-extra'\nimport { getTsconfigPaths } from '../util/getTsconfigPaths'\nimport { getWorkspaceModules } from './getWorkspaceModules'\nimport { isTestFile } from '../util/isTestFile'\nimport { summarizeDependencies } from './summarizeDependencies'\nimport upath from 'upath'\n\n/**\n * The dependency problems of a workspace. A property is left out if there is nothing to report for it.\n */\nexport interface WorkspaceDependencyProblems {\n /** Name of the directory that contains the workspace, e.g. 'libs' or 'apps'. */\n origin: string\n /** The package name of the workspace. */\n workspace: string\n /** Listed in the 'dependencies' of the workspace's package.json, but not imported by any source file. */\n unused?: string[]\n /** Imported by a source file, but not listed in the 'dependencies' of the workspace's package.json. */\n missing?: string[]\n /** Imported by a test file, but not listed in the workspace's 'dependencies' or 'devDependencies'. */\n missingDev?: string[]\n}\n\n/**\n * Compares what the files of a workspace import with what its package.json lists, and returns what does not add\n * up. Returns undefined if there are no problems.\n *\n * A dependency is not reported as missing if the root package.json lists it, or if it is one of the 'paths' in\n * the tsconfig.paths.json of the repo root.\n *\n * @param workspace - The workspace.\n * @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`. Create it with\n * `includeTests` for `missingDev` to be checked.\n */\nexport function getWorkspaceDependencyProblems(\n workspace: Workspace,\n graph: DependencyGraph\n): WorkspaceDependencyProblems | undefined {\n const rootPkg = fs.readJsonSync(upath.join(graph.root, 'package.json')) as PackageJson\n const tsconfigPaths = getTsconfigPaths(graph.root)\n const rootDependencies = rootPkg.dependencies ?? {}\n const rootDevDependencies = rootPkg.devDependencies ?? {}\n\n const modules = getWorkspaceModules(workspace, graph)\n const imported = importedNames(modules.filter((module) => !isTestFile(module.path)))\n const importedByTests = importedNames(modules.filter((module) => isTestFile(module.path)))\n const dependencies = Object.keys(workspace.packageJson.dependencies ?? {}).sort()\n const devDependencies = Object.keys(workspace.packageJson.devDependencies ?? {})\n\n const unused = dependencies.filter((name) => !imported.includes(name))\n const missing = imported\n .filter((name) => !dependencies.includes(name))\n .filter((name) => !(name in rootDependencies) && !(name in tsconfigPaths))\n const missingDev = importedByTests\n .filter((name) => !dependencies.includes(name) && !devDependencies.includes(name))\n .filter((name) => !(name in rootDependencies) && !(name in rootDevDependencies) && !(name in tsconfigPaths))\n\n if (!unused.length && !missing.length && !missingDev.length) {\n return undefined\n }\n return {\n origin: workspace.origin,\n workspace: workspace.name,\n ...(unused.length && { unused }),\n ...(missing.length && { missing }),\n ...(missingDev.length && { missingDev }),\n }\n}\n\nfunction importedNames(modules: GraphModule[]): string[] {\n const { external, internal } = summarizeDependencies(modules)\n return [...external, ...internal].sort()\n}\n","import strip from 'strip-comments'\n\n/**\n * Converts a multi-line import statement to a single line by removing comments and extra whitespace.\n * This function strips comments, normalizes whitespace, and removes trailing commas to create\n * a clean single-line import statement.\n * @param code - The import statement code to convert\n * @returns A single-line import statement with normalized formatting\n * @example\n * ```typescript\n * const multilineImport = `import {\n * foo,\n * bar\n * } from 'module'`\n *\n * importStatementToOneLiner(multilineImport)\n * // 'import { foo, bar } from 'module''\n * ```\n */\nexport function importStatementToOneLiner(code: string) {\n return (\n strip(code)\n // remove newlines\n .replaceAll(/\\r*\\n/g, ' ')\n // remove consecutive whitespace\n .replaceAll(/\\s+/g, ' ')\n // remove trailing commas\n .replace(/,\\s*}/, ' }')\n // Normalize spaces around commas\n .replaceAll(/\\s*,\\s*/g, ', ')\n // remove consecutive whitespace\n .replaceAll(/\\s+/g, ' ')\n // remove leading and trailing whitespace\n .trim()\n )\n}\n","import { importStatementToOneLiner } from './importStatementToOneLiner'\n\n/**\n * Converts a multi-line import statement to a formatted single line with proper spacing.\n * Adds spaces around braces, keywords, and other import statement elements for readability.\n * @param code - The import statement code to format\n * @returns A formatted single-line import statement\n * @example\n * ```typescript\n * importStatementToFormattedOneLiner('import{foo,bar}from\"module\"')\n * // 'import { foo, bar } from \"module\"'\n *\n * importStatementToFormattedOneLiner('import*as foo from\"module\"')\n * // 'import * as foo from \"module\"'\n * ```\n */\nexport function importStatementToFormattedOneLiner(code: string) {\n return importStatementToOneLiner(code)\n .replaceAll(/[{}]|\\bfrom\\b|\\*|\\bas\\b/g, (m) => ` ${m} `)\n .replaceAll(/\\s+,\\s*/g, ', ')\n .replaceAll(/\\s\\s+/g, ' ')\n .trim()\n}\n","/**\n * Easily perform regex 'exec' on a string. An iterable is returned which steps through the exec process and yields all the details you might need.\n * @param regex The regular expression object\n * @returns A generator that yields an object for each match.\n * @throws If the provided regex is not a RegExp instance.\n * @param string The string to perform the operation on\n * @example ```ts\n * const regex = /(?<g1>a)/g\n * const str = 'Anthony wants a girlfriend.'\n * console.log([...rexec(regex, str)])\n * // [\n * // \t{\n * // index: 9,\n * // lastIndex: 10,\n * // groups: { g1: 'a' },\n * // match: 'a',\n * // },\n * // {\n * // index: 14,\n * // lastIndex: 15,\n * // groups: { g1: 'a' },\n * // match: 'a',\n * // },\n * // ]\n * ```\n */\nexport function rexec(regex: RegExp, string: string): RexecResult[] {\n regex = new RegExp(regex.source, regex.flags)\n const result: RexecResult[] = []\n let match\n while ((match = regex.exec(string)) !== null) {\n result.push({\n index: match.index,\n lastIndex: regex.lastIndex,\n location: findLineColumn(string, match.index),\n groups: Object.assign({}, match.groups),\n match: match[0],\n })\n }\n return result\n}\n\nexport interface RexecResult {\n index: number\n lastIndex: number\n location: [line: number, col: number]\n groups: Record<string, string>\n match: string\n}\n\nfunction findLineColumn(content: string, index: number) {\n const lines = content.split('\\n')\n const line = content.substring(0, index).split('\\n').length\n lines.splice(line - 1)\n const startOfLineIndex = lines.join('\\n').length + (lines.length ? 1 : 0)\n const col = index - startOfLineIndex\n return [line, col] as [number, number]\n}\n","import { importStatementToFormattedOneLiner } from './importStatementToFormattedOneLiner'\nimport { isBuiltin } from 'module'\nimport { rexec } from '@mono/regex'\nimport upath from 'upath'\n\n/**\n * Parses an import statement into its constituent parts for detailed analysis.\n * This function breaks down an import statement into keywords, specifiers, module path,\n * and other components, providing a comprehensive analysis of the import structure.\n * @param statement - The import statement string to parse\n * @returns An ImportStatementParser instance with parsed components and utility methods\n * @example\n * ```typescript\n * const parsed = parseImportStatement(\"import type { Foo, Bar as Baz } from './module'\")\n * console.log(parsed.type) // 'named'\n * console.log(parsed.keywords.hasTypeKeyword) // true\n * console.log(parsed.modulePath.type) // 'relative'\n * console.log(parsed.getNames()) // ['Foo', 'Baz']\n * ```\n */\nexport function parseImportStatement(\n statement: string,\n options?: { isWorkspacePath?: (p: string) => boolean }\n): ImportStatement {\n const code = statement\n const oneliner = importStatementToFormattedOneLiner(code)\n\n const groups = rexec(\n /^(?<keywords>import +(?<type>type)? *)(?<specifiers>.*? ?)?(?<mod>(?:from ?)?(?<quote>[\"'`])(?<path>.*?)\\5(?<semi>;?))$/g,\n oneliner\n )[0].groups!\n\n const keywords: ImportKeywords = {\n code: groups.keywords!,\n keywords: groups.keywords.trim().split(/\\s+/g),\n hasTypeKeyword: !!groups.type,\n }\n\n const specifiers: ImportSpecifiers = {\n code: groups.specifiers || '',\n children: ((specifiers?: string) => {\n const children = [] as ImportSpecifier[]\n\n if (!specifiers) {\n return children\n }\n\n children.push(\n ...specifiers\n .replace(/{[^}]+}/, '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => !!s)\n .map((code) => ({\n code: code.trim(),\n type: code.trim().startsWith('* as ') ? ('namespace' as const) : ('default' as const),\n name: code.replace('* as ', '').trim(),\n isType: keywords.hasTypeKeyword || /\\btype /.test(code),\n }))\n )\n\n children.push(\n ...(specifiers.match(/{([^}]+)}/)?.[1] || '')\n .split(',')\n .filter((s) => !!s.trim())\n .map((code) => ({\n code: code.trim(),\n type: 'named' as const,\n name: code.replace(/ as \\w+\\b/, '').trim(),\n isType: keywords.hasTypeKeyword || /\\btype /.test(code),\n }))\n .map((o) => {\n if (o.isType && !o.name.startsWith('type ')) {\n o.name = `type ${o.name}`\n }\n return o\n })\n )\n\n return children\n })(groups.specifiers),\n }\n\n const modulePath: ImportModulePath = {\n code: groups.mod!,\n type: ((): ImportPathType => {\n const p = groups.path!\n return options?.isWorkspacePath?.(p)\n ? 'workspace'\n : upath.isAbsolute(p)\n ? 'absolute'\n : p.startsWith('.')\n ? 'relative'\n : isBuiltin(p)\n ? 'builtin'\n : 'package'\n })(),\n quote: groups.quote!,\n path: groups.path!,\n }\n\n const type =\n specifiers.children.length === 0\n ? 'sideEffect'\n : specifiers.children.length === 1 && specifiers.children[0].type === 'default'\n ? 'default'\n : specifiers.children.length === 1 && specifiers.children[0].type === 'namespace'\n ? 'namespace'\n : specifiers.children.length > 0 &&\n specifiers.children.filter((s) => s.type === 'named').length === specifiers.children.length\n ? 'named'\n : 'mixed'\n\n const semi = groups.semi || ''\n\n return new ImportStatementParser(code, oneliner, type, keywords, specifiers, modulePath, semi)\n}\n\nclass ImportStatementParser implements ImportStatement {\n constructor(\n readonly code: string,\n readonly oneliner: string,\n readonly type: ImportStatementType,\n readonly keywords: ImportKeywords,\n readonly specifiers: ImportSpecifiers,\n readonly modulePath: ImportModulePath,\n readonly semi: string\n ) {}\n\n /**\n * The names that this import statement declares in the global namespace.\n */\n getNames(options?: { unaliasNamedImports?: boolean }) {\n return this.splitBySpecifier(options).flatMap((ins) =>\n ins.specifiers.children\n .map((s) =>\n s.type === 'named' && options?.unaliasNamedImports\n ? s.code.replaceAll(/ as \\w+/g, '')\n : s.code.replaceAll(/[\\w*]+ as /g, '')\n )\n .filter(Boolean)\n )\n }\n\n /**\n * Split the import statement into as many individual import statements as possible.\n */\n splitBySpecifier(options?: { unaliasNamedImports?: boolean }): ImportStatementParser[] {\n return this.type === 'sideEffect'\n ? [this]\n : this.specifiers.children.map((s) => {\n const code =\n s.type === 'named' && options?.unaliasNamedImports ? s.code.replaceAll(/ as \\w+/g, '') : s.code\n return parseImportStatement(\n importStatementToFormattedOneLiner(\n this.oneliner\n .replace(this.specifiers.code, s.type === 'named' ? `{ ${code} } ` : `${code} `)\n .replace(/{ *type /, this.keywords.hasTypeKeyword ? '{ ' : 'type { ')\n ).replace('type { ', '{ type ')\n )\n })\n }\n}\n\n/**\n * The type of path used in an import statement.\n */\ntype ImportPathType = 'relative' | 'absolute' | 'builtin' | 'package' | 'workspace'\n\n/**\n * The type of import specifier.\n */\ntype ImportSpecifierType = 'default' | 'namespace' | 'named'\n\n/**\n * The overall type of import statement based on its specifiers.\n */\ntype ImportStatementType = 'default' | 'namespace' | 'named' | 'sideEffect' | 'mixed'\n\n/**\n * Represents the keywords portion of an import statement (e.g., 'import type').\n */\ninterface ImportKeywords {\n /** The raw code containing the keywords */\n code: string\n /** Array of individual keywords */\n keywords: string[]\n /** Whether the 'type' keyword is present */\n hasTypeKeyword: boolean\n}\n\n/**\n * Represents a single import specifier (e.g., a named import, default import, etc.).\n */\ninterface ImportSpecifier {\n /** The raw code for this specifier */\n code: string\n /** The type of this specifier */\n type: ImportSpecifierType\n /** The name being imported */\n name: string\n /** Whether this is a type-only import */\n isType: boolean\n}\n\n/**\n * Represents the collection of specifiers in an import statement.\n */\ninterface ImportSpecifiers {\n /** The raw code containing all specifiers */\n code: string\n /** Array of individual specifiers */\n children: ImportSpecifier[]\n}\n\n/**\n * Represents the module path portion of an import statement.\n */\ninterface ImportModulePath {\n /** The raw code containing the module path */\n code: string\n /** The type of path (relative, absolute, builtin, package) */\n type: ImportPathType\n /** The quote character used (' or \" or `) */\n quote: string\n /** The actual path string */\n path: string\n}\n\n/**\n * Interface representing a parsed import statement with all its components.\n * This interface enforces consistent structure for analyzing and manipulating\n * import statements in TypeScript source files.\n */\nexport interface ImportStatement {\n /** The original import statement code */\n readonly code: string\n /** The import statement as a formatted single line */\n readonly oneliner: string\n /** The type of import statement */\n readonly type: ImportStatementType\n /** The keywords used in the import statement */\n readonly keywords: ImportKeywords\n /** The import specifiers */\n readonly specifiers: ImportSpecifiers\n /** The module path information */\n readonly modulePath: ImportModulePath\n /** The semicolon at the end, if present */\n readonly semi: string\n\n /**\n * Split the import statement into as many individual import statements as possible.\n * @param options - Configuration options for splitting\n * @param options.unaliasNamedImports - Whether to remove aliases from named imports\n * @returns Array of individual import statements\n */\n splitBySpecifier(options?: { unaliasNamedImports?: boolean }): ImportStatement[]\n\n /**\n * Returns a sorted array of unique names that this import statement declares in the global namespace.\n * @param options - Configuration options for name extraction\n * @param options.unaliasNamedImports - Whether to remove aliases from named imports\n * @returns Array of declared names\n */\n getNames(options?: { unaliasNamedImports?: boolean }): string[]\n}\n","/**\n * Converts CRLF line endings to LF in TypeScript code.\n * This function normalizes line endings from Windows-style (CRLF) to Unix-style (LF)\n * for consistent processing across different operating systems.\n * @param code - The TypeScript code string to normalize\n * @returns The code with LF line endings\n * @example\n * ```typescript\n * tsCrlfToLf('line1\\r\\nline2\\r\\nline3') // 'line1\\nline2\\nline3'\n * ```\n */\nexport function tsCrlfToLf(code: string) {\n return code.replaceAll(/\\r+\\n/g, '\\n')\n}\n","import { importStatementToOneLiner } from './importStatementToOneLiner'\nimport { tsCrlfToLf } from './tsCrlfToLf'\n\n/**\n * Extract all import statements from a given TypeScript source code string.\n * This function parses TypeScript code to identify and extract all import statements,\n * handling both single-line and multi-line imports. It correctly ignores import-like\n * text within comments and string literals.\n * @param code - The TypeScript code as a string from which to extract import statements\n * @returns An array of objects, each representing an import statement. Each object includes\n * the start and end line numbers (0-indexed) of the import statement in the original code,\n * the full text of the import statement, and a one-line version\n */\nexport function tsExtractImports(code: string): TsExtractImportsResult[] {\n code = tsCrlfToLf(code)\n code = replaceImportStatementsInsideLiteralStrings(code)\n code = replaceImportStatementsInsideBlockComments(code)\n const isFirstLine = /^import /\n const isFirstLineInMulti = /{\\s*$/\n const isLastLineInMulti = /^} from [\"']/\n const result: TsExtractImportsResult[] = []\n let isMulti = false\n let impLines = []\n const lines = code.split(/\\r?\\n/)\n for (const [l, line] of lines.entries()) {\n if (isFirstLine.test(line)) {\n if (isFirstLineInMulti.test(line)) {\n impLines.push(line)\n isMulti = true\n } else {\n const match = line\n const matchOneLine = importStatementToOneLiner(match)\n result.push({ start: l, end: l + 1, match, matchOneLine })\n }\n } else if (isMulti) {\n impLines.push(line)\n if (isLastLineInMulti.test(line)) {\n const match = impLines.join('\\n')\n const matchOneLine = importStatementToOneLiner(match)\n result.push({ start: l - impLines.length + 1, end: l + 1, match, matchOneLine })\n impLines = []\n isMulti = false\n }\n }\n }\n return result\n}\n\nfunction replaceImportStatementsInsideLiteralStrings(code: string) {\n return code.replaceAll(/([\"'`])(.*?)\\1/gs, (match) => match.replaceAll(/\\nimport /gs, '\\nIMPORT '))\n}\n\nfunction replaceImportStatementsInsideBlockComments(code: string) {\n return code.replaceAll(/\\/\\*(.*?)\\*\\//gs, (match) => match.replaceAll(/\\nimport /gs, '\\nIMPORT '))\n}\n\n/**\n * Interface representing the result of extracting import statements from TypeScript code.\n * This interface is used to enforce consistent structure when analyzing and manipulating\n * import statements in TypeScript source files.\n */\nexport type TsExtractImportsResult = {\n /**\n * The line index where the import statement starts (0-indexed).\n */\n start: number\n /**\n * The line index of the last line of the import statement (0-indexed).\n */\n end: number\n /**\n * The complete import statement as it appears in the source code.\n */\n match: string\n /**\n * The import statement converted to a single line format.\n */\n matchOneLine: string\n}\n","import type { ImportStatement } from '@mono/tscode'\nimport fs from 'fs-extra'\nimport { parseImportStatement } from '@mono/tscode'\nimport { tsExtractImports } from '@mono/tscode'\n\n/**\n * An import statement together with the file it was found in.\n */\nexport interface FileImport {\n /** The path of the file that contains the import statement, as it was given. */\n filepath: string\n /** The parsed import statement. */\n statement: ImportStatement\n}\n\n/**\n * Reads a TypeScript file and parses its import statements.\n */\nexport function getFileImports(filepath: string): FileImport[] {\n const code = fs.readFileSync(filepath, 'utf8')\n return tsExtractImports(code).map(({ match }) => ({ filepath, statement: parseImportStatement(match) }))\n}\n","import type { Workspace } from './Workspace'\nimport { globSync } from 'glob'\nimport upath from 'upath'\n\n/**\n * Lists the absolute paths of all TypeScript files in the 'src' directory of a workspace, sorted.\n * This includes test files and other files with a semantic extname prefix. Filter with `isSourceFile` or\n * `isTestFile`, or use `getWorkspaceSourceFiles` or `getWorkspaceTestFiles`.\n */\nexport function getWorkspaceFiles(workspace: Workspace): string[] {\n return globSync('src/**/*.{ts,tsx,mts,cts}', { cwd: workspace.path, ignore: '**/node_modules/**', posix: true })\n .map((filepath) => upath.join(workspace.path, filepath))\n .sort()\n}\n","/**\n * Whether fspath is a subpath of a parent directory with the given name.\n */\nexport function hasParentDirname(fspath: string, name: string) {\n return new RegExp(`(^|[/\\\\\\\\])${name}[/\\\\\\\\]`).test(fspath)\n}\n","import { hasExtnamePrefix } from './hasExtnamePrefix'\nimport { hasParentDirname } from '@mono/path'\n\n/**\n * Whether the file is a source file: located in a 'src' directory and without a semantic extname prefix.\n * So not a test file, example file, declaration file etc.\n */\nexport function isSourceFile(filepath: string): boolean {\n return hasParentDirname(filepath, 'src') && !hasExtnamePrefix(filepath)\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaceFiles } from './getWorkspaceFiles'\nimport { isSourceFile } from '../util/isSourceFile'\n\n/**\n * Lists the absolute paths of the source files of a workspace: the TypeScript files in its 'src' directory that\n * have no semantic extname prefix. So no test files, example files, declaration files etc.\n */\nexport function getWorkspaceSourceFiles(workspace: Workspace): string[] {\n return getWorkspaceFiles(workspace).filter((filepath) => isSourceFile(filepath))\n}\n","import type { FileImport } from './getFileImports'\nimport type { Workspace } from '../workspace/Workspace'\nimport { getFileImports } from './getFileImports'\nimport { getWorkspaceSourceFiles } from '../workspace/getWorkspaceSourceFiles'\nimport { getWorkspaces } from '../workspace/getWorkspaces'\n\n/**\n * Parses the import statements of every source file in the given workspaces.\n *\n * @param workspaces - Defaults to all workspaces of the repo that contains the current working directory.\n */\nexport function getAllImports(workspaces: Workspace[] = getWorkspaces()): FileImport[] {\n return workspaces.flatMap((ws) => getWorkspaceSourceFiles(ws).flatMap((filepath) => getFileImports(filepath)))\n}\n","import type { Workspace } from '../workspace/Workspace'\nimport { getFileImports } from './getFileImports'\nimport { getWorkspaceFiles } from '../workspace/getWorkspaceFiles'\nimport { getWorkspaceSourceFiles } from '../workspace/getWorkspaceSourceFiles'\nimport upath from 'upath'\n\n/**\n * An import where a file imports its own workspace by package name instead of by relative path.\n */\nexport interface WorkspaceSelfImport {\n /** Absolute path of the file that contains the import. */\n filepath: string\n /** The module specifier to replace: the workspace's package name. */\n replaceValue: string\n /** The relative module specifier to replace it with. */\n withValue: string\n}\n\n/**\n * Finds the imports in a workspace's files that import the workspace itself by its package name.\n * Such imports should be relative instead.\n *\n * The suggested replacement points at the source file named after the first imported name, if there is one.\n * Otherwise it points at the workspace's src/index file.\n */\nexport function getWorkspaceSelfImports(workspace: Workspace): WorkspaceSelfImport[] {\n const sourceFilesByName = new Map(\n getWorkspaceSourceFiles(workspace).map((filepath) => [upath.parse(filepath).name, filepath])\n )\n const indexFilepath = upath.join(workspace.path, 'src', 'index.ts')\n\n return getWorkspaceFiles(workspace).flatMap((filepath) =>\n getFileImports(filepath)\n .filter(({ statement }) => statement.modulePath.path === workspace.name)\n .map(({ statement }) => {\n const firstName = statement.getNames({ unaliasNamedImports: true })[0]?.replace(/^type /, '')\n const target = (firstName && sourceFilesByName.get(firstName)) || indexFilepath\n return { filepath, replaceValue: workspace.name, withValue: toRelativeSpecifier(filepath, target) }\n })\n )\n}\n\nfunction toRelativeSpecifier(fromFilepath: string, toFilepath: string): string {\n const relative = upath.trimExt(upath.relative(upath.dirname(fromFilepath), toFilepath))\n return relative.startsWith('.') ? relative : `./${relative}`\n}\n","import { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Gets the absolute path to the repository's package.json file.\n */\nexport function getRootPackageJsonPath(): string {\n return upath.joinSafe(getRepoRootDirpath(), 'package.json')\n}\n","import fs from 'fs-extra'\nimport { getRootPackageJsonPath } from './getRootPackageJsonPath'\n\n/**\n * Reads the repository's root package.json file.\n */\nexport async function getRootPackageJson() {\n return await fs.readJson(getRootPackageJsonPath())\n}\n","import { getRootPackageJson } from './getRootPackageJson'\nimport { glob } from 'glob'\nimport upath from 'upath'\n\n/**\n * Returns an array of all workspace directory paths.\n */\nexport async function getAllWorkspacePaths(): Promise<string[]> {\n const pkg = await getRootPackageJson()\n return (\n await Promise.all(pkg.workspaces.filter((ws: string) => ws !== '.').map((pattern: string) => glob(pattern)))\n )\n .flat()\n\n .map((fp) => upath.normalizeSafe(fp))\n}\n","import { getAllWorkspacePaths } from './getAllWorkspacePaths'\nimport upath from 'upath'\n\n/**\n * Gets all workspace package.json file paths.\n */\nexport async function getAllWorkspacePackageJsonPaths(): Promise<string[]> {\n const paths = await getAllWorkspacePaths()\n return paths.map((p) => upath.join(p, 'package.json'))\n}\n","import fs from 'fs-extra'\nimport { getAllWorkspacePackageJsonPaths } from './getAllWorkspacePackageJsonPaths'\n\n/**\n * Gets all workspace package.json contents.\n */\nexport async function getAllWorkspacePackageJsons() {\n const paths = await getAllWorkspacePackageJsonPaths()\n return paths.map((p) => fs.readJsonSync(p))\n}\n","import { getAllWorkspacePackageJsons } from './getAllWorkspacePackageJsons'\n\n/**\n * Gets all workspace package names.\n */\nexport async function getAllWorkspacePackageNames(): Promise<string[]> {\n const pkgs = await getAllWorkspacePackageJsons()\n return pkgs.map((p) => p.name)\n}\n","import { getAllWorkspacePackageNames } from './getAllWorkspacePackageNames'\n\n/**\n * Finds the full package name for a workspace given a partial name.\n */\nexport async function findWorkspacePackageName(name: string): Promise<string | undefined> {\n const wsPkgNames = await getAllWorkspacePackageNames()\n return wsPkgNames.find((n) => n === name) || wsPkgNames.find((n) => n === `@mono/${name}`)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\n\n/**\n * A record mapping semantic extname prefixes to their descriptions.\n *\n * - `d`: Declaration files\n * - `test`: Vitest test suite files\n * - `examples`: Files containing working and tested example usage code (included in git, but ignored by most repo tools)\n * - `benchmark`: Benchmark files (included in git, but ignored by most repo tools)\n * - `temp`: Temporary files (ignored by git, build, tests, etc.)\n * - `wip`: Work in progress files (ignored by git, build, tests, etc.)\n */\nexport const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, string> = {\n d: 'declarations',\n test: 'vitest test suite',\n examples: 'contains working and tested example usage code. Included in git, but ignored by most repo tools',\n benchmark: 'benchmark files, included in git, but ignored by most repo tools.',\n temp: 'temporary files, ignored by git, build, tests, etc.',\n wip: 'work in progress, ignored by git, build, tests, etc.',\n} as const\n","import type { PackageJson } from '@mono/types'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport { globSync } from 'glob'\nimport path from 'upath'\n\n/**\n * Get all workspace directory paths by reading the workspace patterns from the root package.json.\n */\nexport function getWorkspaceDirpaths(): string[] {\n const rootDirpath = getRepoRootDirpath()\n const pkg = fs.readJsonSync(path.joinSafe(rootDirpath, 'package.json')) as PackageJson\n if (!pkg.workspaces) {\n throw new Error(`No workspaces found in package.json at ${rootDirpath}`)\n }\n return pkg.workspaces\n .filter((ws) => ws !== '.')\n .flatMap((workspace: string) => globSync(workspace))\n .map(path.normalizeSafe)\n}\n","import { createCompilerHost } from 'typescript'\nimport fs from 'fs-extra/esm'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport { resolveModuleName } from 'typescript'\nimport upath from 'upath'\n\n/**\n * Returns the resolved import path (relative from repo root)\n */\nexport function resolveModuleImportPath(filepath: string, importFrom: string) {\n const rootdir = getRepoRootDirpath()\n const result = resolveModuleName(\n importFrom,\n filepath,\n {\n paths: fs.readJsonSync(upath.joinSafe(rootdir, 'tsconfig.paths.json')).compilerOptions.paths,\n allowJs: true,\n allowArbitraryExtensions: true,\n allowImportingTsExtensions: true,\n allowSyntheticDefaultImports: true,\n esModuleInterop: true,\n strict: false,\n },\n createCompilerHost({}, true)\n )\n const f = result.resolvedModule?.resolvedFileName\n if (f) {\n result.resolvedModule.resolvedFileName = upath.relative(rootdir, f)\n }\n return result.resolvedModule\n}\n","/**\n * Bumps the semantic versioning (SemVer) of a given version string or array based on the specified level.\n * The function supports 'major', 'minor', and 'patch' levels.\n *\n * @remarks\n * This function will mutate the original version if it's an array.\n *\n * @param version - The current version. It can be a string (e.g., '1.0.0') or an array of strings or numbers (e.g., ['1', '0', '0'] or [1, 0, 0]).\n * @param level - The level of the version bump. It can be 'major', 'minor', or 'patch'.\n *\n * @returns The bumped version as a string.\n *\n * @example\n * ```ts\n * semverVersionBump('1.0.0', 'major'); // '2.0.0'\n * semverVersionBump([1, 0, 4], 'minor'); // '1.1.0'\n * semverVersionBump(['1', '0', '0'], 'patch'); // '1.0.1'\n * ```\n */\nexport function semverVersionBump(\n version: string | string[] | number[],\n level: 'major' | 'minor' | 'patch'\n): string {\n const arr = (typeof version === 'string' ? version.split('.') : version).map(Number)\n switch (level) {\n case 'major': {\n arr[0] += 1\n arr[1] = 0\n arr[2] = 0\n\n break\n }\n case 'minor': {\n arr[1] += 1\n arr[2] = 0\n\n break\n }\n case 'patch': {\n arr[2] += 1\n\n break\n }\n // No default\n }\n return arr.join('.')\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaces } from './getWorkspaces'\nimport upath from 'upath'\n\n/**\n * Finds a workspace by its package name, its directory name or its path relative to the repo root.\n *\n * @example\n * ```ts\n * findWorkspace('@mono/string') // by package name\n * findWorkspace('string') // by directory name\n * findWorkspace('libs/string') // by path relative to the repo root\n * ```\n */\nexport function findWorkspace(query: string, workspaces: Workspace[] = getWorkspaces()): Workspace | undefined {\n return (\n workspaces.find((ws) => ws.name === query) ??\n workspaces.find((ws) => ws.relativePath === upath.normalize(query)) ??\n workspaces.find((ws) => upath.basename(ws.path) === query)\n )\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaceFiles } from './getWorkspaceFiles'\nimport { isTestFile } from '../util/isTestFile'\n\n/**\n * Lists the absolute paths of the test files (*.test.*) in the 'src' directory of a workspace.\n */\nexport function getWorkspaceTestFiles(workspace: Workspace): string[] {\n return getWorkspaceFiles(workspace).filter((filepath) => isTestFile(filepath))\n}\n"]}
|
package/lib/index.js
CHANGED
|
@@ -781,3 +781,5 @@ function getWorkspaceTestFiles(workspace) {
|
|
|
781
781
|
__name(getWorkspaceTestFiles, "getWorkspaceTestFiles");
|
|
782
782
|
|
|
783
783
|
export { SemanticExtnamePrefix, SemanticExtnamePrefixDescriptions, createDependencyGraph, findWorkspace, findWorkspacePackageName, getAllImports, getAllWorkspacePackageJsonPaths, getAllWorkspacePackageJsons, getAllWorkspacePackageNames, getAllWorkspacePaths, getDependencyName, getExternalDependencyVersions, getFileImports, getImportsRecursively, getReachableModules, getRepoRootDirpath, getRootPackageJson, getRootPackageJsonPath, getTsconfigPaths, getWorkspaceDependencies, getWorkspaceDependencyProblems, getWorkspaceDirpaths, getWorkspaceFiles, getWorkspaceModules, getWorkspaceSelfImports, getWorkspaceSourceFiles, getWorkspaceTestFiles, getWorkspaces, hasExtnamePrefix, isSourceFile, isTestFile, readWorkspace, resolveModuleImportPath, semverVersionBump, summarizeDependencies };
|
|
784
|
+
//# sourceMappingURL=index.js.map
|
|
785
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/SemanticExtnamePrefix.ts","../../src/deps/getDependencyName.ts","../../src/util/getRepoRootDirpath.ts","../../src/workspace/readWorkspace.ts","../../src/workspace/getWorkspaces.ts","../../src/deps/createDependencyGraph.ts","../../src/deps/getExternalDependencyVersions.ts","../../src/deps/getReachableModules.ts","../../src/deps/summarizeDependencies.ts","../../src/deps/getImportsRecursively.ts","../../src/deps/getWorkspaceModules.ts","../../src/util/SemanticExtnamePrefixes.ts","../../src/util/hasExtnamePrefix.ts","../../src/util/isTestFile.ts","../../src/deps/getWorkspaceDependencies.ts","../../src/util/getTsconfigPaths.ts","../../src/deps/getWorkspaceDependencyProblems.ts","../../../tscode/src/importStatementToOneLiner.ts","../../../tscode/src/importStatementToFormattedOneLiner.ts","../../../regex/src/rexec.ts","../../../tscode/src/parseImportStatement.ts","../../../tscode/src/tsCrlfToLf.ts","../../../tscode/src/tsExtractImports.ts","../../src/imports/getFileImports.ts","../../src/workspace/getWorkspaceFiles.ts","../../../path/src/lib/hasParentDirname.ts","../../src/util/isSourceFile.ts","../../src/workspace/getWorkspaceSourceFiles.ts","../../src/imports/getAllImports.ts","../../src/imports/getWorkspaceSelfImports.ts","../../src/methods/getRootPackageJsonPath.ts","../../src/methods/getRootPackageJson.ts","../../src/methods/getAllWorkspacePaths.ts","../../src/methods/getAllWorkspacePackageJsonPaths.ts","../../src/methods/getAllWorkspacePackageJsons.ts","../../src/methods/getAllWorkspacePackageNames.ts","../../src/methods/findWorkspacePackageName.ts","../../src/util/SemanticExtnamePrefixDescriptions.ts","../../src/util/getWorkspaceDirpaths.ts","../../src/util/resolveModuleImportPath.ts","../../src/util/semverVersionBump.ts","../../src/workspace/findWorkspace.ts","../../src/workspace/getWorkspaceTestFiles.ts"],"names":["SemanticExtnamePrefix","d","test","examples","benchmark","temp","wip","getDependencyName","moduleSpecifier","split","slice","startsWith","join","getRepoRootDirpath","memoize","fspath","process","cwd","recurse","dirpath","upath","normalizeSafe","pkgpath","joinSafe","fs","existsSync","readJsonSync","throws","workspaces","parent","dirname","Error","readWorkspace","root","path","resolve","packageJsonPath","packageJson","name","relativePath","relative","origin","basename","getWorkspaces","filter","pattern","flatMap","globSync","posix","sort","map","NODE_MODULES","createDependencyGraph","options","graph","modules","Map","entries","ws","dir","entry","length","excludedPrefixes","Object","values","prefix","includeTests","tsConfigPath","hasTsConfig","cruise","default","extractTSConfig","output","baseDir","tsPreCompilationDeps","doNotFollow","exclude","tsConfig","fileName","enhancedResolveOptions","extensions","conditionNames","mainFields","exportsFields","undefined","TypeError","workspacesByPathLength","toSorted","a","b","findWorkspace","filepath","find","source","coreModule","couldNotResolve","dependencies","includes","workspace","module","dependency","toGraphDependency","set","from","specifier","resolved","circular","base","typeOnly","dependencyTypes","kind","pathInNodeModules","lastIndexOf","getExternalDependencyVersions","versions","packageDir","pkg","readPackageJson","toCaretRange","version","typesName","replace","typesPkg","hasOwnTypes","fromEntries","localeCompare","types","typings","JSON","stringify","exports","getReachableModules","follow","reached","stack","toReversed","pop","get","has","next","dep","push","summarizeDependencies","builtin","namesOf","external","internal","names","Set","getImportsRecursively","entryPoints","missing","entryModules","workspaceNames","size","workspaceName","unresolved","describe","filepaths","recursive","local","getWorkspaceModules","hasExtnamePrefix","tsFilepath","prefixes","SemanticExtnamePrefixes","RegExp","flat","isTestFile","getWorkspaceDependencies","own","summary","getTsconfigPaths","compilerOptions","paths","getWorkspaceDependencyProblems","rootPkg","tsconfigPaths","rootDependencies","rootDevDependencies","devDependencies","imported","importedNames","importedByTests","keys","unused","missingDev","importStatementToOneLiner","code","strip","replaceAll","trim","importStatementToFormattedOneLiner","m","rexec","regex","string","flags","result","match","exec","index","lastIndex","location","findLineColumn","groups","assign","content","lines","line","substring","splice","startOfLineIndex","col","parseImportStatement","statement","oneliner","keywords","hasTypeKeyword","type","specifiers","children","s","isType","o","modulePath","mod","p","isWorkspacePath","isAbsolute","isBuiltin","quote","semi","ImportStatementParser","getNames","splitBySpecifier","ins","unaliasNamedImports","Boolean","tsCrlfToLf","tsExtractImports","replaceImportStatementsInsideLiteralStrings","replaceImportStatementsInsideBlockComments","isFirstLine","isFirstLineInMulti","isLastLineInMulti","isMulti","impLines","l","matchOneLine","start","end","getFileImports","readFileSync","getWorkspaceFiles","ignore","hasParentDirname","isSourceFile","getWorkspaceSourceFiles","getAllImports","getWorkspaceSelfImports","sourceFilesByName","parse","indexFilepath","firstName","target","replaceValue","withValue","toRelativeSpecifier","fromFilepath","toFilepath","trimExt","getRootPackageJsonPath","getRootPackageJson","readJson","getAllWorkspacePaths","Promise","all","glob","fp","getAllWorkspacePackageJsonPaths","getAllWorkspacePackageJsons","getAllWorkspacePackageNames","pkgs","findWorkspacePackageName","wsPkgNames","n","SemanticExtnamePrefixDescriptions","getWorkspaceDirpaths","rootDirpath","resolveModuleImportPath","importFrom","rootdir","resolveModuleName","allowJs","allowArbitraryExtensions","allowImportingTsExtensions","allowSyntheticDefaultImports","esModuleInterop","strict","createCompilerHost","f","resolvedModule","resolvedFileName","semverVersionBump","level","arr","Number","query","normalize","getWorkspaceTestFiles"],"mappings":";;;;;;;;;;;;;AAIO,IAAMA,qBAAAA,GAAwB;EACnCC,CAAAA,EAAG,GAAA;EACHC,IAAAA,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,EAAAA,KAAOA,EAAAA,CAAGnB,YAAAA,KAAiBnB,MAAAA,CAAMiS,SAAAA,CAAUD,KAAAA,CAAAA,CAAAA,IAC5DxR,UAAAA,CAAWgE,IAAAA,CAAK,CAAClC,EAAAA,KAAOtC,MAAAA,CAAMsB,QAAAA,CAASgB,EAAAA,CAAGxB,IAAI,CAAA,KAAMkR,KAAAA,CAAAA;AAExD;AANgB1N,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA;;;ACPT,SAAS4N,sBAAsBpN,SAAAA,EAAoB;AACxD,EAAA,OAAO4J,iBAAAA,CAAkB5J,SAAAA,CAAAA,CAAWtD,MAAAA,CAAO,CAAC+C,QAAAA,KAAa6E,UAAAA,CAAW7E,QAAAA,CAAAA,CAAAA;AACtE;AAFgB2N,MAAAA,CAAAA,qBAAAA,EAAAA,uBAAAA,CAAAA","file":"index.js","sourcesContent":["/**\n * Constants for semantic filename prefixes used to categorize files by their purpose.\n */\nexport type SemanticExtnamePrefix = (typeof SemanticExtnamePrefix)[keyof typeof SemanticExtnamePrefix]\nexport const SemanticExtnamePrefix = {\n d: 'd',\n test: 'test',\n examples: 'examples',\n benchmark: 'benchmark',\n temp: 'temp',\n wip: 'wip',\n} as const\n","/**\n * Returns the package name part of a module specifier.\n *\n * @example\n * ```ts\n * getDependencyName('es-toolkit/array') // 'es-toolkit'\n * getDependencyName('@mono/string/camelCase') // '@mono/string'\n * ```\n */\nexport function getDependencyName(moduleSpecifier: string): string {\n return moduleSpecifier\n .split('/')\n .slice(0, moduleSpecifier.startsWith('@') ? 2 : 1)\n .join('/')\n}\n","import fs from 'fs-extra'\nimport { memoize } from 'es-toolkit'\nimport upath from 'upath'\n\n/**\n * Get the root directory path of the monorepo by finding the package.json with workspaces configuration.\n */\nexport const getRepoRootDirpath = memoize((fspath: string = process.cwd()) =>\n (function recurse(dirpath: string) {\n dirpath = upath.normalizeSafe(dirpath)\n const pkgpath = upath.joinSafe(dirpath, 'package.json')\n if (fs.existsSync(pkgpath) && !!fs.readJsonSync(pkgpath, { throws: false })?.workspaces?.join('')) {\n return dirpath\n }\n const parent = upath.dirname(dirpath)\n if (parent === dirpath) {\n throw new Error(`Could not find repo root from current dir: ${fspath}`)\n }\n return recurse(parent)\n })(fspath)\n)\n\n// /**\n// * Get the root directory path of the git repository containing the specified folder.\n// */\n// export const getRepoRootDirpath2 = memoize((rootFolder: string = process.cwd()) => {\n// /** How much git may print of the status of a working tree: far more than any real one. */\n// const LARGEST_GIT_OUTPUT_BYTES = 512 * 1024 * 1024\n\n// const runGit = (gitArguments: readonly string[]) =>\n// spawnSync('git', gitArguments, { cwd: rootFolder, maxBuffer: LARGEST_GIT_OUTPUT_BYTES, windowsHide: true })\n// const topLevel = runGit(['rev-parse', '--show-toplevel'])\n// if (topLevel.error) {\n// return { whyUnavailable: `git could not be started (${topLevel.error.message}), so the repository is unseen` }\n// }\n// if (topLevel.status !== 0) {\n// return { whyUnavailable: `${rootFolder} is not in a git checkout` }\n// }\n// }, {})\n","import type { PackageJson } from '@mono/types'\nimport type { Workspace } from './Workspace'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Reads the package.json of a workspace directory and returns the workspace as plain data.\n *\n * @param dirpath - The workspace directory. A relative path is resolved against the repo root.\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function readWorkspace(dirpath: string, root: string = getRepoRootDirpath()): Workspace {\n const path = upath.resolve(root, dirpath)\n const packageJsonPath = upath.join(path, 'package.json')\n const packageJson = fs.readJsonSync(packageJsonPath) as PackageJson\n if (!packageJson.name) {\n throw new Error(`Workspace package.json missing 'name' field: ${packageJsonPath}`)\n }\n return {\n name: packageJson.name,\n path,\n relativePath: upath.relative(upath.resolve(root), path),\n origin: upath.basename(upath.dirname(path)),\n packageJson,\n }\n}\n","import type { PackageJson } from '@mono/types'\nimport type { Workspace } from './Workspace'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { globSync } from 'glob'\nimport { readWorkspace } from './readWorkspace'\nimport upath from 'upath'\n\n/**\n * Reads every workspace matched by the 'workspaces' patterns of the root package.json.\n * The repo root itself is not included.\n *\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function getWorkspaces(root: string = getRepoRootDirpath()): Workspace[] {\n const packageJsonPath = upath.join(root, 'package.json')\n const packageJson = fs.readJsonSync(packageJsonPath) as PackageJson\n if (!packageJson.workspaces) {\n throw new Error(`Root package.json missing 'workspaces' field: ${packageJsonPath}`)\n }\n return packageJson.workspaces\n .filter((pattern) => pattern !== '.')\n .flatMap((pattern) => globSync(pattern, { cwd: root, posix: true }))\n .filter((dirpath) => fs.existsSync(upath.join(root, dirpath, 'package.json')))\n .sort()\n .map((dirpath) => readWorkspace(dirpath, root))\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphDependency } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { IDependency } from 'dependency-cruiser'\nimport { SemanticExtnamePrefix } from '../util/SemanticExtnamePrefix'\nimport type { Workspace } from '../workspace/Workspace'\nimport fs from 'fs-extra'\nimport { getDependencyName } from './getDependencyName'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { getWorkspaces } from '../workspace/getWorkspaces'\nimport upath from 'upath'\n\n/**\n * Options of `createDependencyGraph`.\n */\nexport interface CreateDependencyGraphOptions {\n /** The repo root. Defaults to the root of the repo that contains the current working directory. */\n root?: string\n /**\n * The files and directories to start from. Relative paths are resolved against the repo root.\n * Everything they import is followed, also into other workspaces. Defaults to the 'src' directory of every\n * workspace.\n */\n entries?: string[]\n /** Whether to include test files (*.test.*). Defaults to false. */\n includeTests?: boolean\n /** The workspaces of the repo. Defaults to `getWorkspaces(root)`. */\n workspaces?: Workspace[]\n}\n\nconst NODE_MODULES = 'node_modules/'\n\n/**\n * Analyzes which files import what, using dependency-cruiser, and returns it as a graph of plain data.\n *\n * Imports are resolved the same way the repo's TypeScript code is: with the 'paths' of the tsconfig.json in the\n * repo root and the 'exports' of package.json files. Files with a semantic extname prefix (examples, benchmarks,\n * declarations etc.) are left out, and so are test files unless `includeTests` is set. Packages in node_modules\n * are not followed.\n *\n * Analyzing a whole repo takes around a second, so create the graph once and pass it to the functions that\n * read from it.\n */\nexport async function createDependencyGraph(options: CreateDependencyGraphOptions = {}): Promise<DependencyGraph> {\n const root = upath.resolve(options.root ?? getRepoRootDirpath())\n const workspaces = options.workspaces ?? getWorkspaces(root)\n const graph: DependencyGraph = { root, workspaces, modules: new Map() }\n\n const entries = (\n options.entries ?? workspaces.map((ws) => upath.join(ws.path, 'src')).filter((dir) => fs.existsSync(dir))\n ).map((entry) => upath.relative(root, upath.resolve(root, entry)))\n if (!entries.length) {\n return graph\n }\n\n const excludedPrefixes = Object.values(SemanticExtnamePrefix).filter(\n (prefix) => !(options.includeTests && prefix === SemanticExtnamePrefix.test)\n )\n const tsConfigPath = upath.join(root, 'tsconfig.json')\n const hasTsConfig = fs.existsSync(tsConfigPath)\n\n // Loaded on demand: dependency-cruiser is ESM-only and slow to load, and most of this library does not need it.\n const { cruise } = await import('dependency-cruiser')\n const { default: extractTSConfig } = await import('dependency-cruiser/config-utl/extract-ts-config')\n\n const { output } = await cruise(\n entries,\n {\n baseDir: root,\n tsPreCompilationDeps: true,\n doNotFollow: { path: ['node_modules'] },\n // Only the repo's own files are excluded: packages often resolve to a file in 'dist' or to a '.d.ts' file.\n exclude: {\n path: [\n `^(?!.*${NODE_MODULES}).*[.](${excludedPrefixes.join('|')})[.][^/]+$`,\n `^(?!.*${NODE_MODULES}).*(^|/)(dist|coverage)/`,\n ],\n },\n ...(hasTsConfig && { tsConfig: { fileName: tsConfigPath } }),\n enhancedResolveOptions: {\n extensions: ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json'],\n conditionNames: ['import', 'require', 'node', 'default', 'types'],\n mainFields: ['module', 'main', 'types', 'typings'],\n exportsFields: ['exports'],\n },\n },\n undefined,\n hasTsConfig ? { tsConfig: extractTSConfig(tsConfigPath) } : undefined\n )\n if (typeof output === 'string') {\n throw new TypeError('Expected dependency-cruiser to return its result as an object.')\n }\n\n // Longest path first, so that a workspace nested in another one wins.\n const workspacesByPathLength = workspaces.toSorted((a, b) => b.relativePath.length - a.relativePath.length)\n const findWorkspace = (filepath: string) =>\n workspacesByPathLength.find((ws) => filepath.startsWith(`${ws.relativePath}/`))\n\n for (const { source, coreModule, couldNotResolve, dependencies } of output.modules) {\n // The output also lists what the repo's files depend on. Only the repo's own files are modules of the graph.\n if (coreModule || couldNotResolve || source.includes(NODE_MODULES)) {\n continue\n }\n const workspace = findWorkspace(source)\n const module: GraphModule = {\n path: source,\n ...(workspace && { workspace }),\n dependencies: dependencies.map((dependency) => toGraphDependency(dependency, workspace, findWorkspace)),\n }\n graph.modules.set(source, module)\n }\n\n return graph\n}\n\nfunction toGraphDependency(\n dependency: IDependency,\n from: Workspace | undefined,\n findWorkspace: (filepath: string) => Workspace | undefined\n): GraphDependency {\n const { module: specifier, resolved, circular } = dependency\n const base = { specifier, resolved, circular, typeOnly: dependency.dependencyTypes.includes('type-only') }\n\n if (dependency.coreModule) {\n return { ...base, kind: 'builtin', name: specifier }\n }\n if (dependency.couldNotResolve) {\n return { ...base, kind: 'unresolved' }\n }\n if (resolved.includes(NODE_MODULES)) {\n // Named after its directory in node_modules, which is what has to be listed in a package.json.\n const pathInNodeModules = resolved.slice(resolved.lastIndexOf(NODE_MODULES) + NODE_MODULES.length)\n return { ...base, kind: 'external', name: getDependencyName(pathInNodeModules) }\n }\n const workspace = findWorkspace(resolved)\n if (workspace && workspace.name !== from?.name) {\n return { ...base, kind: 'workspace', name: workspace.name }\n }\n return { ...base, kind: 'local' }\n}\n","import type { GraphModule } from './DependencyGraph'\nimport fs from 'fs-extra'\nimport upath from 'upath'\n\nconst NODE_MODULES = 'node_modules/'\n\n/**\n * Maps every package the given modules import to a caret range of its installed version, ready to be put in the\n * 'dependencies' of a package.json. Sorted by package name.\n *\n * If a package ships no types of its own and its `@types/` package is installed, that is included too.\n *\n * @param modules - Modules of a dependency graph.\n * @param root - The repo root: the `root` of the dependency graph.\n */\nexport function getExternalDependencyVersions(modules: GraphModule[], root: string): Record<string, string> {\n const versions: Record<string, string> = {}\n\n for (const dependency of modules.flatMap((module) => module.dependencies)) {\n if (dependency.kind !== 'external' || !dependency.name || dependency.name in versions) {\n continue\n }\n const { name, resolved } = dependency\n const packageDir = upath.join(root, resolved.slice(0, resolved.lastIndexOf(NODE_MODULES)), NODE_MODULES, name)\n const pkg = readPackageJson(packageDir)\n versions[name] = toCaretRange(pkg?.version)\n\n const typesName = `@types/${name.replace(/^@/, '').replace('/', '__')}`\n const typesPkg =\n !name.startsWith('@types/') && !hasOwnTypes(packageDir, pkg)\n ? readPackageJson(upath.join(root, NODE_MODULES, typesName))\n : undefined\n if (typesPkg) {\n versions[typesName] = toCaretRange(typesPkg.version)\n }\n }\n\n return Object.fromEntries(Object.entries(versions).sort(([a], [b]) => a.localeCompare(b)))\n}\n\ninterface InstalledPackageJson {\n version?: string\n types?: string\n typings?: string\n exports?: unknown\n}\n\nfunction readPackageJson(dirpath: string): InstalledPackageJson | undefined {\n return fs.readJsonSync(upath.join(dirpath, 'package.json'), { throws: false }) ?? undefined\n}\n\nfunction hasOwnTypes(packageDir: string, pkg: InstalledPackageJson | undefined): boolean {\n return (\n !!pkg?.types ||\n !!pkg?.typings ||\n JSON.stringify(pkg?.exports ?? '').includes('\"types\"') ||\n fs.existsSync(upath.join(packageDir, 'index.d.ts'))\n )\n}\n\nfunction toCaretRange(version: string | undefined): string {\n return version ? `^${version}` : ''\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { DependencyKind } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\n\n/**\n * Returns the given modules and every module they import, directly or through other modules, in the order they\n * are discovered. Each module is returned once.\n *\n * @param graph - The dependency graph.\n * @param entries - The paths of the modules to start from, relative to the repo root.\n * @param follow - The kinds of dependency to follow. Defaults to both `local` and `workspace`. Pass `['local']`\n * to stay within the workspaces of the entries.\n */\nexport function getReachableModules(\n graph: DependencyGraph,\n entries: string[],\n follow: DependencyKind[] = ['local', 'workspace']\n): GraphModule[] {\n const reached = new Map<string, GraphModule>()\n const stack = entries.toReversed()\n\n while (stack.length) {\n const path = stack.pop()!\n const module = graph.modules.get(path)\n if (!module || reached.has(path)) {\n continue\n }\n reached.set(path, module)\n const next = module.dependencies.filter((dep) => follow.includes(dep.kind)).map((dep) => dep.resolved)\n stack.push(...next.toReversed())\n }\n\n return [...reached.values()]\n}\n","import type { GraphDependency } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\n\n/**\n * The names of what a set of modules depends on, each sorted and without duplicates.\n */\nexport interface DependencySummary {\n /** Node built-in modules, without the 'node:' prefix. */\n builtin: string[]\n /** Package names of dependencies in node_modules. */\n external: string[]\n /** Package names of other workspaces of the repo. */\n internal: string[]\n}\n\n/**\n * Lists the names of everything the given modules import directly, grouped by kind.\n */\nexport function summarizeDependencies(modules: GraphModule[]): DependencySummary {\n const dependencies = modules.flatMap((module) => module.dependencies)\n return {\n builtin: namesOf(dependencies, 'builtin'),\n external: namesOf(dependencies, 'external'),\n internal: namesOf(dependencies, 'workspace'),\n }\n}\n\nfunction namesOf(dependencies: GraphDependency[], kind: GraphDependency['kind']): string[] {\n const names = dependencies.filter((dep) => dep.kind === kind).map((dep) => dep.name!)\n return [...new Set(names)].sort()\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport { createDependencyGraph } from './createDependencyGraph'\nimport fs from 'fs-extra'\nimport { getExternalDependencyVersions } from './getExternalDependencyVersions'\nimport { getReachableModules } from './getReachableModules'\nimport { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport { summarizeDependencies } from './summarizeDependencies'\nimport upath from 'upath'\n\n/**\n * What a set of files depends on.\n */\nexport interface ImportedDependencies {\n /** Packages in node_modules, mapped to a caret range of the installed version. */\n external: Record<string, string>\n /** Node built-in modules, without the 'node:' prefix. */\n builtin: string[]\n /** Package names of other workspaces of the repo. */\n internal: string[]\n}\n\n/**\n * The result of `getImportsRecursively`.\n */\nexport interface ImportsRecursivelyResult {\n /** Every file that is reached from the entry points, in the order of discovery. Relative to the repo root. */\n filepaths: string[]\n /** What all the reached files depend on, including the files in other workspaces. */\n recursive: ImportedDependencies\n /** What the reached files in the workspace of the entry points depend on. */\n local: ImportedDependencies\n}\n\n/**\n * Follows the imports of the given entry points through the repo and lists what is depended on along the way.\n *\n * @param entryPoints - Files of a single workspace. Relative paths are resolved against the repo root.\n * @param options.root - The repo root. Defaults to the root of the repo that contains the current working directory.\n * @param options.graph - A dependency graph to read from. By default one is created from the entry points.\n * @throws If the entry points are not all in the same workspace, or if an import cannot be resolved.\n */\nexport async function getImportsRecursively(\n entryPoints: string[],\n options: { root?: string; graph?: DependencyGraph } = {}\n): Promise<ImportsRecursivelyResult> {\n const root = upath.resolve(options.graph?.root ?? options.root ?? getRepoRootDirpath())\n const entries = entryPoints.map((entry) => upath.relative(root, upath.resolve(root, entry)))\n const missing = entries.find((entry) => !fs.existsSync(upath.join(root, entry)))\n if (missing) {\n throw new Error(`Entry point not found: ${missing}`)\n }\n const graph = options.graph ?? (await createDependencyGraph({ root, entries }))\n\n const entryModules = entries.map((entry) => {\n const module = graph.modules.get(entry)\n if (!module) {\n throw new Error(`Entry point is not in the dependency graph: ${entry}`)\n }\n return module\n })\n const workspaceNames = new Set(entryModules.map((module) => module.workspace?.name))\n if (workspaceNames.size > 1) {\n throw new Error(`All entry points must be in the same workspace. Got: ${[...workspaceNames].join(', ')}`)\n }\n const [workspaceName] = workspaceNames\n\n const reached = getReachableModules(graph, entries)\n for (const module of reached) {\n const unresolved = module.dependencies.find((dep) => dep.kind === 'unresolved')\n if (unresolved) {\n throw new Error(`Could not resolve \"${unresolved.specifier}\", imported in ${module.path}`)\n }\n }\n\n const describe = (modules: GraphModule[]): ImportedDependencies => {\n const { builtin, internal } = summarizeDependencies(modules)\n return {\n external: getExternalDependencyVersions(modules, root),\n builtin,\n internal: internal.filter((name) => name !== workspaceName),\n }\n }\n\n return {\n filepaths: reached.map((module) => module.path),\n recursive: describe(reached),\n local: describe(getReachableModules(graph, entries, ['local'])),\n }\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { Workspace } from '../workspace/Workspace'\n\n/**\n * Returns the modules of the dependency graph that belong to the given workspace.\n */\nexport function getWorkspaceModules(workspace: Workspace, graph: DependencyGraph): GraphModule[] {\n return [...graph.modules.values()].filter((module) => module.workspace?.name === workspace.name)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport type { UnionToTuple } from 'type-fest'\n\n/**\n * Array of all semantic extension prefixes used to categorize files by their purpose.\n */\nexport default Object.values(SemanticExtnamePrefix) as unknown as UnionToTuple<SemanticExtnamePrefix>\n","import type { Arrayable } from 'type-fest'\nimport type { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport SemanticExtnamePrefixes from './SemanticExtnamePrefixes'\n\n/**\n * Checks if a file path has any of the specified semantic extension prefixes (e.g., .test.ts).\n */\nexport function hasExtnamePrefix(\n tsFilepath: string,\n prefixes: Arrayable<SemanticExtnamePrefix> = SemanticExtnamePrefixes as unknown as SemanticExtnamePrefix[]\n) {\n return new RegExp(`[.](${[prefixes].flat(2).join('|')})[.][^/\\\\\\\\]+$`).test(tsFilepath)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\nimport { hasExtnamePrefix } from './hasExtnamePrefix'\n\n/**\n * Whether the file is a test file, e.g. 'foo.test.ts'.\n */\nexport function isTestFile(filepath: string): boolean {\n return hasExtnamePrefix(filepath, SemanticExtnamePrefix.test)\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { DependencySummary } from './summarizeDependencies'\nimport type { Workspace } from '../workspace/Workspace'\nimport { getReachableModules } from './getReachableModules'\nimport { getWorkspaceModules } from './getWorkspaceModules'\nimport { isTestFile } from '../util/isTestFile'\nimport { summarizeDependencies } from './summarizeDependencies'\n\n/**\n * Lists what the source files of a workspace depend on: node built-ins, packages and other workspaces.\n * Test files are not counted.\n *\n * @param workspace - The workspace.\n * @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`.\n * @param options.recursive - Whether to also count what the imported files of other workspaces depend on,\n * and so on. Defaults to false: only what the workspace's own files import.\n */\nexport function getWorkspaceDependencies(\n workspace: Workspace,\n graph: DependencyGraph,\n options: { recursive?: boolean } = {}\n): DependencySummary {\n const own = getWorkspaceModules(workspace, graph).filter((module) => !isTestFile(module.path))\n if (!options.recursive) {\n return summarizeDependencies(own)\n }\n const summary = summarizeDependencies(\n getReachableModules(\n graph,\n own.map((module) => module.path)\n )\n )\n return { ...summary, internal: summary.internal.filter((name) => name !== workspace.name) }\n}\n","import fs from 'fs-extra'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Reads the 'compilerOptions.paths' of the tsconfig.paths.json file in the repo root.\n * Returns an empty object if the file does not exist.\n *\n * @param root - The repo root. Defaults to the root of the repo that contains the current working directory.\n */\nexport function getTsconfigPaths(root: string = getRepoRootDirpath()): Record<string, string[]> {\n const filepath = upath.join(root, 'tsconfig.paths.json')\n if (!fs.existsSync(filepath)) {\n return {}\n }\n return fs.readJsonSync(filepath).compilerOptions?.paths ?? {}\n}\n","import type { DependencyGraph } from './DependencyGraph'\nimport type { GraphModule } from './DependencyGraph'\nimport type { PackageJson } from '@mono/types'\nimport type { Workspace } from '../workspace/Workspace'\nimport fs from 'fs-extra'\nimport { getTsconfigPaths } from '../util/getTsconfigPaths'\nimport { getWorkspaceModules } from './getWorkspaceModules'\nimport { isTestFile } from '../util/isTestFile'\nimport { summarizeDependencies } from './summarizeDependencies'\nimport upath from 'upath'\n\n/**\n * The dependency problems of a workspace. A property is left out if there is nothing to report for it.\n */\nexport interface WorkspaceDependencyProblems {\n /** Name of the directory that contains the workspace, e.g. 'libs' or 'apps'. */\n origin: string\n /** The package name of the workspace. */\n workspace: string\n /** Listed in the 'dependencies' of the workspace's package.json, but not imported by any source file. */\n unused?: string[]\n /** Imported by a source file, but not listed in the 'dependencies' of the workspace's package.json. */\n missing?: string[]\n /** Imported by a test file, but not listed in the workspace's 'dependencies' or 'devDependencies'. */\n missingDev?: string[]\n}\n\n/**\n * Compares what the files of a workspace import with what its package.json lists, and returns what does not add\n * up. Returns undefined if there are no problems.\n *\n * A dependency is not reported as missing if the root package.json lists it, or if it is one of the 'paths' in\n * the tsconfig.paths.json of the repo root.\n *\n * @param workspace - The workspace.\n * @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`. Create it with\n * `includeTests` for `missingDev` to be checked.\n */\nexport function getWorkspaceDependencyProblems(\n workspace: Workspace,\n graph: DependencyGraph\n): WorkspaceDependencyProblems | undefined {\n const rootPkg = fs.readJsonSync(upath.join(graph.root, 'package.json')) as PackageJson\n const tsconfigPaths = getTsconfigPaths(graph.root)\n const rootDependencies = rootPkg.dependencies ?? {}\n const rootDevDependencies = rootPkg.devDependencies ?? {}\n\n const modules = getWorkspaceModules(workspace, graph)\n const imported = importedNames(modules.filter((module) => !isTestFile(module.path)))\n const importedByTests = importedNames(modules.filter((module) => isTestFile(module.path)))\n const dependencies = Object.keys(workspace.packageJson.dependencies ?? {}).sort()\n const devDependencies = Object.keys(workspace.packageJson.devDependencies ?? {})\n\n const unused = dependencies.filter((name) => !imported.includes(name))\n const missing = imported\n .filter((name) => !dependencies.includes(name))\n .filter((name) => !(name in rootDependencies) && !(name in tsconfigPaths))\n const missingDev = importedByTests\n .filter((name) => !dependencies.includes(name) && !devDependencies.includes(name))\n .filter((name) => !(name in rootDependencies) && !(name in rootDevDependencies) && !(name in tsconfigPaths))\n\n if (!unused.length && !missing.length && !missingDev.length) {\n return undefined\n }\n return {\n origin: workspace.origin,\n workspace: workspace.name,\n ...(unused.length && { unused }),\n ...(missing.length && { missing }),\n ...(missingDev.length && { missingDev }),\n }\n}\n\nfunction importedNames(modules: GraphModule[]): string[] {\n const { external, internal } = summarizeDependencies(modules)\n return [...external, ...internal].sort()\n}\n","import strip from 'strip-comments'\n\n/**\n * Converts a multi-line import statement to a single line by removing comments and extra whitespace.\n * This function strips comments, normalizes whitespace, and removes trailing commas to create\n * a clean single-line import statement.\n * @param code - The import statement code to convert\n * @returns A single-line import statement with normalized formatting\n * @example\n * ```typescript\n * const multilineImport = `import {\n * foo,\n * bar\n * } from 'module'`\n *\n * importStatementToOneLiner(multilineImport)\n * // 'import { foo, bar } from 'module''\n * ```\n */\nexport function importStatementToOneLiner(code: string) {\n return (\n strip(code)\n // remove newlines\n .replaceAll(/\\r*\\n/g, ' ')\n // remove consecutive whitespace\n .replaceAll(/\\s+/g, ' ')\n // remove trailing commas\n .replace(/,\\s*}/, ' }')\n // Normalize spaces around commas\n .replaceAll(/\\s*,\\s*/g, ', ')\n // remove consecutive whitespace\n .replaceAll(/\\s+/g, ' ')\n // remove leading and trailing whitespace\n .trim()\n )\n}\n","import { importStatementToOneLiner } from './importStatementToOneLiner'\n\n/**\n * Converts a multi-line import statement to a formatted single line with proper spacing.\n * Adds spaces around braces, keywords, and other import statement elements for readability.\n * @param code - The import statement code to format\n * @returns A formatted single-line import statement\n * @example\n * ```typescript\n * importStatementToFormattedOneLiner('import{foo,bar}from\"module\"')\n * // 'import { foo, bar } from \"module\"'\n *\n * importStatementToFormattedOneLiner('import*as foo from\"module\"')\n * // 'import * as foo from \"module\"'\n * ```\n */\nexport function importStatementToFormattedOneLiner(code: string) {\n return importStatementToOneLiner(code)\n .replaceAll(/[{}]|\\bfrom\\b|\\*|\\bas\\b/g, (m) => ` ${m} `)\n .replaceAll(/\\s+,\\s*/g, ', ')\n .replaceAll(/\\s\\s+/g, ' ')\n .trim()\n}\n","/**\n * Easily perform regex 'exec' on a string. An iterable is returned which steps through the exec process and yields all the details you might need.\n * @param regex The regular expression object\n * @returns A generator that yields an object for each match.\n * @throws If the provided regex is not a RegExp instance.\n * @param string The string to perform the operation on\n * @example ```ts\n * const regex = /(?<g1>a)/g\n * const str = 'Anthony wants a girlfriend.'\n * console.log([...rexec(regex, str)])\n * // [\n * // \t{\n * // index: 9,\n * // lastIndex: 10,\n * // groups: { g1: 'a' },\n * // match: 'a',\n * // },\n * // {\n * // index: 14,\n * // lastIndex: 15,\n * // groups: { g1: 'a' },\n * // match: 'a',\n * // },\n * // ]\n * ```\n */\nexport function rexec(regex: RegExp, string: string): RexecResult[] {\n regex = new RegExp(regex.source, regex.flags)\n const result: RexecResult[] = []\n let match\n while ((match = regex.exec(string)) !== null) {\n result.push({\n index: match.index,\n lastIndex: regex.lastIndex,\n location: findLineColumn(string, match.index),\n groups: Object.assign({}, match.groups),\n match: match[0],\n })\n }\n return result\n}\n\nexport interface RexecResult {\n index: number\n lastIndex: number\n location: [line: number, col: number]\n groups: Record<string, string>\n match: string\n}\n\nfunction findLineColumn(content: string, index: number) {\n const lines = content.split('\\n')\n const line = content.substring(0, index).split('\\n').length\n lines.splice(line - 1)\n const startOfLineIndex = lines.join('\\n').length + (lines.length ? 1 : 0)\n const col = index - startOfLineIndex\n return [line, col] as [number, number]\n}\n","import { importStatementToFormattedOneLiner } from './importStatementToFormattedOneLiner'\nimport { isBuiltin } from 'module'\nimport { rexec } from '@mono/regex'\nimport upath from 'upath'\n\n/**\n * Parses an import statement into its constituent parts for detailed analysis.\n * This function breaks down an import statement into keywords, specifiers, module path,\n * and other components, providing a comprehensive analysis of the import structure.\n * @param statement - The import statement string to parse\n * @returns An ImportStatementParser instance with parsed components and utility methods\n * @example\n * ```typescript\n * const parsed = parseImportStatement(\"import type { Foo, Bar as Baz } from './module'\")\n * console.log(parsed.type) // 'named'\n * console.log(parsed.keywords.hasTypeKeyword) // true\n * console.log(parsed.modulePath.type) // 'relative'\n * console.log(parsed.getNames()) // ['Foo', 'Baz']\n * ```\n */\nexport function parseImportStatement(\n statement: string,\n options?: { isWorkspacePath?: (p: string) => boolean }\n): ImportStatement {\n const code = statement\n const oneliner = importStatementToFormattedOneLiner(code)\n\n const groups = rexec(\n /^(?<keywords>import +(?<type>type)? *)(?<specifiers>.*? ?)?(?<mod>(?:from ?)?(?<quote>[\"'`])(?<path>.*?)\\5(?<semi>;?))$/g,\n oneliner\n )[0].groups!\n\n const keywords: ImportKeywords = {\n code: groups.keywords!,\n keywords: groups.keywords.trim().split(/\\s+/g),\n hasTypeKeyword: !!groups.type,\n }\n\n const specifiers: ImportSpecifiers = {\n code: groups.specifiers || '',\n children: ((specifiers?: string) => {\n const children = [] as ImportSpecifier[]\n\n if (!specifiers) {\n return children\n }\n\n children.push(\n ...specifiers\n .replace(/{[^}]+}/, '')\n .split(',')\n .map((s) => s.trim())\n .filter((s) => !!s)\n .map((code) => ({\n code: code.trim(),\n type: code.trim().startsWith('* as ') ? ('namespace' as const) : ('default' as const),\n name: code.replace('* as ', '').trim(),\n isType: keywords.hasTypeKeyword || /\\btype /.test(code),\n }))\n )\n\n children.push(\n ...(specifiers.match(/{([^}]+)}/)?.[1] || '')\n .split(',')\n .filter((s) => !!s.trim())\n .map((code) => ({\n code: code.trim(),\n type: 'named' as const,\n name: code.replace(/ as \\w+\\b/, '').trim(),\n isType: keywords.hasTypeKeyword || /\\btype /.test(code),\n }))\n .map((o) => {\n if (o.isType && !o.name.startsWith('type ')) {\n o.name = `type ${o.name}`\n }\n return o\n })\n )\n\n return children\n })(groups.specifiers),\n }\n\n const modulePath: ImportModulePath = {\n code: groups.mod!,\n type: ((): ImportPathType => {\n const p = groups.path!\n return options?.isWorkspacePath?.(p)\n ? 'workspace'\n : upath.isAbsolute(p)\n ? 'absolute'\n : p.startsWith('.')\n ? 'relative'\n : isBuiltin(p)\n ? 'builtin'\n : 'package'\n })(),\n quote: groups.quote!,\n path: groups.path!,\n }\n\n const type =\n specifiers.children.length === 0\n ? 'sideEffect'\n : specifiers.children.length === 1 && specifiers.children[0].type === 'default'\n ? 'default'\n : specifiers.children.length === 1 && specifiers.children[0].type === 'namespace'\n ? 'namespace'\n : specifiers.children.length > 0 &&\n specifiers.children.filter((s) => s.type === 'named').length === specifiers.children.length\n ? 'named'\n : 'mixed'\n\n const semi = groups.semi || ''\n\n return new ImportStatementParser(code, oneliner, type, keywords, specifiers, modulePath, semi)\n}\n\nclass ImportStatementParser implements ImportStatement {\n constructor(\n readonly code: string,\n readonly oneliner: string,\n readonly type: ImportStatementType,\n readonly keywords: ImportKeywords,\n readonly specifiers: ImportSpecifiers,\n readonly modulePath: ImportModulePath,\n readonly semi: string\n ) {}\n\n /**\n * The names that this import statement declares in the global namespace.\n */\n getNames(options?: { unaliasNamedImports?: boolean }) {\n return this.splitBySpecifier(options).flatMap((ins) =>\n ins.specifiers.children\n .map((s) =>\n s.type === 'named' && options?.unaliasNamedImports\n ? s.code.replaceAll(/ as \\w+/g, '')\n : s.code.replaceAll(/[\\w*]+ as /g, '')\n )\n .filter(Boolean)\n )\n }\n\n /**\n * Split the import statement into as many individual import statements as possible.\n */\n splitBySpecifier(options?: { unaliasNamedImports?: boolean }): ImportStatementParser[] {\n return this.type === 'sideEffect'\n ? [this]\n : this.specifiers.children.map((s) => {\n const code =\n s.type === 'named' && options?.unaliasNamedImports ? s.code.replaceAll(/ as \\w+/g, '') : s.code\n return parseImportStatement(\n importStatementToFormattedOneLiner(\n this.oneliner\n .replace(this.specifiers.code, s.type === 'named' ? `{ ${code} } ` : `${code} `)\n .replace(/{ *type /, this.keywords.hasTypeKeyword ? '{ ' : 'type { ')\n ).replace('type { ', '{ type ')\n )\n })\n }\n}\n\n/**\n * The type of path used in an import statement.\n */\ntype ImportPathType = 'relative' | 'absolute' | 'builtin' | 'package' | 'workspace'\n\n/**\n * The type of import specifier.\n */\ntype ImportSpecifierType = 'default' | 'namespace' | 'named'\n\n/**\n * The overall type of import statement based on its specifiers.\n */\ntype ImportStatementType = 'default' | 'namespace' | 'named' | 'sideEffect' | 'mixed'\n\n/**\n * Represents the keywords portion of an import statement (e.g., 'import type').\n */\ninterface ImportKeywords {\n /** The raw code containing the keywords */\n code: string\n /** Array of individual keywords */\n keywords: string[]\n /** Whether the 'type' keyword is present */\n hasTypeKeyword: boolean\n}\n\n/**\n * Represents a single import specifier (e.g., a named import, default import, etc.).\n */\ninterface ImportSpecifier {\n /** The raw code for this specifier */\n code: string\n /** The type of this specifier */\n type: ImportSpecifierType\n /** The name being imported */\n name: string\n /** Whether this is a type-only import */\n isType: boolean\n}\n\n/**\n * Represents the collection of specifiers in an import statement.\n */\ninterface ImportSpecifiers {\n /** The raw code containing all specifiers */\n code: string\n /** Array of individual specifiers */\n children: ImportSpecifier[]\n}\n\n/**\n * Represents the module path portion of an import statement.\n */\ninterface ImportModulePath {\n /** The raw code containing the module path */\n code: string\n /** The type of path (relative, absolute, builtin, package) */\n type: ImportPathType\n /** The quote character used (' or \" or `) */\n quote: string\n /** The actual path string */\n path: string\n}\n\n/**\n * Interface representing a parsed import statement with all its components.\n * This interface enforces consistent structure for analyzing and manipulating\n * import statements in TypeScript source files.\n */\nexport interface ImportStatement {\n /** The original import statement code */\n readonly code: string\n /** The import statement as a formatted single line */\n readonly oneliner: string\n /** The type of import statement */\n readonly type: ImportStatementType\n /** The keywords used in the import statement */\n readonly keywords: ImportKeywords\n /** The import specifiers */\n readonly specifiers: ImportSpecifiers\n /** The module path information */\n readonly modulePath: ImportModulePath\n /** The semicolon at the end, if present */\n readonly semi: string\n\n /**\n * Split the import statement into as many individual import statements as possible.\n * @param options - Configuration options for splitting\n * @param options.unaliasNamedImports - Whether to remove aliases from named imports\n * @returns Array of individual import statements\n */\n splitBySpecifier(options?: { unaliasNamedImports?: boolean }): ImportStatement[]\n\n /**\n * Returns a sorted array of unique names that this import statement declares in the global namespace.\n * @param options - Configuration options for name extraction\n * @param options.unaliasNamedImports - Whether to remove aliases from named imports\n * @returns Array of declared names\n */\n getNames(options?: { unaliasNamedImports?: boolean }): string[]\n}\n","/**\n * Converts CRLF line endings to LF in TypeScript code.\n * This function normalizes line endings from Windows-style (CRLF) to Unix-style (LF)\n * for consistent processing across different operating systems.\n * @param code - The TypeScript code string to normalize\n * @returns The code with LF line endings\n * @example\n * ```typescript\n * tsCrlfToLf('line1\\r\\nline2\\r\\nline3') // 'line1\\nline2\\nline3'\n * ```\n */\nexport function tsCrlfToLf(code: string) {\n return code.replaceAll(/\\r+\\n/g, '\\n')\n}\n","import { importStatementToOneLiner } from './importStatementToOneLiner'\nimport { tsCrlfToLf } from './tsCrlfToLf'\n\n/**\n * Extract all import statements from a given TypeScript source code string.\n * This function parses TypeScript code to identify and extract all import statements,\n * handling both single-line and multi-line imports. It correctly ignores import-like\n * text within comments and string literals.\n * @param code - The TypeScript code as a string from which to extract import statements\n * @returns An array of objects, each representing an import statement. Each object includes\n * the start and end line numbers (0-indexed) of the import statement in the original code,\n * the full text of the import statement, and a one-line version\n */\nexport function tsExtractImports(code: string): TsExtractImportsResult[] {\n code = tsCrlfToLf(code)\n code = replaceImportStatementsInsideLiteralStrings(code)\n code = replaceImportStatementsInsideBlockComments(code)\n const isFirstLine = /^import /\n const isFirstLineInMulti = /{\\s*$/\n const isLastLineInMulti = /^} from [\"']/\n const result: TsExtractImportsResult[] = []\n let isMulti = false\n let impLines = []\n const lines = code.split(/\\r?\\n/)\n for (const [l, line] of lines.entries()) {\n if (isFirstLine.test(line)) {\n if (isFirstLineInMulti.test(line)) {\n impLines.push(line)\n isMulti = true\n } else {\n const match = line\n const matchOneLine = importStatementToOneLiner(match)\n result.push({ start: l, end: l + 1, match, matchOneLine })\n }\n } else if (isMulti) {\n impLines.push(line)\n if (isLastLineInMulti.test(line)) {\n const match = impLines.join('\\n')\n const matchOneLine = importStatementToOneLiner(match)\n result.push({ start: l - impLines.length + 1, end: l + 1, match, matchOneLine })\n impLines = []\n isMulti = false\n }\n }\n }\n return result\n}\n\nfunction replaceImportStatementsInsideLiteralStrings(code: string) {\n return code.replaceAll(/([\"'`])(.*?)\\1/gs, (match) => match.replaceAll(/\\nimport /gs, '\\nIMPORT '))\n}\n\nfunction replaceImportStatementsInsideBlockComments(code: string) {\n return code.replaceAll(/\\/\\*(.*?)\\*\\//gs, (match) => match.replaceAll(/\\nimport /gs, '\\nIMPORT '))\n}\n\n/**\n * Interface representing the result of extracting import statements from TypeScript code.\n * This interface is used to enforce consistent structure when analyzing and manipulating\n * import statements in TypeScript source files.\n */\nexport type TsExtractImportsResult = {\n /**\n * The line index where the import statement starts (0-indexed).\n */\n start: number\n /**\n * The line index of the last line of the import statement (0-indexed).\n */\n end: number\n /**\n * The complete import statement as it appears in the source code.\n */\n match: string\n /**\n * The import statement converted to a single line format.\n */\n matchOneLine: string\n}\n","import type { ImportStatement } from '@mono/tscode'\nimport fs from 'fs-extra'\nimport { parseImportStatement } from '@mono/tscode'\nimport { tsExtractImports } from '@mono/tscode'\n\n/**\n * An import statement together with the file it was found in.\n */\nexport interface FileImport {\n /** The path of the file that contains the import statement, as it was given. */\n filepath: string\n /** The parsed import statement. */\n statement: ImportStatement\n}\n\n/**\n * Reads a TypeScript file and parses its import statements.\n */\nexport function getFileImports(filepath: string): FileImport[] {\n const code = fs.readFileSync(filepath, 'utf8')\n return tsExtractImports(code).map(({ match }) => ({ filepath, statement: parseImportStatement(match) }))\n}\n","import type { Workspace } from './Workspace'\nimport { globSync } from 'glob'\nimport upath from 'upath'\n\n/**\n * Lists the absolute paths of all TypeScript files in the 'src' directory of a workspace, sorted.\n * This includes test files and other files with a semantic extname prefix. Filter with `isSourceFile` or\n * `isTestFile`, or use `getWorkspaceSourceFiles` or `getWorkspaceTestFiles`.\n */\nexport function getWorkspaceFiles(workspace: Workspace): string[] {\n return globSync('src/**/*.{ts,tsx,mts,cts}', { cwd: workspace.path, ignore: '**/node_modules/**', posix: true })\n .map((filepath) => upath.join(workspace.path, filepath))\n .sort()\n}\n","/**\n * Whether fspath is a subpath of a parent directory with the given name.\n */\nexport function hasParentDirname(fspath: string, name: string) {\n return new RegExp(`(^|[/\\\\\\\\])${name}[/\\\\\\\\]`).test(fspath)\n}\n","import { hasExtnamePrefix } from './hasExtnamePrefix'\nimport { hasParentDirname } from '@mono/path'\n\n/**\n * Whether the file is a source file: located in a 'src' directory and without a semantic extname prefix.\n * So not a test file, example file, declaration file etc.\n */\nexport function isSourceFile(filepath: string): boolean {\n return hasParentDirname(filepath, 'src') && !hasExtnamePrefix(filepath)\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaceFiles } from './getWorkspaceFiles'\nimport { isSourceFile } from '../util/isSourceFile'\n\n/**\n * Lists the absolute paths of the source files of a workspace: the TypeScript files in its 'src' directory that\n * have no semantic extname prefix. So no test files, example files, declaration files etc.\n */\nexport function getWorkspaceSourceFiles(workspace: Workspace): string[] {\n return getWorkspaceFiles(workspace).filter((filepath) => isSourceFile(filepath))\n}\n","import type { FileImport } from './getFileImports'\nimport type { Workspace } from '../workspace/Workspace'\nimport { getFileImports } from './getFileImports'\nimport { getWorkspaceSourceFiles } from '../workspace/getWorkspaceSourceFiles'\nimport { getWorkspaces } from '../workspace/getWorkspaces'\n\n/**\n * Parses the import statements of every source file in the given workspaces.\n *\n * @param workspaces - Defaults to all workspaces of the repo that contains the current working directory.\n */\nexport function getAllImports(workspaces: Workspace[] = getWorkspaces()): FileImport[] {\n return workspaces.flatMap((ws) => getWorkspaceSourceFiles(ws).flatMap((filepath) => getFileImports(filepath)))\n}\n","import type { Workspace } from '../workspace/Workspace'\nimport { getFileImports } from './getFileImports'\nimport { getWorkspaceFiles } from '../workspace/getWorkspaceFiles'\nimport { getWorkspaceSourceFiles } from '../workspace/getWorkspaceSourceFiles'\nimport upath from 'upath'\n\n/**\n * An import where a file imports its own workspace by package name instead of by relative path.\n */\nexport interface WorkspaceSelfImport {\n /** Absolute path of the file that contains the import. */\n filepath: string\n /** The module specifier to replace: the workspace's package name. */\n replaceValue: string\n /** The relative module specifier to replace it with. */\n withValue: string\n}\n\n/**\n * Finds the imports in a workspace's files that import the workspace itself by its package name.\n * Such imports should be relative instead.\n *\n * The suggested replacement points at the source file named after the first imported name, if there is one.\n * Otherwise it points at the workspace's src/index file.\n */\nexport function getWorkspaceSelfImports(workspace: Workspace): WorkspaceSelfImport[] {\n const sourceFilesByName = new Map(\n getWorkspaceSourceFiles(workspace).map((filepath) => [upath.parse(filepath).name, filepath])\n )\n const indexFilepath = upath.join(workspace.path, 'src', 'index.ts')\n\n return getWorkspaceFiles(workspace).flatMap((filepath) =>\n getFileImports(filepath)\n .filter(({ statement }) => statement.modulePath.path === workspace.name)\n .map(({ statement }) => {\n const firstName = statement.getNames({ unaliasNamedImports: true })[0]?.replace(/^type /, '')\n const target = (firstName && sourceFilesByName.get(firstName)) || indexFilepath\n return { filepath, replaceValue: workspace.name, withValue: toRelativeSpecifier(filepath, target) }\n })\n )\n}\n\nfunction toRelativeSpecifier(fromFilepath: string, toFilepath: string): string {\n const relative = upath.trimExt(upath.relative(upath.dirname(fromFilepath), toFilepath))\n return relative.startsWith('.') ? relative : `./${relative}`\n}\n","import { getRepoRootDirpath } from '../util/getRepoRootDirpath'\nimport upath from 'upath'\n\n/**\n * Gets the absolute path to the repository's package.json file.\n */\nexport function getRootPackageJsonPath(): string {\n return upath.joinSafe(getRepoRootDirpath(), 'package.json')\n}\n","import fs from 'fs-extra'\nimport { getRootPackageJsonPath } from './getRootPackageJsonPath'\n\n/**\n * Reads the repository's root package.json file.\n */\nexport async function getRootPackageJson() {\n return await fs.readJson(getRootPackageJsonPath())\n}\n","import { getRootPackageJson } from './getRootPackageJson'\nimport { glob } from 'glob'\nimport upath from 'upath'\n\n/**\n * Returns an array of all workspace directory paths.\n */\nexport async function getAllWorkspacePaths(): Promise<string[]> {\n const pkg = await getRootPackageJson()\n return (\n await Promise.all(pkg.workspaces.filter((ws: string) => ws !== '.').map((pattern: string) => glob(pattern)))\n )\n .flat()\n\n .map((fp) => upath.normalizeSafe(fp))\n}\n","import { getAllWorkspacePaths } from './getAllWorkspacePaths'\nimport upath from 'upath'\n\n/**\n * Gets all workspace package.json file paths.\n */\nexport async function getAllWorkspacePackageJsonPaths(): Promise<string[]> {\n const paths = await getAllWorkspacePaths()\n return paths.map((p) => upath.join(p, 'package.json'))\n}\n","import fs from 'fs-extra'\nimport { getAllWorkspacePackageJsonPaths } from './getAllWorkspacePackageJsonPaths'\n\n/**\n * Gets all workspace package.json contents.\n */\nexport async function getAllWorkspacePackageJsons() {\n const paths = await getAllWorkspacePackageJsonPaths()\n return paths.map((p) => fs.readJsonSync(p))\n}\n","import { getAllWorkspacePackageJsons } from './getAllWorkspacePackageJsons'\n\n/**\n * Gets all workspace package names.\n */\nexport async function getAllWorkspacePackageNames(): Promise<string[]> {\n const pkgs = await getAllWorkspacePackageJsons()\n return pkgs.map((p) => p.name)\n}\n","import { getAllWorkspacePackageNames } from './getAllWorkspacePackageNames'\n\n/**\n * Finds the full package name for a workspace given a partial name.\n */\nexport async function findWorkspacePackageName(name: string): Promise<string | undefined> {\n const wsPkgNames = await getAllWorkspacePackageNames()\n return wsPkgNames.find((n) => n === name) || wsPkgNames.find((n) => n === `@mono/${name}`)\n}\n","import { SemanticExtnamePrefix } from './SemanticExtnamePrefix'\n\n/**\n * A record mapping semantic extname prefixes to their descriptions.\n *\n * - `d`: Declaration files\n * - `test`: Vitest test suite files\n * - `examples`: Files containing working and tested example usage code (included in git, but ignored by most repo tools)\n * - `benchmark`: Benchmark files (included in git, but ignored by most repo tools)\n * - `temp`: Temporary files (ignored by git, build, tests, etc.)\n * - `wip`: Work in progress files (ignored by git, build, tests, etc.)\n */\nexport const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, string> = {\n d: 'declarations',\n test: 'vitest test suite',\n examples: 'contains working and tested example usage code. Included in git, but ignored by most repo tools',\n benchmark: 'benchmark files, included in git, but ignored by most repo tools.',\n temp: 'temporary files, ignored by git, build, tests, etc.',\n wip: 'work in progress, ignored by git, build, tests, etc.',\n} as const\n","import type { PackageJson } from '@mono/types'\nimport fs from 'fs-extra'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport { globSync } from 'glob'\nimport path from 'upath'\n\n/**\n * Get all workspace directory paths by reading the workspace patterns from the root package.json.\n */\nexport function getWorkspaceDirpaths(): string[] {\n const rootDirpath = getRepoRootDirpath()\n const pkg = fs.readJsonSync(path.joinSafe(rootDirpath, 'package.json')) as PackageJson\n if (!pkg.workspaces) {\n throw new Error(`No workspaces found in package.json at ${rootDirpath}`)\n }\n return pkg.workspaces\n .filter((ws) => ws !== '.')\n .flatMap((workspace: string) => globSync(workspace))\n .map(path.normalizeSafe)\n}\n","import { createCompilerHost } from 'typescript'\nimport fs from 'fs-extra/esm'\nimport { getRepoRootDirpath } from './getRepoRootDirpath'\nimport { resolveModuleName } from 'typescript'\nimport upath from 'upath'\n\n/**\n * Returns the resolved import path (relative from repo root)\n */\nexport function resolveModuleImportPath(filepath: string, importFrom: string) {\n const rootdir = getRepoRootDirpath()\n const result = resolveModuleName(\n importFrom,\n filepath,\n {\n paths: fs.readJsonSync(upath.joinSafe(rootdir, 'tsconfig.paths.json')).compilerOptions.paths,\n allowJs: true,\n allowArbitraryExtensions: true,\n allowImportingTsExtensions: true,\n allowSyntheticDefaultImports: true,\n esModuleInterop: true,\n strict: false,\n },\n createCompilerHost({}, true)\n )\n const f = result.resolvedModule?.resolvedFileName\n if (f) {\n result.resolvedModule.resolvedFileName = upath.relative(rootdir, f)\n }\n return result.resolvedModule\n}\n","/**\n * Bumps the semantic versioning (SemVer) of a given version string or array based on the specified level.\n * The function supports 'major', 'minor', and 'patch' levels.\n *\n * @remarks\n * This function will mutate the original version if it's an array.\n *\n * @param version - The current version. It can be a string (e.g., '1.0.0') or an array of strings or numbers (e.g., ['1', '0', '0'] or [1, 0, 0]).\n * @param level - The level of the version bump. It can be 'major', 'minor', or 'patch'.\n *\n * @returns The bumped version as a string.\n *\n * @example\n * ```ts\n * semverVersionBump('1.0.0', 'major'); // '2.0.0'\n * semverVersionBump([1, 0, 4], 'minor'); // '1.1.0'\n * semverVersionBump(['1', '0', '0'], 'patch'); // '1.0.1'\n * ```\n */\nexport function semverVersionBump(\n version: string | string[] | number[],\n level: 'major' | 'minor' | 'patch'\n): string {\n const arr = (typeof version === 'string' ? version.split('.') : version).map(Number)\n switch (level) {\n case 'major': {\n arr[0] += 1\n arr[1] = 0\n arr[2] = 0\n\n break\n }\n case 'minor': {\n arr[1] += 1\n arr[2] = 0\n\n break\n }\n case 'patch': {\n arr[2] += 1\n\n break\n }\n // No default\n }\n return arr.join('.')\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaces } from './getWorkspaces'\nimport upath from 'upath'\n\n/**\n * Finds a workspace by its package name, its directory name or its path relative to the repo root.\n *\n * @example\n * ```ts\n * findWorkspace('@mono/string') // by package name\n * findWorkspace('string') // by directory name\n * findWorkspace('libs/string') // by path relative to the repo root\n * ```\n */\nexport function findWorkspace(query: string, workspaces: Workspace[] = getWorkspaces()): Workspace | undefined {\n return (\n workspaces.find((ws) => ws.name === query) ??\n workspaces.find((ws) => ws.relativePath === upath.normalize(query)) ??\n workspaces.find((ws) => upath.basename(ws.path) === query)\n )\n}\n","import type { Workspace } from './Workspace'\nimport { getWorkspaceFiles } from './getWorkspaceFiles'\nimport { isTestFile } from '../util/isTestFile'\n\n/**\n * Lists the absolute paths of the test files (*.test.*) in the 'src' directory of a workspace.\n */\nexport function getWorkspaceTestFiles(workspace: Workspace): string[] {\n return getWorkspaceFiles(workspace).filter((filepath) => isTestFile(filepath))\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/monorepo",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Monorepo workspace management, package discovery, and TypeScript code processing utilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"./lib/index.js",
|
|
34
34
|
"./lib/index.d.ts",
|
|
35
35
|
"./lib/index.cjs",
|
|
36
|
-
"./lib/index.d.cts"
|
|
36
|
+
"./lib/index.d.cts",
|
|
37
|
+
"./lib/index.js.map",
|
|
38
|
+
"./lib/index.cjs.map"
|
|
37
39
|
],
|
|
38
40
|
"exports": {
|
|
39
41
|
".": {
|