mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-06 02:49:56 +00:00
style(workspace): fix Prettier formatting on all workspace extractors
This commit is contained in:
parent
5555f863e9
commit
0a330878db
10 changed files with 55 additions and 179 deletions
|
|
@ -117,10 +117,7 @@ function expandAlias(expr: string): string[] {
|
|||
return [expr];
|
||||
}
|
||||
|
||||
function matchModuleToApp(
|
||||
moduleName: string,
|
||||
knownApps: Map<string, string>,
|
||||
): string | null {
|
||||
function matchModuleToApp(moduleName: string, knownApps: Map<string, string>): string | null {
|
||||
for (const [prefix, appName] of knownApps) {
|
||||
if (moduleName === prefix || moduleName.startsWith(prefix + '.')) {
|
||||
return appName;
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ async function parseGoMod(
|
|||
}
|
||||
|
||||
// replace directives (local path deps)
|
||||
const replaceLines = content.matchAll(
|
||||
/^replace\s+(\S+)\s+=>\s+\.\//gm,
|
||||
);
|
||||
const replaceLines = content.matchAll(/^replace\s+(\S+)\s+=>\s+\.\//gm);
|
||||
for (const m of replaceLines) {
|
||||
if (!requires.includes(m[1])) requires.push(m[1]);
|
||||
}
|
||||
|
|
@ -129,10 +127,7 @@ function extractImportPaths(content: string): string[] {
|
|||
return [...new Set(paths)];
|
||||
}
|
||||
|
||||
function findMatchingModule(
|
||||
importPath: string,
|
||||
knownModules: Map<string, string>,
|
||||
): string | null {
|
||||
function findMatchingModule(importPath: string, knownModules: Map<string, string>): string | null {
|
||||
for (const [modPath] of knownModules) {
|
||||
if (importPath === modPath || importPath.startsWith(modPath + '/')) {
|
||||
return modPath;
|
||||
|
|
@ -146,10 +141,7 @@ function extractUsedTypes(content: string, importPath: string): string[] {
|
|||
if (!pkgName) return [];
|
||||
|
||||
// Match pkg.TypeName where TypeName is PascalCase (exported)
|
||||
const typeRegex = new RegExp(
|
||||
`\\b${escapeRegex(pkgName)}\\.([A-Z][A-Za-z0-9]*)`,
|
||||
'g',
|
||||
);
|
||||
const typeRegex = new RegExp(`\\b${escapeRegex(pkgName)}\\.([A-Z][A-Za-z0-9]*)`, 'g');
|
||||
const types = new Set<string>();
|
||||
let match;
|
||||
while ((match = typeRegex.exec(content)) !== null) {
|
||||
|
|
|
|||
|
|
@ -43,12 +43,8 @@ async function parseJavaManifest(
|
|||
return null;
|
||||
}
|
||||
|
||||
function parsePom(
|
||||
content: string,
|
||||
): { groupId: string; artifactId: string; deps: string[] } | null {
|
||||
const projectGroupMatch = content.match(
|
||||
/<project[^>]*>[\s\S]*?<groupId>([^<]+)<\/groupId>/,
|
||||
);
|
||||
function parsePom(content: string): { groupId: string; artifactId: string; deps: string[] } | null {
|
||||
const projectGroupMatch = content.match(/<project[^>]*>[\s\S]*?<groupId>([^<]+)<\/groupId>/);
|
||||
const projectArtifactMatch = content.match(
|
||||
/<project[^>]*>[\s\S]*?<artifactId>([^<]+)<\/artifactId>/,
|
||||
);
|
||||
|
|
@ -58,9 +54,7 @@ function parsePom(
|
|||
const artifactId = projectArtifactMatch[1].trim();
|
||||
|
||||
const deps: string[] = [];
|
||||
const depBlocks = content.matchAll(
|
||||
/<dependency>\s*([\s\S]*?)<\/dependency>/g,
|
||||
);
|
||||
const depBlocks = content.matchAll(/<dependency>\s*([\s\S]*?)<\/dependency>/g);
|
||||
for (const block of depBlocks) {
|
||||
const gMatch = block[1].match(/<groupId>([^<]+)<\/groupId>/);
|
||||
const aMatch = block[1].match(/<artifactId>([^<]+)<\/artifactId>/);
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ async function scanImports(
|
|||
|
||||
// ES import: import { Foo, Bar } from '<pkg>'
|
||||
// Also: import { Foo as Baz } from '<pkg>'
|
||||
const esImportRegex =
|
||||
/^import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/gm;
|
||||
const esImportRegex = /^import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/gm;
|
||||
let match;
|
||||
while ((match = esImportRegex.exec(content)) !== null) {
|
||||
const importClause = match[1];
|
||||
|
|
@ -85,8 +84,7 @@ async function scanImports(
|
|||
}
|
||||
|
||||
// ES import default: import Foo from '<pkg>'
|
||||
const defaultImportRegex =
|
||||
/^import\s+([A-Z][A-Za-z0-9]*)\s+from\s+['"]([^'"]+)['"]/gm;
|
||||
const defaultImportRegex = /^import\s+([A-Z][A-Za-z0-9]*)\s+from\s+['"]([^'"]+)['"]/gm;
|
||||
while ((match = defaultImportRegex.exec(content)) !== null) {
|
||||
const symbolName = match[1];
|
||||
const modulePath = match[2];
|
||||
|
|
@ -99,8 +97,7 @@ async function scanImports(
|
|||
}
|
||||
|
||||
// CommonJS: const { Foo, Bar } = require('<pkg>')
|
||||
const cjsRegex =
|
||||
/(?:const|let|var)\s+\{([^}]+)\}\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;
|
||||
const cjsRegex = /(?:const|let|var)\s+\{([^}]+)\}\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;
|
||||
while ((match = cjsRegex.exec(content)) !== null) {
|
||||
const importClause = match[1];
|
||||
const modulePath = match[2];
|
||||
|
|
|
|||
|
|
@ -40,18 +40,16 @@ async function parsePythonManifest(
|
|||
return parseSetupPy(content);
|
||||
}
|
||||
|
||||
function parsePyproject(content: string): { name: string; importName: string; deps: string[] } | null {
|
||||
const nameMatch = content.match(
|
||||
/^\[project\]\s*\n(?:[^\[]*?\n)*?name\s*=\s*"([^"]+)"/m,
|
||||
);
|
||||
function parsePyproject(
|
||||
content: string,
|
||||
): { name: string; importName: string; deps: string[] } | null {
|
||||
const nameMatch = content.match(/^\[project\]\s*\n(?:[^\[]*?\n)*?name\s*=\s*"([^"]+)"/m);
|
||||
if (!nameMatch) return null;
|
||||
const name = nameMatch[1];
|
||||
const importName = name.replace(/-/g, '_');
|
||||
|
||||
const deps: string[] = [];
|
||||
const depsMatch = content.match(
|
||||
/^\[project\]\s*\n[\s\S]*?dependencies\s*=\s*\[([\s\S]*?)\]/m,
|
||||
);
|
||||
const depsMatch = content.match(/^\[project\]\s*\n[\s\S]*?dependencies\s*=\s*\[([\s\S]*?)\]/m);
|
||||
if (depsMatch) {
|
||||
const depLines = depsMatch[1].matchAll(/"([^"]+)"/g);
|
||||
for (const m of depLines) {
|
||||
|
|
@ -59,9 +57,7 @@ function parsePyproject(content: string): { name: string; importName: string; de
|
|||
}
|
||||
}
|
||||
|
||||
const optMatch = content.match(
|
||||
/\[project\.optional-dependencies\]\s*\n([\s\S]*?)(?=\n\[|$)/,
|
||||
);
|
||||
const optMatch = content.match(/\[project\.optional-dependencies\]\s*\n([\s\S]*?)(?=\n\[|$)/);
|
||||
if (optMatch) {
|
||||
const optDeps = optMatch[1].matchAll(/"([^"]+)"/g);
|
||||
for (const m of optDeps) {
|
||||
|
|
@ -72,16 +68,16 @@ function parsePyproject(content: string): { name: string; importName: string; de
|
|||
return { name, importName, deps: [...new Set(deps)] };
|
||||
}
|
||||
|
||||
function parseSetupPy(content: string): { name: string; importName: string; deps: string[] } | null {
|
||||
function parseSetupPy(
|
||||
content: string,
|
||||
): { name: string; importName: string; deps: string[] } | null {
|
||||
const nameMatch = content.match(/name\s*=\s*['"]([^'"]+)['"]/);
|
||||
if (!nameMatch) return null;
|
||||
const name = nameMatch[1];
|
||||
const importName = name.replace(/-/g, '_');
|
||||
|
||||
const deps: string[] = [];
|
||||
const installMatch = content.match(
|
||||
/install_requires\s*=\s*\[([\s\S]*?)\]/,
|
||||
);
|
||||
const installMatch = content.match(/install_requires\s*=\s*\[([\s\S]*?)\]/);
|
||||
if (installMatch) {
|
||||
const depLines = installMatch[1].matchAll(/['"]([^'"]+)['"]/g);
|
||||
for (const m of depLines) {
|
||||
|
|
@ -114,8 +110,7 @@ async function scanPythonImports(
|
|||
|
||||
// from <pkg> import Foo, Bar
|
||||
// from <pkg>.module import Foo
|
||||
const fromImportRegex =
|
||||
/^from\s+(\w[\w.]*)\s+import\s+(.+)/gm;
|
||||
const fromImportRegex = /^from\s+(\w[\w.]*)\s+import\s+(.+)/gm;
|
||||
let match;
|
||||
while ((match = fromImportRegex.exec(content)) !== null) {
|
||||
const modulePath = match[1];
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ describe('ElixirWorkspaceExtractor', () => {
|
|||
'core/mix.exs',
|
||||
'defmodule Core.MixProject do\n use Mix.Project\n def project do\n [app: :core, version: "0.1.0"]\n end\nend\n',
|
||||
);
|
||||
await writeFile(
|
||||
'core/lib/core/schema.ex',
|
||||
'defmodule Core.Schema do\nend\n',
|
||||
);
|
||||
await writeFile('core/lib/core/schema.ex', 'defmodule Core.Schema do\nend\n');
|
||||
|
||||
await writeFile(
|
||||
'web/mix.exs',
|
||||
|
|
@ -121,19 +118,13 @@ describe('ElixirWorkspaceExtractor', () => {
|
|||
'data-store/mix.exs',
|
||||
'defmodule DataStore.MixProject do\n use Mix.Project\n def project do\n [app: :data_store, version: "0.1.0"]\n end\nend\n',
|
||||
);
|
||||
await writeFile(
|
||||
'data-store/lib/data_store/repo.ex',
|
||||
'defmodule DataStore.Repo do\nend\n',
|
||||
);
|
||||
await writeFile('data-store/lib/data_store/repo.ex', 'defmodule DataStore.Repo do\nend\n');
|
||||
|
||||
await writeFile(
|
||||
'web/mix.exs',
|
||||
'defmodule Web.MixProject do\n use Mix.Project\n def project do\n [app: :web, version: "0.1.0"]\n end\n defp deps do\n [{:data_store, in_umbrella: true}]\n end\nend\n',
|
||||
);
|
||||
await writeFile(
|
||||
'web/lib/web/page.ex',
|
||||
'defmodule Web.Page do\n alias DataStore.Repo\nend\n',
|
||||
);
|
||||
await writeFile('web/lib/web/page.ex', 'defmodule Web.Page do\n alias DataStore.Repo\nend\n');
|
||||
|
||||
const repos = { store: 'data_store', web: 'web' };
|
||||
const repoPaths = new Map([
|
||||
|
|
|
|||
|
|
@ -22,14 +22,8 @@ describe('GoWorkspaceExtractor', () => {
|
|||
}
|
||||
|
||||
it('discovers cross-module type usage via require', async () => {
|
||||
await writeFile(
|
||||
'models/go.mod',
|
||||
'module github.com/org/models\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile(
|
||||
'models/schema.go',
|
||||
'package models\n\ntype Schema struct {}\n',
|
||||
);
|
||||
await writeFile('models/go.mod', 'module github.com/org/models\n\ngo 1.21\n');
|
||||
await writeFile('models/schema.go', 'package models\n\ntype Schema struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
'api/go.mod',
|
||||
|
|
@ -62,10 +56,7 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles block require syntax', async () => {
|
||||
await writeFile(
|
||||
'auth/go.mod',
|
||||
'module github.com/org/auth\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile('auth/go.mod', 'module github.com/org/auth\n\ngo 1.21\n');
|
||||
await writeFile('auth/token.go', 'package auth\n\ntype Token struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -90,14 +81,8 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles subpackage imports (module/pkg)', async () => {
|
||||
await writeFile(
|
||||
'core/go.mod',
|
||||
'module github.com/org/core\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile(
|
||||
'core/types/entity.go',
|
||||
'package types\n\ntype Entity struct {}\n',
|
||||
);
|
||||
await writeFile('core/go.mod', 'module github.com/org/core\n\ngo 1.21\n');
|
||||
await writeFile('core/types/entity.go', 'package types\n\ntype Entity struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
'app/go.mod',
|
||||
|
|
@ -121,10 +106,7 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles replace directive with local paths', async () => {
|
||||
await writeFile(
|
||||
'lib/go.mod',
|
||||
'module github.com/org/lib\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile('lib/go.mod', 'module github.com/org/lib\n\ngo 1.21\n');
|
||||
await writeFile('lib/config.go', 'package lib\n\ntype Config struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -149,14 +131,8 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('ignores unexported (lowercase) identifiers', async () => {
|
||||
await writeFile(
|
||||
'lib/go.mod',
|
||||
'module github.com/org/lib\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile(
|
||||
'lib/util.go',
|
||||
'package lib\n\nfunc helper() {}\ntype Config struct {}\n',
|
||||
);
|
||||
await writeFile('lib/go.mod', 'module github.com/org/lib\n\ngo 1.21\n');
|
||||
await writeFile('lib/util.go', 'package lib\n\nfunc helper() {}\ntype Config struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
'app/go.mod',
|
||||
|
|
@ -192,24 +168,15 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('deduplicates identical type usage from multiple files', async () => {
|
||||
await writeFile(
|
||||
'lib/go.mod',
|
||||
'module github.com/org/lib\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile('lib/go.mod', 'module github.com/org/lib\n\ngo 1.21\n');
|
||||
await writeFile('lib/model.go', 'package lib\n\ntype Model struct {}\n');
|
||||
|
||||
await writeFile(
|
||||
'app/go.mod',
|
||||
'module github.com/org/app\n\ngo 1.21\n\nrequire github.com/org/lib v0.1.0\n',
|
||||
);
|
||||
await writeFile(
|
||||
'app/a.go',
|
||||
'package main\n\nimport "github.com/org/lib"\n\nvar x lib.Model\n',
|
||||
);
|
||||
await writeFile(
|
||||
'app/b.go',
|
||||
'package main\n\nimport "github.com/org/lib"\n\nvar y lib.Model\n',
|
||||
);
|
||||
await writeFile('app/a.go', 'package main\n\nimport "github.com/org/lib"\n\nvar x lib.Model\n');
|
||||
await writeFile('app/b.go', 'package main\n\nimport "github.com/org/lib"\n\nvar y lib.Model\n');
|
||||
|
||||
const repos = { lib: 'lib', app: 'app' };
|
||||
const repoPaths = new Map([
|
||||
|
|
@ -223,10 +190,7 @@ describe('GoWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('discovers multiple types from the same module', async () => {
|
||||
await writeFile(
|
||||
'lib/go.mod',
|
||||
'module github.com/org/lib\n\ngo 1.21\n',
|
||||
);
|
||||
await writeFile('lib/go.mod', 'module github.com/org/lib\n\ngo 1.21\n');
|
||||
await writeFile(
|
||||
'lib/types.go',
|
||||
'package lib\n\ntype Request struct {}\ntype Response struct {}\n',
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
'package com.acme.models;\npublic class User {}\n',
|
||||
);
|
||||
|
||||
await writeFile(
|
||||
'api/pom.xml',
|
||||
pomTemplate('com.acme', 'api', ['com.acme:models']),
|
||||
);
|
||||
await writeFile('api/pom.xml', pomTemplate('com.acme', 'api', ['com.acme:models']));
|
||||
await writeFile(
|
||||
'api/src/main/java/com/acme/api/UserService.java',
|
||||
'package com.acme.api;\nimport com.acme.models.User;\npublic class UserService {}\n',
|
||||
|
|
@ -66,10 +63,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles Gradle build files', async () => {
|
||||
await writeFile(
|
||||
'core/build.gradle.kts',
|
||||
"group = \"com.acme\"\nversion = \"1.0\"\n",
|
||||
);
|
||||
await writeFile('core/build.gradle.kts', 'group = "com.acme"\nversion = "1.0"\n');
|
||||
await writeFile(
|
||||
'core/src/main/java/com/acme/core/Config.java',
|
||||
'package com.acme.core;\npublic class Config {}\n',
|
||||
|
|
@ -77,7 +71,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
|
||||
await writeFile(
|
||||
'svc/build.gradle.kts',
|
||||
"group = \"com.acme\"\nversion = \"1.0\"\ndependencies {\n implementation(\"com.acme:core:1.0\")\n}\n",
|
||||
'group = "com.acme"\nversion = "1.0"\ndependencies {\n implementation("com.acme:core:1.0")\n}\n',
|
||||
);
|
||||
await writeFile(
|
||||
'svc/src/main/java/com/acme/svc/App.java',
|
||||
|
|
@ -97,10 +91,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles Gradle project dependencies', async () => {
|
||||
await writeFile(
|
||||
'common/build.gradle',
|
||||
"group = 'com.org'\nversion = '1.0'\n",
|
||||
);
|
||||
await writeFile('common/build.gradle', "group = 'com.org'\nversion = '1.0'\n");
|
||||
await writeFile(
|
||||
'common/src/main/java/com/org/common/Entity.java',
|
||||
'package com.org.common;\npublic class Entity {}\n',
|
||||
|
|
@ -134,10 +125,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
'package com.acme.lib;\npublic class Constants {}\n',
|
||||
);
|
||||
|
||||
await writeFile(
|
||||
'app/pom.xml',
|
||||
pomTemplate('com.acme', 'app', ['com.acme:lib']),
|
||||
);
|
||||
await writeFile('app/pom.xml', pomTemplate('com.acme', 'app', ['com.acme:lib']));
|
||||
await writeFile(
|
||||
'app/src/main/java/com/acme/app/Main.java',
|
||||
'package com.acme.app;\nimport static com.acme.lib.Constants;\npublic class Main {}\n',
|
||||
|
|
@ -174,10 +162,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
'package com.acme.lib;\npublic class Token {}\n',
|
||||
);
|
||||
|
||||
await writeFile(
|
||||
'app/pom.xml',
|
||||
pomTemplate('com.acme', 'app', ['com.acme:lib']),
|
||||
);
|
||||
await writeFile('app/pom.xml', pomTemplate('com.acme', 'app', ['com.acme:lib']));
|
||||
await writeFile(
|
||||
'app/src/main/java/com/acme/app/A.java',
|
||||
'package com.acme.app;\nimport com.acme.lib.Token;\npublic class A {}\n',
|
||||
|
|
@ -205,10 +190,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
'package com.acme.lib\ndata class Model(val id: Int)\n',
|
||||
);
|
||||
|
||||
await writeFile(
|
||||
'app/pom.xml',
|
||||
pomTemplate('com.acme', 'app', ['com.acme:lib']),
|
||||
);
|
||||
await writeFile('app/pom.xml', pomTemplate('com.acme', 'app', ['com.acme:lib']));
|
||||
await writeFile(
|
||||
'app/src/main/kotlin/com/acme/app/Main.kt',
|
||||
'package com.acme.app\nimport com.acme.lib.Model\nfun main() {}\n',
|
||||
|
|
@ -237,10 +219,7 @@ describe('JavaWorkspaceExtractor', () => {
|
|||
'package com.acme.lib;\npublic class Response {}\n',
|
||||
);
|
||||
|
||||
await writeFile(
|
||||
'app/pom.xml',
|
||||
pomTemplate('com.acme', 'app', ['com.acme:lib']),
|
||||
);
|
||||
await writeFile('app/pom.xml', pomTemplate('com.acme', 'app', ['com.acme:lib']));
|
||||
await writeFile(
|
||||
'app/src/main/java/com/acme/app/Handler.java',
|
||||
'package com.acme.app;\nimport com.acme.lib.Request;\nimport com.acme.lib.Response;\npublic class Handler {}\n',
|
||||
|
|
|
|||
|
|
@ -95,10 +95,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles CommonJS destructured require', async () => {
|
||||
await writeFile(
|
||||
'lib/package.json',
|
||||
JSON.stringify({ name: 'auth-lib', version: '1.0.0' }),
|
||||
);
|
||||
await writeFile('lib/package.json', JSON.stringify({ name: 'auth-lib', version: '1.0.0' }));
|
||||
await writeFile('lib/src/index.js', 'module.exports = { Authenticator: class {} };\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -109,10 +106,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
dependencies: { 'auth-lib': 'workspace:*' },
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
'svc/src/handler.js',
|
||||
"const { Authenticator } = require('auth-lib');\n",
|
||||
);
|
||||
await writeFile('svc/src/handler.js', "const { Authenticator } = require('auth-lib');\n");
|
||||
|
||||
const repos = { lib: 'auth-lib', svc: 'api-svc' };
|
||||
const repoPaths = new Map([
|
||||
|
|
@ -127,10 +121,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles scoped package imports with subpaths', async () => {
|
||||
await writeFile(
|
||||
'core/package.json',
|
||||
JSON.stringify({ name: '@acme/core', version: '2.0.0' }),
|
||||
);
|
||||
await writeFile('core/package.json', JSON.stringify({ name: '@acme/core', version: '2.0.0' }));
|
||||
await writeFile('core/src/models.ts', 'export class User {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -141,10 +132,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
dependencies: { '@acme/core': 'workspace:*' },
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
'web/src/routes.ts',
|
||||
"import { User } from '@acme/core/models';\n",
|
||||
);
|
||||
await writeFile('web/src/routes.ts', "import { User } from '@acme/core/models';\n");
|
||||
|
||||
const repos = { core: '@acme/core', web: '@acme/web' };
|
||||
const repoPaths = new Map([
|
||||
|
|
@ -159,10 +147,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('ignores camelCase/snake_case imports (non-type exports)', async () => {
|
||||
await writeFile(
|
||||
'lib/package.json',
|
||||
JSON.stringify({ name: 'utils', version: '1.0.0' }),
|
||||
);
|
||||
await writeFile('lib/package.json', JSON.stringify({ name: 'utils', version: '1.0.0' }));
|
||||
await writeFile('lib/src/index.ts', 'export function helper() {}\nexport class Formatter {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -173,10 +158,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
dependencies: { utils: 'workspace:*' },
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
'app/src/main.ts',
|
||||
"import { helper, Formatter } from 'utils';\n",
|
||||
);
|
||||
await writeFile('app/src/main.ts', "import { helper, Formatter } from 'utils';\n");
|
||||
|
||||
const repos = { lib: 'utils', app: 'myapp' };
|
||||
const repoPaths = new Map([
|
||||
|
|
@ -204,10 +186,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('deduplicates identical imports from multiple files', async () => {
|
||||
await writeFile(
|
||||
'lib/package.json',
|
||||
JSON.stringify({ name: 'shared', version: '1.0.0' }),
|
||||
);
|
||||
await writeFile('lib/package.json', JSON.stringify({ name: 'shared', version: '1.0.0' }));
|
||||
await writeFile('lib/src/index.ts', 'export class Config {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -233,10 +212,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
});
|
||||
|
||||
it('handles aliased imports (import { Foo as Bar })', async () => {
|
||||
await writeFile(
|
||||
'lib/package.json',
|
||||
JSON.stringify({ name: 'models', version: '1.0.0' }),
|
||||
);
|
||||
await writeFile('lib/package.json', JSON.stringify({ name: 'models', version: '1.0.0' }));
|
||||
await writeFile('lib/src/index.ts', 'export class Entity {}\n');
|
||||
|
||||
await writeFile(
|
||||
|
|
@ -247,10 +223,7 @@ describe('NodeWorkspaceExtractor', () => {
|
|||
dependencies: { models: 'workspace:*' },
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
'app/src/main.ts',
|
||||
"import { Entity as BaseEntity } from 'models';\n",
|
||||
);
|
||||
await writeFile('app/src/main.ts', "import { Entity as BaseEntity } from 'models';\n");
|
||||
|
||||
const repos = { lib: 'models', app: 'myapp' };
|
||||
const repoPaths = new Map([
|
||||
|
|
|
|||
|
|
@ -32,10 +32,7 @@ describe('PythonWorkspaceExtractor', () => {
|
|||
'api/pyproject.toml',
|
||||
'[project]\nname = "api-server"\nversion = "0.1.0"\ndependencies = [\n "shared-models>=0.1.0",\n]\n',
|
||||
);
|
||||
await writeFile(
|
||||
'api/api_server/main.py',
|
||||
'from shared_models import Schema\n',
|
||||
);
|
||||
await writeFile('api/api_server/main.py', 'from shared_models import Schema\n');
|
||||
|
||||
const repos = { models: 'shared-models', api: 'api-server' };
|
||||
const repoPaths = new Map([
|
||||
|
|
@ -203,10 +200,7 @@ describe('PythonWorkspaceExtractor', () => {
|
|||
'app/pyproject.toml',
|
||||
'[project]\nname = "myapp"\nversion = "0.1.0"\ndependencies = [\n "models",\n]\n',
|
||||
);
|
||||
await writeFile(
|
||||
'app/myapp/main.py',
|
||||
'from models import Entity as BaseEntity\n',
|
||||
);
|
||||
await writeFile('app/myapp/main.py', 'from models import Entity as BaseEntity\n');
|
||||
|
||||
const repos = { lib: 'models', app: 'myapp' };
|
||||
const repoPaths = new Map([
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue