Dashboard › craft › Distillation
6f2f198b-c702-4bd7-95d5-412e6ef8b0c5["lore_tm_v1_6r1cTP0OBq4WosiwPqI-Idu4F6r9huDD79lllO3FatQ"]
Date: Sep 3, 2026
/home/byk/Code/getsentry/craft/src/utils/workspaces.ts (lines 1–290 of 425). The module imports readFileSync from fs, path, load from js-yaml, glob from glob, and logger from ../logger.src/utils/workspaces.ts defines WorkspacePackage with name, absolute location, private, hasPublicAccess, and workspaceDependencies; WorkspaceDiscoveryResult has type: 'npm' | 'yarn' | 'pnpm' | 'none' and packages.src/utils/workspaces.ts: readPackageJson(packagePath) reads package.json, returns null on errors, and logs a warning except for ENOENT, detected by isNotFoundError(err) checking err instanceof Error, 'code' in err, and err.code === 'ENOENT'.getAllDependencyNames(packageJson) collects unique names from dependencies, peerDependencies, and optionalDependencies, explicitly excluding devDependencies because they do not need to be published first.extractWorkspacesGlobs(workspaces) supports both package.json workspace formats: a string[] directly or an object containing packages?: string[].resolveWorkspaceGlobs(rootDir, patterns) uses glob(pattern, { cwd: rootDir, absolute: true, ignore: ['**/node_modules/**'] }); it first collects package locations and all workspace names, then creates each package’s workspaceDependencies by filtering its publish-relevant dependency names against known workspace names.discoverNpmYarnWorkspaces(rootDir) obtains workspace globs from the root package.json; detects Yarn when yarn.lock exists via fileExists(path.join(rootDir, 'yarn.lock')), otherwise labels the workspace type npm; logs the discovered package count and globs.discoverPnpmWorkspaces(rootDir) reads and YAML-parses pnpm-workspace.yaml via load(content) as PnpmWorkspaceConfig; returns null on missing, unparsable, or empty packages configuration, logs parse warnings except for ENOENT, and logs discovered package count and patterns.discoverWorkspaces(rootDir) prioritizes discoverPnpmWorkspaces(rootDir) over discoverNpmYarnWorkspaces(rootDir) because pnpm detection is more specific; if neither succeeds, returns { type: 'none', packages: [] }.packageNameToArtifactPattern(packageName) strips a leading @, replaces / with -, and returns the regex-pattern string `/^${normalized}-\\d.*\\.tgz$/`; documented examples are @sentry/browser -> sentry-browser-\d.*\.tgz and @sentry-internal/browser-utils -> sentry-internal-browser-utils-\d.*\.tgz.escapeRegex(str) in src/utils/workspaces.ts escapes regex-special characters using str.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&'). The subsequent template-based artifact-filename conversion documentation specifies {{name}}, {{simpleName}}, and {{version}} template variables, but its implementation was outside the displayed lines.